:root {
  /* One canvas pixel, scaled to match the 480×270 ocean with object-fit: cover. */
  --chunk: max(calc(100vw / 480), calc(100vh / 270));

  /* Parallax ridge fills from ocean.js (distant → middle → foreground). */
  --floor-distant: #0a4434;
  --floor-middle: #07392a;
  --floor-foreground: #06241a;

  /* Greens from the swatch, reds as accents. Same trench, chunkier pixels. */
  --abyss: #03241c;
  --deep: #021810;
  --green-dark: #005844;
  --green: #008850;
  --mint: #19d8a0;
  --mint-soft: #8ce3b0;
  --foam: #d3f4e3;
  --paper: #f1ece4;
  --red: #e8244f;
  --red-deep: #6b0c2a;
  --coral: #fa5a3c;
  --salmon: #f7977f;

  --panel: rgba(2, 32, 25, 0.9);
  --panel-line: rgba(25, 216, 160, 0.65);

  --font-display: "VT323", "Courier New", monospace;
  --font-body: "Space Mono", "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

/* `display: grid`/`flex` on a class would otherwise beat the `hidden`
   attribute, and then the finale shows up before anyone has earned it. */
[hidden] { display: none !important; }

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--deep);
  color: var(--foam);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--mint); }
a:hover { color: var(--salmon); }

code {
  font-family: var(--font-body);
  color: var(--mint);
  background: rgba(25, 216, 160, 0.12);
  padding: 0.05em 0.35em;
  border: 1px solid rgba(25, 216, 160, 0.3);
}

/* ---- the pixel ocean ---- */

/* The canvas renders at 480x270 and the browser scales it up. `pixelated`
   keeps the chunky pixels chunky instead of smearing them into soup. */
#ocean {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  image-rendering: pixelated;
}

/* ---- status ---- */

.status {
  position: fixed;
  top: 0.9rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  margin: 0;
  padding: 0.45rem 1rem;
  max-width: min(40rem, 90vw);
  text-align: center;
  font-size: 0.85rem;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  color: var(--foam);
}

.status[data-kind="success"] { border-color: var(--mint); color: var(--mint-soft); }
.status[data-kind="error"] { border-color: var(--red); color: var(--salmon); }

.endless-badge {
  position: fixed;
  top: calc(var(--chunk) * 6);
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--chunk) * 0.5);
  padding: calc(var(--chunk) * 1.5) calc(var(--chunk) * 3);
  background: rgba(2, 32, 25, 0.72);
  border: calc(var(--chunk) * 0.5) solid rgba(25, 216, 160, 0.45);
  pointer-events: none;
  text-align: center;
}

.endless-badge__kicker {
  font-family: var(--font-body);
  font-size: calc(var(--chunk) * 3);
  letter-spacing: 0.14em;
  color: var(--salmon);
  text-transform: uppercase;
}

.endless-badge__title {
  font-family: var(--font-display);
  font-size: calc(var(--chunk) * 5);
  line-height: 1;
  letter-spacing: 0.06em;
  color: var(--mint-soft);
  text-shadow: 0 0 calc(var(--chunk) * 6) rgba(25, 216, 160, 0.35);
}

.endless-badge__hint {
  font-family: var(--font-body);
  font-size: calc(var(--chunk) * 2.5);
  color: rgba(211, 244, 227, 0.55);
}

.progress-bar {
  --progress: 0;
  position: fixed;
  left: 10%;
  right: 10%;
  bottom: calc(var(--chunk) * 10);
  z-index: 30;
}

.progress-bar__track {
  position: relative;
  height: calc(var(--chunk) * 4);
  background: var(--floor-foreground);
  border: calc(var(--chunk) * 1) solid var(--floor-middle);
  box-sizing: content-box;
  overflow: hidden;
}

.progress-bar__fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: calc(var(--progress) * 100%);
  background: var(--floor-distant);
  transition: width 0.4s ease;
}

/* ---- buttons ---- */

.btn {
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 1.4rem;
  letter-spacing: 0.1em;
  color: var(--deep);
  background: var(--mint);
  border: 2px solid var(--mint);
  padding: 0.5rem 1.6rem;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.btn:hover:not(:disabled) {
  background: var(--salmon);
  border-color: var(--salmon);
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: wait;
  opacity: 0.6;
}

.btn--ghost {
  background: transparent;
  color: var(--mint);
}

.btn--ghost:hover:not(:disabled) {
  background: rgba(25, 216, 160, 0.15);
  color: var(--mint-soft);
  border-color: var(--mint);
}

.btn--next,
.btn--skip {
  font-size: 1.2rem;
  padding: 0.35rem 1.2rem;
}

.console__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
}

.btn--skip {
  margin-right: auto;
}

/* ---- overlays (intro / finale) ---- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

/* Intro: centred, darker scrim so the briefing is readable. */
.overlay.intro {
  background:
    radial-gradient(ellipse at 50% 120%, rgba(0, 136, 80, 0.25), transparent 60%),
    rgba(2, 24, 16, 0.82);
}

/* Finale: panel high up, light tint only. Leave the chest and glowing scroll
   in the lower half of the screen unobstructed. */
.overlay.finale {
  place-items: start center;
  align-content: start;
  padding-top: 10vh;
  background: linear-gradient(
    180deg,
    rgba(2, 24, 16, 0.5) 0%,
    rgba(2, 24, 16, 0.12) 38%,
    transparent 58%
  );
  pointer-events: none;
}

.overlay.finale .finale__panel {
  pointer-events: auto;
}

.intro__panel,
.finale__panel {
  max-width: 34rem;
  text-align: center;
  background: var(--panel);
  border: 2px solid var(--panel-line);
  box-shadow: 0 0 40px rgba(25, 216, 160, 0.18), 8px 8px 0 var(--deep);
  padding: 2.25rem 2rem;
}

.intro__kicker,
.finale__kicker {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.18em;
  color: var(--coral);
}

.intro__title,
.finale__title {
  margin: 0.5rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 8vw, 4rem);
  line-height: 0.95;
  color: var(--mint);
  text-shadow: 3px 3px 0 var(--green-dark);
}

.intro__sub,
.finale__sub {
  margin: 1.25rem 0 1.5rem;
  font-size: 0.95rem;
  color: var(--foam);
}

.intro__meta {
  margin: 1.25rem 0 0;
  font-size: 0.8rem;
  color: var(--mint-soft);
  opacity: 0.8;
}

.finale__panel .btn { margin: 0.4rem 0.3rem 0; }

.finale__panel {
  max-width: 32rem;
  padding: 1.75rem 1.5rem;
}

.finale__title {
  font-size: clamp(2rem, 6vw, 3rem);
}

.finale__fine {
  margin: 1.5rem 0 0;
  font-size: 0.8rem;
  color: var(--mint-soft);
}

/* ---- section title cards ---- */

.section-card {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-content: center;
  text-align: center;
  cursor: pointer;
  background: radial-gradient(ellipse at center, rgba(2, 24, 16, 0.55), transparent 75%);
  animation: cardIn 0.5s ease-out;
}

.section-card--moment {
  cursor: default;
  pointer-events: none;
}

@keyframes cardIn {
  from { opacity: 0; transform: scale(1.04); }
  to { opacity: 1; transform: scale(1); }
}

.section-card__kicker {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 0.3em;
  color: var(--coral);
}

.section-card__title {
  margin: 0.4rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 9vw, 5rem);
  line-height: 1;
  color: var(--mint);
  text-shadow: 0 0 24px rgba(25, 216, 160, 0.5), 4px 4px 0 var(--green-dark);
}

.section-card__desc {
  margin: 1rem auto 0;
  max-width: 32rem;
  padding: 0 1rem;
  font-size: 0.95rem;
  color: var(--foam);
}

.section-card__prompt {
  margin: 1.4rem 0 0;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mint-soft);
  animation: promptPulse 1.3s ease-in-out infinite;
}

@keyframes promptPulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

/* ---- the dive console (dialogue box) ---- */

/* Sits a third of the way down the screen rather than along the bottom, so
   the diver trudging along the sea bed stays in view while you type. */
.console {
  position: fixed;
  left: 50%;
  top: 31vh;
  transform: translateX(-50%);
  z-index: 30;
  width: min(46rem, calc(100vw - 1.5rem));
}

.console__frame {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--panel);
  border: 2px solid var(--panel-line);
  box-shadow: 0 0 30px rgba(25, 216, 160, 0.15), 6px 6px 0 var(--deep);
  padding: 1.1rem 1.25rem;
  max-height: min(56vh, 28rem);
  overflow: auto;
}

.console__q {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  line-height: 1.2;
  color: var(--mint);
}

.console__help,
.console__narration {
  margin: 0;
  font-size: 0.9rem;
  color: var(--mint-soft);
}

.console__narration { font-size: 0.95rem; color: var(--foam); }

/* inputs */

.console__text,
.console__textarea,
.console__select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--foam);
  background: rgba(0, 88, 68, 0.35);
  border: 1px solid var(--panel-line);
  padding: 0.6rem 0.75rem;
}

.console__text:focus,
.console__textarea:focus,
.console__select:focus {
  outline: 2px solid var(--mint);
  outline-offset: 1px;
}

.console__textarea { resize: vertical; }

.console__select option { background: var(--deep); }

.console__choice-hint {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.06em;
  color: var(--mint-soft);
}

.console__choice-hint--radio { color: var(--salmon); }
.console__choice-hint--checkboxes { color: var(--mint); }

.console__choices {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.console__choices--radio .console__choice-card {
  border-left: 3px solid var(--salmon);
}

.console__choices--checkboxes .console__choice-card {
  border-left: 3px solid var(--mint);
}

.console__choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.console__choice-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  cursor: pointer;
  padding: 0.5rem 0.8rem;
  font-size: 0.92rem;
  background: rgba(0, 88, 68, 0.3);
  border: 1px solid rgba(25, 216, 160, 0.35);
  transition: background 0.12s, border-color 0.12s, transform 0.12s;
}

.console__choice-text {
  flex: 1;
  line-height: 1.35;
}

.console__choice-mark {
  flex-shrink: 0;
}

/* Radio: hollow circle, fills when selected */
.console__choices--radio .console__choice-mark {
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.12rem;
  border: 2px solid var(--salmon);
  border-radius: 50%;
  background: transparent;
  transition: background 0.12s, box-shadow 0.12s;
}

.console__choices--radio .console__choice input:checked + .console__choice-card .console__choice-mark {
  background: radial-gradient(circle at center, var(--salmon) 42%, transparent 44%);
  box-shadow: inset 0 0 0 2px var(--deep);
}

.console__choices--radio .console__choice input:checked + .console__choice-card {
  background: rgba(232, 36, 79, 0.12);
  border-color: var(--salmon);
  color: var(--paper);
}

/* Checkboxes: square box, checkmark when selected */
.console__choices--checkboxes .console__choice-mark {
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.12rem;
  border: 2px solid var(--mint);
  border-radius: 2px;
  background: transparent;
  position: relative;
}

.console__choices--checkboxes .console__choice input:checked + .console__choice-card .console__choice-mark {
  background: var(--mint);
  border-color: var(--mint);
}

.console__choices--checkboxes .console__choice input:checked + .console__choice-card .console__choice-mark::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--deep);
  line-height: 1;
}

.console__choices--checkboxes .console__choice input:checked + .console__choice-card {
  background: rgba(25, 216, 160, 0.14);
  border-color: var(--mint);
  color: var(--paper);
}

.console__choice-card:hover {
  border-color: var(--mint);
  transform: translateX(3px);
}

.console__choices--radio .console__choice-card:hover {
  border-color: var(--salmon);
}

.console__choice input:focus-visible + .console__choice-card {
  outline: 2px solid var(--mint);
}

/* ---- small screens ---- */

@media (max-width: 540px) {
  .console { top: 24vh; }
  .console__frame { padding: 0.85rem 0.9rem; max-height: 60vh; }
  .console__q { font-size: 1.3rem; }
  .intro__panel, .finale__panel { padding: 1.5rem 1.1rem; }
}
