/* Jettison — a zero-g cargo bay. Self-contained. */

@import url("https://fonts.googleapis.com/css2?family=Archivo:wght@600;700;800;900&family=Geist+Mono:wght@400;500;600&display=swap");

:root{
  --ink: #eaf2ff;
  --dim: rgba(214, 228, 255, 0.64);
  --faint: rgba(214, 228, 255, 0.34);
  --glow: #5fd4ff;
  --warm: #ff9a3c;
  --hot: #ff5a4f;
  --line: rgba(150, 190, 255, 0.18);
  --panel: rgba(6, 10, 20, 0.88);
  --font-display: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after{ box-sizing: border-box; }
html, body{
  height: 100%; margin: 0; overflow: hidden;
  color: var(--ink);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
body{ background: #04060c; }
#c{
  position: fixed; inset: 0; display: block; width: 100%; height: 100%;
  touch-action: none;
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}

/* ---------- HUD ---------- */
.hud{
  position: fixed; z-index: 5; pointer-events: none;
  top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 22px; align-items: flex-end;
  font-family: var(--font-mono);
  padding: 7px 18px;
  border: 1px solid var(--line); border-radius: 12px;
  background: rgba(6, 10, 20, 0.62);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.hud[hidden]{ display: none; }
.hud__cell{ display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 50px; }
.hud__k{ font-size: 8px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--faint); }
.hud__cell > span:not(.hud__k){ font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
#moves{ color: var(--glow); }
#moves.is-over{ color: var(--warm); }
#par.is-target{ color: var(--warm); }

/* ---------- Tip ---------- */
.tip{
  position: fixed; z-index: 5; pointer-events: none;
  left: 50%; transform: translateX(-50%);
  top: max(74px, calc(env(safe-area-inset-top) + 64px));
  /* centred with left:50%, a box shrinks to half the screen: size it explicitly */
  width: max-content; max-width: min(92vw, 520px);
  padding: 8px 14px; border-radius: 10px;
  font-family: var(--font-mono); font-size: 0.72rem; line-height: 1.45; letter-spacing: 0.02em; text-align: center;
  color: var(--ink);
  background: rgba(10, 18, 34, 0.78); border: 1px solid rgba(95, 212, 255, 0.28);
  box-shadow: 0 8px 30px -10px rgba(0, 0, 0, 0.8);
  transition: opacity 500ms ease;
}
.tip[hidden]{ display: none; }
.tip.is-out{ opacity: 0; }

/* ---------- Toolbar ---------- */
.bar{
  position: fixed; z-index: 6;
  left: 50%; transform: translateX(-50%);
  bottom: max(16px, calc(env(safe-area-inset-bottom) + 8px));
  display: flex; gap: 8px;
}
.bar[hidden]{ display: none; }
.bar__btn{
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.04em;
  padding: 11px 14px; border-radius: 999px;
  color: var(--ink);
  background: rgba(10, 16, 30, 0.72); border: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
  touch-action: manipulation;
}
.bar__btn span{ font-size: 0.95rem; line-height: 1; }
.bar__btn:hover{ border-color: var(--glow); }
.bar__btn:active{ transform: scale(0.95); }
.bar__btn:disabled{ opacity: 0.35; pointer-events: none; }
.bar__btn:focus-visible{ outline: none; box-shadow: 0 0 0 3px rgba(95, 212, 255, 0.45); }
.bar__btn.is-on{ border-color: var(--glow); background: rgba(20, 60, 90, 0.7); }

/* ---------- Sound ---------- */
.sound-btn{
  position: fixed; z-index: 6;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(6, 10, 20, 0.6); color: var(--ink);
  font-size: 15px; cursor: pointer; backdrop-filter: blur(8px);
  transition: transform 140ms ease, border-color 140ms ease, opacity 140ms ease;
}
.sound-btn:hover{ transform: translateY(-1px); border-color: var(--glow); }
.sound-btn[aria-pressed="false"]{ opacity: 0.45; }
.sound-btn:focus-visible{ outline: none; box-shadow: 0 0 0 3px rgba(95, 212, 255, 0.45); }

/* ---------- Overlay ---------- */
.overlay{
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
  background: radial-gradient(90% 70% at 50% 46%, rgba(4, 8, 18, 0.45), rgba(2, 3, 8, 0.88));
  transition: opacity 260ms ease;
  overflow-y: auto;
  touch-action: pan-y;
}
.overlay[hidden]{ display: none; }
.overlay.is-out{ opacity: 0; pointer-events: none; }
.panel{
  max-width: 500px; width: 100%; text-align: center; margin: auto;
  padding: clamp(22px, 5vw, 34px);
  border: 1px solid var(--line); border-radius: 18px;
  background: var(--panel);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 30px 90px -20px rgba(0, 0, 0, 0.85), 0 0 70px -30px rgba(95, 212, 255, 0.5);
}
.panel__eyebrow{ margin: 0 0 6px; font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--warm); }
.panel__title{
  margin: 0 0 12px; font-size: clamp(2.3rem, 10vw, 3.6rem); font-weight: 900; letter-spacing: 0.04em; line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ffffff 12%, #bfe6ff 55%, #5fb2ff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 22px rgba(95, 212, 255, 0.35));
}
.panel__text{ margin: 0 0 18px; font-family: var(--font-mono); font-size: 0.8rem; line-height: 1.7; color: var(--dim); }
.panel__text b{ color: var(--ink); font-weight: 600; }
.panel__text .win{ color: #ffd27a; font-weight: 700; }
.panel__text .short{ color: var(--warm); }
.panel__text .big{ display: block; font-family: var(--font-display); font-size: 2.2rem; font-weight: 900; color: var(--ink); line-height: 1.1; margin: 2px 0 6px; }
.badge{
  display: inline-block; margin: 0 0 10px; padding: 3px 10px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: #2a1a02; background: linear-gradient(180deg, #ffe7a6, #ffb840);
}
.demo{ margin: 0 auto 18px; display: block; width: min(320px, 82vw); height: auto; }
.demo[hidden]{ display: none; }
.play-btn{
  appearance: none; font-family: var(--font-display); font-weight: 800; font-size: 1rem;
  padding: 13px 32px; border-radius: 999px; cursor: pointer;
  border: 0; background: linear-gradient(180deg, #ffffff, #bfe6ff);
  color: #04203a; box-shadow: 0 10px 30px -8px rgba(95, 212, 255, 0.6);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.play-btn:hover{ transform: translateY(-2px); box-shadow: 0 16px 38px -10px rgba(95, 212, 255, 0.8); }
.play-btn:focus-visible{ outline: none; box-shadow: 0 0 0 3px rgba(191, 230, 255, 0.6); }
.ghost-btn{
  appearance: none; display: block; margin: 12px auto 0;
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em;
  padding: 9px 18px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(95, 212, 255, 0.45);
  background: rgba(95, 212, 255, 0.1);
  color: var(--ink);
  transition: background 160ms ease, border-color 160ms ease;
}
.ghost-btn[hidden], .text-btn[hidden]{ display: none; }
.ghost-btn:hover{ background: rgba(95, 212, 255, 0.2); border-color: var(--glow); }
.ghost-btn:focus-visible, .text-btn:focus-visible{ outline: none; box-shadow: 0 0 0 3px rgba(191, 230, 255, 0.45); }
.text-btn{
  appearance: none; display: block; margin: 12px auto 0; padding: 4px 8px;
  border: 0; background: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.06em;
  color: var(--faint); text-decoration: underline; text-underline-offset: 3px;
  border-radius: 6px;
}
.text-btn:hover{ color: var(--ink); }
.panel__keys{ margin: 16px 0 0; font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.06em; color: var(--faint); }

/* ---------- Level picker ---------- */
.levels{
  display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px;
  margin: 14px 0 0; max-height: 40vh; overflow-y: auto; padding: 2px;
  touch-action: pan-y;
}
.levels[hidden]{ display: none; }
.levels__stage{
  grid-column: 1 / -1; margin: 8px 0 0; text-align: left;
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint);
}
.lv{
  appearance: none; cursor: pointer; position: relative;
  aspect-ratio: 1; border-radius: 9px;
  font-family: var(--font-mono); font-size: 0.78rem; font-weight: 600;
  color: var(--ink); background: rgba(20, 30, 52, 0.75); border: 1px solid var(--line);
  transition: border-color 120ms ease, transform 120ms ease;
}
.lv:hover{ border-color: var(--glow); }
.lv:active{ transform: scale(0.94); }
.lv:disabled{ opacity: 0.28; cursor: default; }
.lv.is-done{ background: rgba(26, 64, 92, 0.6); }
.lv.is-par::after{
  content: ""; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%;
  background: #ffc84a; box-shadow: 0 0 6px #ffc84a;
}
.lv.is-here{ border-color: var(--warm); }
.lv:focus-visible{ outline: none; box-shadow: 0 0 0 3px rgba(95, 212, 255, 0.5); }

/* ---------- Frame corners ---------- */
.frame{ position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.frame__corner{
  position: fixed; font-family: var(--font-mono); font-size: 0.6rem;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--faint);
}
.frame__corner--tl{ top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); }
.frame__corner--tr{ top: max(14px, env(safe-area-inset-top)); right: max(58px, calc(env(safe-area-inset-right) + 58px)); }
.frame__corner--bl{ bottom: max(14px, env(safe-area-inset-bottom)); left: max(14px, env(safe-area-inset-left)); pointer-events: auto; }
.frame__corner--bl a{ color: var(--faint); text-decoration: none; }
.frame__corner--bl a:hover{ color: var(--glow); }

@media (max-width: 620px){
  .frame__corner--tr, .frame__corner--tl{ display: none; }
  .hud{ gap: 14px; padding: 6px 12px; }
  .hud__cell{ min-width: 44px; }
  .hud__k{ font-size: 7px; letter-spacing: 0.12em; }
  .hud__cell > span:not(.hud__k){ font-size: 16px; }
  /* above the tickets pill, which owns the bottom-left corner */
  .bar{ gap: 6px; bottom: max(62px, calc(env(safe-area-inset-bottom) + 54px)); }
  .bar__btn{ padding: 11px 11px; font-size: 0.68rem; }
  /* the back link sits under the toolbar on a phone; the toolbar owns the bottom */
  .frame__corner--bl{ display: none; }
}
@media (max-width: 370px){
  .bar__btn{ padding: 10px 9px; }
  .bar__btn span{ display: none; }
}
@media (max-height: 520px){
  .hud{
    top: 50%; left: max(12px, env(safe-area-inset-left)); transform: translateY(-50%);
    flex-direction: column; align-items: flex-start; gap: 8px; padding: 9px 12px;
  }
  .hud__cell{ align-items: flex-start; }
  .bar{ left: auto; right: max(12px, env(safe-area-inset-right)); transform: none; flex-direction: column; bottom: 50%; translate: 0 50%; }
  .tip{ top: max(12px, env(safe-area-inset-top)); }
  .frame__corner--tl{ display: none; }
}
@media (prefers-reduced-motion: reduce){
  .play-btn, .sound-btn, .overlay, .tip, .bar__btn{ transition: none; }
}

/* The shared tip-jar / fullscreen badges default to right-CENTRE, over the
   hold. Dock them under the sound button. Doubled classes out-specify the
   components' own injected styles. */
.opt-tipjar.opt-tipjar{ top: max(60px, calc(env(safe-area-inset-top) + 48px)); transform: none; }
.opt-fs.opt-fs{ top: max(112px, calc(env(safe-area-inset-top) + 100px)); transform: none; }
.opt-tipjar.opt-tipjar.tj-nudge{ animation: none; }
