/* components.css — UI building blocks */

/* ============ NAVBAR ============ */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 27px;
  flex-shrink: 0;
}

.navbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 60px;
  height: 27px;
  flex-shrink: 0;
}

/* Language toggle pill (Figma 16:113/216/224/225) — collapsed = orange pill with
   2px black outline showing just "BM"/"EN"; on hover/focus it springs into a black
   track that wraps the orange badge and reveals the "Tukar Bahasa" label. */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: #ff6600;
  color: var(--white);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1;
  height: 26px;
  padding: 0 10px;
  border: 2px solid #000000;
  border-radius: var(--btn-radius);
  overflow: hidden;
  transition: gap 0.28s var(--ease-spring), padding 0.28s var(--ease-spring),
    background-color 0.2s ease, transform 0.12s ease;
}
.lang-toggle:active {
  transform: scale(0.95);
}
.lang-toggle__current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--white);
  border-radius: 100px;
  padding: 0;
  flex-shrink: 0;
  transition: background-color 0.2s ease, padding 0.2s ease;
}
.lang-toggle__label {
  display: inline-block;
  max-width: 0;
  opacity: 0;
  white-space: nowrap;
  overflow: hidden;
  color: var(--orange-mid);
  transform: translateX(-4px);
  transition: max-width 0.32s var(--ease-spring), opacity 0.22s ease,
    transform 0.32s var(--ease-spring);
}
/* Expanded: black track + orange badge + label */
.lang-toggle:hover,
.lang-toggle:focus-visible,
.lang-toggle.is-open {
  background: #000000;
  gap: 5px;
  padding: 0 5px; /* height stays 26px; the black track shows via the shorter badge */
}
.lang-toggle:hover .lang-toggle__current,
.lang-toggle:focus-visible .lang-toggle__current,
.lang-toggle.is-open .lang-toggle__current {
  background: #ff6600;
  padding: 1px 10px;
}
.lang-toggle:hover .lang-toggle__label,
.lang-toggle:focus-visible .lang-toggle__label,
.lang-toggle.is-open .lang-toggle__label {
  max-width: 160px;
  opacity: 1;
  transform: translateX(0);
}

/* Score + coin pills (Figma 16:229 / 16:8) — identical cream pills:
   #FFF6EC fill, 1px #EC6D1A border, 100px radius, 16px Letter Magic in #EC6D1A,
   15px icon, gap 5, 0/10 padding. */
.score-pill,
.coin-pill {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start; /* icon + number hug the left, after the pill padding */
  gap: 6px;
  background: #fff6ec;
  color: var(--orange-mid);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1;
  height: 26px;
  padding: 0 11px 0 9px; /* a touch less left padding so the bigger icon sits nicely */
  border-radius: var(--btn-radius);
  border: 1px solid var(--orange-mid);
  flex-shrink: 0;
}
.score-pill__star,
.coin-pill__icon {
  width: 19px;
  height: 19px;
  object-fit: contain;
  display: inline-block;
  flex-shrink: 0;
}
.coin-pill__num {
  font-size: 16px;
}

/* ============ PROGRESS BAR ============ */
.progress {
  width: 100%;
  height: var(--progress-height);
  background: var(--ash);
  border-radius: 100px;
  overflow: hidden;
  flex-shrink: 0;
}
.progress__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--orange-mid), var(--orange));
  border-radius: 100px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ MASCOT ============ */
.mascot {
  width: 109px;
  height: 168px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}
.mascot--bounce {
  animation: bounce 0.6s var(--ease-spring);
}
.mascot--shake {
  animation: shake 0.45s ease;
}

/* Start-screen hero — Oyen reading (square pose) */
.mascot-reading {
  width: auto;
  height: 230px;
  max-width: 90%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

/* Game-screen mini mascot + speech bubble */
.mascot-mini {
  width: 56px;
  height: 86px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Circular reacting avatar (question screen) — waist-to-head, masked.
   Faces crossfade-by-mount; motion stays framed inside the circle. */
.oyen-avatar {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: radial-gradient(120% 120% at 50% 20%, #fff7ef, #fce6d2);
  box-shadow: 0 0 0 3px var(--white), 0 0 0 5px var(--orange),
    0 6px 14px -6px rgba(210, 87, 6, 0.5);
}
.oyen-avatar__react,
.oyen-avatar__breathe {
  position: absolute;
  inset: 0;
  transform-origin: 50% 82%;
}
.oyen-avatar__breathe {
  animation: oyen-breathe 3.6s ease-in-out infinite;
}
.oyen-avatar__face {
  position: absolute;
  left: 50%;
  top: 3%;
  height: 126%;
  width: auto;
  object-fit: contain;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  user-select: none;
}
.oyen-avatar__face.is-shown {
  opacity: 1;
}
.oyen-avatar--happy .oyen-avatar__react {
  animation: oyen-bounce 0.72s var(--ease-spring) both;
}
.oyen-avatar--sad .oyen-avatar__react {
  animation: oyen-sad 0.85s ease both;
}
.oyen-avatar--celebrate .oyen-avatar__react {
  animation: oyen-celebrate 1s var(--ease-spring) 2 both;
}

/* Larger variant for the results screen */
.oyen-avatar--lg {
  width: 140px;
  height: 140px;
  box-shadow: 0 0 0 5px var(--white), 0 0 0 8px var(--orange),
    0 14px 30px -14px rgba(210, 87, 6, 0.55);
}

.speech-bubble {
  position: relative;
  background: var(--white);
  border: 2px solid var(--orange);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 14px;
  box-shadow: 0 3px 0 rgba(210, 87, 6, 0.25);
  transform-origin: bottom right;
  animation: pop-in 0.35s var(--ease-spring);
}
.speech-bubble::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: -9px;
  border-width: 9px 8px 0 8px;
  border-style: solid;
  border-color: var(--orange) transparent transparent transparent;
}
.speech-bubble::before {
  content: "";
  position: absolute;
  right: 18px;
  bottom: -5px;
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: var(--white) transparent transparent transparent;
  z-index: 1;
}
.speech-bubble--correct {
  border-color: var(--success);
}
.speech-bubble--correct::after {
  border-top-color: var(--success);
}
.speech-bubble--wrong {
  border-color: var(--error);
}
.speech-bubble--wrong::after {
  border-top-color: var(--error);
}

/* ============ BUTTONS ============ */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: var(--btn-width);
  height: var(--btn-height);
  border-radius: var(--btn-radius);
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 0.76;
  transition: transform 0.08s ease, box-shadow 0.08s ease,
    background-color 0.15s ease;
}

.btn--primary {
  background: var(--orange);
  color: var(--white);
  box-shadow: var(--shadow-primary);
}
.btn--primary:hover {
  background: var(--orange-hover);
}
.btn--primary:active {
  transform: translateY(var(--raise));
  box-shadow: none;
}

.btn--secondary {
  background: var(--white);
  color: var(--orange);
  border: 1.5px solid var(--orange);
  box-shadow: var(--shadow-primary);
}
.btn--secondary:hover {
  background: var(--pale-orange);
}
.btn--secondary:active {
  transform: translateY(var(--raise));
  box-shadow: none;
  background: #ffe8d0;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  background: var(--disabled-bg);
  color: var(--white);
  border-color: var(--disabled-bg);
  box-shadow: 0 4px 0 var(--disabled-shadow);
  cursor: not-allowed;
  pointer-events: none;
}

/* Confirm button result states */
.btn--correct {
  background: var(--success) !important;
  color: var(--white) !important;
  box-shadow: var(--shadow-success) !important;
  border: none !important;
}
.btn--wrong {
  background: var(--error) !important;
  color: var(--white) !important;
  box-shadow: var(--shadow-error) !important;
  border: none !important;
}

.btn-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--btn-gap);
  width: 100%;
  max-width: var(--btn-width);
}

/* ============ START SCREEN ============ */
.start-screen {
  justify-content: flex-start;
  gap: var(--start-gap);
}
.start-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 0 0;
  width: 100%;
  gap: 8px;
}
.mascot-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 0 auto;
}
.context-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 25px;
  text-align: center;
  padding-top: 19px;
}
.topic-title {
  font-family: var(--font-display);
  font-size: 50px;
  line-height: 0.76;
  color: var(--orange);
  text-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
}
.topic-title .topic-title__level {
  color: var(--ink);
}
.subtitle {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.2;
  color: var(--ink);
  max-width: 293px;
  white-space: pre-line;
}

/* ============ GAME SCREEN ============ */
.game-screen {
  gap: 10px;
  justify-content: flex-start;
}
.game-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  width: 100%;
  min-height: 0;
}
/* Pin the action buttons to the bottom of the fixed stage. */
.game-screen > .btn-group { margin-top: auto; }
.question-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}
.question-text {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.15;
  color: var(--ink);
  flex: 1 0 0;
}
.question-mascot {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-shrink: 0;
  min-height: 48px;
}

/* Word illustration zone — fixed square inside the scaled stage. */
.illustration {
  width: var(--tile-size);
  height: var(--tile-size);
  border-radius: var(--tile-radius);
  background: var(--pale-orange);
  overflow: hidden;
  flex-shrink: 0;
}
.illustration img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Answer grid 2x2 */
.answer-grid {
  display: grid;
  /* minmax(0, 1fr): keep columns at exactly half-width so a long unbreakable word
     can't expand the column (which overflowed the frame). Text is shrunk to fit
     by fitAnswerTiles() in main.js instead. */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--tile-gap);
  width: 100%;
  max-width: calc(var(--tile-size) * 2 + var(--tile-gap));
}
.answer-tile { overflow: hidden; }
.answer-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--tile-radius);
  background: var(--orange-mid);
  box-shadow: var(--shadow-tile);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(22px, 7.5vw, 30px);
  color: var(--white);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: transform 0.12s ease, box-shadow 0.12s ease,
    background-color 0.15s ease;
}
.answer-tile:hover:not(.is-locked) {
  background: var(--navy);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--navy-dark);
}
.answer-tile:active:not(.is-locked) {
  transform: translateY(var(--raise));
  box-shadow: none;
  background: var(--orange-pressed);
}
.answer-tile.is-selected {
  background: var(--navy);
  box-shadow: var(--shadow-navy);
}
.answer-tile.is-correct {
  background: var(--success);
  box-shadow: var(--shadow-success);
  animation: tile-pop 0.35s ease;
}
.answer-tile.is-wrong {
  background: var(--error);
  box-shadow: var(--shadow-error);
  animation: tile-shake 0.35s ease;
}
.answer-tile.is-locked {
  cursor: default;
}
.answer-tile.is-dimmed {
  opacity: 0.55;
}

/* Smooth entrance when a new question loads (added only on question change,
   so it doesn't replay on every tile selection). */
.game-screen.q-enter .question-text,
.game-screen.q-enter .illustration,
.game-screen.q-enter .btn-group .btn {
  animation: q-fade-up 0.42s var(--ease-spring) both;
}
.game-screen.q-enter .illustration { animation-delay: 0.06s; }
.game-screen.q-enter .btn-group .btn { animation-delay: 0.12s; }
.game-screen.q-enter .btn-group .btn:nth-child(2) { animation-delay: 0.18s; }

.game-screen.q-enter .answer-tile {
  animation: tile-enter 0.42s var(--ease-spring) both;
}
.game-screen.q-enter .answer-tile:nth-child(1) { animation-delay: 0.08s; }
.game-screen.q-enter .answer-tile:nth-child(2) { animation-delay: 0.14s; }
.game-screen.q-enter .answer-tile:nth-child(3) { animation-delay: 0.20s; }
.game-screen.q-enter .answer-tile:nth-child(4) { animation-delay: 0.26s; }

/* Smoother, springier progress fill */
.progress__fill {
  transition: width 0.6s var(--ease-spring);
}

/* ============ RESULTS SCREEN ============ */
.results-screen {
  justify-content: center;
  gap: var(--game-gap);
}
.results-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 0 0;
  gap: 14px;
  text-align: center;
}
.results-mascot {
  width: 130px;
  height: auto;
}
.results-title {
  font-family: var(--font-display);
  font-size: 40px;
  color: var(--orange);
  line-height: 0.9;
  text-shadow: 0 3px 4px rgba(0, 0, 0, 0.2);
}
.results-score {
  font-family: var(--font-display);
  font-size: 80px;
  line-height: 0.9;
  color: var(--navy);
}
.results-stars {
  display: flex;
  gap: 8px;
  font-size: 44px;
  line-height: 1;
}
.results-star {
  filter: grayscale(1) opacity(0.3);
  transform: scale(0.85);
}
.results-star.is-on {
  filter: none;
  animation: star-pop 0.45s var(--ease-spring) backwards;
}
.results-star.is-on:nth-child(1) { animation-delay: 0.15s; }
.results-star.is-on:nth-child(2) { animation-delay: 0.3s; }
.results-star.is-on:nth-child(3) { animation-delay: 0.45s; }
.results-message {
  font-family: var(--font-body);
  font-size: 18px;
  color: var(--ink);
  max-width: 300px;
  white-space: pre-line;
}

/* ============ CONFETTI ============ */
.confetti-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 50;
}
.confetti-piece {
  position: absolute;
  top: -16px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  will-change: transform, opacity;
  animation: confetti-fall linear forwards;
}

/* ============ LEVEL SELECT (the map / entry scene) ============ */
.levelselect-screen { justify-content: flex-start; gap: 12px; }
.levelselect-head { text-align: center; width: 100%; }
.levelselect-title {
  font-family: var(--font-display); font-size: 32px; color: var(--orange);
  line-height: 0.9; text-shadow: 0 3px 4px rgba(0, 0, 0, 0.18);
}
.levelselect-subtitle {
  font-family: var(--font-body); font-weight: 700; font-size: 13px;
  color: var(--ink); margin-top: 4px;
}
.levelselect-scroll {
  flex: 1 1 auto; width: 100%; overflow-y: auto; min-height: 0;
  padding: 4px 2px 16px; display: flex; flex-direction: column; gap: 18px;
}
.level-section__title {
  font-family: var(--font-display); font-size: 22px; color: var(--navy); margin-bottom: 8px;
}
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.level-node {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--pale-orange); border-radius: var(--tile-radius);
  box-shadow: 0 4px 0 #f0d8c4; padding: 8px 6px 10px;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.level-node:not(.is-locked):hover { transform: translateY(-2px); box-shadow: 0 6px 0 #f0d8c4; }
.level-node:not(.is-locked):active { transform: translateY(4px); box-shadow: none; }
.level-node__art {
  position: relative; width: 100%; aspect-ratio: 1 / 1; border-radius: 12px; overflow: hidden;
  background: radial-gradient(120% 120% at 50% 25%, #fff, #fde9d6);
  display: flex; align-items: center; justify-content: center;
}
.level-node__pose { width: 94%; height: 94%; object-fit: contain; }
.level-node__lock { font-size: 26px; opacity: 0.5; }
.level-node__badge { position: absolute; top: 3px; right: 4px; font-size: 13px; }
.level-node__label { display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.level-node__id { font-family: var(--font-display); font-size: 15px; color: var(--navy); }
.level-node__theme { font-family: var(--font-body); font-weight: 700; font-size: 11px; color: var(--orange-dark); }
.level-node.is-locked { background: #f1efea; box-shadow: 0 4px 0 #ddd8cf; cursor: default; }
.level-node.is-locked .level-node__art { background: #e9e6df; }
.level-node.is-locked .level-node__id, .level-node.is-locked .level-node__theme { color: #aaa39a; }
.level-node.is-done .level-node__art { box-shadow: inset 0 0 0 2.5px var(--success); }

/* Start-screen theme chip */
.start-theme {
  display: inline-block; font-family: var(--font-display); font-size: 18px;
  color: var(--white); background: var(--orange); padding: 3px 14px; border-radius: 100px;
}

/* Game illustration placeholder (audio-only, until word art is drawn) */
.illustration--audio { display: flex; align-items: center; justify-content: center; }
.illustration__listen { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px; }
.illustration__icon { font-size: 54px; }
.illustration__hint {
  font-family: var(--font-body); font-weight: 700; font-size: 13px;
  color: var(--orange-dark); text-align: center; max-width: 85%;
}

/* ============ RESULTS — pills + cat paws ============ */
.result-pills { display: flex; gap: 12px; justify-content: center; width: 100%; max-width: 320px; }
.result-pill { flex: 1 1 0; max-width: 150px; border-radius: 18px; padding: 5px; text-align: center; }
.result-pill__label {
  display: block; font-family: var(--font-display); font-size: 12px;
  letter-spacing: 0.8px; text-transform: uppercase; color: var(--white); padding: 5px 0 6px;
}
.result-pill__value {
  background: var(--white); border-radius: 13px; padding: 10px 8px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.result-pill__icon { font-size: 19px; }
.result-pill__num { font-family: var(--font-display); font-size: 24px; }
.result-pill--time { background: var(--orange); box-shadow: 0 4px 0 var(--orange-dark); }
.result-pill--time .result-pill__num { color: var(--orange-dark); }
.result-pill--acc { background: var(--success); box-shadow: 0 4px 0 var(--success-dark); }
.result-pill--acc .result-pill__num { color: var(--success-dark); }
.result-paws { display: flex; gap: 6px; font-size: 30px; line-height: 1; }
.result-paw { filter: grayscale(1) opacity(0.3); transform: scale(0.9); }
.result-paw.is-on { filter: none; transform: scale(1); animation: star-pop 0.45s var(--ease-spring) backwards; }
.result-paw.is-on:nth-child(1) { animation-delay: 0.1s; }
.result-paw.is-on:nth-child(2) { animation-delay: 0.2s; }
.result-paw.is-on:nth-child(3) { animation-delay: 0.3s; }
.result-paw.is-on:nth-child(4) { animation-delay: 0.4s; }
.result-paw.is-on:nth-child(5) { animation-delay: 0.5s; }

/* ---- Results: 3-up pills + paw-coin pill ---- */
.result-pills { gap: 8px; max-width: 360px; }
.result-pill { max-width: none; }
.result-pill__label { font-size: 11px; letter-spacing: 0.5px; }
.result-pill__value { padding: 9px 6px; gap: 5px; }
.result-pill__icon { font-size: 17px; }
.result-pill__num { font-size: 21px; }
.result-pill__coin { width: 23px; height: 23px; object-fit: contain; }
.result-pill--paw { background: var(--navy); box-shadow: 0 4px 0 var(--navy-dark); }
.result-pill--paw .result-pill__num { color: var(--navy); }

/* ============ COIN REVEAL OVERLAY ============ */
.coin-reveal {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 102, 0, 0.5); /* 50% orange tint */
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px); /* blurs the results screen behind */
  animation: cr-fade-in 0.3s ease both;
}
.coin-reveal--out { animation: cr-fade-out 0.45s ease both; }
@keyframes cr-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes cr-fade-out { from { opacity: 1; } to { opacity: 0; } }

.coin-reveal__stage { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.coin-reveal__coinwrap { position: relative; width: 190px; height: 190px; }
.coin-reveal__coin {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.35));
  animation: cr-coin 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both,
    cr-bob 2s ease-in-out 0.7s infinite;
}
@keyframes cr-coin {
  0% { transform: scale(0) rotate(-35deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
@keyframes cr-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.coin-reveal__stars { position: absolute; inset: -8%; width: 116%; height: 116%; pointer-events: none; overflow: visible; }
.cr-star {
  fill: #fff3c4;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: cr-spark 1.1s ease-out 0.6s infinite both;
}
.cr-star.s2 { animation-delay: 0.8s; }
.cr-star.s3 { animation-delay: 1s; }
.cr-star.s4 { animation-delay: 1.3s; }
.cr-star.s5 { animation-delay: 1.55s; }
@keyframes cr-spark {
  0% { opacity: 0; transform: scale(0) rotate(0); }
  35% { opacity: 1; transform: scale(1.2) rotate(35deg); }
  100% { opacity: 0; transform: scale(0.4) rotate(70deg); }
}

.coin-reveal__count {
  font-family: var(--font-display);
  font-size: 62px;
  line-height: 1;
  color: #ffd24a;
  -webkit-text-stroke: 2.5px #7a3b00;
  text-shadow: 0 1px 0 #e3aa00, 0 2px 0 #d29c00, 0 3px 0 #bf8c00,
    0 4px 0 #a87400, 0 5px 0 #8f6300, 0 8px 9px rgba(0, 0, 0, 0.45);
  animation: cr-count 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.5s both;
}
@keyframes cr-count {
  0% { transform: scale(0) translateY(16px); opacity: 0; }
  70% { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); }
}
.coin-reveal__caption {
  font-family: var(--font-display);
  font-size: 22px;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  animation: cr-count 0.5s ease 0.75s both;
}

/* (coin-pill styling unified with .score-pill near the top, per Figma 16:8) */

/* ---- Level node: depth + completed (green) state ---- */
.level-node__pose { filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.16)); }
.level-node__badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 27px;
  height: 27px;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}
/* Cleared inner level → green card */
.level-node.is-done {
  background: #e3f6e9;
  box-shadow: 0 4px 0 var(--success-dark);
}
.level-node.is-done .level-node__art {
  background: radial-gradient(120% 120% at 50% 25%, #ffffff, #cdeed7);
  box-shadow: inset 0 0 0 2.5px var(--success);
}
.level-node.is-done .level-node__id { color: var(--success-dark); }
.level-node.is-done .level-node__theme { color: var(--success-dark); }
.level-node.is-done:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--success-dark); }
.level-node.is-done:active { transform: translateY(4px); box-shadow: none; }

/* Admin / dev controls on the level map (dashed = not part of the kid UI) */
.admin-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 10px 0 4px;
}
.admin-btn {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 800;
  color: #9a8676;
  background: #f1efea;
  border: 1px dashed #cfc6b6;
  border-radius: 100px;
  padding: 5px 14px;
  cursor: pointer;
}
.admin-btn:hover { background: #e9e5db; }
.admin-btn:active { transform: translateY(1px); }

/* Answer-tile label span — measured for auto-fit; single line, centered. */
.answer-tile__label {
  display: inline-block;
  white-space: nowrap;
  pointer-events: none;
}

/* ============================================================================
   AUTH + HOME SCREENS (main / login / signup / home) — Figma 27:1635, 27:847,
   31:8469, 30:7148. Navbar here = logo + language pill only (pills hidden).
   ========================================================================== */
.auth-screen { background: var(--white); }

.auth-body {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 20px 16px; /* + screen pad 15 => ~35px card inset, matches Figma */
  overflow-y: auto;
}
.auth-body--center { justify-content: center; }

/* Peek mascot sitting over the top edge of the card */
.peek-wrap {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.peek-mascot {
  width: 76px;
  height: auto;
  align-self: center;
  margin-bottom: -3px;
  position: relative;
  z-index: 2;
}

.auth-card {
  width: 100%;
  background: #fbf1e6;
  border: 2px solid #40120d; /* peek-mascot cards use the dark mascot-outline border */
  border-radius: 22px;
  padding: 22px 18px;
  box-shadow: 0 8px 22px -10px rgba(26, 42, 94, 0.18);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-card--form { gap: 11px; padding-top: 20px; }

/* Buttons */
.auth-btn {
  width: 100%;
  height: 48px;
  border-radius: 100px;
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.auth-btn--primary { background: var(--orange); color: #fff; box-shadow: 0 4px 0 var(--orange-dark); }
.auth-btn--ghost { background: #fff; color: var(--orange); border: 2px solid var(--orange); }
.auth-btn--navy { background: var(--navy); color: #fff; box-shadow: 0 4px 0 var(--navy-dark); }
.auth-btn--primary:active, .auth-btn--navy:active { transform: translateY(4px); box-shadow: none; }
.auth-btn--ghost:active { transform: translateY(2px); }
.auth-btn[disabled] { opacity: 0.55; cursor: default; }

/* Field: colored label bar + light input */
.field { display: flex; flex-direction: column; gap: 4px; }
.field__label {
  border-radius: 14px;
  padding: 11px 16px;
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1;
  color: #fff;
}
.field__label--orange { background: var(--orange); }
.field__label--navy { background: var(--navy); }
.field__label--left { text-align: left; }
.field__label--center { text-align: center; }
.field__input {
  width: 100%;
  height: 40px;
  border-radius: 12px;
  background: #ececec;
  border: 1.5px solid transparent;
  padding: 0 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
}
.field__input::placeholder { color: #b7b7b7; }
.field__input:focus { outline: none; border-color: var(--orange); background: #f5f5f5; }

.auth-error { color: #e5484d; font-family: var(--font-body); font-weight: 700; font-size: 13px; text-align: center; min-height: 1em; margin: -2px 0; }
.auth-note { color: var(--navy); font-family: var(--font-body); font-weight: 700; font-size: 13px; text-align: center; margin: -2px 0; }

/* Sign-up header */
.signup-title { font-family: var(--font-display); font-size: 21px; color: var(--ink); text-align: center; line-height: 1.1; }
.signup-price { font-family: var(--font-display); font-size: 19px; color: var(--ink); text-align: center; margin-top: -4px; }
.signup-price__amt { color: var(--orange); }

/* ---- Home screen ---- */
.home-body { gap: 14px; align-items: center; justify-content: safe center; padding: 8px 20px 16px; }
.home-card { gap: 14px; }

.home-greet { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.home-greet__hi { font-family: var(--font-display); font-size: 27px; color: var(--ink); line-height: 1; }
.home-greet__name { color: var(--orange); }
.home-greet__q { font-family: var(--font-body); font-weight: 700; font-size: 14px; color: var(--ink); margin-top: 7px; }
.oyen-avatar--home { width: 68px; height: 68px; }

.profile { border-radius: 14px; overflow: hidden; border: 1.5px solid #ead9c2; background: #fff; }
.profile__head { background: var(--orange); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; }
.profile__title { font-family: var(--font-display); font-size: 16px; letter-spacing: 0.3px; }
.profile__badge { background: #fff; color: var(--ink); font-family: var(--font-display); font-size: 13px; padding: 3px 14px; border-radius: 100px; }
.profile-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 14px; border-bottom: 1px solid #f1e8d9; }
.profile-row:last-child { border-bottom: none; }
.profile-row__label { font-family: var(--font-display); font-size: 16px; color: var(--ink); }
.profile-pill { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--orange); border-radius: 100px; padding: 3px 12px 3px 7px; background: #fff6ec; }
.profile-pill__icon { width: 18px; height: 18px; object-fit: contain; }
.profile-pill__num { font-family: var(--font-display); font-size: 15px; color: var(--orange); }
.home-share { height: 44px; font-size: 17px; }

.home-section { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 320px; border-radius: 18px; padding: 14px; }
.home-section--learn { background: #fbf1e6; border: 1.5px solid #ead9c2; }
.home-section--play { background: #e8503c; }
.home-section--shop { background: var(--orange); }
.home-section__text { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4px; min-width: 0; }
.home-section__title { font-family: var(--font-display); font-size: 20px; }
.home-section__sub { font-family: var(--font-body); font-weight: 700; font-size: 12px; }
.home-section--learn .home-section__title { color: var(--ink); }
.home-section--learn .home-section__sub { color: #5b5b5b; }
.home-section--play .home-section__title, .home-section--shop .home-section__title { color: #fff; }
.home-section--play .home-section__sub, .home-section--shop .home-section__sub { color: rgba(255,255,255,0.92); }
.home-section__btn { margin-top: 6px; border-radius: 100px; padding: 7px 18px; font-family: var(--font-display); font-size: 14px; color: #fff; }
.home-section__btn--learn { background: #2fb35e; }
.home-section__btn--play { background: #9e2b1e; }
.home-section__btn--shop { background: #262626; }
.home-section__art { width: 96px; height: 78px; border-radius: 12px; flex-shrink: 0; }
.home-section--learn .home-section__art { background: #e8503c; }
.home-section--play .home-section__art, .home-section--shop .home-section__art { background: #1b1b26; }

/* Sign-out pill (home navbar, left of the language toggle) */
.signout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  width: 32px;
  padding: 0;
  background: #fff6ec;
  border: 1px solid var(--orange-mid);
  border-radius: 100px;
  color: var(--orange);
  flex-shrink: 0;
}
.signout-btn svg { width: 16px; height: 16px; display: block; }
.signout-btn:active { transform: translateY(1px); }

/* ---- Interactive states: clickable logo, back button, hover/press feedback ---- */
.logo-btn { background: none; border: none; padding: 0; cursor: pointer; display: inline-flex; line-height: 0; transition: opacity 0.12s ease, transform 0.12s ease; }
.logo-btn:active { transform: translateY(1px); }

.back-btn {
  display: inline-flex; align-items: center; gap: 4px; align-self: flex-start;
  background: #fff6ec; border: 1px solid var(--orange-mid); border-radius: 100px;
  color: var(--orange); font-family: var(--font-display); font-size: 14px;
  padding: 5px 14px 5px 10px; margin-bottom: 8px; cursor: pointer;
  transition: background 0.12s ease, transform 0.1s ease;
}
.back-btn svg { width: 16px; height: 16px; }
.back-btn:active { transform: translateY(1px); }

.auth-btn { cursor: pointer; }
.home-section { transition: transform 0.14s ease, box-shadow 0.14s ease; }
.home-section__btn { transition: transform 0.12s ease, filter 0.12s ease, opacity 0.12s ease; cursor: pointer; }
.home-section__btn:active:not([disabled]) { transform: translateY(2px); }
.home-section__btn[disabled] { opacity: 0.6; cursor: default; }

/* Pointer-device hover only (avoid sticky hover on touch) */
@media (hover: hover) {
  /* Orange primary → navy on hover (brighten-orange read poorly); navy stays navy. */
  .auth-btn--primary:hover { background: var(--navy); box-shadow: 0 4px 0 var(--navy-dark); transform: translateY(-1px); }
  .auth-btn--navy:hover { filter: brightness(1.1); transform: translateY(-1px); }
  .auth-btn--ghost:hover { border-color: var(--navy); color: var(--navy); }
  .home-section__btn:hover:not([disabled]) { filter: brightness(1.06); transform: translateY(-1px); }
  .home-section:hover { transform: translateY(-2px); box-shadow: 0 8px 18px -10px rgba(26, 42, 94, 0.28); }
  .signout-btn:hover, .back-btn:hover { background: #ffe9d6; }
  .logo-btn:hover { opacity: 0.85; }
}

/* ---- Home promo carousel (one card visible; swipe on mobile, 3s auto on desktop) ---- */
.home-carousel-wrap { width: 100%; max-width: 320px; }
.home-carousel {
  display: flex;
  overflow-x: auto;
  /* overflow-x:auto forces overflow-y to clip too — pad vertically so the cards'
     hover lift + shadow aren't cropped. */
  padding: 8px 0 16px;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.home-carousel::-webkit-scrollbar { display: none; }
.home-carousel__slide { flex: 0 0 100%; scroll-snap-align: center; display: flex; }
.home-carousel__slide .home-section { width: 100%; max-width: none; min-height: 122px; }
.home-carousel__dots { display: flex; justify-content: center; gap: 7px; margin-top: 2px; }
.home-carousel__dot {
  width: 8px; height: 8px; border-radius: 50%; background: #e3d6c4;
  border: none; padding: 0; cursor: pointer; transition: background 0.2s ease, width 0.2s ease;
}
.home-carousel__dot.is-active { background: var(--orange); width: 20px; border-radius: 100px; }
