/* Layout: one centered game column. Screens stack HUD → stage → Sprig's speech bar.
   Single committed look: dusk underwater, sand and coral as the warm "treasure" colors. */
:root {
  --abyss: #082230;
  --deep: #0d3a4a;
  --lagoon: #13576a;
  --shallows: #1f7f8c;
  --foam: #eaf7f4;
  --mist: #a9cfd0;
  --coral: #ff7a59;
  --coral-deep: #c9472f;
  --sand: #f6d68b;
  --sand-deep: #c9993f;
  --kelp: #6cc59f;
  --kelp-deep: #348a66;
  --sky: #8fd3e8;
  --lilac: #c7a6ff;
  --danger: #ff6b7f;
  --ink: #0a2230;
  --panel: rgba(8, 34, 48, 0.74);
  --panel-solid: #0b3040;
  --panel-line: rgba(169, 207, 208, 0.22);
  --well: rgba(234, 247, 244, 0.07);
  --well-strong: rgba(234, 247, 244, 0.14);
  --scrim: rgba(4, 18, 26, 0.74);

  --font-display: 'Lilita One', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --font-body: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;

  /* Kid-sized type: smallest label ~15px, body ~18px, prompts 26px and up. */
  --step--1: clamp(0.94rem, 0.9rem + 0.2vw, 1.02rem);
  --step-0: clamp(1.1rem, 1.04rem + 0.3vw, 1.22rem);
  --step-1: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
  --step-2: clamp(1.6rem, 1.4rem + 1vw, 2.1rem);
  --step-3: clamp(2rem, 1.6rem + 2vw, 3rem);
  --step-4: clamp(3rem, 2rem + 5vw, 5.6rem);

  --radius: 20px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
/* Every screen fits the window: nothing scrolls. Long content pages instead (ui/pager.js). */
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  background: radial-gradient(130% 90% at 50% -10%, var(--lagoon) 0%, var(--deep) 42%, var(--abyss) 100%) fixed, var(--abyss);
  color: var(--foam);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.4;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}

#bubbles, #confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#bubbles { z-index: 0; }
#confetti { z-index: 70; }

#app {
  position: relative;
  z-index: 1;
  height: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px;
  display: flex;
  flex-direction: column;
}
.boot { margin: auto; color: var(--mist); font-weight: 800; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 400; letter-spacing: 0.01em; margin: 0; text-wrap: balance; line-height: 1.1; }
p { margin: 0; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--sand); outline-offset: 3px; }
button:disabled { cursor: not-allowed; }

/* Buttons */
.btn {
  --b: var(--coral); --bd: var(--coral-deep);
  font-family: var(--font-display);
  font-size: var(--step-1);
  letter-spacing: 0.03em;
  padding: 0.62em 1.35em 0.7em;
  border-radius: 999px;
  background: var(--b);
  color: var(--ink);
  box-shadow: 0 5px 0 var(--bd);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.07); }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--bd); }
.btn:disabled { opacity: 0.45; }
.btn--sand { --b: var(--sand); --bd: var(--sand-deep); }
.btn--kelp { --b: var(--kelp); --bd: var(--kelp-deep); }
.btn--ghost { background: transparent; color: var(--foam); box-shadow: inset 0 0 0 2px var(--panel-line); }
.btn--ghost:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 0 0 2px var(--mist); }
.btn--small { font-size: var(--step-0); padding: 0.45em 1em 0.5em; }
.btn--big { font-size: var(--step-2); padding: 0.55em 1.7em 0.65em; }

.icon-btn {
  width: 44px; height: 44px; flex: none;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--panel-line);
  display: grid; place-items: center;
  font-size: 1.15rem;
}
.icon-btn:hover { background: var(--panel-solid); }

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--panel-line), 0 12px 30px rgba(2, 12, 18, 0.35);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.eyebrow {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: var(--step--1);
  color: var(--mist);
}

.stat {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--well);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat-label { font-weight: 800; color: var(--mist); font-size: var(--step--1); text-transform: uppercase; letter-spacing: 0.08em; }
.pearl {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #e9e2f7 45%, #a99cc4);
  box-shadow: 0 0 6px rgba(233, 226, 247, 0.6);
}
.star-glyph { color: var(--sand); }

.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--well-strong);
  font-size: var(--step--1);
  font-weight: 800;
  color: var(--foam);
}

#toast {
  position: fixed; left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  opacity: 0;
  background: var(--sand); color: var(--ink);
  padding: 0.6em 1.2em; border-radius: 999px;
  font-weight: 800; text-align: center;
  z-index: 80; pointer-events: none;
  max-width: calc(100% - 32px);
  transition: opacity 0.25s, transform 0.25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Screens + shared motion */
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; animation: screenIn 0.35s ease-out; }
@keyframes screenIn { from { opacity: 0.35; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.pop-in { animation: popIn 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes popIn { from { transform: scale(0.5); opacity: 0.3; } to { transform: none; opacity: 1; } }

.shake { animation: shake 0.42s; }
@keyframes shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.float-text {
  position: fixed;
  font-family: var(--font-display);
  font-size: var(--step-3);
  color: var(--sand);
  text-shadow: 0 3px 0 var(--ink);
  pointer-events: none;
  z-index: 75;
  animation: floatUp 1.1s ease-out forwards;
  white-space: nowrap;
}
@keyframes floatUp {
  from { opacity: 1; transform: translate(-50%, 0) scale(0.8); }
  to { opacity: 0; transform: translate(-50%, -80px) scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Pager (replaces scrolling) ---------- */
.pager { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.pager-list { flex: 1; min-height: 0; overflow: hidden; touch-action: pan-y; }
.pager-controls { display: flex; align-items: center; justify-content: center; gap: 14px; flex: none; }
.pager-btn {
  width: 60px; height: 52px; border-radius: 16px;
  background: var(--sand); color: var(--ink);
  font-family: var(--font-display); font-size: 2rem; line-height: 1;
  box-shadow: 0 4px 0 var(--sand-deep);
}
.pager-btn:disabled { opacity: 0.3; }
.pager-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--sand-deep); }
.pager-dots { display: flex; gap: 8px; }
.pager-dots span { width: 12px; height: 12px; border-radius: 50%; background: var(--well-strong); }
.pager-dots span.on { background: var(--sand); }

/* Draw attention without moving a child's tap target. */
.pager-next { width: auto; padding: 0 14px; gap: 6px; display: inline-flex; align-items: center; }
.pager-more { font-size: var(--step--1); font-family: var(--font-display); }
.pager-more:empty { display: none; }
.pager-next.nudge { animation: pager-glow 1.4s ease-in-out infinite; }
@keyframes pager-glow { 50% { box-shadow: 0 4px 0 var(--sand-deep), 0 0 16px var(--sand); } }
.pager-list.slide-left { animation: slide-left 0.32s ease-out; }
.pager-list.slide-right { animation: slide-right 0.32s ease-out; }
@keyframes slide-left { from { transform: translateX(40px); opacity: 0; } }
@keyframes slide-right { from { transform: translateX(-40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .pager-next.nudge, .pager-list.slide-left, .pager-list.slide-right { animation: none; }
}

/* ---------- Right-to-left (Arabic) ----------
   Text and layout flip, but puzzle boards, number pads and pager arrows stay left-to-right
   so number patterns read in the order the arrows point. */
[dir="rtl"] body { font-family: 'Segoe UI', Tahoma, 'Noto Sans Arabic', system-ui, sans-serif; }
[dir="rtl"] .fit, [dir="rtl"] .numpad, [dir="rtl"] .pager-controls, [dir="rtl"] .xs-strip,
[dir="rtl"] .maker-row, [dir="rtl"] .trail-box, [dir="rtl"] .round-dots { direction: ltr; }
[dir="rtl"] .fit .intro, [dir="rtl"] .fit .explain-title, [dir="rtl"] .story-card { direction: rtl; }
[dir="rtl"] .icon-btn[aria-label^="Back"] { transform: scaleX(-1); }
[dir="rtl"] .eyebrow { letter-spacing: 0; }
[dir="rtl"] .logo { direction: ltr; }

/* ---------- Language picker ---------- */
.lang-picks { display: flex; gap: 6px; }
.lang-pick { min-height: 40px; padding: 4px 12px; border-radius: 99px; border: 2px solid var(--panel-line); background: transparent; color: var(--foam); font: inherit; font-weight: 800; cursor: pointer; }
.lang-pick.on { background: var(--kelp); border-color: var(--kelp); color: var(--ink); }
