/* style.css — one UI kit: two fonts, one radius/spacing scale, one transition curve. */
:root {
  --sky-top: #7EC8F7; --sky-bottom: #E8F6FF;
  --grass: #58B26B; --stone: #D9D2C5;
  --pink: #FFB3C7; --yellow: #FFD66B; --violet: #9B8CFF;
  --glow: #FFDD88; --enemy: #8E9AA8;
  --ink: #2E3A4A;
  --r: 18px;
  --pad: 18px;
  --ease: cubic-bezier(0.22, 1.4, 0.36, 1);
  /* V6: the webfonts are optional. These stacks are ordered so that every platform
     lands on a rounded, friendly face even with no network at all. */
  --font-display: "Baloo 2", "Baloo2", "Trebuchet MS", "Avenir Next Rounded",
                  "Nunito", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --font-body: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", system-ui, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--sky-top); }
body { font-family: var(--font-body); color: var(--ink); }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }

/* ── HUD ── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#spark-box {
  position: absolute; top: 14px; left: 16px;
  background: rgba(46, 58, 74, 0.55); backdrop-filter: blur(6px);
  border-radius: var(--r); padding: 8px 16px;
  color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 22px;
  display: flex; align-items: center; gap: 8px;
}
#spark-ico { color: var(--yellow); text-shadow: 0 0 10px var(--yellow); }
#spark-goal { opacity: 0.7; font-size: 15px; }
#spark-box.pop { animation: pop 0.32s var(--ease); }
@keyframes pop { 40% { transform: scale(1.18); } }
#prism-box { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; }
.prism-slot {
  font-size: 24px; color: rgba(255, 255, 255, 0.35);
  text-shadow: 0 2px 6px rgba(0,0,0,0.25); transition: color 0.25s, transform 0.25s var(--ease);
}
.prism-slot.got { color: var(--violet); text-shadow: 0 0 12px var(--violet); transform: scale(1.25) rotate(8deg); }
#power-box {
  position: absolute; top: 14px; right: 16px; width: 52px; height: 52px;
  background: rgba(46, 58, 74, 0.55); backdrop-filter: blur(6px);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 26px; border: 2px solid rgba(255,255,255,0.4);
}
#power-box.pop { animation: pop 0.35s var(--ease); }
#timer {
  position: absolute; top: 76px; right: 18px;
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 17px;
  text-shadow: 0 2px 8px rgba(46, 58, 74, 0.5);
}
#dist-box {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(46, 58, 74, 0.55); backdrop-filter: blur(6px);
  border-radius: var(--r); padding: 8px 18px;
  color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 22px;
}
#boss-bar {
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  width: min(480px, 70vw); text-align: center;
}
#boss-name {
  color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 19px;
  text-shadow: 0 2px 8px rgba(46, 58, 74, 0.7);
}
.boss-track {
  margin-top: 5px; height: 14px; border-radius: 7px;
  background: rgba(46, 58, 74, 0.6); border: 2px solid rgba(255,255,255,0.5);
  overflow: hidden;
}
#boss-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--violet), var(--pink));
  transition: width 0.3s var(--ease);
}
#toast {
  position: absolute; top: 78px; left: 50%; transform: translateX(-50%);
  background: rgba(46, 58, 74, 0.72); color: #fff; backdrop-filter: blur(6px);
  border-radius: var(--r); padding: 10px 22px;
  font-family: var(--font-display); font-weight: 700; font-size: 18px;
  white-space: nowrap;
}
#toast.anim { animation: toast-in 0.4s var(--ease); }
@keyframes toast-in { from { transform: translateX(-50%) translateY(-16px); opacity: 0; } }
.set-note {
  margin: -2px 0 10px; color: rgba(255, 255, 255, 0.62);
  font-size: 13px; line-height: 1.4; max-width: 46ch;
}

/* Ä1 beat banner: sits under the toast line, quieter than a toast on purpose */
#beat {
  position: absolute; top: 128px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: baseline; gap: 10px;
  font-family: var(--font-display); font-weight: 700;
  text-shadow: 0 2px 12px rgba(46, 58, 74, 0.85);
  white-space: nowrap; pointer-events: none;
}
#beat .beat-n { color: var(--yellow, #FFCB45); font-size: 15px; letter-spacing: 0.08em; }
#beat .beat-name { color: #fff; font-size: 21px; }
#beat.anim { animation: beat-in 0.5s var(--ease); }
@keyframes beat-in { from { transform: translateX(-50%) translateY(10px); opacity: 0; } }
/* Phase C: Lumi's line. Sits low and to the side so it never covers the action,
   and fades on its own — the story must never interrupt play. */
#say {
  position: absolute; bottom: 132px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: baseline; gap: 9px;
  max-width: min(560px, 86vw);
  padding: 9px 16px; border-radius: 999px;
  background: rgba(28, 36, 52, 0.7);
  backdrop-filter: blur(6px);
  font-family: var(--font-display); font-weight: 700;
  text-shadow: 0 1px 6px rgba(20, 26, 38, 0.7);
  white-space: normal; pointer-events: none;
}
#say .say-who { color: var(--yellow, #FFCB45); font-size: 14px; letter-spacing: 0.06em; flex: none; }
#say .say-text { color: #fff; font-size: 17px; line-height: 1.25; }
#say.anim { animation: say-in 0.42s var(--ease); }
@keyframes say-in { from { transform: translateX(-50%) translateY(12px); opacity: 0; } }

#hint {
  position: absolute; bottom: 90px; left: 50%; transform: translateX(-50%);
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 20px;
  text-shadow: 0 2px 10px rgba(46, 58, 74, 0.8);
  animation: hint-bob 2s ease-in-out infinite;
}
@keyframes hint-bob { 50% { transform: translateX(-50%) translateY(-6px); } }

/* ── menus ── */
#menu-root { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.screen {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: auto;
  background: radial-gradient(ellipse at 50% 40%, rgba(126, 200, 247, 0.25), rgba(46, 58, 74, 0.45));
  animation: screen-in 0.35s var(--ease);
}
@keyframes screen-in { from { opacity: 0; transform: scale(1.04); } }
.panel {
  background: rgba(232, 246, 255, 0.88); backdrop-filter: blur(14px);
  border-radius: calc(var(--r) * 1.6); padding: calc(var(--pad) * 1.8);
  box-shadow: 0 18px 60px rgba(46, 58, 74, 0.35), inset 0 2px 0 rgba(255,255,255,0.8);
  text-align: center; max-width: min(560px, 92vw); max-height: 88vh; overflow-y: auto;
  animation: panel-in 0.45s var(--ease);
}
@keyframes panel-in { from { transform: translateY(22px) scale(0.96); opacity: 0; } }
.logo {
  font-family: var(--font-display); font-weight: 800; font-size: clamp(38px, 7vw, 58px);
  color: var(--ink); line-height: 1;
  text-shadow: 0 3px 0 rgba(255,255,255,0.7);
}
.logo span { color: #E8A33D; text-shadow: 0 0 22px var(--glow), 0 3px 0 rgba(255,255,255,0.7); }
.tag { margin: 6px 0 18px; font-weight: 600; opacity: 0.75; }
h2 { font-family: var(--font-display); font-weight: 800; font-size: 30px; margin-bottom: 14px; }
.btn-col { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.btn {
  font-family: var(--font-display); font-weight: 700; font-size: 19px;
  padding: 11px 30px; border: none; border-radius: var(--r);
  background: #fff; color: var(--ink); cursor: pointer;
  box-shadow: 0 4px 0 rgba(46, 58, 74, 0.18);
  transition: transform 0.15s var(--ease), box-shadow 0.15s, background 0.15s;
}
.btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 6px 0 rgba(46, 58, 74, 0.18); background: var(--yellow); }
.btn:active { transform: translateY(1px); box-shadow: 0 2px 0 rgba(46, 58, 74, 0.18); }
.btn.big { background: var(--grass); color: #fff; font-size: 23px; }
.btn.big:hover { background: #6AC57D; }
.btn.ghost { background: transparent; box-shadow: none; opacity: 0.7; }
.btn.ghost:hover { background: rgba(255,255,255,0.6); }
.validator-line { margin-top: 14px; font-weight: 700; font-size: 14px; opacity: 0.8; }
.validator-line.ok { color: #2F8F4E; }
.validator-line.bad { color: #C24A24; }
.controls-box { margin-top: 12px; font-size: 14px; }
.controls-box summary { cursor: pointer; font-weight: 800; font-family: var(--font-display); }
.controls-box table { margin: 10px auto 0; border-collapse: collapse; text-align: left; }
.controls-box th, .controls-box td { padding: 3px 10px; font-size: 13px; }
.controls-box th { font-family: var(--font-display); }
.seed-row { display: flex; gap: 8px; margin-top: 14px; }
.seed-row input {
  flex: 1; border: 2px solid var(--stone); border-radius: var(--r);
  padding: 10px 14px; font-family: var(--font-body); font-weight: 600; font-size: 16px;
  outline: none;
}
.seed-row input:focus { border-color: var(--sky-top); }
.set-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 9px 0; font-weight: 700;
  border-bottom: 1px solid rgba(46, 58, 74, 0.1);
}
.set-row input[type="range"] { width: 160px; accent-color: var(--grass); }
.seg { display: flex; gap: 6px; }
.seg button {
  border: 2px solid rgba(46, 58, 74, 0.2); background: transparent;
  border-radius: 12px; padding: 5px 14px; cursor: pointer;
  font-family: var(--font-display); font-weight: 700;
}
.seg button.on { background: var(--violet); border-color: var(--violet); color: #fff; }
.swatches { display: flex; gap: 8px; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; cursor: pointer;
  box-shadow: 0 2px 8px rgba(46, 58, 74, 0.3);
  transition: transform 0.15s var(--ease);
}
.swatch:hover { transform: scale(1.15); }
.swatch.on { outline: 3px solid var(--ink); }
.swatch.locked { filter: grayscale(0.9) brightness(0.7); cursor: not-allowed; }
/* ── settings: categories, value readouts, save codes (v2) ── */
.set-cat {
  font-family: var(--font-display); font-size: 15px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--violet); text-align: left;
  margin: 18px 0 2px; padding-top: 8px;
  border-top: 2px solid rgba(155, 140, 255, 0.25);
}
.set-cat:first-of-type { margin-top: 14px; }
.set-val { min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; opacity: 0.75; }
.set-row input[type="range"] { flex: 0 1 130px; }
.save-row { justify-content: center; gap: 10px; border-bottom: none; }
.btn.small-btn { padding: 8px 18px; font-size: 15px; }
.save-code {
  width: 100%; margin-top: 8px; border: 2px solid var(--stone); border-radius: 12px;
  padding: 8px 10px; font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: 11px; resize: vertical; outline: none; word-break: break-all;
}
.save-code:focus { border-color: var(--sky-top); }

/* ── boot / fatal-error overlay (V7) ── */
#boot {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  transition: opacity 0.45s ease;
}
#boot.gone { opacity: 0; pointer-events: none; }
.boot-lantern {
  width: 62px; height: 62px; border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #FFF6DC, var(--glow) 55%, #F2C25A);
  box-shadow: 0 0 34px 10px rgba(255, 221, 136, 0.65);
  animation: bootpulse 1.5s var(--ease) infinite;
}
@keyframes bootpulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.14); } }
.boot-text { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--ink); opacity: 0.75; }
.boot-error { max-width: 460px; text-align: center; padding: 0 24px; }
.boot-error h2 { font-family: var(--font-display); font-size: 24px; margin-bottom: 10px; }
.boot-error p { font-size: 15px; line-height: 1.5; opacity: 0.8; margin-bottom: 8px; }
.boot-error code {
  display: block; margin-top: 10px; font-size: 11px; opacity: 0.6;
  font-family: ui-monospace, monospace; word-break: break-word;
}
@media (prefers-reduced-motion: reduce) {
  .boot-lantern { animation: none; }
}
details { margin-top: 12px; text-align: left; }
details summary { cursor: pointer; font-weight: 800; font-family: var(--font-display); text-align: center; }
details pre {
  background: rgba(46, 58, 74, 0.85); color: #B8F0C8; border-radius: 12px;
  padding: 12px; font-size: 11px; overflow-x: auto; margin-top: 8px; white-space: pre-wrap;
}
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.stats div {
  background: rgba(255,255,255,0.65); border-radius: var(--r); padding: 10px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.stats span { font-size: 13px; font-weight: 600; opacity: 0.65; }
.stats b { font-family: var(--font-display); font-size: 21px; }
#fade {
  position: fixed; inset: 0; background: #2E3A4A; opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease; z-index: 40;
}
#fade.on { opacity: 1; pointer-events: auto; }

/* ── touch ── */
#touch { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
#stick-zone { position: absolute; left: 0; bottom: 0; width: 45%; height: 55%; pointer-events: auto; }
#stick-base {
  position: absolute; left: 60px; bottom: 70px; width: 108px; height: 108px;
  border-radius: 50%; background: rgba(255,255,255,0.18); border: 2px solid rgba(255,255,255,0.45);
  backdrop-filter: blur(4px);
}
#stick-nub {
  position: absolute; left: 50%; top: 50%; margin: -26px;
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,0.75); box-shadow: 0 4px 12px rgba(46,58,74,0.3);
}
#touch-btns {
  position: absolute; right: 22px; bottom: 54px;
  display: flex; align-items: flex-end; gap: 16px; pointer-events: auto;
}
/* Ä9: every control clears the 44 px (Apple) / 48 dp (Android) minimum touch target.
   `touch-action: none` stops the browser hijacking a press as a scroll or a
   double-tap-zoom, which used to eat inputs mid-jump. */
.tbtn {
  width: 68px; height: 68px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.25); color: #fff; font-size: 25px; font-weight: 800;
  backdrop-filter: blur(4px); pointer-events: auto;
  touch-action: none; -webkit-tap-highlight-color: transparent; user-select: none;
}
/* the jump button is the one you hit under pressure: make it unmissable */
.tbtn.big {
  width: 104px; height: 104px; font-size: 38px;
  background: rgba(88, 178, 107, 0.58);
  border-width: 3px;
  box-shadow: 0 6px 18px rgba(46, 58, 74, 0.28);
}
.tbtn.small { position: absolute; top: 14px; right: 84px; width: 48px; height: 48px; font-size: 17px; }
#tb-recenter { top: 14px; right: 140px; }
.tbtn:active { transform: scale(0.93); background: rgba(255, 214, 107, 0.62); }
.tbtn.big:active { transform: scale(0.95); }
#stick-zone, #touch { touch-action: none; }

/* Small phones in landscape: keep the thumb reach comfortable. */
@media (max-height: 460px) {
  .tbtn { width: 60px; height: 60px; font-size: 22px; }
  .tbtn.big { width: 92px; height: 92px; font-size: 34px; }
  #touch-btns { bottom: 34px; right: 18px; gap: 13px; }
  #stick-base { left: 46px; bottom: 46px; }
}

@media (max-width: 700px) {
  .stats { grid-template-columns: 1fr; }
  #timer { top: 70px; }
  .panel { padding: 20px; }
}
