:root {
  --bg-deep: #081820;
  --bg-pool: #0e2a38;
  --ink: #eaf2f4;
  --ink-dim: #9fb6bd;
  --accent: #ffcf6b;
  --accent-2: #f48a5a;
  --good: #76e0a0;
  --bad: #ff7a7a;
  --panel: rgba(8, 22, 30, 0.86);
  --panel-edge: rgba(255, 207, 107, 0.25);
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, "Tiro Devanagari Hindi", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.hidden { display: none !important; }

/* ---------- Screens / panels ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px;
  z-index: 30;
  background: radial-gradient(ellipse at center, rgba(8,22,30,0.55), rgba(4,12,16,0.9));
  backdrop-filter: blur(2px);
}

.panel {
  width: min(520px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 18px;
  padding: clamp(20px, 5vw, 38px);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.04);
}

.title {
  font-size: clamp(34px, 11vw, 64px);
  line-height: 0.95;
  letter-spacing: 1px;
  margin-bottom: 18px;
  color: var(--accent);
  text-shadow: 0 2px 30px rgba(255,207,107,0.25);
}
.title span { display: block; color: var(--ink); font-weight: 400; }

h2 {
  font-size: clamp(22px, 6vw, 30px);
  color: var(--accent);
  margin-bottom: 14px;
}

.story {
  font-size: clamp(14px, 3.7vw, 16px);
  line-height: 1.6;
  color: var(--ink-dim);
  margin-bottom: 14px;
}
.story strong { color: var(--ink); }
.story em { color: var(--accent); font-style: italic; }

.story-sub {
  font-size: clamp(13px, 3.4vw, 15px);
  color: var(--accent-2);
  font-style: italic;
  margin-bottom: 22px;
}

.how-list {
  text-align: left;
  list-style: none;
  margin: 0 auto 24px;
  display: grid;
  gap: 12px;
}
.how-list li {
  font-size: clamp(13px, 3.4vw, 15px);
  line-height: 1.45;
  color: var(--ink-dim);
  padding-left: 18px;
  position: relative;
}
.how-list li::before {
  content: "›";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: bold;
}
.how-list b { color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font);
  font-size: clamp(15px, 4vw, 17px);
  border: none;
  border-radius: 12px;
  padding: 13px 30px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #2a1606;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(244,138,90,0.35);
}
.btn-primary:hover { box-shadow: 0 10px 30px rgba(244,138,90,0.5); }

.btn-ghost {
  background: rgba(255, 207, 107, 0.08);
  color: var(--accent);
  border: 1px solid var(--panel-edge);
  margin-top: 12px;
}
.btn-ghost:hover { background: rgba(255, 207, 107, 0.16); }

.btn-link {
  background: none;
  border: none;
  color: var(--ink-dim);
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 8px 10px;
}
.btn-link:hover { color: var(--accent); }

.over-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
}
.over-actions .btn-ghost { margin-top: 0; }

/* Star rating on level-complete */
.stars {
  font-size: 38px;
  letter-spacing: 8px;
  margin-bottom: 14px;
  min-height: 8px;
}
.stars .on { color: var(--accent); text-shadow: 0 2px 14px rgba(255,207,107,0.4); }
.stars .off { color: rgba(255,255,255,0.14); }

.over-sub {
  font-size: 15px;
  color: var(--ink-dim);
  margin-top: -10px;
  margin-bottom: 20px;
}

/* Combo badge */
.combo-badge {
  position: absolute;
  top: 11%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 22;
  font-size: clamp(20px, 6vw, 30px);
  font-weight: 800;
  color: var(--good);
  text-shadow: 0 2px 14px rgba(118,224,160,0.5);
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.combo-badge.bump { animation: combo-bump 0.3s ease; }
@keyframes combo-bump {
  0% { transform: translateX(-50%) scale(1); }
  40% { transform: translateX(-50%) scale(1.4); }
  100% { transform: translateX(-50%) scale(1); }
}

.title-links {
  margin-top: 18px;
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* ---------- Brand + language (top-left, persistent) ---------- */
.brand {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 14px;
  z-index: 23;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.brand-title {
  font-size: clamp(14px, 4vw, 17px);
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.4px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}
.lang-btn {
  pointer-events: auto;
  background: rgba(8, 22, 30, 0.72);
  border: 1px solid rgba(255, 207, 107, 0.45);
  border-radius: 8px;
  width: 30px; height: 30px;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  line-height: 1;
}
.lang-btn:hover { border-color: var(--accent); }
.menu-corner {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: 14px;
  z-index: 23;
}

/* ---------- HUD (top-left column: level/score row, objective below) ---------- */
.hud {
  position: absolute;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 18px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 46px);
  z-index: 20;
  pointer-events: none;
}
.hud-row { display: flex; gap: clamp(16px, 5vw, 28px); }
.objective-hud { display: flex; align-items: center; gap: 8px; }
.objective-hud .objective-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.hud-item { display: flex; flex-direction: column; line-height: 1.1; }
.hud-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.hud-item span:last-child {
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 700;
  color: var(--ink);
}
#hud-arrows { display: inline-flex; align-items: center; gap: 3px; }
.ai { display: inline-block; vertical-align: middle; }
.ai.on { color: var(--accent); }
.ai.off { color: rgba(255, 255, 255, 0.2); }
.icon-btn {
  margin-left: auto;
  pointer-events: auto;
  background: rgba(8, 22, 30, 0.72);
  border: 1px solid rgba(255, 207, 107, 0.45);
  border-radius: 10px;
  width: 44px; height: 44px;
  font-size: 20px;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}
.icon-btn:hover { background: rgba(8, 22, 30, 0.92); border-color: var(--accent); }

/* ---------- Focus meter ---------- */
.focus-wrap {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(280px, 70vw);
  z-index: 20;
  text-align: center;
  pointer-events: none;
}
.focus-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 5px;
}
.focus-bar {
  height: 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
}
.focus-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--good), var(--accent));
  transition: width 0.1s linear;
}

/* ---------- Toast ---------- */
/* Shot feedback (misses / minor hits): small + low, below the fish's orbit, so
   it never covers the eye — the focal point. The reward bloom (.word-bloom)
   stays central; this is just quiet information. */
.toast {
  position: absolute;
  top: 70%;
  left: 50%;
  transform: translate(-50%, -8px);
  z-index: 40;
  font-size: clamp(15px, 4.4vw, 22px);
  font-weight: 700;
  letter-spacing: 0.5px;
  pointer-events: none;
  opacity: 0;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
}
.toast.show {
  animation: toast-pop 0.9s ease forwards;
}
@keyframes toast-pop {
  0%   { opacity: 0; transform: translate(-50%, 6px) scale(0.85); }
  20%  { opacity: 1; transform: translate(-50%, -10px) scale(1.05); }
  70%  { opacity: 1; transform: translate(-50%, -14px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -28px) scale(0.96); }
}

/* ---------- Game over / initials ---------- */
.big-score {
  font-size: clamp(48px, 16vw, 84px);
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 24px;
  text-shadow: 0 3px 30px rgba(255,207,107,0.3);
}
#initials-wrap { display: grid; gap: 12px; margin-bottom: 12px; }
#initials-wrap label {
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-dim);
}
#initials {
  font-family: var(--font);
  font-size: 34px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 10px;
  text-transform: uppercase;
  width: 180px;
  margin: 0 auto;
  padding: 8px 8px 8px 18px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  color: var(--accent);
  caret-color: var(--accent);
}
#initials:focus { outline: none; border-color: var(--accent); }

/* ---------- Leaderboard list ---------- */
.board-list {
  list-style: none;
  text-align: left;
  margin: 0 auto 22px;
  display: grid;
  gap: 6px;
  counter-reset: rank;
}
.board-list li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  font-size: 15px;
}
.board-list li .rank { color: var(--ink-dim); font-weight: 700; }
.board-list li .name { letter-spacing: 4px; font-weight: 700; color: var(--ink); }
.board-list li .pts { color: var(--accent); font-weight: 700; }
.board-list li.you { background: rgba(255,207,107,0.14); border: 1px solid var(--panel-edge); }
.board-list li.top1 .name { color: var(--accent); }

@media (max-height: 560px) {
  .panel { padding: 18px 22px; }
  .story { margin-bottom: 10px; }
  .story-sub { margin-bottom: 14px; }
}

/* Title: instant instruction (lead with the action) */
.lede {
  font-size: clamp(16px, 4.6vw, 21px);
  color: var(--ink);
  font-weight: 700;
  margin-bottom: 22px;
  text-wrap: balance; /* even out lines — no one-word orphan on the last row */
}
.lede em {
  font-style: italic;
  color: var(--accent); /* the lesson word — "will" — carries the emphasis */
}

/* Pause menu */
.menu-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 14px;
}

/* Goal bar (top) — fills toward the star thresholds */
.goal-wrap {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 58px);
  left: 50%;
  transform: translateX(-50%);
  width: min(300px, 74vw);
  z-index: 20;
  text-align: center;
  pointer-events: none;
}
.goal-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 6px;
}
.goal-wrap.cleared .goal-label { color: var(--good); }
.goal-track {
  position: relative;
  height: 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
}
.goal-fill {
  height: 100%;
  width: 0%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--good), var(--accent));
  transition: width 0.18s linear;
}
.goal-notch {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 13px;
  margin-left: -1px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.28);
}
.goal-notch.lit { background: var(--accent); box-shadow: 0 0 6px rgba(255, 207, 107, 0.6); }
.goal-notch.n1 { left: 52.6%; }
.goal-notch.n2 { left: 73.7%; }
.goal-notch.n3 { left: 100%; }

/* Level intro card */
.level-intro {
  position: absolute;
  top: 32%;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 24;
  pointer-events: none;
  opacity: 0;
}
.level-intro.show { animation: levelintro 1.9s ease forwards; }
.level-intro-label {
  font-size: clamp(12px, 3.4vw, 14px);
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.level-intro-name {
  font-size: clamp(26px, 8vw, 44px);
  font-weight: 800;
  color: var(--ink);
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55);
}
@keyframes levelintro {
  0% { opacity: 0; transform: translateY(10px) scale(0.98); }
  18% { opacity: 1; transform: translateY(0) scale(1); }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-6px); }
}

/* Objective: strike the eye N times (top center) */
.objective {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 56px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.objective-label {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.objective-pips { display: inline-flex; gap: 6px; }
.objective-pips .pip {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.objective-pips .pip.on {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(255, 207, 107, 0.6);
}

/* Word bloom — Sanskrit/Hindi praise on a strike */
.word-bloom {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 35;
  font-family: "Tiro Devanagari Hindi", var(--font);
  font-size: clamp(34px, 11vw, 72px);
  color: var(--accent);
  text-shadow: 0 4px 32px rgba(255, 207, 107, 0.55);
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
}
.word-bloom.show { animation: wordbloom 0.9s ease forwards; }
@keyframes wordbloom {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  18% { opacity: 1; transform: translate(-50%, -52%) scale(1.06); }
  60% { opacity: 1; transform: translate(-50%, -52%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -56%) scale(1); }
}

/* Objective sits in the top-center row (brand left, menu right) */
.objective { top: calc(env(safe-area-inset-top, 0px) + 14px); }

/* Non-blocking "level cleared" bar — the scene stays visible behind it */
.next-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 26;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px calc(env(safe-area-inset-bottom, 0px) + 18px);
  background: linear-gradient(0deg, rgba(4, 12, 16, 0.92), rgba(4, 12, 16, 0));
  pointer-events: none;
  animation: nextbar-up 0.4s ease;
}
.next-bar .btn { pointer-events: auto; }
.next-summary {
  font-size: clamp(14px, 3.8vw, 16px);
  color: var(--ink);
  font-weight: 500;
}
@keyframes nextbar-up {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Level name — bold, top of the left HUD stack */
.level-name {
  font-size: clamp(17px, 5.2vw, 23px);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.3px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
  margin-bottom: 2px;
}
.level-name.show { animation: levelname-in 0.5s ease; }
@keyframes levelname-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* Eye icon in the objective row */
.eye-icon { display: inline-flex; align-items: center; }

/* The "next level" cue is now drawn on the canvas (a flower-coloured chevron
   pulsing at the centre); a tap anywhere advances. No DOM button. */
