/* WordWise — mobile-first styles. */

:root {
  --bg: #F4EFE4;
  --card: #FFFDF8;
  --ink: #1E2433;
  --ink-soft: #454D63;
  --muted: #5F6776;
  --line: rgba(30, 36, 51, 0.10);
  --line-strong: rgba(30, 36, 51, 0.18);
  --gold: #F5A524;
  --gold-deep: #8A5400;
  --danger: #B3261E;
  --radius: 20px;
  --shadow-soft: 0 10px 28px -20px rgba(30, 36, 51, 0.55);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: ui-rounded, "Segoe UI Variable Display", "Segoe UI", system-ui,
    -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 520px at 50% -180px, #FFFDF6 0%, rgba(255, 253, 246, 0) 62%),
    radial-gradient(760px 500px at 108% 88%, #F1E4CC 0%, rgba(241, 228, 204, 0) 60%),
    radial-gradient(720px 560px at -10% 72%, #F2EAD9 0%, rgba(242, 234, 217, 0) 62%);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body.is-modal {
  overflow: hidden;
}

h1, h2, h3, h4, p {
  margin: 0;
}

ul, ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: default;
}

:focus-visible {
  outline: 3px solid #2F6FED;
  outline-offset: 2px;
}

.icon {
  display: block;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.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;
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 600px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
}

.screen {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 16px calc(24px + var(--safe-bottom));
}

/* Themed backdrop shown on the chapter hub and every level of that theme. */
.theme-bg {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  z-index: 0;
  width: min(100%, 600px);
  overflow: hidden;
  transform: translateX(-50%);
  pointer-events: none;
}

.theme-bg-art {
  position: absolute;
  inset: -4%;
  background-size: cover;
  background-position: center;
  opacity: 0.95;
}

.theme-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(244, 239, 228, 0.82) 0%,
    rgba(244, 239, 228, 0.3) 22%,
    rgba(244, 239, 228, 0.46) 58%,
    rgba(244, 239, 228, 0.82) 88%,
    rgba(244, 239, 228, 0.96) 100%
  );
}

/* ------------------------------------------------------------------ *
 * Top bar
 * ------------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: rgba(244, 239, 228, 0.82);
  border-bottom: 1px solid rgba(30, 36, 51, 0.06);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.home-topbar {
  grid-template-columns: minmax(0, 1fr) auto;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-title {
  min-width: 0;
  text-align: center;
}

.topbar-title h1 {
  font-size: 16.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-kicker {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-spacer {
  width: 44px;
  height: 44px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.8);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(30, 36, 51, 0.04);
  transition: transform 0.1s ease, background 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.94);
  background: #FFF9EE;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  color: #FFF9EC;
  font-size: 18px;
  font-weight: 900;
  background: linear-gradient(145deg, #F59E0B, #EA580C);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18),
    0 5px 12px -5px rgba(234, 88, 12, 0.7);
}

.brand-name {
  white-space: nowrap;
}

.coin-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: #FFF6E0;
  border: 1px solid #F1D9A6;
  color: #7A4A00;
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.coin-pill .icon {
  width: 17px;
  height: 17px;
  color: #E8A317;
}

.coin-pill.is-bump {
  animation: coinBump 0.35s ease;
}

.coin-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ------------------------------------------------------------------ *
 * Buttons
 * ------------------------------------------------------------------ */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 16px;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: transform 0.08s ease, box-shadow 0.12s ease, background 0.15s ease;
}

.btn .icon {
  width: 18px;
  height: 18px;
}

.btn:active {
  transform: translateY(2px);
}

.btn-light {
  background: #FFFDF8;
  color: var(--ink);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.16);
}

.btn-light:active {
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.16);
}

.btn-primary {
  background: #1E2433;
  color: #FFF7E8;
  box-shadow: 0 5px 0 #0C101B, 0 16px 26px -14px rgba(0, 0, 0, 0.55);
}

.btn-primary:active {
  box-shadow: 0 2px 0 #0C101B;
}

.btn-ghost {
  min-height: 48px;
  background: rgba(30, 36, 51, 0.06);
  color: var(--ink);
}

.btn-quiet {
  min-height: 40px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.btn-danger {
  min-height: 50px;
  background: #FDE9E7;
  border: 1px solid #F5C6C1;
  color: var(--danger);
}

/* ------------------------------------------------------------------ *
 * Home
 * ------------------------------------------------------------------ */

.continue-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: hidden;
  padding: 20px;
  border-radius: 26px;
  color: #fff;
  background: linear-gradient(135deg, var(--a, #F59E0B), var(--b, #D97706));
  box-shadow: 0 22px 42px -24px rgba(30, 36, 51, 0.6);
}

.continue-card::before {
  content: "";
  position: absolute;
  top: -90px;
  right: -40px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}

.continue-card::after {
  content: "";
  position: absolute;
  bottom: -70px;
  left: -30px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.continue-card.is-complete {
  background: linear-gradient(135deg, #F5A524, #C2410C);
}

.continue-copy,
.continue-card .btn {
  position: relative;
  z-index: 2;
}

.continue-art {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background-size: cover;
  background-position: center;
  opacity: 0.45;
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.continue-kicker {
  display: block;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.92;
}

.continue-title {
  margin: 4px 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  text-wrap: balance;
}

.continue-sub {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  opacity: 0.95;
}

.stats-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 12px 15px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.stat-value {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-total {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
}

.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 2px -2px;
}

.section-head h2 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.section-sub {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.chapter-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  text-align: left;
  box-shadow: 0 6px 18px -15px rgba(30, 36, 51, 0.55);
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.chapter-card:active {
  transform: scale(0.985);
}

.chapter-card.is-locked {
  opacity: 0.7;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: none;
}

.chapter-emoji {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 15px;
  font-size: 25px;
  background: linear-gradient(135deg, var(--a), var(--b));
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.16);
}

.chapter-card.is-locked .chapter-emoji {
  filter: saturate(0.3);
}

.chapter-info {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chapter-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-meta {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dots {
  display: flex;
  gap: 3px;
  margin-top: 3px;
}

.dot {
  width: 14px;
  height: 4px;
  border-radius: 999px;
  background: #E4DCCB;
}

.dot.is-on {
  background: var(--gold);
}

.chapter-tail {
  display: grid;
  place-items: center;
  width: 28px;
  flex: 0 0 auto;
  color: var(--muted);
}

.chapter-tail .icon {
  width: 18px;
  height: 18px;
}

.footnote {
  margin: 4px 8px 0;
  text-align: center;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--muted);
}

/* ------------------------------------------------------------------ *
 * Chapter map
 * ------------------------------------------------------------------ */

.chapter-hero {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: 26px;
  color: #fff;
  background: linear-gradient(135deg, var(--a), var(--b));
  box-shadow: 0 20px 38px -26px rgba(30, 36, 51, 0.65);
}

.chapter-hero::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -70px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.10);
}

.hero-art {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.55;
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.chapter-hero-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 14px;
}

.hero-emoji {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  border-radius: 18px;
  font-size: 30px;
  background: rgba(255, 255, 255, 0.18);
}

.hero-copy h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.hero-copy p {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  opacity: 0.92;
}

.chapter-hero.has-play {
  cursor: pointer;
  transition: transform 0.12s ease;
}

.chapter-hero.has-play:active {
  transform: scale(0.995);
}

.chapter-hero.has-play .chapter-hero-top {
  padding-right: 46px;
}

.hero-play-hit {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 14px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: #fff;
}

.hero-play-hit:focus-visible {
  outline: 3px solid #fff;
  outline-offset: -4px;
}

.hero-play-chip {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: transform 0.12s ease, background 0.15s ease;
}

.hero-play-hit:hover .hero-play-chip {
  background: rgba(255, 255, 255, 0.3);
}

.hero-play-hit:active .hero-play-chip {
  transform: scale(0.92);
}

.hero-play-chip .icon {
  width: 18px;
  height: 18px;
}

.hero-progress {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
}

.bar {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: #fff;
  transition: width 0.4s ease;
}

.hero-progress-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  font-weight: 700;
  opacity: 0.95;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.level-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  aspect-ratio: 1 / 1.08;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 4px 0 rgba(30, 36, 51, 0.05),
    0 10px 20px -17px rgba(30, 36, 51, 0.55);
  transition: transform 0.12s ease;
}

.level-tile:active {
  transform: translateY(2px);
}

.level-tile.is-solved {
  background: linear-gradient(180deg, #FFFDF5, #FFF5DF);
  border-color: #EFD6A2;
}

.level-tile.is-locked {
  background: rgba(255, 255, 255, 0.4);
  border-style: dashed;
  border-color: var(--line-strong);
  color: var(--muted);
  box-shadow: none;
}

.level-num {
  display: grid;
  place-items: center;
  min-height: 20px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.level-num .icon {
  width: 17px;
  height: 17px;
}

.level-stars {
  display: flex;
  line-height: 0;
}

.level-lock-label {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ------------------------------------------------------------------ *
 * Stars
 * ------------------------------------------------------------------ */

.stars {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.icon.star {
  width: 16px;
  height: 16px;
}

.icon.star.is-on {
  color: var(--gold);
  filter: drop-shadow(0 1px 0 rgba(185, 119, 0, 0.35));
}

.icon.star.is-off {
  color: #D9D1C1;
}

.stars.star-sm .icon {
  width: 11px;
  height: 11px;
}

.stars.star-lg .icon {
  width: 36px;
  height: 36px;
}

/* ------------------------------------------------------------------ *
 * Puzzle
 * ------------------------------------------------------------------ */

.play-screen {
  --slot: clamp(38px, 12.4vw, 56px);
  justify-content: center;
}

.play-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-block: auto;
  padding-top: 4px;
}

.play-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.play-chapter {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.play-meta .stars {
  margin-left: auto;
  flex: 0 0 auto;
}

.clue-card {
  padding: 18px 20px;
  border-radius: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  text-align: center;
  box-shadow: 0 12px 30px -24px rgba(30, 36, 51, 0.65);
}

.clue-label {
  display: block;
  margin-bottom: 6px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.clue-text {
  font-size: clamp(17px, 4.6vw, 20px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.4;
  text-wrap: balance;
}

.slots {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), var(--slot));
  gap: 8px;
  justify-content: center;
}

.slot {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 14px;
  padding: 0;
  font-size: calc(var(--slot) * 0.44);
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.8);
  border: 2px dashed var(--line-strong);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.1s ease;
}

.slot.is-empty::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
}

.slot:not(.is-empty) {
  background: #FFFDF8;
  border-style: solid;
  border-color: transparent;
  box-shadow: 0 4px 0 #E4DAC6, 0 12px 18px -15px rgba(30, 36, 51, 0.6);
}

.slot:not(.is-empty):not(.is-locked):active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #E4DAC6;
}

.slot.is-locked {
  background: #FFF3D6;
  border-color: #EFD192;
  color: #8A5400;
  box-shadow: 0 4px 0 #EBD39C;
}

.slot .letter {
  display: block;
  animation: letterIn 0.18s ease;
}

.slots.is-shaking {
  animation: shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.tray {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), var(--slot));
  gap: 8px;
  justify-content: center;
  min-height: var(--slot);
}

.tile {
  display: grid;
  place-items: center;
  width: var(--slot);
  height: var(--slot);
  padding: 0;
  border-radius: 14px;
  font-size: calc(var(--slot) * 0.42);
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
  background: linear-gradient(180deg, #FFFEFB, #FFF8EC);
  border: 1px solid rgba(30, 36, 51, 0.10);
  box-shadow: 0 4px 0 #E3D8C3, 0 14px 20px -16px rgba(30, 36, 51, 0.6);
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.18s ease;
}

.tile:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #E3D8C3;
}

.tile.is-used {
  opacity: 0;
  transform: scale(0.55);
  box-shadow: none;
  pointer-events: none;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.25fr;
  gap: 8px;
}

.act {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 50px;
  padding: 0 8px;
  border-radius: 15px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(30, 36, 51, 0.07);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.act:active {
  transform: translateY(2px);
  box-shadow: none;
}

.act .icon {
  width: 18px;
  height: 18px;
  color: var(--ink-soft);
}

.act-hint {
  background: #FFF6E0;
  border-color: #F0D8A2;
  color: #7A4A00;
}

.act-hint .icon {
  color: var(--gold-deep);
}

.act-hint.is-short {
  opacity: 0.68;
}

.cost {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 1px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(199, 124, 5, 0.13);
  font-size: 11.5px;
  font-weight: 800;
}

.cost .icon {
  width: 12px;
  height: 12px;
  color: var(--gold-deep);
}

/* ------------------------------------------------------------------ *
 * Win overlay
 * ------------------------------------------------------------------ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow: auto;
  background: rgba(18, 22, 34, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.overlay[hidden] {
  display: none;
}

.overlay.is-open {
  opacity: 1;
}

.overlay .win-card,
.overlay .dialog {
  transform: translateY(16px) scale(0.96);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.25);
}

.overlay.is-open .win-card,
.overlay.is-open .dialog {
  transform: none;
}

.win-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  margin: auto;
  padding: 26px 22px 20px;
  border-radius: 28px;
  background: var(--card);
  text-align: center;
  box-shadow: 0 34px 70px -24px rgba(0, 0, 0, 0.6);
}

.win-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--muted);
  background: rgba(30, 36, 51, 0.05);
}

.win-close .icon {
  width: 18px;
  height: 18px;
}

.win-emoji {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 10px;
  border-radius: 22px;
  font-size: 34px;
  background: #FFF4D8;
  box-shadow: 0 10px 20px -12px rgba(199, 124, 5, 0.65);
}

.win-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-deep);
}

.win-title {
  margin: 4px 0;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.02em;
  word-break: break-word;
}

.win-clue {
  max-width: 290px;
  margin: 0 auto 12px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--muted);
}

.win-stars {
  display: flex;
  justify-content: center;
  margin: 6px 0 4px;
}

.win-stars .stars {
  gap: 6px;
}

.win-stars .star {
  animation: starPop 0.45s both;
}

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

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

.win-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #E7F7EE;
  color: #127A4B;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.win-reward {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 12px auto 4px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #FFF6E0;
  color: #7A4A00;
  font-size: 13.5px;
  font-weight: 800;
}

.win-reward .icon {
  width: 16px;
  height: 16px;
  color: #E8A317;
}

.win-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.win-actions .btn {
  min-height: 48px;
}

/* ------------------------------------------------------------------ *
 * Settings & dialogs
 * ------------------------------------------------------------------ */

.settings-screen {
  gap: 12px;
}

.settings-card {
  overflow: hidden;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--line);
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.setting-row:last-child {
  border-bottom: 0;
}

.setting-row.is-static {
  cursor: default;
}

.setting-ico {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: #F3EEE3;
  color: var(--ink-soft);
}

.setting-ico .icon {
  width: 19px;
  height: 19px;
}

.setting-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.setting-copy strong {
  font-size: 14.5px;
  font-weight: 700;
}

.setting-copy small {
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--muted);
}

.setting-value {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.setting-value .icon {
  width: 16px;
  height: 16px;
}

.switch {
  position: relative;
  width: 50px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #DDD5C5;
  transition: background 0.2s ease;
}

.switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  transition: transform 0.2s ease;
}

.setting-row[aria-checked="true"] .switch {
  background: #23A06C;
}

.setting-row[aria-checked="true"] .switch .knob {
  transform: translateX(20px);
}

.app-version {
  padding-top: 6px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.dialog {
  width: 100%;
  max-width: 380px;
  margin: auto;
  padding: 24px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 34px 70px -24px rgba(0, 0, 0, 0.6);
}

.dialog h2 {
  margin-bottom: 8px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.dialog p {
  margin-bottom: 18px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.55;
  color: var(--ink-soft);
}

.dialog-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-state {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 30px 20px;
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin-bottom: 6px;
  border-radius: 24px;
  background: #FFF4D8;
  color: var(--gold-deep);
}

.empty-icon .icon {
  width: 32px;
  height: 32px;
}

.empty-state h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.empty-state p {
  max-width: 280px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--muted);
}

.empty-state .btn {
  max-width: 280px;
}

/* ------------------------------------------------------------------ *
 * Language picker
 * ------------------------------------------------------------------ */

.language-screen {
  justify-content: flex-start;
  gap: 18px;
  padding-top: 10px;
}

.language-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 2px;
  text-align: center;
}

.language-globe {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin-bottom: 4px;
  border-radius: 26px;
  font-size: 38px;
  background: linear-gradient(160deg, #FFF6DF, #FFE7B3);
  box-shadow: inset 0 -3px 0 rgba(199, 124, 5, 0.12),
    0 14px 30px -18px rgba(199, 124, 5, 0.6);
}

.language-hero h2 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  text-wrap: balance;
}

.language-hero p {
  max-width: 330px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--muted);
}

.language-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.language-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--card);
  border: 1.5px solid var(--line);
  text-align: left;
  box-shadow: 0 5px 16px -14px rgba(30, 36, 51, 0.5);
  transition: transform 0.12s ease, border-color 0.15s ease,
    background 0.15s ease, box-shadow 0.15s ease;
}

.language-option:active {
  transform: scale(0.985);
}

.language-option.is-selected {
  background: #FFFAEF;
  border-color: #1E2433;
  box-shadow: 0 0 0 3px rgba(30, 36, 51, 0.07),
    0 8px 20px -16px rgba(30, 36, 51, 0.6);
}

.language-code {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 14px;
  background: #F2ECE0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.language-option.is-selected .language-code {
  background: #1E2433;
  color: #FFF7E8;
}

.language-name {
  flex: 1;
  min-width: 0;
  font-size: 16.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.language-badge {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: #FFF1CD;
  color: var(--gold-deep);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.language-check {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  color: #FFF;
}

.language-check .icon {
  width: 16px;
  height: 16px;
}

.language-option.is-selected .language-check {
  background: #1E2433;
  border-color: #1E2433;
}

.language-note {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--muted);
}

.language-note .icon {
  width: 14px;
  height: 14px;
  margin-top: 1px;
  flex: 0 0 auto;
  color: #23A06C;
}

.language-screen .btn {
  margin-top: 2px;
}

/* ------------------------------------------------------------------ *
 * Toast & confetti
 * ------------------------------------------------------------------ */

.toast {
  position: fixed;
  bottom: calc(22px + var(--safe-bottom));
  left: 50%;
  z-index: 90;
  max-width: min(88vw, 420px);
  padding: 12px 18px;
  border-radius: 16px;
  background: #1E2433;
  color: #FFF7E8;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.6);
}

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

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -24px;
  border-radius: 2px;
  animation-name: confettiFall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

/* ------------------------------------------------------------------ *
 * Motion
 * ------------------------------------------------------------------ */

@keyframes letterIn {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes starPop {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  70% {
    opacity: 1;
    transform: scale(1.16);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

@keyframes coinBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translate3d(0, -10px, 0) rotate(0deg);
  }
  100% {
    opacity: 0.85;
    transform: translate3d(var(--drift, 0px), 105vh, 0) rotate(720deg);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ------------------------------------------------------------------ *
 * Responsive
 * ------------------------------------------------------------------ */

@media (max-width: 360px) {
  .brand-name {
    font-size: 16px;
  }

  .topbar {
    gap: 8px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .continue-title {
    font-size: 25px;
  }

  .actions {
    grid-template-columns: 1fr 1fr;
  }

  .act {
    font-size: 13px;
  }

  .act-hint {
    grid-column: 1 / -1;
  }

  .play-screen {
    --slot: clamp(35px, 11.8vw, 52px);
  }

  .level-tile {
    border-radius: 14px;
  }
}

@media (max-height: 640px) and (orientation: landscape) {
  .play-screen {
    --slot: clamp(32px, 9vh, 46px);
  }

  .play-body {
    gap: 10px;
  }

  .clue-card {
    padding: 12px 16px;
  }

  .clue-text {
    font-size: 15.5px;
  }

  .screen {
    padding-top: 10px;
    padding-bottom: calc(14px + var(--safe-bottom));
  }

  .actions .act {
    min-height: 44px;
  }
}

@media (max-height: 640px) {
  .language-screen {
    gap: 12px;
    padding-top: 4px;
  }

  .language-hero {
    gap: 5px;
    padding: 2px 6px 0;
  }

  .language-globe {
    width: 60px;
    height: 60px;
    margin-bottom: 0;
    border-radius: 21px;
    font-size: 30px;
  }

  .language-hero h2 {
    font-size: 23px;
  }

  .language-hero p {
    font-size: 12.5px;
    line-height: 1.4;
  }

  .language-list {
    gap: 7px;
  }

  .language-option {
    padding: 9px 12px;
    border-radius: 16px;
  }

  .language-code {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 12px;
  }

  .language-name {
    font-size: 15.5px;
  }

  .language-check {
    width: 26px;
    height: 26px;
  }

  .language-note {
    font-size: 10.5px;
  }

  .language-screen .btn {
    min-height: 48px;
  }
}

@media (min-width: 700px) {
  .app {
    max-width: 560px;
  }

  .screen {
    padding-left: 22px;
    padding-right: 22px;
  }

  .play-screen {
    --slot: 56px;
  }
}

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

/* Fallback for browsers without dvh support. */
@supports not (min-height: 100dvh) {
  .app {
    min-height: 100vh;
  }
}
