/* Icillion, pixel edition.
 * The iceberg scene fills the screen; the interface sits on top of it as chunky pixel panels
 * with notched corners, like an old console game. One tall pixel face for headings and numbers
 * (Jersey 10), one readable pixel face for everything else (Pixelify Sans).
 */

:root {
  --px: 3px;
  --ink: #E9F7FD;
  --muted: #8FB2C4;
  --panel: #0B1B2E;
  --panel-2: #12263D;
  --panel-3: #1B3654;
  --edge: #4DE1FF;
  --edge-dim: #1E6E8A;
  --edge-dark: #02070F;
  --glow: rgb(77 225 255 / 0.28);
  --ice: #D3F0FA;
  --gold: #F6C453;
  --gold-dark: #A86A1E;
  --coral: #FF7A6B;
  --pink: #FF4F86;
  --pink-dark: #A3234F;
  --focus: #F6C453;

  --tier-none: #3B4350;
  --tier-0: #EEF9FD;
  --tier-1: #3189C2;
  --tier-2: #1B5891;
  --tier-3: #4FD1C0;
  --tier-4: #F6C453;

  --display: 'Jersey 10', 'Pixelify Sans', monospace;
  --body: 'VT323', 'Pixelify Sans', ui-monospace, monospace;
  --label: 'Silkscreen', 'VT323', ui-monospace, monospace;

  --hud-h: 64px;
  --panel-w: 440px;
  --rail: 0px; /* width of each ad column; 0 on narrow screens */

  color-scheme: dark;
}

@media (max-width: 899px) {
  :root { --px: 2px; --hud-h: 52px; }
}

@media (min-width: 1200px) { :root { --rail: 176px; } }
@media (min-width: 1680px) { :root { --rail: 316px; } }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: #02070F;
  color: var(--ink);
  font: 400 1.3rem/1.25 var(--body);
  letter-spacing: 0.01em;
  -webkit-font-smoothing: none;
}

p, h1, h2, h3, ul, ol, dl, dd { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: var(--px) solid var(--focus); outline-offset: calc(var(--px) * 2); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.muted { color: var(--muted); }

/* Scanlines over everything, like an old monitor. */
body.crt::after {
  content: '';
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgb(0 0 0 / 0.045) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 65%, rgb(0 0 0 / 0.18));
}

/* ---------- The pixel box ----------
 * A notched-corner border drawn with four hard shadows, one pixel (--px) thick. */

.px {
  margin: var(--px);
  background: rgb(6 16 32 / 0.9);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--edge-dim),
    0 var(--px) 0 0 var(--edge-dim),
    calc(var(--px) * -1) 0 0 0 var(--edge-dim),
    var(--px) 0 0 0 var(--edge-dim),
    0 0 22px 0 var(--glow),
    inset 0 0 18px 0 rgb(77 225 255 / 0.08),
    inset 0 var(--px) 0 0 rgb(255 255 255 / 0.06);
}

/* ---------- Scene ---------- */

.scene {
  position: relative;
  height: 50svh;
  height: 50vh;
  min-height: 320px;
  overflow: hidden;
  background: #071833;
}

body[data-screen="play"] .scene { height: 42vh; height: 42svh; min-height: 280px; }
body[data-screen="results"] .scene { height: 78vh; height: 78svh; min-height: 480px; }

@media (min-width: 900px) {
  .frame { position: fixed; inset: 0; overflow: hidden; }
  .scene,
  body[data-screen="play"] .scene,
  body[data-screen="results"] .scene { position: absolute; inset: 0; height: auto; min-height: 0; }
}

/* Playing: the scene takes over the whole game area. */
body[data-screen="play"] .panel,
body[data-screen="play"] .scene__title { display: none; }

@media (max-width: 899px) {
  body[data-screen="play"] .scene { position: fixed; inset: 0; z-index: 15; height: 100vh; height: 100dvh; min-height: 0; }
  body[data-screen="play"] .hud { position: fixed; }
}

.scene__canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.scene__title {
  position: absolute;
  z-index: 2;
  top: calc(var(--hud-h) + 6px);
  left: 14px;
  right: 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
  pointer-events: none;
}

@media (min-width: 900px) {
  .scene__title { top: calc(var(--hud-h) + 14px); left: calc(var(--rail) + 24px); right: calc(var(--rail) + var(--panel-w) + 60px); display: grid; gap: 0; }
}

.scene__kicker {
  flex: none;
  font: 400 0.55rem/1.2 var(--label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #1B5891;
  text-shadow: 1px 1px 0 #FFFFFF;
}

.scene__heading {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font: 400 clamp(1.6rem, 6vw, 3rem)/1 var(--display);
  color: #0A2349;
  text-shadow: 2px 2px 0 #FFFFFF;
}

@media (min-width: 900px) {
  .scene__heading { font-size: clamp(2rem, 3.2vw, 3.4rem); }
}

.scene__title.is-changing .scene__heading { animation: blink-in 0.5s steps(4) both; }

/* ---------- HUD ---------- */

.hud {
  position: absolute;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--hud-h);
  padding: 8px 10px;
  pointer-events: none;
}

@media (min-width: 900px) {
  .hud { position: absolute; padding: 12px calc(var(--rail) + 22px); gap: 14px; }
}

.hud > * { pointer-events: auto; }

.hud__brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  color: var(--ink);
  text-decoration: none;
  font: 700 0.78rem/1 var(--label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hud__mark { width: 20px; height: 20px; color: var(--edge); filter: drop-shadow(0 0 6px var(--edge)); }

.hud__run {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 36px;
  padding: 0 12px;
  margin-left: auto;
}

.pips { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }

.pips li {
  width: 12px;
  height: 12px;
  background: var(--panel-3);
  box-shadow: inset 0 0 0 2px #071833;
}

.pips li[data-tier] { background: var(--pip); }
.pips li.is-current { background: var(--pink); box-shadow: 0 0 8px var(--pink); animation: pip 0.8s steps(2) infinite; }

.hud__score { display: flex; align-items: baseline; gap: 8px; font: 400 1.9rem/1 var(--body); color: var(--pink); text-shadow: 0 0 10px rgb(255 79 134 / 0.6); }
.hud__label { font: 400 0.55rem/1 var(--label); letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; text-shadow: none; }

.hud__tools { display: flex; gap: 8px; margin-left: auto; }
.hud__run:not([hidden]) + .hud__tools { margin-left: 0; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 36px;
  padding: 0;
  border: 0;
  color: var(--ink);
  cursor: pointer;
}

.icon-btn svg { width: 18px; height: 18px; shape-rendering: crispEdges; }
.icon-btn:hover { background: var(--panel-3); }
.icon-btn:active { transform: translateY(var(--px)); }

@media (max-width: 899px) {
  .hud__brand { height: 30px; font-size: 1.4rem; padding: 0 8px; }
  .hud__mark { width: 16px; height: 16px; }
  .hud__run { height: 30px; padding: 0 8px; gap: 8px; }
  .pips li { width: 9px; height: 9px; }
  .hud__score { font-size: 1.3rem; }
  .hud__label { display: none; }
  .icon-btn { width: 32px; height: 30px; }
}

body[data-screen="play"] .hud__brand span { display: none; }

/* ---------- Panel ---------- */

.panel {
  position: relative;
  z-index: 10;
  padding: 18px 16px 28px;
  margin: calc(var(--px) * 3) calc(var(--px) * 2);
}

@media (min-width: 900px) {
  .panel {
    position: absolute;
    top: calc(var(--hud-h) + 14px);
    right: calc(var(--rail) + 26px);
    width: var(--panel-w);
    max-height: calc(100vh - var(--hud-h) - 40px);
    max-height: calc(100dvh - var(--hud-h) - 40px);
    overflow-y: auto;
    padding: 26px 26px 30px;
    margin: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--edge) var(--panel);
  }
}

.screen { animation: blink-in 0.35s steps(3) both; }

.kicker {
  font: 400 0.62rem/1.4 var(--label);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pink);
}

/* Title with a pink/cyan split, like a misaligned CRT. */
.wordmark {
  margin: 8px 0 6px;
  font: 400 clamp(4.4rem, 19vw, 6.8rem)/0.85 var(--display);
  letter-spacing: 0.04em;
  text-align: center;
  color: #F2FCFF;
  text-shadow: calc(var(--px) * -1) 0 0 var(--pink), var(--px) 0 0 var(--edge), 0 0 26px rgb(77 225 255 / 0.45);
}

.tagline {
  text-align: center;
  font: 700 0.78rem/1 var(--label);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--edge);
  text-indent: 0.4em;
}

.spec { margin: 14px 0 22px; text-align: center; font-size: 1.1rem; color: var(--muted); letter-spacing: 0.04em; }

.section-title {
  margin: 28px 0 8px;
  font: 700 0.72rem/1 var(--label);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--edge);
}

.note { margin-top: 10px; color: var(--muted); font-size: 1.05rem; line-height: 1.2; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- Buttons and controls ---------- */

.btn {
  --btn-bg: var(--ice);
  --btn-ink: #0A2349;
  --btn-shade: #6CBEE3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  margin: var(--px);
  padding: 8px 18px 10px;
  border: 0;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font: 700 0.78rem/1.2 var(--label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--edge-dark),
    0 var(--px) 0 0 var(--edge-dark),
    calc(var(--px) * -1) 0 0 0 var(--edge-dark),
    var(--px) 0 0 0 var(--edge-dark),
    inset 0 calc(var(--px) * -2) 0 0 var(--btn-shade),
    inset 0 var(--px) 0 0 rgb(255 255 255 / 0.45);
}

.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(var(--px)); box-shadow: 0 calc(var(--px) * -1) 0 0 var(--edge-dark), 0 var(--px) 0 0 var(--edge-dark), calc(var(--px) * -1) 0 0 0 var(--edge-dark), var(--px) 0 0 0 var(--edge-dark); }

.btn--gold { --btn-bg: var(--pink); --btn-ink: #FFF0F5; --btn-shade: var(--pink-dark); }
.btn--ice { --btn-bg: var(--ice); --btn-ink: #0A2349; --btn-shade: #6CBEE3; }
.btn--ghost { --btn-bg: var(--panel-3); --btn-ink: var(--ink); --btn-shade: #0A2349; }
.btn--danger { --btn-bg: var(--coral); --btn-ink: #2A0A06; --btn-shade: #A8402F; font-size: 0.68rem; min-height: 38px; }

/* The big hollow call to action: "▼ BEGIN DESCENT ▼". */
.btn--descent {
  --btn-bg: rgb(8 28 52 / 0.92);
  --btn-ink: #F2FCFF;
  --btn-shade: rgb(77 225 255 / 0.12);
  display: flex;
  gap: 14px;
  width: calc(100% - var(--px) * 2);
  min-height: 62px;
  font-size: 0.95rem;
  letter-spacing: 0.2em;
  text-shadow: 0 0 12px var(--edge);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--edge),
    0 var(--px) 0 0 var(--edge),
    calc(var(--px) * -1) 0 0 0 var(--edge),
    var(--px) 0 0 0 var(--edge),
    0 0 26px 0 rgb(77 225 255 / 0.4),
    inset 0 0 22px 0 rgb(77 225 255 / 0.18);
}

.btn--descent::before, .btn--descent::after { content: '▼'; font-size: 0.7rem; color: var(--edge); animation: bob 1.2s steps(2) infinite; }
.btn--descent::after { animation-delay: 0.6s; }
.btn--descent:hover { --btn-bg: rgb(14 52 92 / 0.95); filter: none; }
.btn--descent:active { box-shadow: 0 calc(var(--px) * -1) 0 0 var(--edge), 0 var(--px) 0 0 var(--edge), calc(var(--px) * -1) 0 0 0 var(--edge), var(--px) 0 0 0 var(--edge); }

.quick { display: flex; gap: 8px; margin-top: 16px; }

.quick__btn {
  flex: 1;
  margin: var(--px);
  padding: 8px 4px;
  border: 0;
  background: rgb(8 28 52 / 0.7);
  color: var(--muted);
  font: 400 0.6rem/1.2 var(--label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 calc(var(--px) * -1) 0 0 var(--edge-dim), 0 var(--px) 0 0 var(--edge-dim), calc(var(--px) * -1) 0 0 0 var(--edge-dim), var(--px) 0 0 0 var(--edge-dim);
}

.quick__btn:hover { color: var(--edge); background: rgb(14 52 92 / 0.8); }

.link {
  padding: 10px 0;
  border: 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.link:hover { color: var(--ink); }

.swatch {
  display: inline-block;
  flex: none;
  width: 14px;
  height: 14px;
  background: var(--sw, var(--tier-none));
  box-shadow: inset 0 0 0 2px rgb(2 7 15 / 0.6);
}

.swatch--big { width: 24px; height: 24px; box-shadow: inset 0 0 0 3px rgb(2 7 15 / 0.6); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 16px; }

.chip {
  margin: var(--px);
  padding: 4px 10px;
  border: 0;
  background: var(--panel-2);
  color: var(--ink);
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: 0 calc(var(--px) * -1) 0 0 var(--panel-3), 0 var(--px) 0 0 var(--panel-3), calc(var(--px) * -1) 0 0 0 var(--panel-3), var(--px) 0 0 0 var(--panel-3);
}

.chip:hover { background: var(--panel-3); }
.chip[aria-pressed="true"] { background: var(--edge); color: #04121F; box-shadow: 0 calc(var(--px) * -1) 0 0 var(--ice), 0 var(--px) 0 0 var(--ice), calc(var(--px) * -1) 0 0 0 var(--ice), var(--px) 0 0 0 var(--ice), 0 0 14px var(--glow); }

/* ---------- Home ---------- */

.stats { display: flex; flex-wrap: wrap; gap: 10px 30px; margin-top: 22px; }
.stats { justify-content: center; }
.stats dt { color: var(--muted); font: 400 0.55rem/1.4 var(--label); letter-spacing: 0.14em; text-transform: uppercase; }
.stats dd { font: 400 2.2rem/1 var(--body); color: var(--pink); text-shadow: 0 0 10px rgb(255 79 134 / 0.5); text-align: center; }

.free { margin-top: 30px; padding-top: 4px; border-top: var(--px) dashed var(--panel-3); }

/* ---------- Playing ---------- */

.prompt {
  margin: 8px 0 16px;
  font: 400 clamp(2.2rem, 8vw, 3rem)/1.05 var(--body);
  letter-spacing: 0.01em;
  text-shadow: 0 0 14px rgb(77 225 255 / 0.35);
}

.prompt:focus { outline: none; }
.prompt.is-entering { animation: type-in 0.5s steps(8) both; }

.timer { display: flex; align-items: center; gap: 12px; }

.timer__track { flex: 1; height: 14px; padding: 3px; background: #071833; }

.timer__fill {
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--edge) 0 8px, #6CBEE3 8px 10px);
  transform-origin: left center;
}

.timer__num {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  font: 400 1.7rem/1 var(--body);
  color: var(--edge);
  border-radius: 50%;
  background: rgb(4 14 28 / 0.9);
  box-shadow: 0 0 0 2px var(--edge-dim), 0 0 14px var(--glow);
}
.timer.is-low .timer__fill { background: repeating-linear-gradient(90deg, var(--coral) 0 8px, #A8402F 8px 10px); }
.timer.is-low .timer__num { color: var(--coral); box-shadow: 0 0 0 2px var(--coral), 0 0 14px rgb(255 122 107 / 0.5); animation: pip 0.5s steps(2) infinite; }
.timer { flex-direction: row-reverse; }

.guess { display: flex; gap: 8px; margin-top: 14px; }

.guess input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 8px 12px;
  border: 0;
  border-radius: 0;
  background: #071833;
  font: 400 1.6rem/1 var(--body);
  caret-color: var(--pink);
  box-shadow: 0 calc(var(--px) * -1) 0 0 var(--edge-dim), 0 var(--px) 0 0 var(--edge-dim), calc(var(--px) * -1) 0 0 0 var(--edge-dim), var(--px) 0 0 0 var(--edge-dim);
}

.guess input::placeholder { color: #5C7A8F; }
.guess input:focus-visible { outline: none; box-shadow: 0 calc(var(--px) * -1) 0 0 var(--edge), 0 var(--px) 0 0 var(--edge), calc(var(--px) * -1) 0 0 0 var(--edge), var(--px) 0 0 0 var(--edge), 0 0 16px var(--glow); }
.guess.is-wrong input { animation: shake 0.3s steps(4); }

.feedback { min-height: 1.2em; margin-top: 8px; color: var(--coral); font-size: 1.1rem; }


/* ---------- Diving: cards and depth gauge on the scene ---------- */

.dive { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.dive > * { pointer-events: auto; }

.dive__card {
  position: absolute;
  left: 50%;
  bottom: 24px;
  width: min(540px, calc(100% - 40px));
  margin: 0;
  padding: 20px 22px 16px;
  background: rgb(11 27 46 / 0.93);
  transform: translateX(-50%);
  animation: card-in 0.35s ease-out both;
  max-height: 46dvh;
  overflow-y: auto;
}

.dive__card .prompt { margin: 6px 0 12px; font-size: clamp(1.8rem, 4vw, 2.5rem); }


.gauge {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  pointer-events: none;
}

body[data-screen="play"] .gauge { display: block; }

.gauge__chip {
  position: absolute;
  top: calc(var(--hud-h) + 10px);
  left: calc(var(--rail) + 16px);
  min-width: 118px;
  margin: 0;
  padding: 8px 14px 8px;
}

.gauge__label { font: 400 0.52rem/1 var(--label); letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.gauge__metres { margin-top: 4px; font: 400 2.2rem/0.9 var(--body); color: var(--edge); text-shadow: 0 0 12px var(--edge); font-variant-numeric: tabular-nums; }
.gauge__level { margin-top: 2px; font-size: 0.95rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* A depth ruler down the right edge with a marker that follows the dive. */
.gauge__track {
  position: absolute;
  top: calc(var(--hud-h) + 24px);
  bottom: 40px;
  right: calc(var(--rail) + 22px);
  width: 2px;
  background: linear-gradient(to bottom, rgb(143 210 236 / 0.8), rgb(49 137 194 / 0.6) 40%, rgb(77 225 255 / 0.15));
}

.gauge__track::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 10px;
  background: repeating-linear-gradient(to bottom, rgb(143 210 236 / 0.55) 0 1px, transparent 1px 22px);
  -webkit-mask: linear-gradient(to left, #000 0 100%);
}

.gauge__track::after {
  content: '0M';
  position: absolute;
  top: -16px;
  right: -4px;
  font: 400 0.5rem/1 var(--label);
  letter-spacing: 0.1em;
  color: var(--muted);
}

.gauge__marker {
  position: absolute;
  right: -6px;
  width: 16px;
  top: calc(var(--share, 0) * 100%);
  height: 4px;
  margin-top: -2px;
  background: var(--pink);
  box-shadow: 0 0 10px var(--pink), 0 0 0 1px #02070F;
}

@media (max-width: 899px) {
  .dive__card { bottom: 12px; transform: translateX(-50%); width: calc(100% - 20px); padding: 14px 14px 10px; }
  .dive__card .prompt { font-size: clamp(1.7rem, 7.5vw, 2.3rem); }
  .gauge__chip { top: calc(var(--hud-h) + 6px); left: 10px; min-width: 0; padding: 5px 10px; }
  .gauge__label, .gauge__level { display: none; }
  .gauge__metres { margin: 0; font-size: 1.7rem; }
  .gauge__track { right: 12px; bottom: 150px; }
}

/* ---------- Ad columns ---------- */

.ad-rail { display: none; }

@media (min-width: 1200px) {
  .ad-rail {
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--rail);
    background: rgb(2 7 15 / 0.55);
    -webkit-backdrop-filter: saturate(0.8);
    backdrop-filter: saturate(0.8);
  }
  .ad-rail--left { box-shadow: inset -1px 0 0 rgb(77 225 255 / 0.18); }
  .ad-rail--right { box-shadow: inset 1px 0 0 rgb(77 225 255 / 0.18); }
  .ad-rail--left { left: 0; }
  .ad-rail--right { right: 0; }
  .ad-slot { width: 160px; min-height: 600px; }
}

@media (min-width: 1680px) { .ad-slot { width: 300px; } }

/* While developing locally, show where the ads will go. */
body.show-ad-slots .ad-slot:empty { display: grid; place-items: center; outline: 2px dashed var(--panel-3); }
body.show-ad-slots .ad-slot:empty::after { content: 'Ad space'; color: var(--muted); font-size: 0.85rem; }

/* ---------- Results ---------- */

.rank { margin: 6px 0 20px; }
.rank__name { font: 400 clamp(3rem, 13vw, 4.6rem)/0.9 var(--display); color: var(--gold); text-shadow: var(--px) var(--px) 0 #5E2E24, 0 0 24px rgb(246 196 83 / 0.4); }
.rank__line { margin-top: 8px; font-size: 1.35rem; }
.rank__depth { margin-top: 10px; padding: 10px 12px; background: var(--panel-2); color: var(--edge); font-size: 1.15rem; }

.meter { position: relative; height: 16px; margin-top: 14px; padding: 3px; background: #071833; }
.meter__fill {
  display: block;
  height: 100%;
  width: calc(var(--f, 0) * 100%);
  background: repeating-linear-gradient(90deg, var(--pink) 0 8px, var(--pink-dark) 8px 10px);
  transition: width 1.2s steps(14) 0.2s;
}

.share-fallback { width: calc(100% - var(--px) * 2); min-height: 7em; margin-top: 12px; padding: 10px; border: 0; background: #071833; }

.log { margin: 8px 0 18px; padding: 0; list-style: none; }

.log li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: var(--px) dashed var(--panel-3);
  animation: blink-in 0.35s steps(3) both;
  animation-delay: calc(0.2s + var(--i, 0) * 80ms);
}

.log__q { display: block; color: var(--muted); font-size: 1.05rem; }
.log__a { display: block; font-size: 1.5rem; line-height: 1; }
.log__level { color: var(--muted); font-size: 1.05rem; }
.log__pts { font: 400 2rem/1 var(--body); color: var(--pink); text-align: right; }

/* ---------- Menu ---------- */

.menu {
  margin: auto;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 20px;
  border: 0;
  color: var(--ink);
  overflow-y: auto;
}

.menu::backdrop { background: rgb(2 7 15 / 0.7); }
.menu[open] { animation: blink-in 0.3s steps(3); }

.menu__head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.menu__head > div { margin-right: auto; }
.menu__title { font: 400 2.8rem/0.9 var(--display); color: var(--ice); text-shadow: calc(var(--px) * -1) 0 0 var(--pink), var(--px) 0 0 var(--edge); }

.menu__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.tile {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 18px 10px 14px;
  border: 0;
  background: var(--panel-2);
  color: var(--ink);
  font: 400 0.58rem/1.3 var(--label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

.tile svg { width: 26px; height: 26px; color: var(--edge); shape-rendering: crispEdges; }
.tile:hover { background: var(--panel-3); }
.tile:hover svg { color: var(--gold); }
.tile:active { transform: translateY(var(--px)); }
.tile--wide { grid-column: 1 / -1; grid-auto-flow: column; justify-content: center; align-items: center; }

.menu__foot { margin-top: 18px; color: var(--muted); font-size: 1.05rem; text-align: center; }

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: var(--px) dashed var(--panel-3);
}

.setting__name { font: 400 1.4rem/1.1 var(--body); }
.setting__hint { color: var(--muted); font-size: 1.05rem; line-height: 1.15; }
.setting--danger .setting__name { color: var(--coral); }

.switch {
  position: relative;
  flex: none;
  width: 52px;
  height: 26px;
  padding: 0;
  border: 0;
  background: #071833;
  cursor: pointer;
}

.switch span {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  background: var(--muted);
  transition: transform 0.15s steps(3);
}

.switch[aria-checked="true"] { background: #0E3260; }
.switch[aria-checked="true"] span { transform: translateX(26px); background: var(--gold); }

.seg { display: flex; flex: none; gap: 4px; }

.seg button {
  margin: var(--px);
  padding: 4px 8px;
  border: 0;
  background: var(--panel-2);
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 calc(var(--px) * -1) 0 0 var(--panel-3), 0 var(--px) 0 0 var(--panel-3), calc(var(--px) * -1) 0 0 0 var(--panel-3), var(--px) 0 0 0 var(--panel-3);
}

.seg button[aria-checked="true"] { background: var(--edge); color: #04121F; box-shadow: 0 calc(var(--px) * -1) 0 0 var(--ice), 0 var(--px) 0 0 var(--ice), calc(var(--px) * -1) 0 0 0 var(--ice), var(--px) 0 0 0 var(--ice); }

.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.statgrid > div { padding: 10px; background: var(--panel-2); }
.statgrid dt { color: var(--muted); font-size: 1rem; line-height: 1.1; }
.statgrid dd { font: 400 2.6rem/1 var(--body); color: var(--pink); text-shadow: 0 0 10px rgb(255 79 134 / 0.5); }

.dist, .levels, .archive { margin: 8px 0 0; padding: 0; list-style: none; }

.dist li { display: grid; grid-template-columns: 9.5em 1fr auto; align-items: center; gap: 10px; padding: 5px 0; font-size: 1.05rem; }
.dist__bar { height: 14px; background: #071833; }
.dist__bar span { display: block; height: 100%; width: calc(var(--f, 0) * 100%); background: var(--sw); min-width: 3px; }
.dist__n { font: 400 1.3rem/1 var(--display); min-width: 2ch; text-align: right; }

.archive li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: var(--px) dashed var(--panel-3); }
.archive__name { font: 400 1.5rem/1 var(--display); }
.archive__meta { color: var(--muted); font-size: 1.05rem; }
.archive .btn { font-size: 0.6rem; min-height: 34px; padding: 4px 12px 6px; }

.rules { display: grid; gap: 10px; padding-left: 1.2em; margin-bottom: 18px; font-size: 1.25rem; line-height: 1.15; }
.levels li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.levels__name { font: 400 1.5rem/1 var(--display); }
.levels__pts { margin-left: auto; color: var(--gold); font: 400 1.5rem/1 var(--display); }

.faq dt { margin-top: 14px; font: 400 1.6rem/1 var(--display); color: var(--ice); }
.faq dd { margin-top: 4px; color: var(--ink); font-size: 1.2rem; line-height: 1.15; }

@media (max-width: 480px) {
  .statgrid { grid-template-columns: 1fr 1fr; }
  .setting { flex-wrap: wrap; }
}

/* ---------- Keyframes (stepped, for a pixel feel) ---------- */
.rarity-card {
  padding: 22px 18px;
  margin-bottom: 22px;
  border: 2px solid var(--edge);
  background: linear-gradient(145deg, #12304a, #071322 75%);
  box-shadow: inset 0 0 32px rgb(77 225 255 / 0.1), 0 0 26px var(--glow);
  text-align: center;
}
.rarity-card__value {
  margin: 6px 0;
  font: 400 clamp(4rem, 12vw, 6rem)/1 var(--display);
  color: var(--pink);
  text-shadow: calc(var(--px) * -1) 0 0 var(--pink-dark), var(--px) 0 0 var(--edge), 0 0 28px rgb(255 79 134 / 0.5);
}
.rarity-card .note { margin-top: 12px; font-size: 1rem; color: var(--muted); }

@keyframes blink-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes type-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes drop { from { opacity: 0; translate: 0 -14px; } to { opacity: 1; translate: 0 0; } }
@keyframes card-in { from { opacity: 0; scale: 0.92; } to { opacity: 1; scale: 1; } }
@keyframes pip { 50% { opacity: 0.35; } }
@keyframes bob { 50% { transform: translateY(3px); } }
@keyframes glow { 50% { color: #FFF6D8; } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- Motion preferences ---------- */

body[data-motion="reduced"] *,
body[data-motion="reduced"] *::before,
body[data-motion="reduced"] *::after { animation: none !important; transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  body:not([data-motion="full"]) *,
  body:not([data-motion="full"]) *::before,
  body:not([data-motion="full"]) *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 420px) {
  .btn--descent { font-size: 0.8rem; letter-spacing: 0.12em; gap: 8px; }
  .wordmark { font-size: clamp(3.6rem, 18vw, 4.6rem); }
}

/* ---------- Result: centred, no box, like a title card ---------- */

.dive__reveal {
  --rc: #A8E4FA;
  position: absolute;
  left: 50%;
  bottom: 3vh;
  display: grid;
  justify-items: center;
  gap: 4px;
  width: min(640px, calc(100% - 24px));
  margin: 0;
  padding: 36px 28px 18px;
  text-align: center;
  background: radial-gradient(closest-side at 50% 55%, rgb(2 7 15 / 0.88), rgb(2 7 15 / 0.62) 55%, rgb(2 7 15 / 0) 100%);
  transform: translateX(-50%);
}

.dive__reveal[data-tier="none"] { --rc: #8FB2C4; }
.dive__reveal[data-tier="1"] { --rc: #7FD3F7; }
.dive__reveal[data-tier="2"] { --rc: #6FA8FF; }
.dive__reveal[data-tier="3"] { --rc: #9BF5E8; }
.dive__reveal[data-tier="4"] { --rc: #F6C453; }
.dive__reveal[data-tier="none"] { --cw: 12; --ch: 12; }
.dive__reveal[data-tier="0"] { --cw: 16; --ch: 15; }
.dive__reveal[data-tier="1"] { --cw: 20; --ch: 11; }
.dive__reveal[data-tier="2"] { --cw: 16; --ch: 15; }
.dive__reveal[data-tier="3"] { --cw: 20; --ch: 14; }
.dive__reveal[data-tier="4"] { --cw: 15; --ch: 11; }
/* The two long level names get a slightly smaller title so they stay on one line. */
.dive__reveal[data-tier="1"] .reveal__tier,
.dive__reveal[data-tier="4"] .reveal__tier { font-size: clamp(2rem, 5.4vw, 3.1rem); }

.reveal__icon {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 48px;
  margin-bottom: 8px;
  color: var(--rc);
  animation: float 2.4s ease-in-out infinite;
}

.reveal__icon svg {
  /* One icon cell is one scene pixel, so the icon matches the pixel art around it. */
  width: calc(var(--cw, 16) * var(--px));
  height: calc(var(--ch, 15) * var(--px));
  shape-rendering: crispEdges;
  filter: drop-shadow(0 0 10px var(--rc)) drop-shadow(0 0 2px var(--rc));
}

/* Two bubbles rising off the icon. */
.reveal__icon::before,
.reveal__icon::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 16px;
  width: 7px;
  height: 7px;
  border: 1px solid rgb(233 247 253 / 0.75);
  border-radius: 50%;
  animation: bubble 2.2s ease-in infinite;
}

.reveal__icon::after { right: 2px; top: 30px; width: 4px; height: 4px; animation-delay: 1.1s; }

.reveal__tier {
  font: 400 clamp(2.6rem, 7vw, 3.9rem)/1 var(--body);
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  text-transform: uppercase;
  color: var(--rc);
  text-shadow: 0 0 18px var(--rc), 0 0 2px var(--rc);
}

.reveal__said { margin-top: 8px; font-size: 1.75rem; line-height: 1.1; letter-spacing: 0.06em; color: #F2FCFF; }
.reveal__said strong { font-weight: 400; }
.reveal__said .muted { font-size: 1.15rem; }
.reveal__stats { font-size: 1.75rem; line-height: 1.1; letter-spacing: 0.06em; color: #F2FCFF; }
.reveal__points { color: var(--rc); text-transform: uppercase; text-shadow: 0 0 10px var(--rc); }
.reveal__dot { margin: 0 0.45em; color: var(--muted); }
.reveal__note { margin-top: 6px; font-size: 1.15rem; letter-spacing: 0.16em; color: var(--muted); }
.reveal__lists { margin-top: 10px; font-size: 1.1rem; line-height: 1.35; letter-spacing: 0.04em; color: #CFE6F0; }
.reveal__lists .muted { margin-right: 6px; font: 400 0.55rem/1 var(--label); letter-spacing: 0.16em; text-transform: uppercase; }
.dive__reveal .btn { margin-top: 16px; min-width: min(320px, 100%); }

/* Entrance: the icon pops, the title tracks in, the rest rises one line at a time. */
.dive__reveal.is-entering > * { animation: rise 0.5s ease-out both; }
.dive__reveal.is-entering > .reveal__icon { animation: pop 0.55s cubic-bezier(0.2, 1.6, 0.4, 1) both, float 2.4s ease-in-out 0.55s infinite; }
.dive__reveal.is-entering > .reveal__tier { animation: track-in 0.8s ease-out 0.08s both; }
.dive__reveal.is-entering > :nth-child(3) { animation-delay: 0.22s; }
.dive__reveal.is-entering > :nth-child(4) { animation-delay: 0.3s; }
.dive__reveal.is-entering > :nth-child(5) { animation-delay: 0.38s; }
.dive__reveal.is-entering > :nth-child(6) { animation-delay: 0.46s; }
.dive__reveal.is-entering > :nth-child(7) { animation-delay: 0.54s; }

/* The rarest levels keep glowing after they land. */
.dive__reveal.is-rare > .reveal__tier,
.dive__reveal.is-bottom > .reveal__tier { animation: track-in 0.8s ease-out 0.08s both, glow-pulse 1.8s ease-in-out 0.9s infinite; }
.dive__reveal.is-bottom .reveal__icon svg { filter: drop-shadow(0 0 16px var(--rc)) drop-shadow(0 0 3px #FFF6D8); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.4); } to { opacity: 1; transform: scale(1); } }
@keyframes float { 50% { transform: translateY(-4px); } }
@keyframes track-in { from { opacity: 0; letter-spacing: 0.7em; filter: blur(3px); } to { opacity: 1; letter-spacing: 0.18em; filter: none; } }
@keyframes bubble { 0% { opacity: 0; transform: translateY(0); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-36px); } }
@keyframes glow-pulse { 50% { text-shadow: 0 0 34px var(--rc), 0 0 6px var(--rc), 0 0 2px #FFFFFF; } }

@media (max-width: 899px) {
  .dive__reveal { bottom: 8px; width: calc(100% - 12px); padding: 30px 14px 12px; }
  .reveal__tier { font-size: clamp(2.1rem, 10vw, 3rem); }
  .reveal__said, .reveal__stats { font-size: 1.5rem; }
}

/* A soft glow instead of a hard box when the result button has keyboard focus. */
.dive__reveal .btn:focus-visible { outline: none; box-shadow: 0 0 0 2px rgb(255 255 255 / 0.55), 0 0 22px rgb(255 79 134 / 0.65); }
/* Focus is moved to the results title for screen readers; it needs no visible box. */
#results-title:focus { outline: none; }

/* Links to the content pages under the home panel (also how search engines find them). */
.explore { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 26px; padding-top: 4px; border-top: var(--px) dashed var(--panel-3); }
.explore .section-title { width: 100%; }
.explore a { color: var(--muted); font: 400 0.58rem/1.8 var(--label); letter-spacing: 0.12em; text-transform: uppercase; text-decoration: none; }
.explore a:hover { color: var(--edge); }
