/* =========================================================================
   Hearthpine Café — Merge & Story (Cozy Winter Mountain Café UI)
   Zero-Scroll 360x740 Strict-Fit Mobile Architecture
   ========================================================================= */

:root {
  --sky-dark: #23324A;
  --sky-mid: #3A5072;
  --wood-dark: #5A351E;
  --wood-mid: #8B5733;
  --wood-light: #C69062;
  --cream: #FFF8F0;
  --cream-soft: #F7ECDF;
  --tile-a: #F4E6D4;
  --tile-b: #E5D4BE;
  --berry: #C9434F;
  --berry-deep: #A22D39;
  --pine: #2E7D5B;
  --pine-bright: #3BA274;
  --amber: #F5B442;
  --ice: #8ED4FF;
  --ink: #3E2618;
  --ink-muted: #7C5C48;
  --font-display: 'Mali', 'Noto Sans Thai', system-ui, sans-serif;
  --font-body: 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--sky-dark);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app-shell {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, #273B59 0%, #425B80 48%, #2E4160 100%);
}

/* =========================================================================
   Top Resource HUD
   ========================================================================= */
.top-hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: calc(7px + env(safe-area-inset-top)) 10px 6px;
  background: linear-gradient(180deg, rgba(24, 36, 56, 0.92), rgba(24, 36, 56, 0.65));
  z-index: 10;
}

.res-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 8px 0 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, #FFF7EC 0%, #EFE0CC 100%);
  border: 2px solid #9B6439;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.res-energy {
  cursor: pointer;
}

.res-val strong { font-weight: 700; }
.res-val small { font-size: 10px; color: var(--ink-muted); }

.regen-tag {
  font-size: 9.5px;
  font-weight: 700;
  color: #FFFFFF;
  background: var(--pine);
  padding: 1px 5px;
  border-radius: 999px;
}

.res-ico {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 15px;
}
.ico-bolt {
  background: radial-gradient(circle at 35% 30%, #FFF7B2, #F4A926 70%, #C7740E);
  box-shadow: inset 0 0 0 1.5px #FFF3C2;
}
.ico-coin {
  background: radial-gradient(circle at 35% 30%, #FFF5B8, #F3B93B 65%, #BA7814);
  border: 1px solid #9D620E;
}
.ico-gem {
  background: linear-gradient(135deg, #D5F3FF 0%, #68C4FA 50%, #3288D8 100%);
  border-radius: 4px;
  transform: rotate(45deg) scale(0.84);
}

.hud-icon-btn {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
  border: 2px solid #9B6439;
  background: #FFF6EA;
  color: var(--wood-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.hud-icon-btn.muted {
  opacity: 0.55;
}

/* =========================================================================
   Main Stage & Screens
   ========================================================================= */
.main-stage {
  flex: 1 1 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.screen-view {
  display: none;
  width: 100%;
  height: 100%;
}

.screen-view.active {
  display: flex;
  flex-direction: column;
}

/* =========================================================================
   VIEW 1: COZY SNOW CAFÉ DIORAMA
   ========================================================================= */
.cafe-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.cafe-scene-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 44%;
  display: block;
  transition: filter 0.4s ease;
}

.cafe-scene-img.flash-restore {
  animation: restoreGlow 0.9s ease;
}

@keyframes restoreGlow {
  0%   { filter: brightness(1); }
  35%  { filter: brightness(1.45) saturate(1.25); }
  100% { filter: brightness(1); }
}

.snow-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.chapter-pill {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 5px;
  border-radius: 999px;
  background: rgba(35, 22, 16, 0.72);
  border: 1.5px solid rgba(255, 232, 198, 0.45);
  color: #FFF7EB;
  font-size: 11.5px;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

.chap-badge {
  background: linear-gradient(135deg, #F6B948, #D97E24);
  color: #3D1F08;
  font-weight: 700;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
}

.cafe-hotspot {
  position: absolute;
  left: 48%;
  top: 56%;
  transform: translate(-50%, -50%);
  z-index: 5;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.hs-ring {
  position: absolute;
  top: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #FFE27A;
  animation: hsPulse 1.6s ease-out infinite;
}

@keyframes hsPulse {
  0%   { transform: scale(0.9); opacity: 0.95; }
  100% { transform: scale(1.75); opacity: 0; }
}

.hs-core {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(180deg, #FFE278 0%, #E79325 100%);
  border: 2.5px solid #FFFDF2;
  color: #5C2C07;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.38);
}

.hs-label {
  background: rgba(54, 30, 16, 0.88);
  color: #FFF6E6;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 224, 150, 0.55);
  white-space: nowrap;
}

.chap-complete-banner {
  position: absolute;
  top: 48px;
  left: 12px;
  right: 12px;
  z-index: 5;
  padding: 10px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(64, 35, 18, 0.90), rgba(145, 58, 44, 0.88));
  border: 2px solid #F7CE76;
  color: #FFF8EC;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}
.chap-complete-banner strong { font-family: var(--font-display); font-size: 15px; color: #FFE38F; }
.chap-complete-banner span { font-size: 11px; opacity: 0.95; }

.cafe-bottom-dock {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 6;
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 74px;
  gap: 8px;
  align-items: center;
}

.cafe-side-btn {
  position: relative;
  height: 58px;
  border-radius: 18px;
  border: 2px solid #A46A3E;
  background: linear-gradient(180deg, #FFF7EB 0%, #EAD6BC 100%);
  color: var(--wood-dark);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.30);
}

.cafe-play-btn {
  height: 62px;
  border-radius: 20px;
  border: 2.5px solid #FFF2C6;
  background: linear-gradient(180deg, #F7BF4E 0%, #D97E1F 100%);
  color: #3E1E06;
  font-family: var(--font-display);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(217, 126, 31, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.55);
  transition: transform 0.12s ease;
}

.cafe-play-btn:active, .cafe-side-btn:active {
  transform: scale(0.95);
}

.play-btn-title { font-size: 17px; font-weight: 700; line-height: 1.1; }
.play-btn-sub { font-family: var(--font-body); font-size: 11px; font-weight: 600; opacity: 0.88; }

.notif-dot {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--berry);
  color: #FFFFFF;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* =========================================================================
   VIEW 2: MERGE-2 PUZZLE BOARD (Zero-Scroll 360x740 Strict Fit)
   ========================================================================= */
#view-board.active {
  justify-content: space-between;
  gap: 5px;
  padding: 4px 10px calc(10px + env(safe-area-inset-bottom));
  overflow: hidden;
}

/* Customer Order Queue */
.orders-strip {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.order-card {
  position: relative;
  min-width: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #FFF9F0 0%, #F3E5D4 100%);
  border: 2px solid #B58255;
  padding: 5px 5px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
}

.order-card.ready {
  border-color: #49C17D;
  box-shadow: 0 0 0 2px rgba(73, 193, 125, 0.35), 0 4px 12px rgba(0, 0, 0, 0.24);
}

.order-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 5px;
}

.order-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #C8935B;
  flex: 0 0 30px;
  background: #F3F7FC;
}

.order-reward {
  font-size: 10.5px;
  font-weight: 700;
  color: #9A5B13;
  background: #FFF1CC;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid #E5BC68;
  white-space: nowrap;
}

.order-reqs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
}

.req-slot {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(139, 87, 51, 0.10);
  border: 1.5px solid rgba(139, 87, 51, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
}

.req-slot.met {
  background: #E2F8EC;
  border-color: #45B877;
}

.req-slot img {
  width: 84%;
  height: 84%;
  object-fit: contain;
}

.req-check {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #2CA964;
  color: #FFFFFF;
  font-size: 9.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #FFFFFF;
}

.serve-btn {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 3px 6px;
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 700;
  color: #FFFFFF;
  background: linear-gradient(180deg, #43BE79, #248F54);
  cursor: pointer;
  animation: pulseServe 1.2s ease-in-out infinite;
}

@keyframes pulseServe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

/* 6x7 Wooden Snow-Trimmed Merge Board */
.board-frame {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.merge-grid {
  position: relative;
  width: 100%;
  max-width: 340px;
  max-height: 100%;
  aspect-ratio: 6 / 7;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(7, minmax(0, 1fr));
  gap: 3px;
  padding: 6px;
  border-radius: 16px;
  background: linear-gradient(180deg, #9C633A 0%, #6D4021 100%);
  border: 3px solid #D9B084;
  box-shadow: 0 10px 26px rgba(10, 16, 28, 0.45), inset 0 2px 4px rgba(255, 240, 220, 0.35);
  touch-action: none;
}

.cell {
  position: relative;
  border-radius: 9px;
  background: var(--tile-a);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  overflow: visible;
}

.cell.alt {
  background: var(--tile-b);
}

.cell.selected {
  box-shadow: inset 0 0 0 2.5px #F5A623, 0 0 10px rgba(245, 180, 66, 0.55);
  z-index: 2;
}

.cell.drop-merge {
  box-shadow: inset 0 0 0 3px #2FC06F, 0 0 14px rgba(47, 192, 111, 0.7);
  background: #DFF8EA !important;
  transform: scale(1.05);
  z-index: 3;
}

.cell.drop-move {
  box-shadow: inset 0 0 0 2.5px rgba(255, 255, 255, 0.9);
}

.cell.frozen {
  background: linear-gradient(135deg, #CBEBFF 0%, #99D4FA 100%) !important;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.cell.frozen .piece-img {
  opacity: 0.62;
  filter: saturate(0.55) contrast(0.9);
}

.ice-overlay {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.62) 0%, transparent 45%),
    radial-gradient(circle at 75% 78%, rgba(255,255,255,0.45) 0%, transparent 50%);
  border: 1.5px solid rgba(255, 255, 255, 0.85);
}

.piece-img {
  width: 88%;
  height: 88%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(62, 38, 24, 0.24));
}

.piece-img.pop-in {
  animation: piecePop 0.32s cubic-bezier(0.22, 1.25, 0.36, 1);
}

@keyframes piecePop {
  0% { transform: scale(0.35); opacity: 0.4; }
  70% { transform: scale(1.14); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.piece-img.gen-tap {
  animation: genBounce 0.24s ease;
}

@keyframes genBounce {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.15, 0.86); }
}

.gen-bolt-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(180deg, #FFE678, #EE9A1E);
  border: 1.5px solid #FFFFFF;
  color: #5C2B04;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.28);
}

.lv-badge {
  position: absolute;
  left: 2px;
  bottom: 1px;
  font-size: 8.5px;
  font-weight: 700;
  padding: 0 3px;
  border-radius: 4px;
  background: rgba(62, 38, 24, 0.72);
  color: #FFF7EB;
  pointer-events: none;
  line-height: 1.3;
}

.order-need-dot {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2FC06F;
  border: 1.5px solid #FFFFFF;
  pointer-events: none;
}

/* Iridescent Bonus Bubble */
.cell.bubble-cell {
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.9), rgba(164,218,255,0.58) 55%, rgba(235,175,255,0.65)) !important;
  box-shadow: inset 0 0 0 2px #FFFFFF, 0 0 12px rgba(170, 215, 255, 0.8);
  animation: bubbleWobble 2s ease-in-out infinite;
}

@keyframes bubbleWobble {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.bubble-timer {
  position: absolute;
  bottom: 1px;
  right: 2px;
  font-size: 8.5px;
  font-weight: 700;
  background: rgba(54, 30, 88, 0.82);
  color: #FFF7EB;
  padding: 0 3px;
  border-radius: 4px;
  pointer-events: none;
}

.fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
}

/* Drag Ghost */
.drag-ghost {
  position: fixed;
  width: 62px;
  height: 62px;
  transform: translate(-50%, -62%);
  pointer-events: none;
  z-index: 90;
  filter: drop-shadow(0 12px 16px rgba(20, 10, 5, 0.42));
}
.drag-ghost img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Inspector Bar */
.inspector-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 13px;
  background: rgba(255, 248, 238, 0.94);
  border: 2px solid #B07C4E;
  min-height: 44px;
}

.insp-left {
  min-width: 0;
  flex: 1 1 0;
}
.insp-name {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.insp-desc {
  font-size: 10px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insp-actions {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}

.insp-btn {
  border: 1.5px solid #B68356;
  background: #FFF6E8;
  color: var(--wood-dark);
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
}
.insp-sell {
  background: #FFF0CC;
  border-color: #DCA137;
  color: #87500B;
}

/* Bottom Board Dock */
.board-dock {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.dock-btn {
  position: relative;
  height: 48px;
  border-radius: 14px;
  border: 2px solid #9E673D;
  background: linear-gradient(180deg, #FFF7EB 0%, #EBD6BB 100%);
  color: var(--wood-dark);
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}
.dock-btn:active { transform: scale(0.95); }

.dock-star {
  background: linear-gradient(180deg, #FFE184 0%, #E79B2A 100%);
  border-color: #FFF4C8;
  color: #4A2406;
}

/* =========================================================================
   Story Visual Novel Overlay
   ========================================================================= */
.story-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(16, 24, 38, 0.62);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px 12px calc(22px + env(safe-area-inset-bottom));
}

.story-card {
  width: 100%;
  max-width: 396px;
  border-radius: 22px;
  background: linear-gradient(180deg, #FFFBF4 0%, #F4E6D4 100%);
  border: 3px solid #A87043;
  padding: 12px;
  display: flex;
  gap: 11px;
  align-items: flex-start;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  animation: storyUp 0.28s ease;
}

@keyframes storyUp {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.story-portrait-wrap {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  border-radius: 18px;
  overflow: hidden;
  border: 2.5px solid #C68D58;
  background: #F3F7FC;
}
.story-portrait-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-body {
  flex: 1 1 0;
  min-width: 0;
}

.story-speaker-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.story-speaker-row strong {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--berry-deep);
}
.story-speaker-row span {
  font-size: 10.5px;
  color: var(--ink-muted);
}

#story-text {
  margin: 5px 0 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink);
}

.story-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.text-link-btn {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.warm-pill-btn {
  border: 0;
  border-radius: 999px;
  padding: 7px 16px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  color: #FFFFFF;
  background: linear-gradient(180deg, #E15B64, #B6333F);
  box-shadow: 0 4px 12px rgba(182, 51, 63, 0.35);
  cursor: pointer;
}
.warm-pill-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.soft-pill-btn {
  border: 1.5px solid #B78559;
  border-radius: 999px;
  padding: 7px 14px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  color: var(--wood-dark);
  background: #FFF6E8;
  cursor: pointer;
}

/* =========================================================================
   Modals (Tasks, Quests, Backpack, Info Book, Bubble)
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(16, 24, 38, 0.68);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 14px;
}

.modal-sheet {
  width: 100%;
  max-width: 344px;
  max-height: 82vh;
  border-radius: 22px;
  background: linear-gradient(180deg, #FFFBF5 0%, #F4E7D7 100%);
  border: 3px solid #A87043;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.48);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.modal-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--wood-dark);
}
.modal-sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--ink-muted);
}

.modal-close {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  border: 1.5px solid #B8865A;
  background: #FFF7EB;
  color: var(--wood-dark);
  font-weight: 700;
  cursor: pointer;
}

.modal-scroll {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 56vh;
  padding-right: 2px;
}

.task-row {
  border-radius: 14px;
  background: #FFFFFF;
  border: 1.5px solid #DFC5AA;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.task-row.done {
  background: #EEF9F2;
  border-color: #9EDBB7;
  opacity: 0.82;
}
.task-row.locked {
  opacity: 0.6;
}
.task-title { font-family: var(--font-display); font-size: 13px; font-weight: 700; }
.task-desc { font-size: 10.5px; color: var(--ink-muted); margin-top: 2px; }
.task-reward { font-size: 10px; color: var(--pine); font-weight: 700; margin-top: 3px; }

.energy-shop-box {
  border-radius: 14px;
  background: #FFF2D6;
  border: 1.5px solid #E5B65D;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.reset-box {
  border-radius: 14px;
  background: #FDF1F2;
  border: 1.5px solid #E8B9BE;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.danger-pill-btn {
  border: 1.5px solid #D45863;
  border-radius: 999px;
  padding: 6px 12px;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 700;
  color: #A82834;
  background: #FFFFFF;
  cursor: pointer;
  white-space: nowrap;
}
.danger-pill-btn.confirming {
  background: #C9434F;
  color: #FFFFFF;
  border-color: #A22D39;
}

.bag-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.bag-slot {
  aspect-ratio: 1;
  border-radius: 14px;
  background: #EFE1CF;
  border: 2px dashed #C09064;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px;
  cursor: pointer;
  position: relative;
}
.bag-slot.filled {
  background: #FFFFFF;
  border-style: solid;
  border-color: #B47E4F;
}
.bag-slot img {
  width: 78%;
  height: 78%;
  object-fit: contain;
}

.chain-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.chain-card {
  border-radius: 14px;
  background: #FFFFFF;
  border: 1.5px solid #DEC4A9;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.chain-card img {
  width: 58px;
  height: 58px;
  object-fit: contain;
}
.chain-card.undiscovered img {
  filter: brightness(0) opacity(0.18);
}
.chain-lv { font-size: 10px; font-weight: 700; color: var(--berry); }
.chain-nm { font-size: 10.5px; font-weight: 600; line-height: 1.25; }

.bubble-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 6px 0;
}
.bubble-preview img {
  width: 82px;
  height: 82px;
  object-fit: contain;
}
.bubble-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

/* Toast */
.toast {
  position: fixed;
  top: 48px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  z-index: 95;
  background: rgba(45, 25, 16, 0.92);
  color: #FFF7EC;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden {
  display: none !important;
}
