/* ============================================================================
   Cat Quest — "Storybook Twilight Kingdom"
   ========================================================================== */
:root {
  /* Twilight sky */
  --night-0: #1b1340;
  --night-1: #2a1d63;
  --night-2: #3b2a7e;
  --night-glow: #5b3fa6;
  --magic-pink: #ff8bd0;
  --magic-teal: #54e0d0;

  /* Surfaces */
  --panel: rgba(46, 33, 96, 0.72);
  --panel-edge: rgba(150, 122, 232, 0.45);
  --panel-soft: rgba(63, 46, 120, 0.6);

  /* Reading parchment */
  --parchment: #fbf7ff;
  --parchment-edge: #e6dcff;
  --ink: #322a4f;
  --ink-soft: #6f6794;

  /* Semantic */
  --gold: #ffce4d;
  --gold-deep: #f3a93a;
  --good: #38c98a;
  --good-soft: #d7f7e7;
  --good-ink: #1d8a5c;
  --bad: #ff6b86;
  --bad-soft: #ffe0e6;
  --bad-ink: #d83a59;
  --auto: #9b8fe6;
  --auto-soft: #ece7ff;
  --you: #ffce4d;

  /* Finger colors */
  --f-left-pinky: #f59ac6;
  --f-left-ring: #f6a96b;
  --f-left-middle: #ffd95e;
  --f-left-index: #7fd18a;
  --f-right-index: #56cfc4;
  --f-right-middle: #6fb1f0;
  --f-right-ring: #9d8bf0;
  --f-right-pinky: #e58fd8;
  --f-thumb: #cfe9ff;

  --font-display: 'Baloo 2', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --radius: 22px;
  --shadow: 0 18px 40px rgba(12, 6, 38, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: #f3eeff;
  background: var(--night-0);
}

body {
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Starfield ---------------------------------------------------------- */
.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 700px at 78% -8%, #5234a3 0%, transparent 60%),
    radial-gradient(900px 600px at 12% 8%, #6a3fb0 0%, transparent 55%),
    linear-gradient(180deg, var(--night-2) 0%, var(--night-1) 45%, var(--night-0) 100%);
  overflow: hidden;
}
.stars {
  position: absolute;
  inset: -50% -50% 0 -50%;
  background-repeat: repeat;
}
.stars-1 {
  background-image:
    radial-gradient(1.6px 1.6px at 20% 30%, #fff 50%, transparent),
    radial-gradient(1.4px 1.4px at 70% 60%, #ffe9bd 50%, transparent),
    radial-gradient(1.2px 1.2px at 40% 80%, #fff 50%, transparent),
    radial-gradient(1.8px 1.8px at 85% 25%, #fff 50%, transparent);
  background-size: 360px 320px;
  animation: twinkle 4s ease-in-out infinite alternate;
}
.stars-2 {
  background-image:
    radial-gradient(1.3px 1.3px at 50% 20%, #cfe0ff 50%, transparent),
    radial-gradient(1.1px 1.1px at 15% 70%, #fff 50%, transparent),
    radial-gradient(1.5px 1.5px at 90% 80%, #ffd7f5 50%, transparent);
  background-size: 280px 260px;
  opacity: 0.8;
  animation: twinkle 6s ease-in-out infinite alternate-reverse;
}
.stars-3 {
  background-image: radial-gradient(1px 1px at 33% 45%, #fff 50%, transparent);
  background-size: 180px 200px;
  opacity: 0.5;
  animation: drift 90s linear infinite;
}
@keyframes twinkle { from { opacity: 0.45; } to { opacity: 0.95; } }
@keyframes drift { from { transform: translateY(0); } to { transform: translateY(120px); } }
.moon {
  position: absolute;
  top: 6%;
  right: 9%;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff7e0, #ffe9a8 60%, #f5cf78);
  box-shadow: 0 0 60px 18px rgba(255, 226, 150, 0.35), inset -14px -10px 0 rgba(214, 170, 90, 0.25);
}
.hills {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 26vh;
  background:
    radial-gradient(120% 100% at 20% 100%, #2b1c5c 0 40%, transparent 41%),
    radial-gradient(120% 110% at 70% 100%, #241654 0 44%, transparent 45%),
    linear-gradient(180deg, transparent, #1a1140 88%);
  opacity: 0.85;
}

/* ---- Topbar ------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 42px);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  font-size: 1.7rem;
  filter: drop-shadow(0 2px 6px rgba(255, 180, 90, 0.5));
}
.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  letter-spacing: 0.5px;
  background: linear-gradient(180deg, #fff 0%, #ffd98a 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 3px 14px rgba(255, 197, 110, 0.25);
}
.topbar-stats { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  box-shadow: var(--shadow);
}
.stat-icon { align-self: center; }
.stat-points .stat-icon { color: var(--gold); }
.stat-value { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; }
.stat-label { font-size: 0.8rem; color: #cdbff5; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-points { transition: transform 0.18s; }
.stat-points.pop { transform: scale(1.16); }
.cats-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 700;
  text-decoration: none;
  color: #2a1a4d;
  background: linear-gradient(180deg, #ffe08a, var(--gold-deep));
  border: 2px solid #ffe9a8;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.cats-link:hover { transform: translateY(-2px); }
.auth-nudge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  border: 2px solid var(--panel-edge);
  background: var(--panel);
  color: #e7defc;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.auth-nudge[data-state='out'] {
  border-color: var(--magic-teal);
  color: #d6fbf4;
  animation: nudgepulse 2.6s ease-in-out infinite;
}
.auth-nudge[data-state='out']:hover { transform: translateY(-2px); }
.auth-nudge[data-state='in'] { cursor: default; color: #aef0d8; border-color: rgba(56, 201, 138, 0.5); animation: none; }
@keyframes nudgepulse { 50% { box-shadow: var(--shadow), 0 0 16px rgba(84, 224, 208, 0.5); } }

/* Expanded adult panel */
.adult-account {
  margin: 4px 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(20, 12, 50, 0.5);
  border: 1.5px solid var(--panel-edge);
  text-align: left;
}
.adult-acct-status { margin: 0 0 8px; font-size: 0.88rem; color: #d7ccff; }
.adult-acct-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.adult-section { text-align: left; margin: 14px 0; }
.adult-section-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #b9abe0;
}
.btn-sm { font-size: 0.85rem; padding: 7px 14px; border-radius: 11px; box-shadow: none; }
.profile-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.profile-chip, .animal-chip {
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: #e7defc;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid var(--panel-edge);
  box-shadow: none;
}
.profile-chip[data-active='true'], .animal-chip[data-active='true'] {
  color: #2a1a4d;
  background: linear-gradient(180deg, #fff, #c8f3ea);
  border-color: var(--magic-teal);
}
.profile-edit { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-edit input {
  flex: 1 1 120px;
  padding: 9px 12px;
  border-radius: 11px;
  border: 2px solid var(--panel-edge);
  background: rgba(20, 12, 50, 0.7);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.animal-toggle { display: flex; gap: 8px; flex-wrap: wrap; }
.adult-version { margin: 14px 0 0; text-align: center; font-size: 0.72rem; color: #8d80bd; letter-spacing: 0.4px; }

/* ---- Quest map ---------------------------------------------------------- */
.questmap {
  display: flex;
  gap: 0;
  align-items: center;
  overflow-x: auto;
  padding: 6px clamp(16px, 4vw, 42px) 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--night-glow) transparent;
}
.qm-node {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  padding: 0 2px;
}
.qm-link {
  width: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qm-star {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-family: var(--font-display);
  font-weight: 700;
  color: #d8ccff;
  background: rgba(40, 28, 86, 0.8);
  border: 2px solid rgba(146, 120, 220, 0.45);
  position: relative;
  z-index: 1;
}
.qm-node::after {
  /* dotted trail to the next node */
  content: '';
  position: absolute;
  top: 22px;
  left: 50%;
  width: 100%;
  height: 3px;
  background-image: linear-gradient(90deg, rgba(160, 134, 230, 0.6) 30%, transparent 30%);
  background-size: 9px 3px;
  z-index: 0;
}
.qm-node:last-child::after { display: none; }
.qm-node[data-state='done'] .qm-star {
  color: #2a1a4d;
  background: linear-gradient(180deg, #ffe79a, var(--gold-deep));
  border-color: #fff0c2;
  box-shadow: 0 0 12px rgba(255, 206, 77, 0.6);
}
.qm-node[data-state='current'] .qm-star {
  color: #2a1a4d;
  background: linear-gradient(180deg, #fff, #b9f5e8);
  border-color: var(--magic-teal);
  box-shadow: 0 0 0 4px rgba(84, 224, 208, 0.3), 0 0 16px rgba(84, 224, 208, 0.7);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  50% { box-shadow: 0 0 0 7px rgba(84, 224, 208, 0.12), 0 0 22px rgba(84, 224, 208, 0.9); }
}
.qm-label {
  font-size: 0.6rem;
  color: #b4a6e0;
  max-width: 52px;
  text-align: center;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qm-node[data-state='current'] .qm-label { color: #fff; font-weight: 700; }

/* ---- Stage layout ------------------------------------------------------- */
.stage {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: clamp(14px, 2.5vw, 28px);
  padding: 6px clamp(16px, 4vw, 42px) 28px;
  align-items: start;
}

/* ---- Companion ---------------------------------------------------------- */
.companion { position: sticky; top: 10px; }
.companion-card {
  position: relative;
  padding: 22px 18px 18px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  box-shadow: var(--shadow);
  text-align: center;
  overflow: hidden;
}
.companion-aura {
  position: absolute;
  top: 18%;
  left: 50%;
  width: 78%;
  aspect-ratio: 1;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255, 206, 120, 0.4), transparent 65%);
  filter: blur(6px);
  animation: aura 4s ease-in-out infinite;
}
@keyframes aura { 50% { opacity: 0.55; transform: translateX(-50%) scale(1.08); } }
.cushion {
  position: absolute;
  bottom: 64px;
  left: 50%;
  width: 64%;
  height: 26px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(157, 139, 240, 0.55), rgba(157, 139, 240, 0.05) 70%);
  filter: blur(2px);
}
.companion-img {
  position: relative;
  width: 88%;
  max-width: 230px;
  filter: drop-shadow(0 14px 18px rgba(10, 4, 30, 0.5));
}
.breathe { transform-origin: 50% 92%; animation: breathe 3.6s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1) translateY(0) rotate(0deg); }
  30%      { transform: scale(1.035, 0.985) translateY(1px) rotate(-0.4deg); }
  65%      { transform: scale(0.99, 1.02) translateY(-2px) rotate(0.5deg); }
}
.companion-bounce { animation: catbounce 0.7s ease; }
@keyframes catbounce {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-16px) scale(1.08, 0.96); }
  55% { transform: translateY(0) scale(0.96, 1.06); }
  100% { transform: translateY(0) scale(1); }
}
.companion-name {
  position: relative;
  margin: 6px 0 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  color: #fff2cf;
}
.companion-progress-label { font-size: 0.78rem; color: #cdbff5; margin-bottom: 6px; }

/* ---- Progress bars ------------------------------------------------------ */
.bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(20, 12, 50, 0.6);
  border: 1.5px solid rgba(150, 122, 232, 0.35);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--magic-teal), #8fe9dd);
  transition: width 0.4s cubic-bezier(0.3, 1.2, 0.5, 1);
}
.bar-gold > span { background: linear-gradient(90deg, var(--gold), var(--gold-deep)); }

/* ---- Play area ---------------------------------------------------------- */
.play {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.level-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  box-shadow: var(--shadow);
}
.level-badge {
  width: 50px; height: 50px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  color: #2a1a4d;
  background: linear-gradient(180deg, #fff, #c8f3ea);
  border: 3px solid var(--magic-teal);
  box-shadow: 0 0 16px rgba(84, 224, 208, 0.5);
}
.level-eyebrow { margin: 0; font-size: 0.78rem; color: #c5b6ef; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700; }
.level-name { margin: 2px 0 0; font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; color: #fff; }
.level-progress { min-width: 150px; text-align: right; }
.level-progress-label { font-size: 0.78rem; color: #cdbff5; margin-bottom: 6px; }

/* ---- Passage (typewriter) ---------------------------------------------- */
.passage-card {
  position: relative;
  padding: clamp(16px, 3vw, 30px) clamp(18px, 3vw, 34px);
  border-radius: var(--radius);
  background: var(--parchment);
  border: 2px solid var(--parchment-edge);
  box-shadow: var(--shadow), inset 0 2px 0 #fff;
  transition: box-shadow 0.3s;
}
.passage-card.done {
  box-shadow: var(--shadow), inset 0 2px 0 #fff, 0 0 0 3px rgba(56, 201, 138, 0.55), 0 0 28px rgba(56, 201, 138, 0.45);
}
.passage {
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 3.1vw, 2.05rem);
  line-height: 2.1;
  color: var(--ink);
  letter-spacing: 0.5px;
  word-break: normal;
  overflow-wrap: normal;
}
.word { display: inline-block; white-space: nowrap; }
.ch {
  position: relative;
  display: inline-block;
  padding: 2px 1px;
  border-radius: 7px;
  transition: background 0.1s, color 0.1s;
  white-space: pre;
  font-weight: 600;
}
.ch.you  { color: #2a2347; font-weight: 800; }     /* YOUR letters: dark + bold */
.ch.auto { color: #9c8a3c; }                        /* the game types these (grayish-yellow) */
.ch.good { background: var(--good-soft); color: var(--good-ink); }
.ch.autodone { color: #9c8a3c; background: rgba(156, 138, 60, 0.16); }
.ch.bad {
  background: var(--bad-soft);
  color: var(--bad-ink);
  box-shadow: inset 0 0 0 2px var(--bad);
}
/* Line cursor — shows where the next character will go (typing.com style). */
.ch.caret::after {
  content: '';
  position: absolute;
  left: 8%; right: 8%; bottom: -2px;
  height: 3px;
  border-radius: 2px;
  background: var(--gold-deep);
  animation: caret 1s steps(1) infinite;
}
.ch.auto.caret::after { background: #b89b34; }
@keyframes caret { 50% { opacity: 0.12; } }
/* A mistyped key briefly appears in red, then falls away — cueing "backspace me". */
.ghost-wrong {
  position: absolute;
  left: 50%; top: -2px;
  transform: translateX(-50%);
  color: var(--bad-ink);
  font-weight: 800;
  pointer-events: none;
  animation: ghostdrop 0.55s ease-in forwards;
}
@keyframes ghostdrop {
  0% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(24px) scale(0.78); }
}

.hint-line {
  margin: 2px 2px 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  color: #ffe6a8;
  text-align: center;
  min-height: 1.4em;
}
.legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: #cdbff5;
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 16px; height: 16px; border-radius: 5px; display: inline-block; }
.swatch-you { background: rgba(255, 206, 77, 0.55); box-shadow: inset 0 0 0 2px var(--gold); }
.swatch-auto { background: var(--auto-soft); box-shadow: inset 0 0 0 2px var(--auto); }
.swatch-good { background: var(--good-soft); box-shadow: inset 0 0 0 2px var(--good); }
.swatch-bad { background: var(--bad-soft); box-shadow: inset 0 0 0 2px var(--bad); }

/* ---- Keyboard ----------------------------------------------------------- */
.keyboard-wrap {
  margin-top: 4px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--panel-soft);
  border: 2px solid var(--panel-edge);
  box-shadow: var(--shadow);
}
.keyboard {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 720px;
  margin: 0 auto;
}
.kb-row { display: flex; gap: 6px; justify-content: center; }
.kb-row.row-home { padding-left: 18px; }
.kb-row.row-bottom { padding-left: 38px; }
.key {
  position: relative;
  min-width: clamp(30px, 4.4vw, 46px);
  height: clamp(34px, 4.6vw, 46px);
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(0.7rem, 1.5vw, 0.92rem);
  color: #b9abe0;
  background: rgba(28, 19, 64, 0.7);
  border: 2px solid rgba(120, 96, 190, 0.35);
  box-shadow: inset 0 -3px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s, background 0.12s, color 0.12s;
  --fc: var(--f-left-index);
}
.key[data-state='review'] {
  color: color-mix(in srgb, var(--fc) 80%, #fff);
  background: color-mix(in srgb, var(--fc) 16%, rgba(28, 19, 64, 0.8));
  border-color: color-mix(in srgb, var(--fc) 40%, transparent);
}
.key[data-state='focus'] {
  color: #fff;
  background: color-mix(in srgb, var(--fc) 34%, rgba(28, 19, 64, 0.7));
  border-color: color-mix(in srgb, var(--fc) 70%, transparent);
}
.key.active {
  transform: translateY(-4px);
  color: #2a1a4d;
  background: var(--fc);
  border-color: #fff;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.28), 0 0 18px color-mix(in srgb, var(--fc) 60%, transparent);
  z-index: 3;
}
.key.shift-active {
  color: #2a1a4d;
  background: linear-gradient(180deg, #fff, #ffe6a8);
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(255, 206, 77, 0.7);
}
.key-space { min-width: 220px; }
.key-shift { min-width: clamp(56px, 8vw, 84px); font-size: 0.66rem; }
.kb-hands { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 1; }
.tutor-finger {
  stroke: rgba(20, 12, 50, 0.55);
  stroke-width: 1.4;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.tutor-finger[data-active='true'] { opacity: 0.92; stroke-width: 1.7; }

/* ---- Overlays / popups -------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(12, 6, 34, 0.72);
  backdrop-filter: blur(5px);
  animation: fade 0.2s ease;
}
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.popup {
  position: relative;
  width: min(440px, 92vw);
  padding: 30px 28px 26px;
  border-radius: 28px;
  text-align: center;
  background: linear-gradient(180deg, #3a2a7e, #2a1d63);
  border: 2px solid var(--panel-edge);
  box-shadow: var(--shadow), 0 0 60px rgba(120, 80, 200, 0.4);
  animation: popin 0.4s cubic-bezier(0.2, 1.4, 0.4, 1);
  overflow: hidden;
}
@keyframes popin { from { transform: scale(0.8) translateY(20px); opacity: 0; } }
.popup-kicker {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: var(--magic-teal);
}
.popup-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.9rem;
  color: #fff;
}
.popup-sub { margin: 6px 0 16px; color: #d7ccff; }
.popup-keys {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.popup-key {
  min-width: 42px;
  height: 48px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.3rem;
  color: #2a1a4d;
  background: linear-gradient(180deg, #fff, #ffe6a8);
  border: 2px solid var(--gold);
  box-shadow: 0 5px 0 var(--gold-deep);
  animation: keypop 0.4s backwards;
}
@keyframes keypop { from { transform: translateY(-14px) scale(0.6); opacity: 0; } }
.catunlock-img {
  width: 180px;
  margin: 4px auto 8px;
  display: block;
  filter: drop-shadow(0 12px 18px rgba(10, 4, 30, 0.5));
  animation: catbounce 0.8s ease;
}
.popup-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.popup-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
@keyframes confetti {
  to { transform: translateY(420px) rotate(540deg); opacity: 0; }
}

.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 12px 24px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  transition: transform 0.14s, box-shadow 0.14s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  color: #2a1a4d;
  background: linear-gradient(180deg, #ffe08a, var(--gold-deep));
  box-shadow: 0 5px 0 #c97f22;
}
.btn-ghost {
  color: #efe6ff;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid var(--panel-edge);
}

/* ---- Adult panel -------------------------------------------------------- */
.adult-dot {
  position: fixed;
  bottom: 8px;
  right: 8px;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  z-index: 40;
}
.adult-dot:hover { background: rgba(255, 255, 255, 0.3); }
.adult-input {
  width: 100%;
  margin: 12px 0;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid var(--panel-edge);
  background: rgba(20, 12, 50, 0.7);
  color: #fff;
  font-size: 1.4rem;
  text-align: center;
  letter-spacing: 8px;
  font-family: var(--font-mono);
}
.adult-error { color: var(--bad); margin: 0 0 8px; }
.adult-field { display: block; text-align: left; margin: 18px 0; }
.adult-field span { display: block; margin-bottom: 8px; font-weight: 700; }
.adult-field input[type='range'] { width: 100%; accent-color: var(--magic-teal); }
.adult-stage-name { color: var(--magic-teal); font-weight: 700; }
.adult-points-field { margin: 0 0 14px; }
.adult-points-field input[type='number'] {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid var(--panel-edge);
  background: rgba(20, 12, 50, 0.7);
  color: #fff;
  font-size: 1.2rem;
  font-family: var(--font-mono);
}

/* ---- Responsive --------------------------------------------------------- */
@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; }
  .companion { position: static; }
  .companion-img { max-width: 170px; }
  .level-head { grid-template-columns: auto 1fr; }
  .level-progress { grid-column: 1 / -1; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}
