@font-face {
  font-family: "Zhezari";
  src: url("./assets/Zhezari_Standard_v4.5.ttf") format("truetype");
  font-display: swap;
}

/* Self-hosted so the desktop app's UI type is correct offline (variable fonts) */
@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("./assets/fonts/baloo2.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("./assets/fonts/nunito.woff2") format("woff2");
}

/* ============================================================
   Design tokens
   :root .............. dark "storybook night" palette
   body.theme-light ... warm storybook palette (the default)
   ============================================================ */
:root {
  color-scheme: dark;

  --deskspace:   #241d2a;
  --deskspace-2: #2c2333;
  --ground:      #2b2431;
  --panel:       #332a3b;
  --panel-2:     #3e3349;
  --edge:        #52425e;
  --edge-soft:   #443750;

  --ink:         #ece2ec;
  --ink-strong:  #fdf7fd;
  --ink-soft:    #b6a6bd;

  --frame:       #9c4666;
  --frame-inner: #c46f8c;

  --pink:        #f09ac1;
  --pink-hot:    #ef7fb0;
  --pink-ghost:  #45303c;

  --peach:       #f7c48d;
  --peach-deep:  #f0a862;
  --peach-ghost: #43362c;

  --tile-a:      #4b3a40;
  --tile-b:      #40323a;
  --tile-edge:   #5c4650;
  --tile-ink:    #f7e8de;
  --tile-label:  #e8b58d;

  --card-white:  #2f2734;

  --start-a:     #ef8fbb;
  --start-b:     #f4b978;

  --track-empty: #453a4e;
  --field-bg:    #241d2a;

  --good:        #7bd08d;
  --good-bg:     #22371f;
  --good-ink:    #e9ffe6;
  --bad:         #ff8f9f;
  --bad-bg:      #3a1a20;
  --bad-ink:     #ffe9ec;

  --r-window:  32px;
  --r-panel:   15px;
  --r-control: 12px;

  --shadow-panel: 0 8px 22px rgba(0, 0, 0, .26), inset 0 1px 0 rgba(255, 255, 255, .05);
  --shadow-pop:   0 7px 0 rgba(58, 20, 36, .55), 0 14px 22px rgba(0, 0, 0, .3);
  --shadow-tile:  0 5px 0 rgba(0, 0, 0, .3);

  --font-display: "Baloo 2", "Trebuchet MS", "Segoe UI Rounded", system-ui, sans-serif;
  --font-body:    "Nunito", "Trebuchet MS", system-ui, sans-serif;
}

body.theme-light {
  color-scheme: light;

  --deskspace:   #e6ddd6;
  --deskspace-2: #efe8e0;
  --ground:      #fbf1e8;
  --panel:       #fefaf3;
  --panel-2:     #f6ede0;
  --edge:        #e8d5c3;
  --edge-soft:   #f0e4d4;

  --ink:         #5c4247;
  --ink-strong:  #3b2a2e;
  --ink-soft:    #9a827d;

  --frame:       #8c3a4f;
  --frame-inner: #b9647a;

  --pink:        #ef8fbb;
  --pink-hot:    #e86ba4;
  --pink-ghost:  #f9e6ef;

  --peach:       #f8c58c;
  --peach-deep:  #eb9c54;
  --peach-ghost: #fdf1e3;

  --tile-a:      #fbe8d8;
  --tile-b:      #f6dcc8;
  --tile-edge:   #e8bd9c;
  --tile-ink:    #3f2d24;
  --tile-label:  #7a5238;

  --card-white:  #ffffff;

  --start-a:     #f6b2d0;
  --start-b:     #f9d9a6;

  --track-empty: #e2d8cd;
  --field-bg:    #fefbf6;

  --good:        #57a06a;
  --good-bg:     #d7f3df;
  --good-ink:    #15351f;
  --bad:         #b5344c;
  --bad-bg:      #ffd8df;
  --bad-ink:     #5a1420;

  --shadow-panel: 0 9px 24px rgba(120, 66, 52, .10), inset 0 1px 0 rgba(255, 255, 255, .7);
  --shadow-pop:   0 7px 0 rgba(140, 58, 79, .18), 0 14px 22px rgba(232, 107, 164, .2);
  --shadow-tile:  0 5px 0 rgba(163, 116, 82, .2);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  padding: 26px 20px 42px;
  background:
    radial-gradient(1100px 440px at 50% -12%, var(--deskspace-2), transparent 70%),
    var(--deskspace);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
}

button,
select,
input { font: inherit; }

h1, h2, p { margin: 0; }

/* ============================================================
   Window frame
   ============================================================ */
.app-shell {
  position: relative;
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 13px;
  background: var(--ground);
  border: 6px solid var(--frame);
  border-radius: var(--r-window);
  box-shadow:
    inset 0 0 0 2px var(--frame-inner),
    0 26px 60px -14px rgba(40, 12, 22, .45),
    0 8px 20px rgba(40, 12, 22, .24);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* custom window controls — only shown in the frameless desktop build */
.winctl {
  position: absolute;
  top: 9px;
  right: 11px;
  display: none;
  gap: 8px;
  z-index: 6;
  -webkit-app-region: no-drag;
}
/* frameless desktop build: the window is transparent, so the app-shell is a
   floating rounded card. The transparent margin around it carries the shadow
   and doubles as the window resize border. */
body.desktop-frameless {
  padding: 12px;
  background: transparent;
  min-height: 100vh;
}
body.desktop-frameless .app-shell {
  width: 100%;
  min-height: calc(100vh - 24px);
  margin: 0;
  padding-top: 0;
  border-width: 5px;
  border-radius: var(--r-window);
}
/* maximized: fill the screen, no rounded corners or shadow gap */
body.desktop-frameless.is-maximized { padding: 0; }
body.desktop-frameless.is-maximized .app-shell {
  min-height: 100vh;
  border-radius: 0;
}
body.desktop-frameless .winctl { display: flex; }

/* Draggable zones: the top bar and the stage strip below it (neither holds
   anything the drag would swallow). Everything interactive opts back out. */
body.desktop-frameless .topbar,
body.desktop-frameless .level-strip { -webkit-app-region: drag; }
body.desktop-frameless button,
body.desktop-frameless select,
body.desktop-frameless input,
body.desktop-frameless a,
body.desktop-frameless .choice,
body.desktop-frameless .winctl { -webkit-app-region: no-drag; }

.winctl button {
  width: 34px;
  height: 29px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1.5px solid var(--edge);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--frame);
  cursor: pointer;
}
.winctl button svg { width: 15px; height: 15px; }
.winctl button:hover { background: var(--panel); }
.winctl .winctl-close:hover {
  background: var(--pink-hot);
  border-color: var(--pink-hot);
  color: #fff;
}

/* ============================================================
   Panels
   ============================================================ */
.topbar,
.controls,
.level-strip,
.card-area,
.summary {
  background: var(--panel);
  border: 1.5px solid var(--edge);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-panel);
}

/* ---------- topbar ---------- */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 20px;
}
body.desktop-frameless .topbar { padding-right: 132px; }

.brand-lockup { min-width: 0; flex: 1 1 auto; }

.brand-heading {
  display: grid;
  grid-template-columns: minmax(56px, 0.42fr) 2px minmax(160px, 1.4fr);
  align-items: center;
  gap: clamp(9px, 1.4vw, 16px);
  width: min(100%, 440px);
  min-width: 0;
}
.brand-logo {
  display: block;
  width: 100%;
  height: auto;
  max-height: 56px;
  object-fit: contain;
  filter: drop-shadow(0 3px 0 rgba(140, 58, 79, .16));
}
.brand-logo-script { max-width: 108px; justify-self: end; }
.brand-logo-title  { max-width: 280px; justify-self: start; }
.brand-divider {
  width: 2px;
  height: 38px;
  border-radius: 2px;
  background: var(--edge);
}
.data-status {
  grid-column: 1 / -1;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
}
.data-status:empty { display: none; }

.score-strip {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.score-strip > span {
  min-width: 72px;
  padding: 5px 11px 4px;
  background: var(--panel-2);
  border: 1.5px solid var(--edge);
  border-radius: 13px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.15;
}
.score-strip strong {
  display: block;
  color: var(--ink-strong);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

/* ---------- controls ---------- */
.controls {
  display: grid;
  grid-template-columns: 0.82fr 0.82fr 0.82fr 1.55fr auto auto auto;
  gap: 10px;
  padding: 11px 13px;
  align-items: end;
}
.controls label {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding-left: 2px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}
.controls label.is-disabled { opacity: .45; }

select {
  width: 100%;
  height: 40px;
  padding: 0 34px 0 12px;
  border: 1.5px solid var(--edge);
  border-radius: var(--r-control);
  background-color: var(--field-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%239a827d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 14px;
  color: var(--ink-strong);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14.5px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1.5px solid var(--edge);
  border-radius: var(--r-control);
  background: var(--field-bg);
  color: var(--ink-strong);
}
input[type="range"] { padding: 0; height: 40px; }
input[type="number"] { font-variant-numeric: tabular-nums; }

/* generic buttons */
button {
  display: inline-grid;
  place-items: center;
  padding: 0 18px;
  border: 0;
  border-radius: var(--r-control);
  background: linear-gradient(135deg, var(--pink), var(--pink-hot));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  cursor: pointer;
}
button:disabled { cursor: not-allowed; opacity: .5; }

/* pill buttons in the controls row (unlock all / preview / settings) */
#skipButton,
#previewButton,
#settingsButton {
  height: 40px;
  align-self: end;
  display: grid;
  grid-auto-flow: row;
  justify-items: center;
  align-content: center;
  gap: 1px;
  padding: 0 13px;
  background: var(--pink-ghost);
  border: 1.5px solid var(--edge);
  border-radius: var(--r-control);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: .02em;
  text-transform: lowercase;
}
#skipButton::before,
#previewButton::before,
#settingsButton::before {
  content: "";
  width: 19px;
  height: 19px;
  background: var(--pink-hot);
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
#skipButton {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='10.5' width='14' height='10' rx='2.4'/%3E%3Cpath d='M8 10.5V7.5a4 4 0 0 1 7.7-1.5'/%3E%3C/svg%3E");
}
#previewButton {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
}
#settingsButton {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3.4'/%3E%3Cpath d='M12 2.6v3.1M12 18.3v3.1M21.4 12h-3.1M5.7 12H2.6M18.6 5.4l-2.2 2.2M7.6 16.4l-2.2 2.2M18.6 18.6l-2.2-2.2M7.6 7.6 5.4 5.4'/%3E%3C/svg%3E");
  background: var(--peach-ghost);
}
#settingsButton::before { background: var(--peach-deep); }

/* ---------- level strip ---------- */
.level-strip {
  display: grid;
  grid-template-columns: minmax(140px, auto) 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 8px 18px;
}
.level-strip > div:first-child { display: grid; gap: 0; }
#levelName {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  color: var(--ink-strong);
}
#xpText { color: var(--ink-soft); font-size: 12px; font-weight: 700; }

.xp-track {
  height: 13px;
  border-radius: 999px;
  background: var(--track-empty);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(90, 45, 45, .2);
}
#xpFill {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #93d3c6, #b7c2e6 32%, #d9b8df 55%, #f4b3ce 78%, #f8cb9c);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .35s ease;
}

.hearts {
  min-width: 90px;
  text-align: right;
  color: var(--pink);
  font-size: 25px;
  line-height: 1;
  letter-spacing: 3px;
  -webkit-text-stroke: 0.5px var(--pink-hot);
  text-shadow: 0 2px 0 rgba(140, 58, 79, .2);
}

/* ---------- card area ---------- */
.card-area { padding: 12px 15px 13px; }

.timer-row {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
  align-items: center;
  width: min(620px, 100%);
  margin: 0 auto 2px;
  opacity: .78;
}
.timer-track {
  height: 7px;
  border-radius: 999px;
  background: var(--track-empty);
  overflow: hidden;
}
#timerFill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #6cd1c8, #a98df0 42%, var(--pink-hot) 72%, var(--peach));
  transform-origin: left center;
}
#timerText {
  color: var(--ink-soft);
  text-align: right;
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.play-row {
  display: grid;
  grid-template-columns: minmax(128px, 176px) 1fr;
  gap: 13px;
  margin: 7px 0;
}

.mascot-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-height: 148px;
  padding: 9px;
  background: var(--card-white);
  border: 1.5px solid var(--edge-soft);
  border-radius: 14px;
  overflow: hidden;
}
.mascot {
  width: min(122px, 100%);
  aspect-ratio: 1;
  object-fit: contain;
  transform-origin: 50% 85%;
  filter: drop-shadow(0 10px 14px rgba(40, 15, 25, .26));
}

.speech-bubble {
  position: relative;
  min-height: 26px;
  margin: 0 0 4px;
  padding: 5px 14px;
  background: var(--card-white);
  color: var(--frame);
  border: 2.5px solid var(--frame);
  border-radius: 13px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  text-align: center;
  box-shadow: 0 3px 0 rgba(140, 58, 79, .18);
}
.speech-bubble::before {
  content: "";
  position: absolute;
  bottom: -9px;
  left: 50%;
  width: 13px;
  height: 13px;
  background: var(--card-white);
  border-right: 2.5px solid var(--frame);
  border-bottom: 2.5px solid var(--frame);
  transform: translateX(-50%) rotate(45deg);
}

.prompt-panel {
  display: grid;
  place-items: center;
  min-height: 138px;
  padding: 14px;
  background: var(--card-white);
  border: 1.5px solid var(--edge-soft);
  border-radius: 14px;
  text-align: center;
}
#promptKind {
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 7px;
}
#promptText {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(24px, 3.7vw, 46px);
  line-height: 1.05;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--ink-strong);
}

.prompt-image {
  display: block;
  width: min(100%, 260px);
  height: min(28vh, 260px);
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(69, 37, 54, .16));
}
.prompt-image[hidden] { display: none; }
.prompt-panel:has(.prompt-image:not([hidden])) { min-height: 262px; padding: 14px 18px 18px; }

.zhezari-script {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  max-width: 100%;
  color: var(--pink-hot);
}
.zhezari-script[hidden] { display: none; }
.zhezari-glyph {
  font-family: "Zhezari", serif;
  font-feature-settings: "kern" 1, "liga" 1, "clig" 1;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  font-size: clamp(36px, 5.6vw, 74px);
  line-height: 1;
}
.roman-guide {
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(13px, 1.7vw, 19px);
  line-height: 1.1;
  letter-spacing: .04em;
  overflow-wrap: anywhere;
}

/* ---------- round-complete celebration ---------- */
.prompt-panel [hidden] { display: none !important; }
.round-complete {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: 100%;
}
.rc-head {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(22px, 3.4vw, 34px);
  line-height: 1.1;
  color: var(--ink-strong);
  text-wrap: balance;
}
.rc-head.is-perfect {
  color: var(--pink-hot);
  text-shadow: 0 2px 0 rgba(232, 107, 164, .22);
}
.rc-tally {
  display: flex;
  align-items: center;
  gap: clamp(10px, 2vw, 20px);
}
.rc-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
#rcNum { color: var(--pink-hot); }
.rc-sep { margin: 0 .06em; }
.rc-flowers { display: inline-flex; gap: 5px; }
.rc-flower { width: clamp(26px, 3.6vw, 38px); height: clamp(26px, 3.6vw, 38px); }
.rc-flower.is-full g { fill: var(--pink); }
.rc-flower.is-full circle { fill: #fff3c4; }
.rc-flower.is-empty g { fill: var(--track-empty); }
.rc-flower.is-empty circle { fill: var(--panel-2); }
.rc-flowers.is-in .rc-flower {
  animation: rc-pop .34s cubic-bezier(.2, 1.4, .4, 1) backwards;
}
.rc-flowers.is-in .rc-flower:nth-child(2) { animation-delay: .07s; }
.rc-flowers.is-in .rc-flower:nth-child(3) { animation-delay: .14s; }
@keyframes rc-pop {
  from { transform: scale(0) rotate(-40deg); }
  to { transform: scale(1) rotate(0); }
}
.rc-perfect {
  margin-top: 2px;
  padding: 4px 16px;
  background: linear-gradient(120deg, var(--pink-hot), var(--peach-deep));
  color: #fff;
  border: 2px solid var(--frame);
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(13px, 1.6vw, 16px);
  letter-spacing: .1em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(140, 58, 79, .4);
  transform: rotate(-2deg);
  box-shadow: 0 4px 0 rgba(140, 58, 79, .22);
  animation: rc-badge .4s ease .28s backwards;
}
@keyframes rc-badge {
  from { transform: rotate(-2deg) scale(.4); opacity: 0; }
  to { transform: rotate(-2deg) scale(1); opacity: 1; }
}
.rc-next {
  margin-top: 4px;
  font-size: clamp(12px, 1.5vw, 14px);
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: .02em;
}
.rc-next[hidden], .rc-perfect[hidden] { display: none !important; }

/* ---------- choices ---------- */
.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
/* 3+ answers (Challenge, later stages) spread across one row when there's room,
   so the card area still fits without scrolling */
.choices:has(button:nth-child(3)) {
  grid-template-columns: repeat(auto-fit, minmax(184px, 1fr));
}
.choice {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  min-height: 66px;
  padding: 9px;
  background: linear-gradient(180deg, var(--tile-a), var(--tile-b));
  border: 1.5px solid var(--tile-edge);
  border-radius: 14px;
  color: var(--tile-ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(17px, 1.9vw, 24px);
  line-height: 1.08;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow-tile);
  transition: filter .12s ease, border-color .12s ease, box-shadow .12s ease, transform .06s ease;
}
.choice .zhezari-glyph { font-size: clamp(28px, 4vw, 50px); color: var(--tile-ink); }
.choice .roman-guide { font-size: clamp(12px, 1.35vw, 15px); color: var(--tile-label); }
.choice:hover:not(:disabled) {
  border-color: var(--pink-hot);
  box-shadow: var(--shadow-tile), inset 0 0 0 2px var(--pink-ghost);
  filter: saturate(1.5) brightness(1.05);
}
.choice:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.choice.correct {
  background: var(--good-bg);
  border-color: var(--good);
  color: var(--good-ink);
}
.choice.correct .zhezari-glyph,
.choice.correct .roman-guide { color: var(--good-ink); }
.choice.wrong {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--bad-ink);
}
.choice.wrong .zhezari-glyph,
.choice.wrong .roman-guide { color: var(--bad-ink); }
.choices.is-paused .choice { pointer-events: none; opacity: .6; }

.feedback {
  min-height: 19px;
  margin-top: 6px;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 13.5px;
}

/* ---------- action dock ---------- */
.action-dock {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1.5px solid var(--edge-soft);
}
.dock-tools {
  display: flex;
  gap: 9px;
  justify-self: start;
}
.dock-play {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 12px;
}

.dictionary-button {
  display: grid;
  place-items: center;
  gap: 2px;
  width: 66px;
  min-height: 56px;
  padding: 5px;
  background: var(--panel-2);
  border: 1.5px solid var(--edge);
  border-radius: 14px;
  color: var(--frame);
}
.dictionary-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 21px;
  line-height: 1;
}
.dictionary-icon svg { width: 24px; height: 24px; }
.dictionary-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 9.5px;
  letter-spacing: .03em;
  text-transform: lowercase;
  color: var(--ink);
}

#pauseButton,
#resetButton {
  width: 54px;
  min-height: 54px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--pink-ghost);
  border: 1.5px solid var(--edge);
  border-radius: 50%;
  color: var(--pink-hot);
  font-size: 18px;
}
#pauseButton svg,
#resetButton svg { width: 22px; height: 22px; }
#pauseButton[hidden],
#resetButton[hidden] { display: none; }

.start-button {
  position: relative;
  min-height: 60px;
  padding: 0 56px 0 28px;
  background: linear-gradient(120deg, var(--start-a), var(--start-b));
  border: 2.5px solid var(--frame);
  border-radius: 18px;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(140, 58, 79, .38);
  -webkit-text-stroke: 1.4px var(--frame);
  paint-order: stroke fill;
  box-shadow: var(--shadow-pop);
  transition: transform .08s ease, box-shadow .08s ease;
}
.start-button::after {
  content: "";
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #fff;
  background:
    rgba(255, 255, 255, .3)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9 7l9 5-9 5z'/%3E%3C/svg%3E")
    center / 17px no-repeat;
}
.start-button[hidden] { display: none; }
.start-button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 rgba(140, 58, 79, .18), 0 8px 14px rgba(232, 107, 164, .2);
}

/* ---------- summary ---------- */
.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 10px 16px 12px;
}
h2 {
  margin-bottom: 2px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.summary p { color: var(--ink-soft); line-height: 1.3; font-weight: 600; font-size: 13px; }

/* ---------- build tag ---------- */
.build-tag {
  position: absolute;
  right: 12px;
  bottom: 7px;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink-soft);
  opacity: .65;
  pointer-events: none;
}
body.desktop-frameless .build-tag { bottom: 9px; }

/* ============================================================
   Dialogs
   ============================================================ */
.settings-dialog,
.dictionary-dialog,
.alphabet-dialog,
.confirm-dialog {
  padding: 0;
  border: 2.5px solid var(--frame);
  border-radius: var(--r-panel);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 26px 54px -12px rgba(40, 12, 22, .5);
}
.settings-dialog { width: min(460px, calc(100vw - 32px)); }
.dictionary-dialog { width: min(760px, calc(100vw - 32px)); }
.confirm-dialog { width: min(420px, calc(100vw - 32px)); }
.alphabet-dialog {
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
}
.settings-dialog::backdrop,
.dictionary-dialog::backdrop,
.alphabet-dialog::backdrop,
.confirm-dialog::backdrop { background: rgba(30, 12, 20, .55); }

.settings-card,
.dictionary-card {
  display: grid;
  gap: 13px;
  padding: 18px;
}
.settings-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.settings-head h2 {
  margin: 0;
  font-size: 18px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-strong);
}
.settings-card label,
.dictionary-card label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.checkbox-row input { width: 18px; height: 18px; flex: none; }
.settings-note {
  margin-top: -6px;
  font-size: 11.5px;
  font-weight: 600;
  font-style: italic;
  color: var(--ink-soft);
  line-height: 1.3;
}
.audio-test-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.settings-head button,
.review-actions button,
.audio-test-row button {
  height: 42px;
  padding: 0 16px;
  background: linear-gradient(135deg, var(--pink), var(--pink-hot));
  color: #fff;
  border-radius: var(--r-control);
}
.settings-head button { background: var(--panel-2); color: var(--ink-strong); border: 1.5px solid var(--edge); }

.review-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.preview-intro { color: var(--ink-soft); line-height: 1.45; font-weight: 600; }
.preview-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* confirm dialog (unlock all) */
.confirm-card {
  display: grid;
  gap: 12px;
  padding: 22px 20px;
  text-align: center;
}
.confirm-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16.5px;
  line-height: 1.32;
  color: var(--ink-strong);
  text-wrap: balance;
}
.confirm-sub { font-size: 12px; color: var(--ink-soft); }
.confirm-sub em { font-style: italic; }
.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.confirm-actions button { height: 44px; }
.confirm-no {
  background: var(--panel-2);
  color: var(--ink-strong);
  border: 1.5px solid var(--edge);
}

.dictionary-list {
  display: grid;
  gap: 6px;
  max-height: min(520px, 58vh);
  overflow: auto;
  padding-right: 4px;
  scroll-padding-top: 8px;
}
.dictionary-alpha {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  gap: 4px;
  padding: 4px 0 8px;
  background: var(--panel);
}
.dictionary-alpha button {
  min-height: 28px;
  padding: 2px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--ink-strong);
  border: 1.5px solid var(--edge);
  font-size: 13px;
  font-weight: 800;
}
.dictionary-alpha button:disabled { opacity: .32; cursor: default; }
.dictionary-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) minmax(100px, .9fr) minmax(120px, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1.5px solid var(--edge);
  border-radius: 10px;
}
.dictionary-row strong,
.dictionary-row span { overflow-wrap: anywhere; }
.dictionary-row strong { color: var(--ink-strong); }
.dictionary-row > span:not(.dictionary-script) { color: var(--pink-hot); font-weight: 800; }
.dictionary-script {
  justify-self: center;
  color: var(--pink-hot);
  font-family: "Zhezari", serif;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}
#dictionarySearch { width: 100%; }

.alphabet-card { position: relative; display: grid; padding: 0; }
.alphabet-image { display: block; width: 100%; height: auto; border-radius: var(--r-panel); }
.alphabet-close {
  position: sticky;
  top: 8px;
  margin: 8px 8px -40px auto;
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--frame);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  z-index: 1;
}

/* ============================================================
   Confetti
   ============================================================ */
.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  overflow: hidden;
}
.confetti-layer span {
  position: absolute;
  top: -32px;
  color: var(--pink-hot);
  font-size: 24px;
  animation: confetti-fall 1.45s ease-in forwards;
}
@keyframes confetti-fall {
  to { transform: translate(var(--fall-x), 110vh) rotate(var(--spin)); opacity: 0; }
}

/* ============================================================
   Focus + motion
   ============================================================ */
:focus-visible { outline: 3px solid var(--pink-hot); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: .001ms !important; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .brand-lockup { width: 100%; }
  .brand-heading { width: 100%; }
  .score-strip { justify-content: stretch; }
  .score-strip span { flex: 1; }
  .controls { grid-template-columns: 1fr 1fr; }
  .level-strip { grid-template-columns: 1fr; }
  .hearts { text-align: left; }
  .play-row { grid-template-columns: 1fr; }
  .mascot-panel { flex-direction: row; min-height: 120px; }
  .choices { grid-template-columns: 1fr; }
  .action-dock { grid-template-columns: 1fr; justify-items: center; gap: 10px; }
  .dock-tools { justify-self: center; }
  .dock-play { grid-column: auto; }
  .summary { grid-template-columns: 1fr; }
  .review-actions { grid-template-columns: 1fr; }
  .dictionary-alpha { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  body { padding: 12px; }
  .app-shell { border-width: 4px; padding: 11px; border-radius: 18px; }
  .brand-logo { max-height: 52px; }
  .card-area, .controls, .summary { padding-left: 11px; padding-right: 11px; }
  .mascot { width: 100px; }
  .prompt-panel { min-height: 130px; padding: 14px; }
  #promptText { font-size: clamp(24px, 9vw, 40px); }
  .choice { min-height: 56px; font-size: clamp(16px, 5.5vw, 22px); }
  .start-button { font-size: 23px; padding: 0 50px 0 22px; }
}
