/* ============================================================
   Wordmote — visual layer
   ============================================================ */

@font-face {
  font-family: "Fredoka";
  src: url("fonts/fredoka-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-0: #070b1a;
  --bg-1: #0c1230;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text: #f7f3ea;
  --muted: #98a2c0;
  --gold: #ffd166;
  --gold-deep: #e9a93a;
  --rose: #ff8fa3;
  --teal: #5eead4;
  --blue: #7dd3fc;
  --violet: #c4b5fd;
  --lime: #bef264;
  --ink: #171a33;
  --radius: 22px;
  --font: "Fredoka", "Trebuchet MS", "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bg-0);
}

body {
  font-family: var(--font);
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button {
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* ---------- ambient background ---------- */

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(76, 56, 160, 0.22), transparent 60%),
    linear-gradient(180deg, var(--bg-0) 0%, #0a1028 55%, #0a0f24 100%);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.42;
  animation: orbDrift 16s ease-in-out infinite alternate;
}

.orb-1 {
  width: 62vw;
  height: 62vw;
  left: -22vw;
  top: -18vw;
  background: #4b2fa8;
}

.orb-2 {
  width: 54vw;
  height: 54vw;
  right: -20vw;
  top: 22vh;
  background: #0e6f6a;
  opacity: 0.28;
  animation-delay: -6s;
}

.orb-3 {
  width: 46vw;
  height: 46vw;
  left: 24vw;
  bottom: -24vw;
  background: #7a2f63;
  opacity: 0.22;
  animation-delay: -11s;
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.07) 0.5px, transparent 0.5px);
  background-size: 4px 4px;
  mix-blend-mode: soft-light;
}

/* ---------- app frame ---------- */

#app {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    max(10px, env(safe-area-inset-top), var(--safe-top, 0px))
    16px
    max(12px, env(safe-area-inset-bottom), var(--safe-bottom, 0px));
}

.hud,
.stage {
  width: 100%;
  max-width: 520px;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

#app[data-screen="title"] .hud,
#app[data-screen="title"] .stage {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

/* ---------- HUD ---------- */

.hud {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-top: 2px;
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
}

.level-pill {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 10px 7px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.12s ease;
}

.level-pill:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.1);
}

.level-pill:disabled {
  opacity: 0.55;
  cursor: default;
}

.level-pill:disabled:active {
  transform: none;
  background: var(--panel);
}

.level-chevron {
  width: 13px;
  height: 13px;
  align-self: center;
  margin-left: -1px;
  color: var(--muted);
}

.level-map-icon {
  width: 13px;
  height: 13px;
  align-self: center;
  margin-right: -1px;
  color: var(--gold);
  opacity: 0.9;
}

.level-caption {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 500;
}

.level-value {
  font-size: 18px;
  line-height: 1;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.score-block {
  text-align: center;
  min-width: 112px;
}

.score-label {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.19em;
  color: var(--gold);
  margin-bottom: 1px;
}

.score-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
}

.score-value {
  display: inline-block;
  font-size: 32px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-shadow: 0 4px 22px rgba(255, 209, 102, 0.18);
}

.score-value.bump {
  animation: scoreBump 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.score-caption {
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 500;
}

.score-caption span {
  color: var(--gold);
}

.hud-actions {
  display: flex;
  gap: 7px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--panel-border);
  border-radius: 13px;
  background: var(--panel);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: background 0.16s ease, transform 0.12s ease;
}

.icon-btn:active {
  transform: scale(0.94);
  background: rgba(255, 255, 255, 0.11);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.icon-btn .icon {
  width: 21px;
  height: 21px;
}

.icon-btn .icon-off,
.icon-btn.muted .icon-on {
  display: none;
}

.icon-btn.muted .icon-off {
  display: block;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-track {
  flex: 1 1 auto;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}

.progress-pct {
  flex: 0 0 auto;
  min-width: 30px;
  text-align: right;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  box-shadow: 0 0 14px rgba(255, 209, 102, 0.55);
  transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hud-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
}

.moves-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.moves {
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--muted);
  transition: color 0.2s ease;
}

.moves strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  margin-right: 2px;
  font-variant-numeric: tabular-nums;
}

.moves.low strong {
  color: var(--rose);
  animation: lowPulse 1s ease-in-out infinite;
}

.to-go {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: rgba(255, 209, 102, 0.78);
  font-variant-numeric: tabular-nums;
}

.to-go.done {
  color: var(--teal);
}

/* ---------- powers ---------- */

.power-cluster {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.power-dock {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.power-meter {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}

.meter-label {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: rgba(152, 162, 192, 0.72);
}

.meter-track {
  flex: 1 1 auto;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.42);
  overflow: hidden;
}

.meter-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  box-shadow: 0 0 8px rgba(255, 209, 102, 0.5);
  transition: width 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.meter-value {
  min-width: 27px;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: rgba(152, 162, 192, 0.9);
}

.power-meter.near .meter-value {
  color: var(--gold);
}

.power-meter.ready .meter-fill {
  background: linear-gradient(90deg, var(--gold), #ffe08a, var(--gold));
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.85);
}

.power-meter [hidden] {
  display: none;
}

.power-claim {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 224, 138, 0.9);
  background: linear-gradient(180deg, #ffd166, #ff9f5a);
  color: #241505;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.1em;
  cursor: pointer;
  animation: claimPulse 1.15s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.6);
}

.power-claim:active {
  transform: scale(0.93);
}

.power-meter.paid .meter-fill {
  animation: meterPaid 0.6s ease;
}

.power-btn {
  --pc: 152, 162, 192;
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(var(--pc), 0.24);
  background: rgba(var(--pc), 0.09);
  color: rgb(var(--pc));
  cursor: pointer;
  transition: transform 0.12s ease, background 0.16s ease,
    box-shadow 0.16s ease, opacity 0.16s ease;
}

.power-btn .power-icon {
  width: 19px;
  height: 19px;
}

.power-btn:active {
  transform: scale(0.92);
}

.power-btn:disabled {
  opacity: 0.32;
  cursor: default;
  transform: none;
}

.power-btn.armed {
  background: rgba(var(--pc), 0.24);
  box-shadow:
    0 0 0 2px rgba(var(--pc), 0.55),
    0 0 18px rgba(var(--pc), 0.32);
  animation: powerPulse 1.1s ease-in-out infinite;
}

.power-btn.spent {
  animation: powerSpend 0.36s ease;
}

.power-btn.gain {
  animation: powerGain 0.85s ease;
}

.power-count {
  position: absolute;
  top: -4px;
  right: -4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: rgba(var(--pc), 0.92);
  border: 1px solid rgba(8, 12, 28, 0.92);
  color: #0a1024;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hint-btn {
  --pc: 94, 234, 212;
}

.shuffle-btn {
  --pc: 125, 211, 252;
}

.hammer-btn {
  --pc: 255, 209, 102;
}

.wild-btn {
  --pc: 196, 181, 253;
}

.swap-btn {
  --pc: 255, 143, 163;
}

/* ---------- stage & board ---------- */

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding-top: 4px;
}

.ticker {
  width: 100%;
  height: 40px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  overflow: hidden;
  padding: 0 4px;
}

.ticker-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  white-space: nowrap;
  animation: chipIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.ticker-chip b {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.ticker-chip span {
  font-size: 10px;
  font-weight: 500;
  color: var(--gold);
}

.ticker-chip.out {
  animation: chipOut 0.25s ease forwards;
}

.ticker-empty {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(152, 162, 192, 0.55);
}

.board-shell {
  flex: 0 0 auto;
  width: min(92vw, 440px);
  filter: drop-shadow(0 26px 38px rgba(0, 0, 0, 0.38));
}

.board {
  position: relative;
  width: 100%;
  padding: 9px;
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.11);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.13),
    inset 0 -14px 34px rgba(0, 0, 0, 0.26),
    0 1px 0 rgba(255, 255, 255, 0.04);
}

.grid {
  position: relative;
  width: 100%;
  height: 0;
  --cell: 48px;
  --gap: 5px;
  touch-action: none;
}

.fx {
  position: absolute;
  inset: 9px;
  pointer-events: none;
  overflow: visible;
}

.board.shake {
  animation: boardShake 0.38s ease;
}

.board.shuffle {
  animation: boardFlash 0.32s ease;
}

.caption {
  margin: 0;
  min-height: 18px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-align: center;
  color: rgba(152, 162, 192, 0.8);
  text-transform: uppercase;
}

.caption.prompt {
  color: var(--gold);
  animation: captionPulse 1.2s ease-in-out infinite;
}

/* While a target power is armed, every legal tile gets a soft halo. */
.board[data-target] .tile .tile-face {
  outline: 1px dashed rgba(255, 255, 255, 0.28);
  outline-offset: -3px;
}

.board[data-target="hammer"] .tile .tile-face {
  outline-color: rgba(255, 209, 102, 0.6);
}

.board[data-target="wild"] .tile:not(.stone) .tile-face {
  outline-color: rgba(196, 181, 253, 0.6);
}

.board[data-target="swap"] .tile:not(.stone) .tile-face {
  outline-color: rgba(255, 143, 163, 0.55);
}

.tile.picked .tile-face {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.34),
    inset 0 -3px 0 rgba(0, 0, 0, 0.26),
    0 0 0 3px rgba(255, 143, 163, 0.85),
    0 0 22px rgba(255, 143, 163, 0.45);
}

.tile.smashing .tile-face {
  animation: tileSmash 0.3s ease-in forwards;
}

.tile.forging .tile-face {
  animation: tileForge 0.55s ease;
}

/* ---------- tiles ---------- */

.tile {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--cell);
  height: var(--cell);
  z-index: 1;
  transform: translate(0, 0);
  transition: transform 0.27s cubic-bezier(0.2, 0.9, 0.3, 1.12);
  will-change: transform;
  cursor: pointer;
  touch-action: none;
}

.tile.no-transition {
  transition: none !important;
}

.tile-face {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 24%;
  font-size: calc(var(--cell) * 0.52);
  font-weight: 600;
  color: #ffffff;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.34),
    inset 0 -3px 0 rgba(0, 0, 0, 0.26),
    inset 0 0 0 1px rgba(255, 255, 255, 0.1),
    0 4px 0 rgba(0, 0, 0, 0.3),
    0 8px 13px rgba(0, 0, 0, 0.24);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.34);
  transition:
    transform 0.18s ease,
    opacity 0.18s ease,
    filter 0.18s ease,
    box-shadow 0.18s ease;
  will-change: transform;
  overflow: hidden;
}

.tile-face::after {
  content: "";
  position: absolute;
  inset: 7% 9% auto;
  height: 24%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0));
  opacity: 0.8;
  pointer-events: none;
}

.tile-letter {
  position: relative;
  z-index: 1;
  transform: translateY(-1%);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.38);
}

/* Tile colours are meaningful: amber = vowel, emerald/teal = common
   consonant, sapphire = uncommon consonant, rose = rare consonant
   (J Q X Z). Deep jewel tones keep white letters crisp on the dark board
   while four shades per family stop a common-heavy board looking flat. */
.tv { background: linear-gradient(160deg, #ffc94a 0%, #f59e0b 48%, #b45309 100%); }
.tv.tva { background: linear-gradient(160deg, #ffd76b 0%, #f2a516 46%, #a85c00 100%); }
.tv.tvb { background: linear-gradient(160deg, #ffb24a 0%, #ea7d12 46%, #9a3d00 100%); }
.tv.tvc { background: linear-gradient(160deg, #ffd98a 0%, #e9a800 44%, #966400 100%); }

.tc { background: linear-gradient(160deg, #34d399 0%, #059669 48%, #065f46 100%); }
.tc.tca { background: linear-gradient(160deg, #5eead4 0%, #0d9488 46%, #115e59 100%); }
.tc.tcb { background: linear-gradient(160deg, #4ade80 0%, #16a34a 46%, #14532d 100%); }
.tc.tcc { background: linear-gradient(160deg, #6ee7b7 0%, #10b981 46%, #047857 100%); }

.tu { background: linear-gradient(160deg, #60a5fa 0%, #3b82f6 48%, #1d4ed8 100%); }
.tu.tua { background: linear-gradient(160deg, #38bdf8 0%, #0ea5e9 46%, #0369a1 100%); }
.tu.tub { background: linear-gradient(160deg, #7ca7ff 0%, #4f7bf7 46%, #1e40af 100%); }
.tu.tuc { background: linear-gradient(160deg, #a5b4fc 0%, #6366f1 46%, #3730a3 100%); }

.tr { background: linear-gradient(160deg, #fb7185 0%, #f43f5e 46%, #be123c 100%); }
.tr.tra { background: linear-gradient(160deg, #f472b6 0%, #ec4899 46%, #9d174d 100%); }
.tr.trb { background: linear-gradient(160deg, #fca5a5 0%, #ef4444 44%, #991b1b 100%); }
.tr.trc { background: linear-gradient(160deg, #e879f9 0%, #d946ef 46%, #86198f 100%); }

/* Special tiles: wildcard matches any letter, ×2 doubles the word, stone
   blocks the board until a word clears beside it. */
.tile-face.wild {
  background: linear-gradient(150deg, #ffd166 0%, #ff8b5e 46%, #9d6bff 100%);
  color: #2a1b3d;
}

.tile-face.bonus {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.62),
    inset 0 -3px 0 rgba(0, 0, 0, 0.17),
    0 0 0 2px rgba(255, 232, 168, 0.75),
    0 4px 0 rgba(0, 0, 0, 0.24),
    0 8px 13px rgba(0, 0, 0, 0.22);
}

.tile-bonus {
  position: absolute;
  right: 4%;
  top: 3%;
  z-index: 2;
  padding: 1px 4px;
  border-radius: 999px;
  background: rgba(24, 20, 40, 0.78);
  color: #ffe8a8;
  font-size: calc(var(--cell) * 0.2);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0;
}

.tile-face.stone {
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.24), transparent 46%),
    linear-gradient(160deg, #5b6478, #2c3242);
  color: rgba(255, 255, 255, 0.82);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.26),
    inset 0 -3px 0 rgba(0, 0, 0, 0.32),
    0 4px 0 rgba(0, 0, 0, 0.3),
    0 8px 13px rgba(0, 0, 0, 0.26);
}

.tile.stone,
.tile.stone .tile-face {
  cursor: default;
}

.tile.breaking .tile-face {
  animation: stoneBreak 0.2s ease-in forwards;
}

@keyframes stoneBreak {
  0% { transform: scale(1); filter: brightness(1); opacity: 1; }
  35% { transform: scale(1.12) rotate(-4deg); filter: brightness(1.6); }
  100% { transform: scale(0.5) rotate(12deg); filter: brightness(1.9); opacity: 0; }
}

.tile.pressed .tile-face {
  transform: scale(0.94);
  filter: brightness(1.04);
}

.tile.selected .tile-face {
  transform: translateY(-4px) scale(1.07);
  filter: brightness(1.1);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.6),
    0 0 0 3px var(--gold),
    0 10px 24px rgba(255, 209, 102, 0.42);
}

.tile.hint .tile-face {
  animation: hintPulse 0.82s ease-in-out infinite;
}

.tile.matched {
  z-index: 4;
}

.tile.matched .tile-face {
  animation: matchFlash 0.34s ease;
  filter: brightness(1.3) saturate(1.15);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.7),
    0 0 0 2px rgba(255, 255, 255, 0.85),
    0 0 26px rgba(255, 255, 255, 0.55);
}

.tile.clearing .tile-face {
  transform: scale(0.12) rotate(10deg);
  opacity: 0;
  transition: transform 0.2s ease-in, opacity 0.2s ease-in;
}

/* ---------- floating feedback ---------- */

.float-score {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  font-size: 21px;
  font-weight: 600;
  color: var(--gold);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
  pointer-events: none;
  animation: floatUp 0.98s ease-out forwards;
}

.float-score small {
  margin-left: 3px;
  font-size: 12px;
  color: var(--teal);
}

.burst {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}

.burst .shard {
  position: absolute;
  left: -3px;
  top: -3px;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--gold);
  box-shadow: 0 0 10px rgba(255, 209, 102, 0.55);
  transform: rotate(var(--a));
  animation: shardOut 0.58s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}

.burst.spark .shard {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 10px rgba(196, 181, 253, 0.8);
}

.burst.shuffle .shard {
  background: var(--blue);
  box-shadow: 0 0 10px rgba(125, 211, 252, 0.65);
}

.combo {
  position: fixed;
  left: 50%;
  top: 30%;
  z-index: 30;
  padding: 8px 17px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe08a, #ffc247);
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.12em;
  box-shadow: 0 10px 32px rgba(255, 193, 71, 0.48);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.7);
}

.combo.show {
  animation: comboPop 0.92s cubic-bezier(0.2, 0.9, 0.3, 1.15) forwards;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + max(env(safe-area-inset-bottom), var(--safe-bottom, 0px)));
  z-index: 90;
  max-width: calc(100vw - 40px);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(19, 26, 52, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- level goal bar (always visible during play) ---------- */

.level-intro {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 6px 15px;
  border-radius: 999px;
  background: rgba(15, 21, 44, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-align: center;
  opacity: 1;
  pointer-events: none;
  transform: scale(1);
}

#app[data-screen="title"] .level-intro {
  opacity: 0;
}

.level-intro.show {
  animation: levelIntro 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}

.level-intro-item {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.level-intro-kicker {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--gold);
}

.level-intro-item b {
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.level-intro-item b.low {
  color: var(--danger, #ff7a8a);
}

.level-intro-target {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(20px, env(safe-area-inset-top), var(--safe-top, 0px))
    22px
    max(20px, env(safe-area-inset-bottom), var(--safe-bottom, 0px));
  background: rgba(4, 7, 18, 0.72);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  animation: overlayIn 0.24s ease;
}

.overlay.hidden {
  display: none !important;
}

/* ---------- level intro screen ---------- */

.intro-screen {
  z-index: 72;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 209, 102, 0.1), transparent 58%),
    rgba(4, 7, 18, 0.78);
}

.intro-card {
  position: relative;
  width: min(360px, 100%);
  max-height: calc(100vh - 44px);
  max-height: calc(100dvh - 44px);
  overflow-y: auto;
  padding: 24px 22px 18px;
  border-radius: 28px;
  background: linear-gradient(180deg, #1b2448, #111731);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  text-align: center;
  animation: sheetIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}

.intro-level {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  margin: 7px 0 2px;
}

.intro-level-num {
  font-size: clamp(52px, 15vw, 64px);
  line-height: 0.9;
  font-weight: 600;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 6px 26px rgba(255, 209, 102, 0.35);
}

.intro-tags {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.intro-tag {
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.intro-card h2 {
  margin: 8px 0 15px;
  font-size: clamp(20px, 5.6vw, 25px);
  line-height: 1.14;
  font-weight: 600;
}

.intro-goal {
  padding: 12px 13px 11px;
  border-radius: 16px;
  background: rgba(255, 209, 102, 0.07);
  border: 1px solid rgba(255, 209, 102, 0.2);
}

.intro-goal-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.intro-goal-top > span:first-child {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--gold);
}

.intro-goal-count {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.intro-goal-count b {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.intro-goal p {
  margin: 7px 0 0;
  font-size: 11px;
  line-height: 1.45;
  text-align: left;
  color: var(--muted);
}

.intro-specials {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
}

.intro-special {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 10px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.intro-special b {
  color: var(--text);
  font-weight: 600;
}

.intro-powers {
  margin: 10px 0 0;
  font-size: 9.5px;
  line-height: 1.55;
  letter-spacing: 0.04em;
  color: rgba(152, 162, 192, 0.85);
}

.intro-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.intro-moves {
  flex: 0 0 auto;
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.1;
}

.intro-moves b {
  display: block;
  margin-bottom: 2px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.intro-footer .primary-btn {
  flex: 1;
  min-height: 48px;
  font-size: 16px;
}

.intro-tap {
  margin: 9px 0 0;
  font-size: 8.5px;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: rgba(152, 162, 192, 0.65);
}

/* ---------- title ---------- */

.title-screen {
  z-index: 60;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 16%, rgba(94, 66, 190, 0.4), transparent 55%),
    radial-gradient(circle at 10% 84%, rgba(20, 140, 128, 0.18), transparent 48%),
    linear-gradient(180deg, #070b1a 0%, #0c1230 100%);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  animation: none;
}

.title-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ghost-letter {
  position: absolute;
  left: var(--x);
  top: var(--y);
  font-size: clamp(46px, 14vw, 82px);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.035);
  transform: rotate(var(--r));
  animation: ghostDrift 9s ease-in-out infinite;
  animation-delay: var(--d);
}

.title-inner {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.logo {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 26px;
}

.logo-row {
  display: flex;
  justify-content: center;
  gap: 7px;
}

.logo-tile {
  width: clamp(48px, 14.5vw, 66px);
  height: clamp(48px, 14.5vw, 66px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22%;
  font-size: clamp(27px, 8vw, 38px);
  font-weight: 600;
  color: #ffffff;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.32);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.34),
    inset 0 -4px 0 rgba(0, 0, 0, 0.24),
    inset 0 0 0 1px rgba(255, 255, 255, 0.1),
    0 6px 0 rgba(0, 0, 0, 0.28),
    0 15px 26px rgba(0, 0, 0, 0.32);
  animation: logoBob 3.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.09s);
}

.logo-tile.c0 { background: linear-gradient(160deg, #ffc94a 0%, #f59e0b 48%, #b45309 100%); }
.logo-tile.c1 { background: linear-gradient(160deg, #34d399 0%, #059669 48%, #065f46 100%); }
.logo-tile.c2 { background: linear-gradient(160deg, #60a5fa 0%, #3b82f6 48%, #1d4ed8 100%); }
.logo-tile.c3 { background: linear-gradient(160deg, #fb7185 0%, #f43f5e 46%, #be123c 100%); }
.logo-tile.c4 { background: linear-gradient(160deg, #5eead4 0%, #0d9488 46%, #115e59 100%); }
.logo-tile.c5 { background: linear-gradient(160deg, #ffb24a 0%, #ea7d12 46%, #9a3d00 100%); }

.logo-row:nth-child(2) {
  transform: translateX(7px);
}

.tagline {
  margin: 0 0 28px;
  font-size: clamp(16px, 4.6vw, 20px);
  line-height: 1.45;
  letter-spacing: 0.02em;
  color: #bcc5de;
}

.tagline em {
  font-style: normal;
  color: var(--gold);
}

.title-actions {
  width: min(300px, 82vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.continue-btn {
  width: 100%;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: 14px;
  border: 1px solid rgba(94, 234, 212, 0.55);
  background: rgba(13, 148, 136, 0.16);
  color: #b8fff4;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.continue-btn:active {
  transform: scale(0.98);
}

.title-chips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.chip-btn {
  min-height: 44px;
  padding: 5px 3px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.06);
  color: #cdd5ea;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.16s ease;
}

.chip-btn:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.1);
}

.chip-btn.done {
  border-color: rgba(94, 234, 212, 0.45);
  color: #9df5e8;
}

.text-btn {
  min-height: 38px;
  padding: 6px 12px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.text-btn:active {
  color: var(--text);
}

.best-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.17em;
  color: var(--muted);
}

.best-line strong {
  margin-left: 4px;
  font-size: 14px;
  letter-spacing: 0.05em;
  color: var(--gold);
}

.best-sep {
  opacity: 0.45;
}

.star-glyph {
  font-size: 12px;
  color: var(--gold);
}

/* ---------- buttons ---------- */

.primary-btn,
.ghost-btn {
  width: 100%;
  min-height: 52px;
  padding: 13px 22px;
  border-radius: 16px;
  border: none;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.16s ease;
}

.primary-btn {
  color: #241a05;
  background: linear-gradient(180deg, #ffe08a, #ffc247);
  box-shadow:
    0 5px 0 #b7791f,
    0 14px 28px rgba(255, 193, 71, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.primary-btn:active {
  transform: translateY(4px);
  box-shadow:
    0 1px 0 #b7791f,
    0 6px 16px rgba(255, 193, 71, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.ghost-btn {
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.ghost-btn:active {
  transform: scale(0.98);
  background: rgba(255, 255, 255, 0.09);
}

/* ---------- sheets ---------- */

.sheet {
  position: relative;
  width: min(370px, 100%);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  padding: 26px 22px 22px;
  border-radius: 28px;
  background: linear-gradient(180deg, #1b2448, #111731);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  text-align: center;
  overflow-y: auto;
  animation: sheetIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}

.sheet h2 {
  margin: 7px 0 6px;
  font-size: clamp(24px, 7vw, 30px);
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.eyebrow {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--gold);
}

.sheet-sub {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.sheet-sub strong {
  color: var(--text);
  font-weight: 600;
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 20px;
}

.sheet .primary-btn,
.sheet .ghost-btn {
  min-height: 48px;
  font-size: 16px;
}

.how-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin: 21px 0 22px;
  text-align: left;
}

.how-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.how-num {
  flex: 0 0 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 209, 102, 0.12);
  border: 1px solid rgba(255, 209, 102, 0.28);
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
}

.how-item h3 {
  margin: 2px 0 3px;
  font-size: 15px;
  font-weight: 600;
}

.how-item p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.tile-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 12px;
  margin: 4px 0 18px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.legend-swatch.wild {
  background: linear-gradient(150deg, #ffd166 0%, #ff8b5e 46%, #9d6bff 100%);
}

.legend-swatch.bonus {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(24, 20, 40, 0.92);
  box-shadow: inset 0 0 0 1.5px #ffe8a8;
  color: #ffe8a8;
  font-size: 7px;
  font-style: normal;
  font-weight: 600;
  line-height: 1;
}

.legend-swatch.bonus::after {
  content: "×2";
}

.legend-swatch.stone {
  background: linear-gradient(160deg, #5b6478, #2c3242);
}

/* ---------- level map ---------- */

.levels-sheet {
  width: min(400px, 100%);
}

.level-map {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0 4px;
  padding: 4px;
  max-height: min(44vh, 340px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.level-node {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease;
}

.level-node:active {
  transform: scale(0.94);
}

.level-node-num {
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.level-node-stars {
  display: flex;
  gap: 1px;
  font-size: 7px;
  line-height: 1;
  color: var(--gold);
}

.level-node-stars .dim {
  color: rgba(255, 255, 255, 0.16);
}

.level-node.current {
  border-color: rgba(255, 209, 102, 0.65);
  background: rgba(255, 209, 102, 0.12);
  box-shadow:
    0 0 0 1px rgba(255, 209, 102, 0.28),
    0 8px 20px rgba(255, 209, 102, 0.14);
}

.level-node.done {
  border-color: rgba(94, 234, 212, 0.28);
  background: rgba(94, 234, 212, 0.09);
}

.level-node.locked {
  cursor: default;
  color: rgba(152, 162, 192, 0.5);
  background: rgba(255, 255, 255, 0.025);
  border-color: rgba(255, 255, 255, 0.06);
}

.level-node.locked .level-node-stars {
  display: none;
}

.level-node.locked::after {
  content: "LOCKED";
  font-size: 6px;
  letter-spacing: 0.1em;
  color: rgba(152, 162, 192, 0.6);
}

.map-note {
  margin: 10px 4px 0;
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
}

.next-goal {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 209, 102, 0.07);
  border: 1px solid rgba(255, 209, 102, 0.18);
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.next-goal strong {
  color: var(--gold);
  font-weight: 600;
}

/* ---------- level complete ---------- */

.stars {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin: 14px 0 4px;
  font-size: 27px;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255, 209, 102, 0.55);
}

.stars .star {
  display: inline-block;
  animation: starPop 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.4) both;
}

.stars .star:nth-child(2) {
  animation-delay: 0.1s;
}

.stars .star:nth-child(3) {
  animation-delay: 0.2s;
}

.stars .star.dim {
  color: rgba(255, 255, 255, 0.13);
  text-shadow: none;
  animation: none;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 18px 0 14px;
}

.stat-grid > div {
  padding: 11px 4px 9px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-grid span {
  display: block;
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-grid small {
  display: block;
  margin-top: 3px;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.star-note {
  margin: 2px 0 0;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- stats, achievements, settings ---------- */

.stats-sheet {
  width: min(400px, 100%);
}

.stats-grid {
  grid-template-columns: repeat(2, 1fr);
  margin: 18px 0 8px;
}

.stats-grid span {
  font-size: 17px;
}

.stats-grid small {
  font-size: 8px;
}

.daily-stats {
  margin: 18px 0 0;
}

.ach-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 18px 2px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.ach-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: min(38vh, 300px);
  overflow-y: auto;
  padding: 2px;
  scrollbar-width: thin;
}

.ach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  opacity: 0.62;
}

.ach-item.unlocked {
  opacity: 1;
  background: rgba(255, 209, 102, 0.08);
  border-color: rgba(255, 209, 102, 0.24);
}

.ach-badge {
  flex: 0 0 29px;
  height: 29px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.4);
  font-size: 15px;
}

.ach-item.unlocked .ach-badge {
  background: linear-gradient(160deg, #ffe08a, #ffb84d);
  color: #3a2500;
  box-shadow: 0 0 10px rgba(255, 209, 102, 0.32);
}

.ach-copy {
  min-width: 0;
}

.ach-copy b {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.ach-copy small {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  line-height: 1.35;
  color: var(--muted);
}

.setting-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 20px 0 16px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-height: 54px;
  padding: 9px 13px;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.setting-copy b {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.setting-copy small {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--muted);
}

.switch {
  position: relative;
  flex: 0 0 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: background 0.18s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #c8d0e6;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s ease, background 0.18s ease;
}

.setting-row[aria-checked="true"] .switch {
  background: linear-gradient(90deg, #0d9488, #34d399);
}

.setting-row[aria-checked="true"] .switch::after {
  transform: translateX(18px);
  background: #ffffff;
}

.danger-btn {
  width: 100%;
  min-height: 46px;
  margin-top: 4px;
  padding: 11px 18px;
  border-radius: 14px;
  border: 1px solid rgba(251, 113, 133, 0.45);
  background: rgba(190, 18, 60, 0.16);
  color: #ffc2cb;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
}

.danger-btn.armed {
  background: linear-gradient(180deg, #f43f5e, #be123c);
  color: #ffffff;
  animation: claimPulse 1s ease-in-out infinite;
}

.setting-note {
  margin: 9px 2px 0;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--muted);
}

.word-review {
  margin: 0;
  padding: 10px 12px 11px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
}

.word-review-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}

.word-review-head span:last-child {
  color: var(--gold);
  font-weight: 600;
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  max-height: 76px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.word-chip {
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(94, 234, 212, 0.1);
  border: 1px solid rgba(94, 234, 212, 0.22);
  color: #d7fff9;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  animation: chipIn 0.24s ease both;
}

.word-chip.best {
  background: rgba(255, 209, 102, 0.14);
  border-color: rgba(255, 209, 102, 0.38);
  color: var(--gold);
}

.word-chip.more {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--muted);
}

.word-empty {
  font-size: 11px;
  font-style: italic;
  color: var(--muted);
}

.run-note {
  margin: 8px 0 0;
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--muted);
}

/* ---------- game over ---------- */

.big-score {
  margin: 16px 0 2px;
  font-size: 52px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 6px 30px rgba(255, 209, 102, 0.3);
}

.new-best {
  display: inline-block;
  margin: 13px 0 0;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.13);
  border: 1px solid rgba(255, 209, 102, 0.3);
  color: var(--gold);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  animation: bestGlow 1.4s ease-in-out infinite;
}

/* ---------- animations ---------- */

@keyframes orbDrift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(3vw, 2vh, 0) scale(1.08); }
}

@keyframes scoreBump {
  0% { transform: scale(1); }
  42% { transform: scale(1.16); color: var(--gold); }
  100% { transform: scale(1); }
}

@keyframes lowPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@keyframes chipIn {
  from { opacity: 0; transform: translateY(8px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes chipOut {
  to { opacity: 0; transform: translateY(-8px) scale(0.92); }
}

@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -35%) scale(0.8); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1.06); }
}

@keyframes comboPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6) rotate(-6deg); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.08) rotate(2deg); }
  70% { opacity: 1; transform: translate(-50%, -55%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -95%) scale(0.95) rotate(0deg); }
}

@keyframes boardShake {
  0%, 100% { transform: translateX(0); }
  18% { transform: translateX(-7px) rotate(-0.5deg); }
  36% { transform: translateX(6px) rotate(0.4deg); }
  54% { transform: translateX(-4px); }
  72% { transform: translateX(3px); }
  88% { transform: translateX(-1px); }
}

@keyframes boardFlash {
  0%, 100% { filter: brightness(1); }
  40% { filter: brightness(1.35); }
}

@keyframes powerPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(var(--pc), 0.5), 0 0 12px rgba(var(--pc), 0.25); }
  50% { box-shadow: 0 0 0 3px rgba(var(--pc), 0.8), 0 0 22px rgba(var(--pc), 0.5); }
}

@keyframes powerSpend {
  0% { transform: scale(1); }
  35% { transform: scale(0.82); }
  100% { transform: scale(1); }
}

@keyframes powerGain {
  0% { transform: scale(1); }
  22% {
    transform: scale(1.24);
    box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.7), 0 0 26px rgba(255, 209, 102, 0.6);
  }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@keyframes meterPaid {
  0% { filter: brightness(2.4); }
  100% { filter: brightness(1); }
}

@keyframes claimPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 10px rgba(255, 209, 102, 0.45);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 0 20px rgba(255, 209, 102, 0.85);
  }
}

@keyframes captionPulse {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}

@keyframes tileSmash {
  0% { transform: scale(1) rotate(0); opacity: 1; }
  35% { transform: scale(1.1) rotate(3deg); filter: brightness(1.7); }
  100% { transform: scale(0.15) rotate(-16deg); opacity: 0; }
}

@keyframes tileForge {
  0% { filter: brightness(1); }
  35% { filter: brightness(2); transform: scale(1.08); }
  100% { filter: brightness(1); transform: scale(1); }
}

@keyframes shardOut {
  0% { opacity: 1; transform: rotate(var(--a)) translateX(2px) scale(1); }
  100% { opacity: 0; transform: rotate(var(--a)) translateX(var(--d)) scale(0.3); }
}

@keyframes hintPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow:
      inset 0 2px 0 rgba(255, 255, 255, 0.55),
      inset 0 -3px 0 rgba(0, 0, 0, 0.17),
      0 4px 0 rgba(0, 0, 0, 0.24),
      0 0 0 0 rgba(94, 234, 212, 0);
  }
  50% {
    transform: scale(1.07);
    box-shadow:
      inset 0 2px 0 rgba(255, 255, 255, 0.65),
      inset 0 -3px 0 rgba(0, 0, 0, 0.17),
      0 0 0 3px rgba(94, 234, 212, 0.9),
      0 0 24px rgba(94, 234, 212, 0.6);
  }
}

@keyframes matchFlash {
  0% { transform: scale(1); }
  45% { transform: scale(1.15); }
  100% { transform: scale(1.04); }
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheetIn {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes levelIntro {
  0% { transform: scale(0.9); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@keyframes logoBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes ghostDrift {
  0%, 100% { transform: rotate(var(--r)) translateY(0); }
  50% { transform: rotate(var(--r)) translateY(-14px); }
}

@keyframes starPop {
  from { opacity: 0; transform: scale(0.2) rotate(-18deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes bestGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 209, 102, 0); }
  50% { box-shadow: 0 0 18px rgba(255, 209, 102, 0.28); }
}

/* ---------- short screens ---------- */

@media (max-height: 660px) {
  .logo {
    margin-bottom: 18px;
  }

  .tagline {
    margin-bottom: 20px;
  }

  .title-actions {
    margin-bottom: 18px;
  }

  .logo-tile {
    width: clamp(42px, 12vw, 56px);
    height: clamp(42px, 12vw, 56px);
    font-size: clamp(24px, 7vw, 32px);
  }

  .sheet {
    padding: 22px 18px 18px;
  }

  .level-map {
    max-height: 34vh;
  }

  .stat-grid {
    margin: 14px 0 10px;
  }

  .intro-card {
    padding: 18px 18px 14px;
  }

  .intro-level-num {
    font-size: 48px;
  }

  .intro-card h2 {
    margin: 6px 0 10px;
    font-size: 20px;
  }

  .intro-footer {
    margin-top: 12px;
  }

  .word-list {
    max-height: 58px;
  }

  .power-dock {
    gap: 4px;
  }

  .power-btn {
    width: 35px;
    height: 35px;
  }
}

@media (max-width: 350px) {
  .power-dock {
    gap: 3px;
    padding: 2px;
  }

  .power-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }

  .power-btn .power-icon {
    width: 16px;
    height: 16px;
  }

  .power-count {
    min-width: 14px;
    height: 14px;
    font-size: 8.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}
