/* TRENCH RIDER — CRT trading terminal × neon arcade */

:root {
  --bg: #060a08;
  --panel: #0b120e;
  --panel-2: #0e1713;
  --line: #1c2b23;
  --pump: #2bf57f;
  --pump-dim: #15824a;
  --dump: #ff3d5a;
  --gold: #ffc94d;
  --ink: #c9d8cf;
  --dim: #5d6f64;
  --glow-pump: 0 0 18px rgba(43, 245, 127, 0.45);
  --glow-gold: 0 0 22px rgba(255, 201, 77, 0.4);
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --disp: 'Bungee', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* The hidden attribute must ALWAYS win, even over display:flex classes. */
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none; /* iOS ignores the unprefixed prop — without this, hold-to-flip selects the page (blue) */
  -moz-user-select: none;
  -ms-user-select: none;
  touch-action: manipulation; /* no double-tap zoom / tap delay on UI */
  -webkit-touch-callout: none;
}
/* …but the wallet field must stay selectable/pasteable */
input, textarea { user-select: text; -webkit-user-select: text; }

#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }

/* CRT dressing */
.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 40; opacity: 0.5;
  background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(0, 0, 0, 0.16) 2px 4px);
}
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 41;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

/* ── Top bar ─────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 65; /* above overlay cards — always interactive */
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 18px;
  background: linear-gradient(180deg, rgba(6, 10, 8, 0.92), rgba(6, 10, 8, 0.55) 80%, transparent);
}
.brand { display: flex; align-items: baseline; gap: 6px; transform: skewX(-6deg); }
.brand-main { font-family: var(--disp); font-size: 26px; color: var(--pump); text-shadow: var(--glow-pump); letter-spacing: 1px; }
.brand-sub  { font-family: var(--disp); font-size: 26px; color: var(--ink); }
.brand-tag  { color: var(--dim); font-size: 11px; font-style: italic; margin-left: 8px; }
.brand-koth { display: none; } /* mobile-only short brand */

.pot { text-align: center; position: relative; }
.pot-label { font-size: 10px; letter-spacing: 3px; color: var(--dim); }
.pot-value {
  font-family: var(--disp); font-size: 30px; line-height: 1; color: var(--gold);
  text-shadow: var(--glow-gold);
}
.pot-value .pot-unit { font-size: 13px; margin-left: 6px; color: var(--dim); text-shadow: none; }
.pot-dry {
  position: absolute; top: -4px; right: -56px; font-size: 9px; letter-spacing: 1px;
  color: var(--bg); background: var(--gold); padding: 2px 6px; border-radius: 2px; transform: rotate(6deg);
}
.pot.bump .pot-value { animation: potbump 0.5s ease; }
@keyframes potbump { 30% { transform: scale(1.16); } }
.pot.jackpot .pot-label::after { content: ' ★ JACKPOT'; color: var(--dump); animation: blink 1s steps(2) infinite; }
.pot.jackpot .pot-value { animation: jackpotpulse 1.2s ease-in-out infinite; }
@keyframes jackpotpulse { 50% { text-shadow: 0 0 34px rgba(255, 201, 77, 0.95); transform: scale(1.05); } }

.right-cluster { display: flex; align-items: center; gap: 14px; }
.token-chip {
  display: flex; flex-direction: column; align-items: flex-end; gap: 1px;
  border: 1px solid var(--line); background: rgba(11, 18, 14, 0.85);
  padding: 5px 10px; border-radius: 4px;
}
.chip-riding { font-size: 8px; letter-spacing: 2.5px; color: var(--dump); animation: blink 1.4s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.chip-symbol { font-weight: 700; color: var(--pump); font-size: 15px; }
.chip-mint { color: var(--dim); font-size: 10px; text-decoration: none; }
.chip-mint:hover { color: var(--ink); }

.clock { font-family: var(--disp); font-size: 24px; color: var(--ink); min-width: 92px; text-align: center; }
.clock.hot { color: var(--dump); animation: blink 1s steps(2) infinite; }

.mute-btn {
  background: none; border: 1px solid var(--line); border-radius: 3px;
  font-size: 14px; padding: 7px 9px; cursor: pointer; line-height: 1;
}
.mute-btn:hover { border-color: var(--pump-dim); }

.wallet-btn {
  font-family: var(--mono); font-weight: 700; font-size: 12px; letter-spacing: 1px;
  color: var(--bg); background: var(--pump); border: none; border-radius: 3px;
  padding: 10px 16px; cursor: pointer; box-shadow: var(--glow-pump);
  transition: transform 0.12s ease, filter 0.12s ease;
}
.wallet-btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.wallet-btn.connected { background: var(--panel-2); color: var(--pump); border: 1px solid var(--pump-dim); box-shadow: none; }

/* ── Leaderboard rail ────────────────────────────── */
.rail {
  position: fixed; top: 76px; right: 14px; z-index: 65; width: 252px; /* above overlay cards — always interactive */
  background: rgba(11, 18, 14, 0.88); border: 1px solid var(--line); border-radius: 6px;
  backdrop-filter: blur(4px); overflow: hidden;
}
.rail-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; font-size: 11px; letter-spacing: 3px; color: var(--ink);
  border-bottom: 1px solid var(--line); background: var(--panel-2);
}
.rail-live { color: var(--dump); font-size: 9px; letter-spacing: 1px; animation: blink 1.6s steps(2) infinite; }
.board { list-style: none; max-height: 44vh; overflow-y: auto; }
.board li {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 7px 12px; font-size: 12px; border-bottom: 1px dashed rgba(28, 43, 35, 0.6);
}
.board li:nth-child(1) .b-rank { color: var(--gold); }
.board li.me { background: rgba(43, 245, 127, 0.07); }
.b-rank { color: var(--dim); width: 22px; }
.b-wallet { flex: 1; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.b-score { color: var(--pump); font-weight: 700; }
.board-empty { color: var(--dim); font-style: italic; font-size: 11px; }
.rail-foot { display: flex; gap: 4px; border-top: 1px solid var(--line); }
.link-btn {
  flex: 1; background: none; border: none; color: var(--dim); font-family: var(--mono);
  font-size: 9.5px; letter-spacing: 1px; padding: 8px 4px; cursor: pointer;
}
.link-btn:hover { color: var(--pump); }

/* ── HUD ─────────────────────────────────────────── */
.hud { position: fixed; left: 22px; top: 86px; z-index: 45; pointer-events: none; }
.hud-score { font-family: var(--disp); font-size: 44px; color: var(--ink); text-shadow: 0 0 14px rgba(201, 216, 207, 0.25); line-height: 1; }
.hud-score small { font-size: 14px; color: var(--dim); margin-left: 6px; }
.hud-row { display: flex; gap: 16px; margin-top: 6px; font-size: 12px; color: var(--dim); }
.hud-stat b { color: var(--ink); }
.hud-stat.combo b { color: var(--gold); }
.hud-stat.mcap b { color: var(--pump); }
.hud-best { margin-top: 8px; font-size: 11px; color: var(--dim); letter-spacing: 0.5px; }
.hud-best b { color: var(--gold); }

.controls-hint {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 45;
  color: var(--dim); font-size: 11.5px; letter-spacing: 0.5px;
  background: rgba(6, 10, 8, 0.7); padding: 8px 14px; border-radius: 4px; border: 1px solid var(--line);
}
.controls-hint b { color: var(--ink); }

/* ── Overlay cards ───────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
/* The dim backdrop must never swallow clicks — only the card is interactive. */
.overlay.active { background: rgba(4, 7, 5, 0.55); }
.overlay.active .card { pointer-events: auto; }
.card {
  display: none; text-align: center; min-width: 340px; max-width: 480px;
  background: rgba(9, 14, 11, 0.96); border: 1px solid var(--line); border-radius: 8px;
  padding: 30px 34px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: cardin 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.overlay.active .card { display: block; }
@keyframes cardin { from { transform: translateY(26px) scale(0.94); opacity: 0; } }

.card h1 { font-family: var(--disp); font-size: 34px; line-height: 1.05; margin-bottom: 6px; }
.card h1.green { color: var(--pump); text-shadow: var(--glow-pump); }
.card h1.red { color: var(--dump); text-shadow: 0 0 18px rgba(255, 61, 90, 0.45); }
.card h1.gold { color: var(--gold); text-shadow: var(--glow-gold); }
.card .sub { color: var(--dim); font-size: 12px; margin-bottom: 18px; }
.card .big-num { font-family: var(--disp); font-size: 52px; color: var(--ink); line-height: 1.1; }
.card .stat-row { display: flex; justify-content: center; gap: 26px; margin: 14px 0 4px; font-size: 12px; color: var(--dim); }
.card .stat-row b { color: var(--ink); display: block; font-size: 16px; }
.card .ca-row {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 12px 0 4px; padding: 8px 10px;
  background: rgba(14, 23, 19, 0.9); border: 1px solid var(--line); border-radius: 4px;
}
.card .ca-row .ca-label { font-size: 9px; letter-spacing: 2px; color: var(--dim); }
.card .ca-row code { font-size: 10.5px; color: var(--pump); word-break: break-all; text-align: left; }
.copy-btn {
  font-family: var(--mono); font-size: 9px; letter-spacing: 1px; flex-shrink: 0;
  color: var(--bg); background: var(--gold); border: none; border-radius: 3px;
  padding: 5px 8px; cursor: pointer;
}
.copy-btn:hover { filter: brightness(1.15); }
.card .howto {
  display: grid; grid-template-columns: 1fr 1fr; gap: 7px 16px;
  margin: 14px 0 2px; padding: 10px 12px; text-align: left;
  font-size: 11px; color: var(--dim); line-height: 1.5;
  background: rgba(14, 23, 19, 0.6); border: 1px solid var(--line); border-radius: 4px;
}
.card .howto b { color: var(--ink); }
@media (max-width: 760px) { .card .howto { grid-template-columns: 1fr; gap: 5px; } }
.card .links-row { font-size: 11px; color: var(--dim); margin-bottom: 4px; }
.card .links-row a { color: var(--pump); text-decoration: none; }
.card .links-row a:hover { text-decoration: underline; }
.card .links-row .how-btn { background: none; border: none; color: var(--gold); font-family: var(--mono); font-size: 11px; cursor: pointer; text-decoration: underline dotted; }
.card .verify-line { margin-top: 12px; font-size: 11px; color: var(--dim); }
.card .verify-line.ok { color: var(--pump); }
.card .verify-line.err { color: var(--dump); }
.card .hash { font-size: 9.5px; color: var(--dim); word-break: break-all; margin-top: 10px; }

.btn {
  font-family: var(--disp); font-size: 16px; letter-spacing: 1px; color: var(--bg);
  background: var(--pump); border: none; border-radius: 4px; padding: 13px 34px;
  margin-top: 18px; cursor: pointer; box-shadow: var(--glow-pump);
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:hover { transform: translateY(-2px) scale(1.02); filter: brightness(1.12); }
.btn.gold { background: var(--gold); box-shadow: var(--glow-gold); }
.btn.ghost { background: transparent; color: var(--dim); box-shadow: none; border: 1px solid var(--line); font-size: 12px; }

/* ── Modal ───────────────────────────────────────── */
.modal-back {
  position: fixed; inset: 0; z-index: 70; background: rgba(4, 7, 5, 0.7);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  position: relative; width: min(680px, 92vw); max-height: 78vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 26px 28px;
}
.modal h2 { font-family: var(--disp); font-size: 20px; color: var(--pump); margin-bottom: 12px; }
.modal p, .modal li { font-size: 12px; color: var(--ink); line-height: 1.7; }
.modal ol { padding-left: 18px; margin: 8px 0; }
.modal code { color: var(--gold); font-size: 11px; word-break: break-all; }
.modal table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.modal th, .modal td { text-align: left; font-size: 11px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.modal th { color: var(--dim); font-weight: 400; letter-spacing: 1px; }
.modal td a { color: var(--pump); text-decoration: none; }
.modal-x {
  position: absolute; top: 10px; right: 14px; background: none; border: none;
  color: var(--dim); font-size: 22px; cursor: pointer;
}
.modal-x:hover { color: var(--dump); }

/* ── Toast ───────────────────────────────────────── */
.toast {
  position: fixed; bottom: 64px; left: 50%; transform: translateX(-50%); z-index: 80;
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--dump);
  color: var(--ink); font-size: 12px; padding: 10px 16px; border-radius: 4px;
  animation: cardin 0.25s ease;
}

/* ── Mobile ──────────────────────────────────────── */
@media (max-width: 760px) {
  .brand-tag { display: none; }
  /* the full name wraps badly on phones — show the ticker instead */
  .brand-main, .brand-sub { display: none; }
  .brand-koth {
    display: inline; font-family: var(--disp); font-size: 20px;
    color: var(--pump); text-shadow: var(--glow-pump); white-space: nowrap;
  }
  .controls-hint {
    font-size: 10px; padding: 6px 10px; white-space: nowrap;
    bottom: calc(10px + env(safe-area-inset-bottom));
  }
  .brand-main, .brand-sub { font-size: 18px; }
  .pot-value { font-size: 22px; }
  .clock { font-size: 17px; min-width: 64px; }
  .rail { width: 200px; top: 64px; }
  /* mid-run the leaderboard covers half the track — get it out of the way */
  body.in-run .rail, body.in-run .controls-hint { display: none; }
  .hud-score { font-size: 30px; }
  .topbar { padding: 8px 10px; gap: 8px; }
  .wallet-btn { padding: 8px 10px; font-size: 10px; }
  .card { min-width: 0; width: calc(100vw - 28px); padding: 22px 18px; }
}
