/* Maw — a living well, seen from its rim. 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: #eafcff;
  --dim: rgba(234, 252, 255, 0.6);
  --faint: rgba(234, 252, 255, 0.32);
  --glow: #5cffdb;          /* retinted per depth from script.js */
  --bg1: #062028;
  --bg2: #010406;
  --hot: #ff5c6b;
  --pearl: #f4fbff;
  --line: rgba(160, 255, 236, 0.16);
  --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;
  /* just the game on the screen (owner): no pinch or double-tap zoom, no
     pull-to-refresh, no text selection or its magnifier, no long-press menus */
  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: radial-gradient(120% 90% at 50% 42%, var(--bg1) 0%, var(--bg2) 72%);
  background-color: var(--bg2);
  transition: background 900ms ease;
}
canvas{
  position: fixed; inset: 0; display: block; width: 100%; height: 100%;
  touch-action: none;
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}
#gl{ z-index: 0; pointer-events: none; }
#fx{ z-index: 1; cursor: crosshair; }
.vignette{
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(130% 100% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

/* ---------- 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: 24px; align-items: flex-end;
  font-family: var(--font-mono);
  padding: 7px 18px;
  border: 1px solid var(--line); border-radius: 12px;
  background: rgba(2, 10, 14, 0.58);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.hud[hidden]{ display: none; }
.hud__cell{ position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.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; }
#score{ color: var(--glow); transition: color 600ms ease; }
#mult{ color: var(--pearl); }
#mult.is-up{ animation: bump 380ms ease-out; }
#mult.is-down{ animation: knock 420ms ease-out; }
@keyframes bump{ 0%{ transform: scale(1.55); color: #fff; text-shadow: 0 0 14px var(--glow); } 100%{ transform: scale(1); } }
@keyframes knock{ 0%{ transform: translateY(3px); color: var(--hot); } 100%{ transform: none; } }
.pips{ display: flex; gap: 2px; margin-top: 2px; }
.pips b{ width: 5px; height: 2px; border-radius: 1px; background: rgba(234, 252, 255, 0.16); transition: background 160ms ease; }
.pips b.on{ background: var(--glow); box-shadow: 0 0 5px var(--glow); }
.lives{ display: flex; gap: 3px; align-items: center; height: 22px; }
.lives i{
  width: 11px; height: 8px; display: block;
  border-radius: 8px 8px 3px 3px;
  background: radial-gradient(circle at 50% 70%, #fff 0 22%, #bff8ff 40%, rgba(191, 248, 255, 0.35) 100%);
  box-shadow: 0 0 6px rgba(191, 248, 255, 0.55);
}
.lives i.lost{ background: rgba(234, 252, 255, 0.12); box-shadow: none; }
#lives.is-struck{ animation: knock 520ms ease-out; }
#best.is-target{ color: var(--hot); }

/* ---------- Flare ---------- */
.flare{
  position: fixed; z-index: 7;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(66px, calc(env(safe-area-inset-bottom) + 56px));
  width: 72px; height: 72px; border-radius: 50%;
  border: 1px solid rgba(160, 255, 236, 0.35);
  background: radial-gradient(circle at 50% 45%, rgba(92, 255, 219, 0.28), rgba(4, 18, 22, 0.7) 70%);
  color: var(--ink);
  font-family: var(--font-mono); font-size: 0.58rem; letter-spacing: 0.16em; text-transform: uppercase;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  touch-action: none; cursor: pointer;
  transition: transform 100ms ease, opacity 200ms ease, border-color 200ms ease;
}
.flare[hidden]{ display: none; }
.flare__ring{
  position: absolute; inset: 5px; border-radius: 50%;
  border: 1.5px solid var(--glow); opacity: 0.8;
  box-shadow: 0 0 14px var(--glow), inset 0 0 10px var(--glow);
  animation: breathe 2.2s ease-in-out infinite;
}
.flare__label{ position: relative; }
.flare:active{ transform: scale(0.94); }
.flare.is-weak .flare__ring{ opacity: 0.35; animation: none; border-style: dashed; box-shadow: none; }
.flare.is-weak{ background: rgba(4, 18, 22, 0.66); }
.flare.is-spent{ opacity: 0.32; pointer-events: none; }
.flare.is-spent .flare__ring{ display: none; }
.flare:focus-visible{ outline: none; box-shadow: 0 0 0 3px rgba(160, 255, 236, 0.5); }
@keyframes breathe{ 0%, 100%{ transform: scale(1); opacity: 0.8; } 50%{ transform: scale(0.93); opacity: 0.5; } }

/* ---------- Callout ---------- */
.callout{
  position: fixed; z-index: 6; pointer-events: none;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center; white-space: nowrap;
}
.callout[hidden]{ display: none; }
.callout__big{
  font-family: var(--font-display); font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase;
  font-size: clamp(1.25rem, 5vw, 2.1rem); line-height: 1;
  color: #fff;
  text-shadow: 0 0 18px var(--glow), 0 0 42px var(--glow), 0 4px 24px rgba(0, 0, 0, 0.8);
}
.callout__sub{
  font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink); opacity: 0.85;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9);
}
.callout__sub:empty{ display: none; }
.callout.is-bad .callout__big{ text-shadow: 0 0 14px var(--hot), 0 0 40px rgba(255, 60, 80, 0.9), 0 4px 24px rgba(0, 0, 0, 0.9); }
.callout.is-pop{ animation: pop 320ms cubic-bezier(.2, 1.4, .4, 1); }
.callout.is-out{ opacity: 0; transition: opacity 400ms ease; }
@keyframes pop{ from{ transform: translate(-50%, -50%) scale(0.6); opacity: 0; } to{ transform: translate(-50%, -50%) scale(1); opacity: 1; } }

/* ---------- 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(2, 10, 14, 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(160, 255, 236, 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(1, 8, 10, 0.5), rgba(0, 2, 4, 0.9));
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  transition: opacity 260ms ease;
  overflow-y: auto;
}
/* the panel is the one thing that may need to scroll, on a short screen */
.overlay{ touch-action: pan-y; }
.overlay[hidden]{ display: none; }
.overlay.is-out{ opacity: 0; pointer-events: none; }
.panel{
  max-width: 520px; text-align: center; margin: auto;
  padding: clamp(22px, 5vw, 34px);
  border: 1px solid var(--line); border-radius: 18px;
  background: rgba(2, 10, 14, 0.82);
  box-shadow: 0 30px 90px -20px rgba(0, 0, 0, 0.85), 0 0 60px -30px var(--glow);
}
.panel__eyebrow{ margin: 0 0 6px; font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--glow); }
.panel__title{
  margin: 0 0 12px; font-size: clamp(2.2rem, 9vw, 3.4rem); font-weight: 900; letter-spacing: 0.02em; line-height: 1;
  text-shadow: 0 0 30px color-mix(in srgb, var(--glow) 55%, transparent);
}
.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 .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; letter-spacing: 0.01em; }
.panel__text .stat{ color: var(--ink); }
.panel__text .win{ color: var(--glow); font-weight: 700; }
.panel__text .short{ color: var(--hot); }
.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, #bff8ff);
  color: #03212a; box-shadow: 0 10px 30px -8px color-mix(in srgb, var(--glow) 70%, transparent);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.play-btn:hover{ transform: translateY(-2px); box-shadow: 0 16px 38px -10px color-mix(in srgb, var(--glow) 85%, transparent); }
.play-btn:focus-visible{ outline: none; box-shadow: 0 0 0 3px rgba(191, 248, 255, 0.55); }
.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 color-mix(in srgb, var(--glow) 45%, transparent);
  background: color-mix(in srgb, var(--glow) 10%, transparent);
  color: var(--ink);
  transition: background 160ms ease, border-color 160ms ease;
}
.ghost-btn[hidden]{ display: none; }
.ghost-btn:hover{ background: color-mix(in srgb, var(--glow) 20%, transparent); border-color: var(--glow); }
.ghost-btn:focus-visible{ outline: none; box-shadow: 0 0 0 3px rgba(191, 248, 255, 0.45); }
.panel__keys{ margin: 16px 0 0; font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.06em; color: var(--faint); }

/* ---------- Frame corners + hint ---------- */
.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); }

.hint{
  position: fixed; z-index: 4; pointer-events: none;
  bottom: max(14px, calc(env(safe-area-inset-bottom) + 6px)); left: 50%; transform: translateX(-50%);
  margin: 0; font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.1em;
  color: var(--faint); white-space: nowrap;
  transition: opacity 600ms ease;
}
.hint.is-gone{ opacity: 0; }

@media (max-width: 620px){
  .frame__corner--tr{ display: none; }
  .hint{ display: none; }
  .hud{ gap: 12px; padding: 6px 11px; }
  .hud__k{ font-size: 7px; letter-spacing: 0.12em; }
  .hud__cell > span:not(.hud__k){ font-size: 15px; }
  .lives i{ width: 9px; height: 7px; }
}
@media (max-width: 380px){
  .hud{ gap: 9px; padding: 6px 9px; }
  .hud__cell > span:not(.hud__k){ font-size: 14px; }
}
@media (max-height: 520px){
  /* a landscape phone has no height to spare above the well, so the HUD
     stands up in a column on the left, where the round well never reaches */
  .hud{
    top: 50%; left: max(12px, env(safe-area-inset-left)); transform: translateY(-50%);
    flex-direction: column; align-items: flex-start; gap: 7px; padding: 9px 12px;
  }
  .hud__cell{ align-items: flex-start; }
  .frame__corner--tl{ display: none; }
  .hint{ display: none; }
  .flare{ width: 60px; height: 60px; bottom: max(14px, calc(env(safe-area-inset-bottom) + 8px)); }
}
/* The well moving IS the game, so reduced motion keeps it — what goes is the
   punishment layer: shake, full-screen flashes, the pulsing chrome. */
@media (prefers-reduced-motion: reduce){
  .play-btn, .sound-btn, .overlay, .flare, body{ transition: none; }
  .flare__ring{ animation: none; }
  .callout.is-pop{ animation: none; }
  #mult.is-up, #mult.is-down, #lives.is-struck{ animation: none; }
}

/* The well fills the width of a phone, so the shared tip-jar / fullscreen
   badges at right-CENTRE would sit on top of a lane. Dock them in a column
   under the sound button instead, where no well shape reaches. 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; }
