/* style.css — one palette, one typeface family, three surface levels.

   The game is a twilight scene, so the UI is dark glass over it: nothing is a
   flat grey panel. Every surface is a translucent tint of the water, which is
   what keeps the HUD from looking like a spreadsheet sitting on a painting.

   Type scale is fixed (4 steps). Colour is semantic: gold = money/earning,
   cyan = water/neutral action, red = danger/tension. Nothing else is coloured
   for decoration. */

:root {
  --ink: #eaf6fb;
  --ink-2: #b9d2dd;
  --ink-3: #8aa6b3;
  --faint: #5d7885;

  --glass: rgba(8, 26, 36, 0.72);
  --glass-2: rgba(6, 20, 29, 0.86);
  --line: rgba(180, 226, 245, 0.16);
  --line-2: rgba(180, 226, 245, 0.30);

  --cyan: #6fd8ef;
  --cyan-deep: #2b93ad;
  --gold: #ffc247;
  --gold-deep: #d99521;
  --red: #ff6b6b;
  --green: #6fe3a0;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;

  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Full HUD scaling, set from Settings. Individual element placement is not
     customisable, so this is the accessibility fallback the HUD guidelines
     recommend: one control that makes everything on the glass bigger. It
     multiplies the HUD layer only — the canvas scene keeps its own resolution. */
  --hud: 1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden], .hide { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #06121a;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  height: 100dvh;
}

/* ── HUD shell ─────────────────────────────────────────────────────── */

#hud {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  padding: max(14px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  /* One control for the whole glass layer. Scaling the layer rather than each
     panel keeps the composition intact at every size; the inverse width/height
     stops the scaled layer from leaving a gap at the right and bottom edges. */
  transform: scale(var(--hud));
  transform-origin: top left;
  width: calc(100% / var(--hud));
  height: calc(100% / var(--hud));
}

#hudTop {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

#brand h1 {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.14em;
  line-height: 1;
  color: var(--ink);
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.7);
}

#brand span {
  display: block;
  margin-top: 5px;
  font-size: 9.5px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 700;
}

#wallet {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px 8px 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.coinIcon {
  color: var(--gold);
  font-size: 15px;
  line-height: 1;
  text-shadow: 0 0 12px rgba(255, 194, 71, 0.6);
}

#coins {
  font-size: 16px;
  font-weight: 900;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  min-width: 1ch;
}

#coins.bump { animation: bump 0.35s ease; }
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* ── right rail ────────────────────────────────────────────────────── */

#hudRight {
  position: absolute;
  right: 16px;
  top: 74px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
}

.chip {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  font: 700 12px/1 var(--font);
  letter-spacing: 0.06em;
  cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: border-color 0.16s, color 0.16s, background 0.16s, transform 0.1s;
}

.chip:hover { border-color: var(--line-2); color: var(--ink); background: rgba(14, 40, 54, 0.82); }
.chip:active { transform: scale(0.96); }
.chip b { color: var(--cyan); font-weight: 900; font-variant-numeric: tabular-nums; }
.chip.icon { padding: 8px 12px; font-size: 13px; }

/* the daily deep cast: gold when it is ready, greyed once spent, lit when armed */
.chip.daily {
  border-color: rgba(255, 194, 71, 0.42);
  color: #ffe6a8;
  background: linear-gradient(180deg, rgba(255, 194, 71, 0.16), rgba(255, 194, 71, 0.05));
}

.chip.daily:hover {
  border-color: rgba(255, 194, 71, 0.8);
  box-shadow: 0 0 18px rgba(255, 194, 71, 0.28);
  color: #fff4d6;
}

.chip.daily.spent {
  border-color: var(--line);
  color: var(--faint);
  background: var(--glass);
  box-shadow: none;
}

.chip.daily.armed {
  border-color: var(--gold);
  color: #fff4d6;
  background: linear-gradient(180deg, rgba(255, 194, 71, 0.34), rgba(255, 194, 71, 0.12));
  box-shadow: 0 0 0 1px rgba(255, 194, 71, 0.35), 0 0 22px rgba(255, 194, 71, 0.45);
  animation: armPulse 1.6s ease-in-out infinite;
}

@keyframes armPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255, 194, 71, 0.35), 0 0 22px rgba(255, 194, 71, 0.45); }
  50% { box-shadow: 0 0 0 1px rgba(255, 194, 71, 0.6), 0 0 34px rgba(255, 194, 71, 0.65); }
}

/* ── readout ───────────────────────────────────────────────────────── */

#castInfo {
  position: absolute;
  left: 16px;
  bottom: 118px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
}

#rodLine {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
}

#depthLine {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* a run worth protecting: only appears from two catches in a row upward */
#streakChip {
  margin-top: 2px;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 14px rgba(255, 194, 71, 0.55);
  transition: opacity 0.2s;
}

#streakChip.hide { opacity: 0; }

#prompt {
  position: absolute;
  left: 50%;
  bottom: 168px;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  text-align: center;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
  transition: opacity 0.2s;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── power meter ───────────────────────────────────────────────────── */

#powerWrap {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  width: min(320px, 74vw);
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: center;
}

#powerTrack {
  position: relative;
  width: 100%;
  height: 10px;
  background: rgba(4, 16, 23, 0.8);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

#powerFill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan-deep), var(--cyan) 55%, var(--gold));
  transition: width 0.04s linear;
  box-shadow: 0 0 18px rgba(111, 216, 239, 0.6);
}

/* the sweet-spot mark, so the meter is a skill test not a slider.
   Its left/width are set per cast by ui.js — the window moves every throw. */
#powerMark {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 78%;
  width: 6%;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
  border-radius: 2px;
  opacity: 0.55;
  transition: left 0.15s ease, width 0.15s ease, opacity 0.12s;
}

/* when the charge is actually inside the window, both the mark and the fill
   go solid gold — the player is being told to let go, not guessing */
#powerMark.live,
#powerTrack.sweet #powerMark {
  opacity: 1;
  background: #ffe6a8;
  box-shadow: 0 0 16px var(--gold), 0 0 32px rgba(255, 194, 71, 0.7);
}

#powerFill.sweet {
  background: linear-gradient(90deg, var(--gold), #ffe6a8);
  box-shadow: 0 0 22px rgba(255, 194, 71, 0.9);
}

#powerLabel {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
}

/* the cast button celebrates the window too, so a player watching their thumb
   rather than the meter still learns the timing */
#actionBtn.sweet {
  border-color: rgba(255, 194, 71, 0.75);
  box-shadow: 0 0 0 1px rgba(255, 194, 71, 0.3), 0 10px 30px rgba(255, 194, 71, 0.22);
  background: linear-gradient(180deg, rgba(255, 194, 71, 0.2), rgba(255, 194, 71, 0.07));
}

#actionBtn.sweet #actionLabel { color: #ffe6a8; }

/* ── reeling card ──────────────────────────────────────────────────── */

#reelWrap {
  position: absolute;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(360px, 86vw);
}

#reelFish { display: none; }

#reelCard {
  width: 100%;
  padding: 14px 16px 12px;
  background: var(--glass-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

#reelHead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}

#reelName {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.01em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#reelState {
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--cyan);
  flex: none;
  transition: color 0.12s;
}
#reelState.hot { color: var(--red); animation: pulse 0.5s infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

.meter {
  position: relative;
  height: 13px;
  background: rgba(3, 12, 18, 0.85);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 7px;
}

.meter i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 999px;
  transition: width 0.06s linear, background 0.15s;
}

#progFill { background: linear-gradient(90deg, #2b7f96, var(--cyan)); }
#strainFill { background: linear-gradient(90deg, #4a9c74, #d6c04a 55%, var(--red)); }

.meter em {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font: 900 8px/1 var(--font);
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.5);
  font-style: normal;
}

.meter.strain { margin-bottom: 9px; }

/* the payout readout: how fast the line is actually moving right now.
   It answers "am I in the good zone?" without asking the player to read
   two meters and do subtraction in their head mid-fight. It sits on a dark
   pill so it stays legible over the bright fill as well as the empty track. */
#payTag {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(2, 9, 14, 0.72);
  font: 900 7.5px/1 var(--font);
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.72);
  pointer-events: none;
  z-index: 2;
}

#payTag.idle { color: rgba(255, 255, 255, 0.3); }
#payTag.weak { color: rgba(255, 255, 255, 0.5); }
#payTag.good { color: #b9f5c9; }
#payTag.slow { color: #ffd67a; }
#payTag.dead { color: var(--red); }

/* red edge-of-screen pressure, opacity driven from main.js by the tension.
   Purely additive information: at 0 it is invisible. */
#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 3;
  transition: opacity 0.12s linear;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 46%, rgba(255, 60, 60, 0.5) 100%);
}

#reelHint {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--faint);
  text-align: center;
}

/* ── fight clock ───────────────────────────────────────────────────────
   The fight ends when fightLimit runs out, which used to be invisible. It is
   drawn as a thin depleting rule under the meters — quiet for most of the
   fight, then the only thing you look at. Colour alone never carries it: the
   numeric readout and the shrinking bar both move. */

#fightClock {
  position: relative;
  height: 14px;
  margin: 9px 0 8px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

#clockFill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--cyan-deep), var(--cyan));
  transition: width 0.1s linear, background 0.2s;
}

#clockTag {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

#fightClock.low #clockFill { background: linear-gradient(90deg, var(--gold-deep), var(--gold)); }
#fightClock.critical #clockFill { background: linear-gradient(90deg, #b8322e, var(--red)); }
#fightClock.critical { box-shadow: 0 0 0 1px rgba(255, 107, 107, 0.55), 0 0 14px rgba(255, 107, 107, 0.45); }

@media (prefers-reduced-motion: reduce) {
  #clockFill { transition: none; }
}

#reelCard.danger { border-color: rgba(255, 107, 107, 0.6); animation: shake 0.3s; }
@keyframes shake {
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* ── action button ─────────────────────────────────────────────────── */

#actionRow {
  margin-top: auto;
  display: flex;
  justify-content: center;
  padding-bottom: 4px;
}

#actionBtn {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: min(340px, 88vw);
  padding: 15px 20px 13px;
  background: linear-gradient(180deg, rgba(24, 70, 92, 0.9), rgba(10, 36, 49, 0.92));
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  color: var(--ink);
  font-family: var(--font);
  cursor: pointer;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.09);
  transition: transform 0.08s, border-color 0.16s, background 0.16s;
}

#actionBtn:hover { border-color: rgba(111, 216, 239, 0.5); }
#actionBtn:active, #actionBtn.down {
  transform: scale(0.985);
  background: linear-gradient(180deg, rgba(34, 96, 122, 0.95), rgba(14, 46, 62, 0.95));
}

#actionLabel {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#actionSub {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--faint);
  text-transform: uppercase;
}

#actionBtn.urgent {
  border-color: var(--gold);
  animation: urgent 0.42s infinite alternate;
}
@keyframes urgent {
  from { box-shadow: var(--shadow), 0 0 0 rgba(255, 194, 71, 0); }
  to { box-shadow: var(--shadow), 0 0 26px rgba(255, 194, 71, 0.55); }
}

#actionBtn[disabled] { opacity: 0.4; cursor: default; }

/* ── overlays ──────────────────────────────────────────────────────── */

.ov {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 10, 15, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade 0.22s ease;
  overflow-y: auto;
}

@keyframes fade { from { opacity: 0; } }

.panel {
  width: min(660px, 100%);
  max-height: min(88vh, 820px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(14, 40, 53, 0.97), rgba(7, 22, 31, 0.99));
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes rise {
  from { transform: translateY(16px) scale(0.98); opacity: 0; }
}

.panelHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.panelHead h2 {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}

.panelHead .sub {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--faint);
  margin-top: 3px;
}

.xBtn {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-3);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}
.xBtn:hover { background: rgba(255, 255, 255, 0.11); color: var(--ink); }

.panelBody { padding: 16px 20px 20px; overflow-y: auto; flex: 1; }

/* ── catch card ────────────────────────────────────────────────────── */

#card { z-index: 60; }

.catchCard {
  width: min(400px, 100%);
  padding: 26px 24px 22px;
  text-align: center;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(16, 46, 60, 0.98), rgba(6, 19, 27, 1));
  box-shadow: var(--shadow);
  animation: rise 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.catchCard::before {
  content: '';
  position: absolute;
  inset: -40% -20% auto;
  height: 70%;
  background: radial-gradient(ellipse at center, var(--glowCol, rgba(111, 216, 239, 0.4)), transparent 68%);
  opacity: 0.5;
  pointer-events: none;
}

.catchCard > * { position: relative; }

/* a secret is not a rarity tier — it is a thing that happened to you.
   Give it its own halo so the card reads differently from a lucky roll. */
.catchCard.secret {
  border-color: rgba(255, 194, 71, 0.65);
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 194, 71, 0.25), 0 0 60px rgba(255, 194, 71, 0.22);
}
.catchCard.secret::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 214, 130, 0.16) 50%, transparent 65%);
  animation: sheen 2.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sheen {
  0%, 100% { transform: translateX(-60%); }
  50% { transform: translateX(60%); }
}
.catchCard.secret .catchEmoji {
  filter: drop-shadow(0 0 22px rgba(255, 194, 71, 0.6));
}

.rarityTag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font: 900 9px/1 var(--font);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  opacity: 0.95;
}

.catchEmoji {
  display: block;
  font-size: 76px;
  line-height: 1;
  margin: 18px 0 10px;
  filter: drop-shadow(0 8px 26px rgba(0, 0, 0, 0.6));
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob {
  50% { transform: translateY(-7px) rotate(-2deg); }
}

.catchName {
  font-size: 22px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.catchBlurb {
  margin: 11px auto 0;
  max-width: 30ch;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-3);
  font-weight: 600;
}

/* the measured length of the thing you pulled out — small, tabular, and
   the only number on the card that changes between catches of one species */
.catchSize {
  margin-top: 8px;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.catchSize em {
  font-style: normal;
  color: #7ee0a2;
  text-shadow: 0 0 12px rgba(126, 224, 162, 0.6);
}

/* a new personal best: the card earns a green edge, so re-catching a common
   species still has a moment even when it is not a new discovery */
.catchCard.record {
  border-color: rgba(126, 224, 162, 0.55);
  box-shadow: 0 0 0 1px rgba(126, 224, 162, 0.2), 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 60px rgba(126, 224, 162, 0.16);
}

.catchCard.record .catchEmoji {
  filter: drop-shadow(0 8px 22px rgba(126, 224, 162, 0.45));
}

.catchStats {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.stat {
  padding: 7px 13px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.stat b { color: var(--gold); font-size: 12px; }

.newTag {
  display: inline-block;
  margin-top: 14px;
  padding: 5px 14px;
  border-radius: 999px;
  font: 900 10px/1 var(--font);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #07141b;
  background: var(--gold);
  box-shadow: 0 0 26px rgba(255, 194, 71, 0.5);
  animation: pop 0.4s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }

.cardBtns {
  display: flex;
  gap: 9px;
  margin-top: 20px;
}

.btn {
  flex: 1;
  padding: 13px 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: 900 12px/1 var(--font);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.16s, transform 0.08s;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: linear-gradient(180deg, #47c6e3, #2b93ad);
  border-color: transparent;
  color: #04141c;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn.primary:hover { background: linear-gradient(180deg, #5fd8f2, #34a3bf); }
.btn.gold {
  background: linear-gradient(180deg, #ffcf6b, #d99521);
  border-color: transparent;
  color: #241400;
}
.btn.gold:hover { background: linear-gradient(180deg, #ffdc8f, #e8a530); }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ── codex grid ────────────────────────────────────────────────────── */

.codexGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

.cx {
  position: relative;
  /* not a fixed square: the name has to fit under the emoji at every width */
  min-height: 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  padding: 8px 5px 7px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, transform 0.1s;
  overflow: hidden;
}
.cx:hover { border-color: var(--line-2); background: rgba(255, 255, 255, 0.075); transform: translateY(-2px); }

.cx.unknown { opacity: 0.34; filter: grayscale(1); cursor: default; }
.cx.unknown:hover { transform: none; }

.cxEmoji { font-size: 25px; line-height: 1; }
.cxName {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-align: center;
  color: var(--ink-3);
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.cxCount {
  position: absolute;
  top: 4px;
  right: 5px;
  font-size: 8px;
  font-weight: 900;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.cx::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: var(--rc, transparent);
}

.sectLabel {
  margin: 20px 0 10px;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sectLabel:first-child { margin-top: 0; }
.sectLabel::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ── settings rows ─────────────────────────────────────────────────────
   A label column and a control column, so the thing you change and the thing
   that describes it stay in one line at every width. Below 520px the control
   drops under its label instead of crushing the text. */

.setRow {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 13px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.03);
}

.setInfo { flex: 1; min-width: 0; }

.setName {
  font-size: 12.5px;
  font-weight: 900;
  color: var(--ink);
}

.setDesc {
  margin-top: 3px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--faint);
}

.setCtrl {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* a native range, restyled — no custom drag maths, so keyboard arrows and
   screen-reader semantics come free */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 132px;
  height: 24px;
  background: transparent;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}
.range::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--cyan);
  border: 2px solid #06202b;
  box-shadow: 0 0 0 1px var(--cyan);
}
.range::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--cyan);
  border: 2px solid #06202b;
}

.rangeOut {
  min-width: 42px;
  text-align: right;
  font-size: 11px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--cyan);
}

/* switch: the state is in the knob position, the word, and aria-checked, so it
   never depends on colour alone */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px 5px 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--ink-3);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, color 0.16s;
}
.toggle i {
  width: 24px;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  position: relative;
  transition: background 0.16s;
}
.toggle i::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink-3);
  transition: transform 0.16s, background 0.16s;
}
.toggle.on { color: var(--ink); border-color: rgba(111, 216, 239, 0.5); }
.toggle.on i { background: rgba(111, 216, 239, 0.35); }
.toggle.on i::after { transform: translateX(10px); background: var(--cyan); }

.btn.danger {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.45);
  color: #ffb3b3;
}
.btn.danger:hover { background: rgba(255, 107, 107, 0.22); color: #fff; }

.confirm {
  margin: -2px 0 8px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 107, 107, 0.4);
  border-radius: var(--r-sm);
  background: rgba(255, 107, 107, 0.07);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink-2);
}
.confirmBtns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}

@media (max-width: 520px) {
  .setRow { flex-direction: column; align-items: stretch; gap: 10px; }
  .setCtrl { justify-content: flex-end; }
  .range { flex: 1; width: auto; }
}

/* reduced motion: honour the OS and the in-game switch the same way. The
   in-game class is applied to <body>; the media query covers a player who
   never opens settings. */
body.calm #prompt,
body.calm .catchEmoji,
body.calm #toast { animation: none !important; }

.codexProgress {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 4px;
}
.bar {
  flex: 1;
  height: 7px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 999px;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan-deep), var(--gold));
  transition: width 0.4s;
}
.codexProgress span {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  flex: none;
}

/* ── shop ──────────────────────────────────────────────────────────── */

.item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 8px;
  transition: border-color 0.16s;
}
.item.owned { border-color: rgba(111, 227, 160, 0.4); background: rgba(111, 227, 160, 0.07); }
.item.locked { opacity: 0.55; }

.itemEmoji { font-size: 24px; line-height: 1; flex: none; }
.itemInfo { flex: 1; min-width: 0; }
.itemName { font-size: 12.5px; font-weight: 900; color: var(--ink); }
.itemDesc { font-size: 10.5px; font-weight: 600; color: var(--faint); margin-top: 3px; line-height: 1.45; }
.itemMeta {
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.09em;
  color: var(--cyan);
  margin-top: 4px;
  text-transform: uppercase;
}

/* upgrade level: the number beside the name */
.lvl {
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

/* pip row: one dot per level, filled for levels already bought */
.pips {
  display: flex;
  gap: 4px;
  margin-top: 7px;
}
.pip {
  width: 13px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.2s, box-shadow 0.2s;
}
.pip.on {
  background: var(--gold);
  box-shadow: 0 0 8px rgba(255, 194, 71, 0.55);
}

.buyBtn {
  flex: none;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: 900 11px/1 var(--font);
  letter-spacing: 0.06em;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.16s, transform 0.08s;
  white-space: nowrap;
}
.buyBtn:hover:not(:disabled) { background: rgba(255, 194, 71, 0.18); border-color: var(--gold); }
.buyBtn:active:not(:disabled) { transform: scale(0.96); }
.buyBtn:disabled { opacity: 0.4; cursor: default; }

/* ── help ──────────────────────────────────────────────────────────── */

.helpStep {
  display: flex;
  gap: 12px;
  margin-bottom: 11px;
}
.helpNum {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(111, 216, 239, 0.14);
  border: 1px solid rgba(111, 216, 239, 0.4);
  color: var(--cyan);
  font: 900 11px/1 var(--font);
}
.helpTxt { font-size: 12px; font-weight: 600; line-height: 1.55; color: var(--ink-3); padding-top: 1px; }
.helpTxt b { color: var(--ink); font-weight: 900; }
/* the closing notes must not end flush against the scroll edge, or the last
   line reads as clipped content instead of a scrollable panel */
#help .panelBody > :last-child { margin-bottom: 4px; }

/* ── toast ─────────────────────────────────────────────────────────── */

#toast {
  position: fixed;
  left: 50%;
  top: 16%;
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.toastItem {
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(8, 26, 36, 0.95);
  border: 1px solid var(--line-2);
  font: 800 11.5px/1 var(--font);
  letter-spacing: 0.05em;
  color: var(--ink);
  box-shadow: var(--shadow);
  animation: toastIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  white-space: nowrap;
}
.toastItem.good { border-color: rgba(255, 194, 71, 0.6); color: var(--gold); }
.toastItem.bad { border-color: rgba(255, 107, 107, 0.5); color: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }

/* ── responsive ────────────────────────────────────────────────────── */

@media (max-width: 560px) {
  #hudRight { top: 62px; right: 12px; flex-direction: row; gap: 6px; align-items: center; }
  .chip { padding: 7px 10px; font-size: 10.5px; letter-spacing: 0.04em; }
  .chip.icon { padding: 7px 10px; }
  #brand h1 { font-size: 18px; }
  #castInfo { bottom: 112px; left: 12px; }
  #prompt { bottom: 158px; font-size: 12px; }
  #actionBtn { padding: 13px 16px 11px; }
  #actionLabel { font-size: 12.5px; }
  .catchEmoji { font-size: 64px; }
  .catchName { font-size: 19px; }
  .panelBody { padding: 14px 16px 18px; }
  .panelHead { padding: 15px 16px 12px; }
  .codexGrid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
}

@media (max-height: 560px) {
  #castInfo { display: none; }
  #prompt { bottom: 128px; }
  #reelWrap, #powerWrap { bottom: 70px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important; }
}

/* focus visibility — the game is keyboard playable, so this matters */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
