:root {
  --navy: #071422;
  --navy-2: #10233d;
  --blue: #3d7dff;
  --lime: #c6f135;
  --yellow: #ffd23a;
  --white: #f4f7fb;
  --ink: #d5e2f2;
  --muted: #93a6c0;
  --line: rgba(255, 255, 255, 0.14);
  --accent: var(--lime);
  --accent-ink: #102008;
  --pad-blue: #3d7dff;
  --pad-lime: #c6f135;
  --pad-yellow: #ffd23a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Avenir Next Condensed", "Arial Narrow", "Segoe UI", sans-serif;
  color: var(--white);
  background: var(--navy) center / cover fixed no-repeat;
  letter-spacing: 0.01em;
}
body[data-colour="lime"] { --accent: var(--lime); --accent-ink: #102008; }
body[data-colour="blue"] { --accent: var(--blue); --accent-ink: #f7fbff; }
body[data-colour="yellow"] { --accent: var(--yellow); --accent-ink: #1a1402; }
body[data-bg="night"] {
  background-image: linear-gradient(180deg, rgba(5, 12, 24, 0.84), rgba(5, 12, 24, 0.58) 40%, rgba(5, 12, 24, 0.86)), url("bg-night.jpg");
}
body[data-bg="flood"] {
  background-image: linear-gradient(180deg, rgba(5, 14, 28, 0.8), rgba(6, 16, 32, 0.55) 42%, rgba(5, 12, 24, 0.86)), url("bg-flood.jpg");
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, p { margin: 0; }
h2 { font-size: clamp(22px, 3vw, 32px); letter-spacing: 0.04em; text-transform: uppercase; }
img { max-width: 100%; display: block; }

.kicker {
  color: var(--accent);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
}
.lead { color: var(--ink); max-width: 42ch; font-size: 15px; line-height: 1.35; }
.status {
  min-height: 1.4em;
  color: var(--yellow);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 13px;
  font-weight: 700;
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(5, 12, 24, 0.72), rgba(5, 12, 24, 0.55)),
    url("bg-night.jpg") center / cover no-repeat;
}
.splash-card { text-align: center; width: min(440px, calc(100% - 32px)); }
.splash-card img { width: 148px; height: 148px; margin: 0 auto 8px; object-fit: contain; }
.splash-card h1 { font-size: clamp(34px, 8vw, 58px); line-height: 0.9; text-transform: uppercase; }
.splash-line { margin-top: 12px; letter-spacing: 0.22em; color: var(--lime); font-weight: 700; }
.loadbar { margin: 18px auto 0; height: 4px; background: rgba(255, 255, 255, 0.15); }
.loadbar span { display: block; height: 100%; width: 0; background: var(--lime); animation: load 1.5s linear forwards; }
@keyframes load { to { width: 100%; } }

.onboard {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 10, 20, 0.72);
}
.panel {
  width: min(560px, 100%);
  background: rgba(8, 18, 36, 0.94);
  border: 1px solid rgba(198, 241, 53, 0.45);
  padding: 16px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
}
.panel h2 { margin: 4px 0 8px; }
.panel p { line-height: 1.4; color: var(--ink); }
.dots { display: flex; gap: 6px; margin-bottom: 12px; }
.dots i { width: 28px; height: 4px; background: rgba(255, 255, 255, 0.2); display: block; }
.dots i.on { background: var(--accent); }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.choice, .btn-accent, .btn-ghost, .chip, .pip, .utils button, .sector, .pitch, .pad, .wpad {
  border: 1px solid var(--line);
  border-radius: 2px;
}
.choice { min-height: 74px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.choice[data-pick="blue"] { background: var(--blue); color: #fff; }
.choice[data-pick="lime"] { background: var(--lime); color: #102008; }
.choice[data-pick="yellow"] { background: var(--yellow); color: #1a1402; }
.choice.on { box-shadow: 0 0 0 3px var(--white); }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.btn-accent, .btn-ghost {
  min-height: 40px;
  padding: 8px 14px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
}
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-accent:disabled { opacity: 0.4; cursor: default; }
.btn-ghost { background: transparent; color: var(--white); }
.markline { margin-top: 12px; color: var(--lime) !important; font-weight: 700; }

.flip {
  width: min(340px, 100%);
  min-height: 180px;
  margin: 14px auto;
  padding: 0;
  border: 0;
  background: none;
  display: block;
}
.flip-inner { display: block; }
.face {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  min-height: 180px;
  padding: 12px;
  background: #0d2244;
  border: 1px solid rgba(198, 241, 53, 0.5);
  text-align: center;
}
.face img { width: 120px; height: 96px; object-fit: contain; margin: 0 auto; }
.face.back { display: none; background: #102818; }
.flip.on .face.front { display: none; }
.flip.on .face.back { display: grid; }
.face small { color: var(--ink); max-width: 32ch; }

.shell { min-height: 100vh; display: flex; flex-direction: column; }
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "brand stats utils" "ticker ticker ticker";
  gap: 6px 10px;
  align-items: center;
  padding: 6px 10px 8px;
  background: rgba(7, 20, 38, 0.94);
  border-bottom: 3px solid var(--accent);
  backdrop-filter: blur(8px);
}
.brand { grid-area: brand; display: flex; gap: 8px; align-items: center; background: none; border: 0; padding: 0; text-align: left; }
.brand img { width: 46px; height: 46px; object-fit: contain; }
.brand strong { display: block; font-size: 20px; letter-spacing: 0.03em; text-transform: uppercase; }
.brand em { font-style: normal; color: var(--accent); letter-spacing: 0.2em; font-size: 11px; text-transform: uppercase; }
.stats { grid-area: stats; display: flex; gap: 6px; justify-content: center; }
.stats div { min-width: 64px; text-align: center; background: var(--navy-2); border: 1px solid var(--line); padding: 4px 6px; }
.stats b { display: block; color: var(--accent); font-size: 18px; font-variant-numeric: tabular-nums; }
.stats small { color: var(--muted); font-size: 9px; letter-spacing: 0.14em; }
.utils { grid-area: utils; display: flex; gap: 4px; justify-content: flex-end; }
.utils button { background: #0c1e38; padding: 8px 10px; text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; font-weight: 800; }
.utils button b { color: var(--accent); font-variant-numeric: tabular-nums; }
.utils button.on { background: var(--accent); color: var(--accent-ink); }
.utils button.on b { color: inherit; }
.ticker { grid-area: ticker; overflow: hidden; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #06101c; }
.ticker-track { display: flex; width: max-content; animation: tick 16s linear infinite; }
.ticker-track span { color: var(--lime); font-weight: 800; letter-spacing: 0.22em; font-size: 12px; padding: 5px 0; white-space: nowrap; }
@keyframes tick { to { transform: translateX(-50%); } }

.layout { display: flex; align-items: stretch; flex: 1; }
main { flex: 1; width: min(1100px, 100%); margin: 0 auto; padding: 12px; }
.view { display: grid; gap: 12px; align-content: start; }
.subhead { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; justify-content: space-between; }
.subhead h2:focus { outline: none; }

.bowl {
  width: min(980px, 100%);
  height: auto;
  margin: 0 auto;
  border-radius: 50%;
  display: grid;
  grid-template-columns: 1fr 1.05fr 1fr;
  grid-template-rows: auto auto auto;
  grid-template-areas: ". chant ." "crowd pitch quiz" ". day .";
  padding: 22px 7%;
  gap: 8px 10px;
  background:
    radial-gradient(ellipse at center, rgba(86, 170, 72, 0.72) 0 20%, rgba(18, 70, 36, 0.18) 21% 34%, rgba(6, 16, 32, 0.28) 35%),
    linear-gradient(180deg, rgba(6, 16, 32, 0.15), rgba(6, 16, 32, 0.45)),
    url("bg-flood.jpg") center 42% / cover;
  border: 2px solid rgba(198, 241, 53, 0.7);
  box-shadow: 0 0 0 8px rgba(8, 20, 40, 0.78), inset 0 0 50px rgba(0, 0, 0, 0.35);
}
.sector-n { grid-area: chant; }
.sector-e { grid-area: quiz; }
.sector-s { grid-area: day; }
.sector-w { grid-area: crowd; }
.pitch { grid-area: pitch; }
.sector, .pitch {
  width: min(100%, 168px);
  justify-self: center;
  align-self: center;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 1px;
  min-height: 62px;
  padding: 6px 8px;
  background: rgba(7, 18, 36, 0.9);
  text-align: center;
}
.sector small, .pitch em, .sector em { font-style: normal; color: var(--muted); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.sector strong, .pitch strong { font-size: clamp(16px, 2.4vw, 26px); letter-spacing: 0.08em; text-transform: uppercase; }
.sector-n { border-top: 4px solid var(--blue); }
.sector-e { border-top: 4px solid var(--yellow); }
.sector-s { border-top: 4px solid var(--white); }
.sector-w { border-top: 4px solid var(--lime); }
.pitch {
  width: min(124px, 88%);
  min-height: 124px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--accent);
}
.pitch img { width: 36px; height: 36px; object-fit: contain; }
.sector:hover, .pitch:hover { border-color: var(--accent); }

.hud { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.hud div { background: rgba(8, 18, 36, 0.9); border: 1px solid var(--line); padding: 6px 8px; }
.hud small { display: block; color: var(--muted); letter-spacing: 0.12em; font-size: 10px; }
.hud b { font-size: 22px; color: var(--accent); font-variant-numeric: tabular-nums; }
.speedbar { height: 6px; background: rgba(255, 255, 255, 0.12); }
.speedbar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--lime), var(--yellow)); }

.pads { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pad, .wpad {
  min-height: 84px;
  background: #0c1c34;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: background 0.05s linear, color 0.05s linear, box-shadow 0.05s linear;
}
.pad:disabled, .wpad:disabled { cursor: default; opacity: 1; }
.pad[data-colour="blue"], .wpad[data-colour="blue"] { box-shadow: inset 0 4px 0 var(--pad-blue); }
.pad[data-colour="lime"], .wpad[data-colour="lime"] { box-shadow: inset 0 4px 0 var(--pad-lime); }
.pad[data-colour="yellow"], .wpad[data-colour="yellow"] { box-shadow: inset 0 4px 0 var(--pad-yellow); }
.pad.lit[data-colour="blue"], .wpad.lit[data-colour="blue"] { background: var(--pad-blue); color: #fff; box-shadow: 0 0 22px var(--pad-blue); }
.pad.lit[data-colour="lime"], .wpad.lit[data-colour="lime"] { background: var(--pad-lime); color: #102008; box-shadow: 0 0 22px var(--pad-lime); }
.pad.lit[data-colour="yellow"], .wpad.lit[data-colour="yellow"] { background: var(--pad-yellow); color: #1a1402; box-shadow: 0 0 22px var(--pad-yellow); }
.pad.bad, .wpad.bad { background: #e23b3b; color: white; box-shadow: 0 0 18px #e23b3b; }

.pips, .lamps, .rail { display: flex; flex-wrap: wrap; gap: 6px; }
.pip, .lamp, .daycell {
  min-width: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
  background: #0c1c34;
  border: 1px solid var(--line);
  font-weight: 800;
}
.pip.on, .lamp.on, .daycell.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.pip:disabled { opacity: 0.35; }
.daycell { min-width: 64px; padding: 4px; font-size: 11px; letter-spacing: 0.06em; }
.daycell small { display: block; color: inherit; }

.cards, .boards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.card, .board {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 8px;
  background: rgba(8, 18, 36, 0.92);
  border: 1px solid var(--line);
  padding: 8px;
}
.card.pinned { border-color: var(--accent); }
.card img, .board > img { width: 74px; height: 74px; object-fit: cover; background: #0c2244; }
.card header, .board header { display: flex; gap: 6px; align-items: center; justify-content: space-between; }
.card b, .board b { letter-spacing: 0.04em; text-transform: uppercase; }
.card p, .board p { color: var(--ink); font-size: 14px; line-height: 1.35; margin-top: 4px; }
.tag {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 800;
  padding: 2px 5px;
  color: #102008;
}
.tag.blue { background: var(--blue); color: white; }
.tag.lime { background: var(--lime); }
.tag.yellow { background: var(--yellow); }
.mini {
  background: transparent;
  border: 1px solid var(--line);
  padding: 4px 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 800;
}
.mini[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.quiz-top { display: flex; justify-content: space-between; gap: 8px; align-items: end; }
.quiz-play { display: grid; grid-template-columns: 1.3fr 0.7fr; gap: 12px; }
.slots, .chips { display: grid; gap: 6px; align-content: start; margin: 0; padding: 0; list-style: none; }
.slot {
  display: grid;
  grid-template-columns: 52px 1fr;
  min-height: 42px;
  background: #0e1c33;
  border: 1px solid var(--line);
}
.slot em { display: grid; place-items: center; font-style: normal; background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.slot span { display: grid; align-items: center; padding: 0 10px; letter-spacing: 0.04em; }
.slot.ghost span { color: var(--muted); }
.chip {
  text-align: left;
  background: #123056;
  padding: 10px 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.chip.shake { animation: shake 0.28s linear; }
@keyframes shake {
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-3px); }
}
.strikes { display: flex; gap: 6px; align-items: center; color: var(--muted); letter-spacing: 0.12em; font-size: 12px; }
.strikes i { width: 18px; height: 18px; border: 1px solid var(--yellow); display: block; }
.strikes i.on { background: #e23b3b; border-color: #e23b3b; }

.wave-bowl {
  position: relative;
  width: min(540px, 100%);
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(198, 241, 53, 0.55);
  background:
    radial-gradient(circle at center, rgba(86, 170, 72, 0.78) 0 16%, rgba(8, 22, 40, 0.15) 17% 48%, rgba(5, 12, 24, 0.62) 49%),
    url("bg-night.jpg") center / cover;
  box-shadow: inset 0 0 36px rgba(0, 0, 0, 0.35), 0 0 0 8px rgba(8, 20, 40, 0.65);
}
.core {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}
.core small { display: block; letter-spacing: 0.16em; color: var(--white); font-size: 10px; }
.core b { font-size: 40px; color: var(--white); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4); }
.wpad { position: absolute; width: 26%; min-height: 58px; display: grid; place-items: center; align-content: center; }
.wpad small { display: block; letter-spacing: 0.08em; font-size: 10px; }
.wpad.n { left: 37%; top: 3%; }
.wpad.ne { right: 5%; top: 26%; }
.wpad.se { right: 5%; bottom: 26%; }
.wpad.s { left: 37%; bottom: 3%; }
.wpad.sw { left: 5%; bottom: 26%; }
.wpad.nw { left: 5%; top: 26%; }

.drawer {
  width: min(380px, 100%);
  background: rgba(6, 14, 28, 0.96);
  border-left: 1px solid rgba(198, 241, 53, 0.4);
  padding: 12px;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.drawer-head h2 { font-size: 22px; }
.drawer p { color: var(--ink); line-height: 1.4; }
.logrow, .pinrow, .heatrow, .slotrow {
  display: grid;
  gap: 2px 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.logrow { grid-template-columns: 72px 1fr auto; align-items: center; }
.logrow b, .pinrow b { text-transform: uppercase; letter-spacing: 0.04em; }
.logrow span, .meta { color: var(--muted); font-size: 12px; }
.heatrow { grid-template-columns: 72px 1fr 32px; align-items: center; }
.bar { height: 8px; background: rgba(255, 255, 255, 0.1); }
.bar span { display: block; height: 100%; }
.bar.blue span { background: var(--blue); }
.bar.lime span { background: var(--lime); }
.bar.yellow span { background: var(--yellow); }
.heatbowl {
  width: 220px;
  aspect-ratio: 1;
  margin: 8px auto;
  border-radius: 50%;
  position: relative;
  border: 1px solid var(--line);
  background: rgba(12, 28, 52, 0.8);
}
.heatbowl i {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 2px;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.themes { display: grid; gap: 10px; }
.bgrow, .choices.compact { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bgpick { padding: 0; text-align: left; background: #0c1c34; border: 1px solid var(--line); }
.bgpick img { height: 72px; width: 100%; object-fit: cover; }
.bgpick span, .slotrow { padding: 6px; }
.bgpick.on, .slotrow.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.slotrow { grid-template-columns: 1fr auto auto; align-items: center; }
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.swatches button { min-height: 42px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; border: 1px solid transparent; }
.swatches button[data-pick="blue"] { background: var(--blue); }
.swatches button[data-pick="lime"] { background: var(--lime); color: #102008; }
.swatches button[data-pick="yellow"] { background: var(--yellow); color: #1a1402; }
.swatches button.on { box-shadow: 0 0 0 2px var(--white); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  z-index: 20;
}

@media (max-height: 520px) {
  .top { gap: 4px 8px; padding: 4px 8px 6px; }
  .stats b { font-size: 15px; }
  .stats div { min-width: 48px; padding: 2px 4px; }
  .ticker-track span, .utils button { padding-top: 3px; padding-bottom: 3px; }
  .subhead { gap: 4px; }
  .subhead .kicker, .subhead .lead { display: none; }
  .subhead h2 { font-size: 18px; }
  main { padding: 8px; }
  .bowl { padding: 10px 6%; gap: 4px; }
  .wave-bowl { width: min(250px, calc(100vh - 150px)); }
  .wpad { min-height: 0; height: 20%; width: 28%; font-size: 11px; }
  .core b { font-size: 20px; }
  .sector { min-height: 52px; }
  .pitch { width: 96px; min-height: 96px; }
  .pitch img { width: 28px; height: 28px; }
}

@media (max-width: 800px) {
  .top {
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand stats" "ticker ticker" "utils utils";
  }
  .stats { justify-content: flex-end; }
  .utils { justify-content: stretch; }
  .utils button { flex: 1; }
  .layout { flex-direction: column; }
  .drawer { width: 100%; border-left: 0; border-top: 1px solid rgba(198, 241, 53, 0.4); }
  .hud { grid-template-columns: repeat(3, 1fr); }
  .quiz-play { grid-template-columns: 1fr; }
  .bowl { box-shadow: 0 0 0 5px rgba(8, 20, 40, 0.78), inset 0 0 30px rgba(0, 0, 0, 0.35); }
}

@media (max-width: 520px) {
  .stats div { min-width: 52px; padding: 3px; }
  .stats b { font-size: 15px; }
  .choices { grid-template-columns: 1fr; }
  .pad { min-height: 68px; letter-spacing: 0.06em; }
  .card, .board { grid-template-columns: 56px 1fr; }
  .card img, .board > img { width: 56px; height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track, .loadbar span, .chip.shake { animation: none; }
  .loadbar span { width: 100%; }
}
