/* ==========================================================================
   HONEYCOMB HEXA (v3 — 100% AI Hand-Painted Wood HUD & Candy-Gloss Buttons)
   Zero CSS gradient HUD boxes: every pill, card, tray, objective bar, modal,
   and button uses our hand-painted AI transparent artwork.
   ========================================================================== */
:root {
  --gold-bright: #ffe654;
  --cream: #fff9eb;
  --font-main: "Fredoka", "Nunito", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  background: #2389da;
  color: var(--cream);
  touch-action: none;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.bg-backdrop {
  position: absolute;
  inset: 0;
  background-image: url("../assets/images/bg-portrait.webp");
  background-size: cover;
  background-position: center bottom;
  background-repeat: no-repeat;
  z-index: 0;
}

@media (orientation: landscape) and (min-aspect-ratio: 11/10) {
  .bg-backdrop {
    background-image: url("../assets/images/bg-landscape.webp");
    background-position: center center;
  }
}

/* ==========================================================================
   PORTRAIT GAMEPLAY LAYOUT (Matches Reference 1000209599.png)
   ========================================================================== */
.game-layout {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  padding: calc(6px + var(--safe-top)) calc(8px + var(--safe-right)) calc(6px + var(--safe-bottom)) calc(8px + var(--safe-left));
  display: grid;
  grid-template-columns: minmax(98px, 31%) minmax(0, 23%) minmax(0, 46%);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "top top top"
    "side tray tray"
    "board board board"
    "obj obj boost"
    "corners corners corners";
  gap: clamp(4px, 0.8vh, 8px) clamp(6px, 1.4vw, 12px);
  max-width: 680px;
  margin: 0 auto;
}

.hud-top {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
}

.hud-side-left {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
}

.hud-tray-wrap {
  grid-area: tray;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.hud-board-stage {
  grid-area: board;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
}

#board-canvas {
  display: block;
  touch-action: none;
  cursor: pointer;
}

.hud-objective-wrap {
  grid-area: obj;
  display: flex;
  align-items: center;
}

.hud-boosters-wrap {
  grid-area: boost;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(5px, 1.4vw, 10px);
}

.hud-corners {
  grid-area: corners;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
}

@media (orientation: portrait), (max-aspect-ratio: 11/10) {
  .hud-side-left .moves-card,
  .hud-side-left .fever-card {
    display: none;
  }
  .hud-side-left.has-moves .moves-card {
    display: flex;
  }
}

/* ==========================================================================
   LANDSCAPE GAMEPLAY LAYOUT (Matches Reference 1000209598.png)
   ========================================================================== */
@media (orientation: landscape) and (min-aspect-ratio: 11/10) {
  .game-layout {
    max-width: 1380px;
    padding: calc(8px + var(--safe-top)) calc(14px + var(--safe-right)) calc(8px + var(--safe-bottom)) calc(14px + var(--safe-left));
    grid-template-columns: clamp(148px, 18.5vw, 218px) minmax(0, 1fr) clamp(86px, 10.5vw, 126px);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "top top top"
      "side board boost"
      "obj tray corners";
    gap: clamp(6px, 1.2vh, 12px) clamp(10px, 1.6vw, 18px);
  }

  .hud-side-left {
    justify-content: flex-start;
    padding-top: 4px;
    gap: 8px;
  }

  .hud-side-left .moves-card,
  .hud-side-left .fever-card {
    display: flex;
  }

  .hud-boosters-wrap {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: clamp(8px, 1.8vh, 16px);
  }

  .hud-corners {
    justify-content: flex-end;
    gap: 10px;
  }

  .wood-tray {
    max-width: 540px;
  }
}

/* ==========================================================================
   100% AI-GENERATED ART BUTTONS (NATIVE ASPECT RATIO, 3D TACTILE PRESS)
   ========================================================================== */
.pill-art-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s cubic-bezier(0.2, 1.4, 0.4, 1), filter 0.14s ease;
  filter: drop-shadow(0 4px 5px rgba(25, 10, 2, 0.42));
}
.pill-art-btn:hover {
  transform: translateY(-2px) scale(1.04);
  filter: drop-shadow(0 6px 8px rgba(25, 10, 2, 0.46)) brightness(1.05);
}
.pill-art-btn:active {
  transform: translateY(2px) scale(0.95);
  filter: drop-shadow(0 2px 2px rgba(25, 10, 2, 0.45));
}
.pill-art-btn:disabled {
  filter: grayscale(0.75) brightness(0.75);
  cursor: not-allowed;
  transform: none;
}

.pill-art-btn img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  pointer-events: none;
}

.pill-art-btn.lg { width: min(296px, 80vw); }
.pill-art-btn.md { width: min(256px, 70vw); }
.pill-art-btn.sm { width: min(156px, 42vw); }
.pill-art-btn.xs { width: 102px; }

.pill-art-btn span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px 2px;
  font-family: var(--font-main);
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 0.03em;
  text-shadow:
    0 2.5px 0 rgba(48, 18, 3, 0.92),
    0 -1px 0 rgba(48, 18, 3, 0.8),
    1.5px 0 0 rgba(48, 18, 3, 0.8),
    -1.5px 0 0 rgba(48, 18, 3, 0.8);
  pointer-events: none;
  white-space: nowrap;
}
.pill-art-btn.lg span { font-size: clamp(19px, 2.9vh, 24px); letter-spacing: 0.04em; }
.pill-art-btn.md span { font-size: clamp(15.5px, 2.35vh, 19px); letter-spacing: 0.04em; }
.pill-art-btn.sm span { font-size: clamp(13px, 1.95vh, 15.5px); letter-spacing: 0.03em; }
.pill-art-btn.xs span { font-size: 12.5px; }

.art-close-btn {
  position: absolute;
  right: -10px;
  top: -10px;
  width: 42px;
  height: 42px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.12s ease;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.45));
  z-index: 4;
}
.art-close-btn:hover { transform: scale(1.1); }
.art-close-btn:active { transform: scale(0.9); }
.art-close-btn img { width: 100%; height: 100%; object-fit: contain; }

/* ==========================================================================
   100% AI HAND-PAINTED CARVED WOODEN HUD CONTAINERS
   ========================================================================== */
.wood-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: clamp(38px, 5.6vh, 48px);
  min-width: clamp(106px, 16vw, 142px);
  padding: 4px 16px 4px 6px;
  background: url("../assets/images/ui/hud-pill-wood.png") center / 100% 100% no-repeat;
  border: none;
  color: #fff;
  font-family: var(--font-main);
  font-weight: 900;
  font-size: clamp(14px, 2.2vh, 19px);
  text-shadow: 0 2px 0 #3a1704;
  filter: drop-shadow(0 3px 4px rgba(24, 10, 2, 0.4));
  transition: transform 0.14s ease;
}
.wood-pill.bump { transform: scale(1.1); }

.coin-pill {
  cursor: pointer;
  padding-right: 6px;
  justify-content: space-between;
}
.coin-pill:hover { filter: drop-shadow(0 4px 6px rgba(24, 10, 2, 0.45)) brightness(1.06); }
.coin-pill:active { transform: scale(0.94); }

.pill-icon {
  width: clamp(28px, 4.4vh, 38px);
  height: clamp(28px, 4.4vh, 38px);
  margin-left: -4px;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
}

.plus-art-icon {
  width: clamp(24px, 3.6vh, 30px);
  height: clamp(24px, 3.6vh, 30px);
  margin-right: -2px;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3));
}

.score-stack {
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.score-val { font-size: clamp(15px, 2.3vh, 20px); font-weight: 900; }
.best-val { font-size: clamp(9px, 1.25vh, 11px); color: #ffd97a; font-weight: 700; }

.hud-right-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.level-plaque {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  height: clamp(46px, 7vh, 64px);
  transition: transform 0.14s ease;
}
.level-plaque:hover { transform: scale(1.05); }
.level-plaque:active { transform: scale(0.94); }

.level-plaque img {
  height: 100%;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.4));
}

.level-plaque-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 0.96;
  pointer-events: none;
}
.lvl-word { font-size: clamp(10px, 1.5vh, 13px); font-weight: 800; color: #fff8e6; text-shadow: 0 2px 0 #461b04; }
.lvl-num { font-size: clamp(17px, 2.8vh, 25px); font-weight: 900; color: var(--gold-bright); text-shadow: 0 2.5px 0 #461b04; }

.icon-circle-btn,
.corner-circle-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  width: clamp(38px, 5.8vh, 52px);
  height: clamp(38px, 5.8vh, 52px);
  transition: transform 0.12s cubic-bezier(0.2, 1.4, 0.4, 1), filter 0.12s ease;
}
.icon-circle-btn:hover,
.corner-circle-btn:hover { transform: translateY(-2px) scale(1.08); }
.icon-circle-btn:active,
.corner-circle-btn:active { transform: translateY(2px) scale(0.91); }
.icon-circle-btn.muted-state { filter: grayscale(0.8) brightness(0.8); }

.icon-circle-btn img,
.corner-circle-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.42));
}

/* Hand-Painted Carved Wood Cards (Target & Moves) */
.wood-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: url("../assets/images/ui/hud-card-tab.png") center / 100% 100% no-repeat;
  border: none;
  padding: 5px 12px 12px;
  min-height: clamp(78px, 12.5vh, 108px);
  filter: drop-shadow(0 4px 5px rgba(22, 9, 2, 0.4));
}

.wood-card-tab {
  text-align: center;
  font-size: clamp(10px, 1.45vh, 13px);
  font-weight: 900;
  color: #fff8e6;
  text-shadow: 0 1.5px 0 #421a04;
  padding-top: 1px;
  margin-bottom: 4px;
}

.target-card-body,
.moves-card-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 2px 4px;
}

.target-canvas {
  width: clamp(32px, 5.2vh, 46px);
  height: clamp(32px, 5.2vh, 46px);
  flex-shrink: 0;
}

.target-count {
  font-size: clamp(14px, 2.2vh, 19px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 #3a1603;
}

.moves-val {
  font-size: clamp(20px, 3.2vh, 28px);
  font-weight: 900;
  color: var(--gold-bright);
  text-shadow: 0 2px 0 #3a1603;
}
.moves-val.low-moves {
  color: #ff625c;
  animation: pulseWarn 0.65s infinite alternate;
}

/* Fever Charge Wood Bar */
.fever-card {
  background: url("../assets/images/ui/hud-obj-wood.png") center / 100% 100% no-repeat;
  min-height: 0;
  padding: 8px 12px;
}
.fever-card.fever-hot {
  filter: drop-shadow(0 0 14px rgba(255, 232, 82, 0.95));
}
.fever-inner {
  display: flex;
  align-items: center;
  gap: 7px;
}
.fever-gem {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}
.fever-card.fever-hot .fever-gem { animation: pulseWarn 0.45s infinite alternate; }
.fever-bar-col { flex: 1; min-width: 0; }
.fever-label {
  display: block;
  font-size: 10.5px;
  font-weight: 900;
  color: #ffe854;
  text-shadow: 0 1.5px 0 #3a1503;
  margin-bottom: 3px;
}
.fever-track {
  height: 9px;
  background: rgba(30, 10, 2, 0.72);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #2b1002;
}
.fever-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff54a8, #ffe756, #4ef7c5);
  transition: width 0.35s cubic-bezier(0.22, 1.2, 0.36, 1);
}

/* Hand-Painted Carved Wooden Next Pieces Tray */
.wood-tray {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  background: url("../assets/images/ui/hud-tray-wood.png") center / 100% 100% no-repeat;
  border: none;
  padding: 4px 14px 10px;
  filter: drop-shadow(0 4px 6px rgba(22, 9, 2, 0.42));
}

.wood-tray-label {
  text-align: center;
  font-size: clamp(10px, 1.45vh, 13px);
  font-weight: 900;
  color: #fff8e6;
  text-shadow: 0 1.5px 0 #421a04;
  margin-bottom: 4px;
}
.tray-hint-sub {
  font-size: 0.85em;
  color: #ffdf9a;
  font-weight: 700;
}

.tray-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  background: none;
  border: none;
  padding: 2px 4px;
}

.piece-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: clamp(54px, 8.6vh, 76px);
  border-radius: 10px;
  cursor: grab;
  transition: transform 0.16s cubic-bezier(0.2, 1.35, 0.4, 1), opacity 0.16s ease, box-shadow 0.2s ease, background 0.18s ease;
}
.piece-slot:hover:not(.empty):not(.unplayable) {
  transform: translateY(-2px) scale(1.07);
  background: rgba(255, 232, 150, 0.1);
}
.piece-slot.selected {
  transform: translateY(-4px) scale(1.09);
  background: rgba(255, 230, 90, 0.2);
  box-shadow: 0 0 0 2.5px #ffe654, 0 0 14px rgba(255, 230, 84, 0.78);
}
.piece-slot.dragging { opacity: 0.2; transform: scale(0.86); }
.piece-slot.empty { pointer-events: none; cursor: default; }
.piece-slot.unplayable { opacity: 0.42; filter: grayscale(0.55); }
.piece-slot.hint-highlight {
  box-shadow: 0 0 0 2.5px #ffe654, 0 0 16px rgba(255, 230, 84, 0.92);
  animation: hintSlotPulse 0.8s infinite alternate;
}

.piece-canvas { width: 100%; height: 100%; pointer-events: none; }

/* Hand-Painted Carved Wooden Objective Bar */
.wood-objective-panel {
  width: 100%;
  background: url("../assets/images/ui/hud-obj-wood.png") center / 100% 100% no-repeat;
  border: none;
  padding: 9px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  filter: drop-shadow(0 4px 6px rgba(22, 9, 2, 0.42));
  transition: transform 0.15s ease;
}
.wood-objective-panel.bump { transform: scale(1.04); }

.obj-top-row { display: flex; align-items: center; gap: 6px; }
.obj-trophy-icon { width: clamp(22px, 3.2vh, 28px); height: clamp(22px, 3.2vh, 28px); object-fit: contain; flex-shrink: 0; }
.obj-label {
  font-size: clamp(11px, 1.6vh, 14px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1.5px 0 #3f1804;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.obj-progress-track {
  position: relative;
  height: clamp(17px, 2.5vh, 22px);
  background: rgba(34, 12, 2, 0.78);
  border: 1.5px solid #2b1002;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.55);
}
.obj-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(180deg, #ffe756 0%, #f5a616 100%);
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.22, 1.15, 0.36, 1);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55);
}
.obj-progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(11px, 1.5vh, 13px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1.5px 0 #3a1503;
}

/* Boosters */
.booster-btn {
  position: relative;
  background: none;
  border: none;
  padding: 0;
  width: clamp(48px, 7vh, 64px);
  height: clamp(48px, 7vh, 64px);
  cursor: pointer;
  transition: transform 0.12s cubic-bezier(0.2, 1.4, 0.4, 1), filter 0.14s ease;
}
.booster-btn:hover { transform: translateY(-3px) scale(1.08); }
.booster-btn:active { transform: translateY(2px) scale(0.91); }
.booster-btn.disabled { filter: saturate(0.45) brightness(0.84); }
.booster-btn img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.42)); }

.count-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: clamp(19px, 2.7vh, 24px);
  height: clamp(19px, 2.7vh, 24px);
  padding: 0 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff4b4b 0%, #c7141b 100%);
  border: 2px solid #570709;
  color: #fff;
  font-size: clamp(11px, 1.55vh, 13px);
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
}
.count-badge.empty-ad {
  background: linear-gradient(180deg, #86ef2c 0%, #37a30c 100%);
  border-color: #174c04;
}

.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 60;
  display: none;
  filter: drop-shadow(0 14px 16px rgba(24, 10, 2, 0.52));
}
.drag-ghost.spring-back {
  transition: transform 0.22s cubic-bezier(0.2, 1.25, 0.4, 1), opacity 0.22s ease;
}

/* ==========================================================================
   OVERLAYS, HOME SCREEN & HAND-PAINTED WOODEN MODAL FRAMES
   ========================================================================== */
.screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(16, 26, 36, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.screen-overlay.open { opacity: 1; pointer-events: auto; }

#screen-loading {
  z-index: 80;
  background: radial-gradient(circle at 50% 35%, rgba(42, 148, 232, 0.9), rgba(22, 74, 128, 0.95));
}

.loading-card,
.home-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 420px;
  width: 100%;
  animation: popIn 0.35s cubic-bezier(0.2, 1.2, 0.4, 1);
}

.loading-logo,
.home-emblem {
  width: clamp(104px, 21vh, 162px);
  height: clamp(104px, 21vh, 162px);
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.42));
  animation: floatGentle 3.2s ease-in-out infinite;
}

.game-title {
  margin: 4px 0 10px;
  font-size: clamp(30px, 5.8vh, 46px);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0.02em;
  color: #ffe654;
  text-shadow:
    0 4px 0 #592405,
    0 -2px 0 #592405,
    3px 0 0 #592405,
    -3px 0 0 #592405,
    0 8px 14px rgba(0, 0, 0, 0.45);
}
.game-title span { color: #ffffff; font-size: 1.12em; }

.loading-bar-track {
  width: 220px;
  height: 16px;
  background: #3d1804;
  border: 2.5px solid #260e02;
  border-radius: 999px;
  overflow: hidden;
}
.loading-bar-fill { width: 15%; height: 100%; background: linear-gradient(180deg, #ffe756, #f29d12); transition: width 0.2s ease; }
.loading-status { margin: 8px 0 0; font-weight: 800; font-size: 14px; text-shadow: 0 2px 2px rgba(0, 0, 0, 0.45); }

.home-stats-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 14px; }
.home-secondary-row { margin-top: 12px; display: grid; grid-template-columns: repeat(2, auto); justify-content: center; gap: 8px 12px; }

/* 100% AI Hand-Painted Carved Wooden Modal Dialog Frame */
.modal-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  background: url("../assets/images/ui/modal-wood-frame.png") center / 100% 100% no-repeat;
  border: none;
  padding: 46px 40px 38px;
  filter: drop-shadow(0 16px 32px rgba(0, 0, 0, 0.58));
  animation: popIn 0.25s cubic-bezier(0.2, 1.2, 0.4, 1);
}

.levels-card,
.shop-card,
.achievements-card {
  max-width: 560px;
  padding: 48px 44px 40px;
}

.modal-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -18px;
  margin-bottom: 10px;
}

.modal-title-banner {
  position: relative;
  height: clamp(46px, 7vh, 58px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-title-banner img { height: 100%; width: auto; object-fit: contain; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.4)); }
.modal-title-banner span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 5px;
  font-size: clamp(13.5px, 2.1vh, 17.5px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 #5c2404;
  letter-spacing: 0.03em;
}

/* Chapter Tabs & 120-Level Grid */
.chapter-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-bottom: 10px; }
.chapter-tab {
  padding: 6px 4px;
  border-radius: 10px;
  border: 2px solid #3f1804;
  background: rgba(58, 22, 4, 0.82);
  color: #f6d7a7;
  font-family: var(--font-main);
  font-size: clamp(10px, 1.4vw, 12px);
  font-weight: 800;
  cursor: pointer;
}
.chapter-tab.active {
  background: linear-gradient(180deg, #ffd94a 0%, #ea9312 100%);
  color: #461b04;
  border-color: #4a1e04;
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  overflow-y: auto;
  padding: 4px;
  max-height: 48dvh;
}

.level-tile-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 2px solid #3c1803;
  background: linear-gradient(180deg, #cf7a26 0%, #944b12 100%);
  color: #fff;
  font-family: var(--font-main);
  font-size: 16px;
  font-weight: 900;
  text-shadow: 0 2px 0 #3f1804;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.level-tile-btn:hover:not(.locked) { transform: scale(1.07); }
.level-tile-btn.current { background: linear-gradient(180deg, #86f030 0%, #3fb00e 100%); border-color: #184f03; }
.level-tile-btn.locked { background: rgba(45, 18, 5, 0.72); color: #9e775a; cursor: not-allowed; opacity: 0.72; }

.tile-stars { display: flex; gap: 2px; }
.tile-stars img { width: 13px; height: 13px; }
.tile-stars img.dim { filter: grayscale(1) brightness(0.45); opacity: 0.55; }

/* Victory / Failure / Shop / Achievements / Settings */
.victory-stars { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin: 2px 0 10px; }
.v-star { width: 50px; height: 50px; object-fit: contain; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35)); }
.v-star.mid { width: 64px; height: 64px; transform: translateY(-6px); }
.v-star.dim { filter: grayscale(1) brightness(0.45); opacity: 0.45; }
.v-star.pop-anim { animation: starSlam 0.45s cubic-bezier(0.2, 1.5, 0.4, 1); }

.result-stats {
  background: rgba(36, 13, 2, 0.55);
  border: 1.5px solid rgba(255, 200, 120, 0.22);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.result-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 700; }
.result-row strong { font-size: 16px; color: var(--gold-bright); }
.inline-coin { width: 18px; height: 18px; vertical-align: middle; margin-right: 3px; }
.fail-reason { margin: 0 0 8px; text-align: center; font-size: 13.5px; font-weight: 700; color: #ffe6c4; }

.modal-btn-stack { display: flex; flex-direction: column; align-items: center; gap: 7px; width: 100%; }
.two-col-btns { display: flex; justify-content: center; gap: 10px; width: 100%; }

.shop-balance { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 18px; font-weight: 900; color: var(--gold-bright); margin-bottom: 8px; }
.shop-items { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 10px; }
.shop-item-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 6px;
  border-radius: 14px;
  background: rgba(36, 13, 2, 0.55);
  border: 1.5px solid rgba(255, 200, 120, 0.22);
  text-align: center;
}
.shop-item-card img.shop-icon { width: 42px; height: 42px; object-fit: contain; }
.shop-item-title { font-size: 12.5px; font-weight: 800; }
.shop-ad-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }

.achievements-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 50dvh; padding-right: 4px; }
.ach-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
  background: rgba(36, 13, 2, 0.55);
  border: 1.5px solid rgba(255, 200, 120, 0.22);
  border-radius: 14px;
}
.ach-row img.ach-trophy { width: 32px; height: 32px; flex-shrink: 0; }
.ach-row.locked img.ach-trophy { filter: grayscale(1) brightness(0.5); }
.ach-info { flex: 1; min-width: 0; }
.ach-info strong { display: block; font-size: 13.5px; color: var(--gold-bright); }
.ach-info span { display: block; font-size: 11.5px; color: #f4d9b5; }
.ach-prog { margin-top: 4px; height: 7px; background: #2f1203; border-radius: 999px; overflow: hidden; }
.ach-prog-fill { height: 100%; background: linear-gradient(90deg, #ffd842, #f59c12); }

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: rgba(36, 13, 2, 0.55);
  border: 1.5px solid rgba(255, 200, 120, 0.22);
  border-radius: 14px;
  padding: 11px;
}
.setting-row { display: flex; align-items: center; justify-content: space-between; font-size: 13.5px; font-weight: 800; gap: 8px; }
.setting-row.column { flex-direction: column; align-items: stretch; gap: 4px; }
.slider-head { display: flex; justify-content: space-between; }
.setting-row input[type="range"] { accent-color: #ffd538; width: 100%; }
.toggle-input { width: 22px; height: 22px; accent-color: #69db1c; cursor: pointer; }

.ad-card { text-align: center; max-width: 360px; }
.ad-heading { margin: 0 0 6px; color: var(--gold-bright); font-size: 19px; font-weight: 900; }
.ad-reward-text { margin: 0 0 12px; font-size: 15px; font-weight: 800; }
.ad-progress-track { height: 14px; background: #2d1002; border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.ad-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #86f030, #ffe654); transition: width 0.1s linear; }
.ad-timer { margin: 0 0 12px; font-size: 13px; color: #fce2b6; }

.toast-banner {
  position: fixed;
  top: max(18px, calc(18px + var(--safe-top)));
  left: 50%;
  opacity: 0;
  transform: translate(-50%, -220%);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: url("../assets/images/ui/hud-pill-wood.png") center / 100% 100% no-repeat;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.48));
  transition: transform 0.35s cubic-bezier(0.2, 1.25, 0.4, 1);
  pointer-events: none;
}
.toast-banner.show { opacity: 1; transform: translate(-50%, 0); }
.toast-icon { width: 28px; height: 28px; }
.toast-text strong { display: block; font-size: 12px; color: var(--gold-bright); }
.toast-text span { display: block; font-size: 13px; font-weight: 800; }

@keyframes popIn { from { opacity: 0; transform: scale(0.88); } to { opacity: 1; transform: scale(1); } }
@keyframes floatGentle { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes pulseWarn { from { transform: scale(1); } to { transform: scale(1.13); } }
@keyframes hintSlotPulse { from { transform: scale(1); } to { transform: scale(1.07); } }
@keyframes starSlam {
  0% { transform: scale(2.2) rotate(-18deg); opacity: 0; }
  65% { transform: scale(0.92) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
