:root {
  --bg: #0b0e1a;
  --bg-2: #111527;
  --bg-3: #1a2038;
  --bg-4: #232947;
  --line: #232947;
  --text: #e6e9f5;
  --text-dim: #8a90ad;
  --accent: #ff5a28;
  --accent-2: #ff9028;
  --green: #22c55e;
  --red: #ef4444;
  --blue: #3b82f6;
  --purple: #a855f7;
  --pink: #ec4899;
  --gold: #facc15;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; touch-action: manipulation; }
body {
  background:
    radial-gradient(1200px 600px at 50% -200px, #1a1330 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 100%, #201028 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* =========================================================
   INTRO SPLASH
   ========================================================= */
.intro {
  position: fixed; inset: 0; z-index: 9999;
  background: radial-gradient(ellipse at center, #1a0f2b 0%, #05070f 100%);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.5s, transform 0.5s;
}
.intro.hiding { opacity: 0; transform: scale(1.04); pointer-events: none; }
.intro-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(800px 400px at 50% 50%, rgba(255,90,40,0.15), transparent 60%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.015) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.015) 0 1px, transparent 1px 40px);
  animation: introGrid 20s linear infinite;
}
@keyframes introGrid {
  0% { background-position: 0 0, 0 0, 0 0; }
  100% { background-position: 0 0, 800px 0, 0 800px; }
}
.intro-content {
  position: relative;
  text-align: center;
  max-width: 440px;
  padding: 30px;
  animation: introFadeUp 0.8s ease-out;
}
@keyframes introFadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.intro-mark {
  font-size: 72px;
  color: var(--accent);
  filter: drop-shadow(0 0 30px var(--accent));
  transform: rotate(30deg);
  animation: introPulse 2.4s ease-in-out infinite;
}
@keyframes introPulse {
  0%,100% { filter: drop-shadow(0 0 20px var(--accent)); }
  50% { filter: drop-shadow(0 0 45px var(--accent-2)); }
}
.intro-title {
  font-size: clamp(36px, 8vw, 58px);
  letter-spacing: 0.14em;
  font-weight: 900;
  margin: 10px 0 6px;
  color: #fff;
  text-shadow: 0 2px 18px rgba(255,144,40,0.35);
  /* extra right padding so letter-spacing on the last glyph never clips */
  padding-right: 0.14em;
  white-space: nowrap;
  overflow: visible;
}
.intro-tag {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 0 28px;
  letter-spacing: 0.06em;
}
.intro-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}
.intro-stats > div {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 12px 8px;
}
.intro-stats b { display: block; font-size: 20px; color: var(--gold); }
.intro-stats span { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.intro-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  box-shadow: 0 10px 30px rgba(255,90,40,0.35);
  transition: transform 0.15s, filter 0.15s;
}
.intro-btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.intro-foot { margin-top: 16px; font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.1em; }

/* =========================================================
   TOP BAR
   ========================================================= */
.topbar {
  display: grid;
  grid-template-columns: 200px 1fr auto;
  align-items: center;
  padding: 10px 18px;
  background: linear-gradient(180deg, var(--bg-2), transparent);
  border-bottom: 1px solid var(--line);
  gap: 16px;
  flex: 0 0 auto;
}
.brand { display: flex; align-items: baseline; gap: 10px; font-weight: 800; letter-spacing: 0.18em; font-size: 17px; }
.brand-mark { color: var(--accent); font-size: 22px; filter: drop-shadow(0 0 8px var(--accent)); transform: rotate(30deg); align-self: center; }
.brand-sub { font-size: 9px; color: var(--text-dim); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
.admin-link { text-decoration: none; display: inline-block; margin-left: 8px; }
.history-wrap { display: flex; align-items: center; min-width: 0; }
.history { display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.history::-webkit-scrollbar { display: none; }
.hist-chip {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 14px;
  background: var(--bg-3);
  white-space: nowrap;
  border: 1px solid transparent;
}
.hist-chip.low  { color: #6ee7ff; border-color: #1e3a5f; }
.hist-chip.mid  { color: #c084fc; border-color: #3b1f5a; }
.hist-chip.high { color: #fb7185; border-color: #5a1e3a; }
.hist-chip.huge { color: var(--gold); border-color: #5a4a1e; box-shadow: 0 0 8px rgba(250,204,21,0.3); }

.top-right { display: flex; align-items: center; gap: 12px; }
.icon-btn {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 8px;
  font-size: 16px;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--bg-4); }
.icon-btn.muted { opacity: 0.4; }

.balance { text-align: right; }
.balance-label { color: var(--text-dim); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; }
.balance-val { font-size: 18px; font-weight: 800; color: var(--gold); }
.balance-val small { color: var(--text-dim); font-size: 10px; font-weight: 600; }

/* =========================================================
   MAIN LAYOUT
   ========================================================= */
.layout {
  flex: 1;
  display: grid;
  /* [ sidecol | bet1col | stage | bet2col ] — bets flank the stage */
  grid-template-columns: 240px 210px 1fr 210px;
  gap: 12px;
  padding: 12px;
  min-height: 0;
}
.layout > * { min-height: 0; min-width: 0; }

/* Individual bet columns — each holds a single betpanel that fills it */
.betcol.bet1col, .betcol.bet2col {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
.betcol.bet1col .betpanel, .betcol.bet2col .betpanel { flex: 0 0 auto; }

/* ========== Side column (bets/chat tabs) ========== */
.sidecol {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidetabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.sidetab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 12px 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.sidetab.active { color: var(--text); border-bottom-color: var(--accent); }
.sidetab .count {
  display: inline-block;
  background: var(--bg-3);
  color: var(--text);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  margin-left: 4px;
}
.sidepanel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidepanel[hidden] { display: none; }

.livebets-head, .livebets-row {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 0.7fr 0.9fr;
  gap: 6px;
  padding: 8px 14px;
  font-size: 12px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}
.livebets-head {
  color: var(--text-dim);
  border-bottom: 1px solid var(--line);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.08em;
  flex: 0 0 auto;
}
.livebets-list {
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.livebets-row {
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.2s;
}
.livebets-row.cashed { background: rgba(34,197,94,0.1); }
.livebets-row.lost { opacity: 0.42; }
.livebets-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.livebets-row .name.you { color: var(--gold); font-weight: 700; }
.livebets-row .mult.cashed { color: var(--green); font-weight: 700; }
.livebets-row .win.cashed { color: var(--green); font-weight: 700; }
.livebets-row .win.lost { color: var(--red); }

/* ========== Chat panel ========== */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.chat-msg {
  font-size: 12px;
  padding: 6px 10px;
  background: var(--bg-3);
  border-radius: 12px;
  max-width: 90%;
  word-break: break-word;
  animation: chatIn 0.25s ease-out;
}
@keyframes chatIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.chat-msg .who { font-weight: 700; color: var(--accent-2); margin-right: 6px; font-size: 11px; }
.chat-msg.self { background: rgba(255,90,40,0.14); align-self: flex-end; border: 1px solid rgba(255,90,40,0.3); }
.chat-msg.self .who { color: var(--gold); }
.chat-msg.sys { background: transparent; color: var(--text-dim); font-style: italic; font-size: 11px; text-align: center; align-self: center; }
.chat-form {
  display: flex;
  padding: 8px;
  gap: 6px;
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
}
.chat-form input {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 12px;
  outline: none;
}
.chat-form input:focus { border-color: var(--accent); }
.chat-form button {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 12px;
}

/* ========== Stage ==========
   The stage is divided into fixed vertical slots so overlays never overlap:
     10%  status / debrief
     20%  destination HUD
     40%  multiplier display (center, the star)
     62%  win preview + dest callout (same row, mutually exclusive)
     74%  countdown bar (betting only)
     88%  preflight info (betting only) or flight plan badge
     bottom-right  round id
*/
.stage {
  position: relative;
  background:
    radial-gradient(800px 400px at 50% 100%, rgba(255,90,40,0.08), transparent 60%),
    linear-gradient(180deg, #0a0d1a 0%, #0f0818 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  min-height: 0;
}
#canvas { width: 100%; height: 100%; display: block; }
.stage-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.mult-display {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(44px, 9vw, 108px);
  font-weight: 900;
  letter-spacing: -0.03em;
  color: #fff;
  text-shadow: 0 0 40px rgba(255,90,40,0.4);
  font-variant-numeric: tabular-nums;
  transition: color 0.15s;
  white-space: nowrap;
}
.mult-display span { font-size: 0.55em; color: var(--text-dim); font-weight: 700; }
.mult-display.crashed {
  color: var(--red);
  text-shadow: 0 0 60px rgba(239,68,68,0.7);
  animation: crashShake 0.5s ease-in-out;
}
@keyframes crashShake {
  0%,100% { transform: translateX(0) scale(1); }
  15% { transform: translateX(-8px) scale(1.04); }
  30% { transform: translateX(8px) scale(1.04); }
  45% { transform: translateX(-6px) scale(1.02); }
  60% { transform: translateX(6px) scale(1.02); }
  80% { transform: translateX(-2px) scale(1.01); }
}
.status {
  position: absolute;
  left: 50%;
  top: 8%;
  transform: translateX(-50%);
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status.crashed { color: var(--red); font-weight: 800; font-size: 16px; letter-spacing: 0.2em; }
.round-id { position: absolute; bottom: 10px; right: 14px; color: var(--text-dim); font-size: 10px; font-variant-numeric: tabular-nums; opacity: 0.6; }

/* Round stats pill — bottom-right of stage. Live count + total bet amount. */
.round-stats {
  position: absolute;
  bottom: 10px;
  right: 14px;
  background: rgba(10,13,26,0.72);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 6px 12px;
  text-align: right;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  min-width: 120px;
}
.round-stats .rs-head {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}
.round-stats .rs-body {
  display: flex;
  gap: 6px;
  align-items: baseline;
  justify-content: flex-end;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text);
}
.round-stats .rs-count b {
  color: var(--accent-2);
  font-weight: 800;
  font-size: 13px;
  transition: color 0.2s;
}
.round-stats .rs-count b.bump { color: var(--gold); }
.round-stats .rs-total b {
  color: var(--gold);
  font-weight: 800;
  font-size: 13px;
}
.round-stats .rs-sep { color: var(--text-dim); opacity: 0.6; }

.countdown-bar {
  position: absolute;
  left: 50%; top: 74%;
  transform: translateX(-50%);
  width: 260px;
  max-width: 70%;
  height: 5px;
  background: var(--bg-3);
  border-radius: 4px;
  overflow: hidden;
}
.countdown-bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.1s linear;
}

/* Float-up text (cashout confirmation) */
.floater {
  position: absolute;
  pointer-events: none;
  font-weight: 800;
  color: var(--green);
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  animation: floatUp 1.6s ease-out forwards;
  font-size: 18px;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 0); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60px); }
}

/* Cashout floater — small pill slide-in at the top edge of the stage */
.cashout-float {
  position: absolute;
  transform: translate(-50%, 0);
  pointer-events: none;
  padding: 8px 16px;
  background: linear-gradient(180deg, rgba(34,197,94,0.95), rgba(22,163,74,0.95));
  color: #fff;
  border-radius: 100px;
  box-shadow: 0 6px 22px rgba(34,197,94,0.4), 0 0 0 1px rgba(255,255,255,0.15) inset;
  text-align: center;
  display: flex;
  gap: 8px;
  align-items: baseline;
  animation: cashFloat 2.2s cubic-bezier(.22,.9,.3,1) forwards;
  z-index: 20;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(6px);
  top: 28% !important;
}
.cashout-float .cf-head {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.85;
}
.cashout-float .cf-mult {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.01em;
}
.cashout-float .cf-win {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
}
.cashout-float .cf-tag { display: none; }
@keyframes cashFloat {
  0%   { opacity: 0; transform: translate(-50%, -16px) scale(0.9); }
  12%  { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  22%  { transform: translate(-50%, 0) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -30px) scale(0.95); }
}

/* ========== Bet column ========== */
.betcol {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.betpanel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
}
.betpanel.active { border-color: rgba(255,90,40,0.4); }
.betpanel.cashed { border-color: rgba(34,197,94,0.5); box-shadow: 0 0 20px rgba(34,197,94,0.15); }
.betpanel[data-cashed-badge]::before {
  content: attr(data-cashed-badge);
  display: block;
  margin: 0 0 6px 0;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  background: rgba(34,197,94,0.15);
  color: var(--green);
  border: 1px solid rgba(34,197,94,0.35);
  font-variant-numeric: tabular-nums;
}
.betpanel[data-cashed-badge*="LOST"]::before {
  background: rgba(239,68,68,0.15);
  color: var(--red);
  border-color: rgba(239,68,68,0.35);
}
.panel-title {
  padding: 2px 0 4px 0;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
}
.panel-hint { color: var(--text-dim); font-size: 10px; font-weight: 500; }

.stake-row {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  gap: 6px;
  align-items: stretch;
}
.stake-row input,
.auto-row input.target {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-weight: 700;
  text-align: center;
  font-size: 15px;
  outline: none;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.stake-row input:focus, .auto-row input.target:focus { border-color: var(--accent); }

/* ---- Build-version chip (shown in each game's footer) ---- */
.demo-badge[hidden] { display: none; }
.demo-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  margin-left: 4px;
  border-radius: 8px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  animation: demo-pulse 2s ease-in-out infinite;
}
@keyframes demo-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.build-chip {
  display: inline-block;
  padding: 3px 8px;
  margin-left: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted, #8a90ad);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  vertical-align: middle;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  user-select: text;  /* let support copy it */
}

/* ---- Bet error toast ---- */
.bet-error-toast {
  position: absolute;
  top: 60px; left: 50%;
  transform: translate(-50%, -20px);
  display: flex; align-items: center; gap: 12px;
  min-width: 260px; max-width: 420px;
  padding: 14px 20px 14px 16px;
  background: linear-gradient(135deg, #2a0e12 0%, #3d1318 100%);
  border: 1px solid rgba(255, 86, 86, 0.6);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 86, 86, 0.2);
  color: #ffd7d7;
  font-size: 13px; font-weight: 500; line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  z-index: 9500;
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2), opacity 0.2s;
}
.bet-error-toast.show { opacity: 1; transform: translate(-50%, 0); }
.bet-error-toast .bet-error-icon {
  flex-shrink: 0;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255, 86, 86, 0.22);
  color: #ff5656;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800;
}
.bet-error-toast .bet-error-body { flex: 1; min-width: 0; }
.bet-error-toast .bet-error-title {
  font-size: 12px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: #ff5656;
  margin-bottom: 2px;
}
.bet-error-toast .bet-error-msg { color: #ffd7d7; word-break: break-word; }
.err-flash { color: #ff7070 !important; font-weight: 700; animation: err-pulse 0.5s ease; }
@keyframes err-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

#walletFatalOverlay {
  position: fixed; inset: 0;
  background: rgba(6, 10, 18, 0.92);
  backdrop-filter: blur(6px);
  z-index: 99999;
  display: none;
  align-items: center; justify-content: center;
  font-family: inherit;
}
#walletFatalOverlay.show { display: flex; }
#walletFatalOverlay .wf-card {
  max-width: 420px;
  margin: 24px;
  padding: 32px 28px;
  background: #12172a;
  border: 1px solid rgba(255, 86, 86, 0.4);
  border-radius: 14px;
  text-align: center;
  color: #e5eaf4;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
#walletFatalOverlay .wf-icon {
  font-size: 48px; color: #ff5656; margin-bottom: 8px;
}
#walletFatalOverlay h2 { margin: 4px 0 14px; font-size: 22px; }
#walletFatalOverlay .wf-msg {
  color: #ffb2b2; font-weight: 700; margin: 8px 0 14px; font-size: 13px;
  word-break: break-word;
}
#walletFatalOverlay .wf-help {
  color: #9aa0a6; font-size: 13px; line-height: 1.5; margin: 0 0 20px;
}
#walletFatalOverlay .wf-close {
  background: #ff5656; color: #0b0f1a; border: 0;
  padding: 10px 28px; border-radius: 8px;
  font-weight: 800; font-size: 14px; cursor: pointer;
}
body.wallet-blocked { pointer-events: none; }
body.wallet-blocked #walletFatalOverlay { pointer-events: auto; }

.stake-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
  min-width: 0;
}
.stake-wrap input {
  flex: 1;
  padding-right: 34px !important;
  width: 100%;
}
.stake-unit {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted, #9aa0a6);
  letter-spacing: 0.02em;
  pointer-events: none;
  text-transform: uppercase;
}
.qbtn {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  transition: background 0.15s;
}
.qbtn:hover { background: var(--bg-4); }
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.chips.chips-set { grid-template-columns: repeat(3, 1fr); }
.chips button {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 0;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  transition: all 0.15s;
}
.chips button:hover { color: var(--text); border-color: var(--accent); }
/* Quick-set chips — distinct gold styling so they're obviously different */
.chips.chips-set button {
  color: var(--gold);
  border-color: rgba(250,204,21,0.25);
  font-weight: 800;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.chips.chips-set button:hover {
  background: rgba(250,204,21,0.1);
  color: var(--gold);
  border-color: var(--gold);
}
.auto-row {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 8px;
  align-items: center;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
}
.toggle input { accent-color: var(--accent); }

/* Advanced auto-bet */
.advanced { font-size: 11px; }
.advanced summary {
  list-style: none;
  color: var(--text-dim);
  padding: 6px 0;
  cursor: pointer;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  user-select: none;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary:hover { color: var(--text); }
.advanced-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
  padding-bottom: 2px;
}
.advanced-body input[type=number], .advanced-body select {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text);
  width: 100%;
  outline: none;
  font-size: 12px;
}
.advanced-body input[type=number]:focus, .advanced-body select:focus { border-color: var(--accent); }
.advanced-body .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.advanced-body .grid2 label { display: flex; flex-direction: column; gap: 3px; font-size: 10px; color: var(--text-dim); text-transform: uppercase; }

.action {
  padding: 15px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: filter 0.1s, transform 0.08s;
  color: #fff;
  margin-top: 4px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: auto !important;
  cursor: pointer;
}
.action:active { transform: scale(0.98); }
.action[disabled], .action:disabled { pointer-events: auto !important; opacity: 1 !important; cursor: pointer !important; }
/* Inner children never intercept clicks — entire button area triggers the handler */
.action > *, .action br, .action span, .action small { pointer-events: none; }
.action { min-height: 56px; }
.action.btn-bet {
  background: linear-gradient(180deg, #22c55e, #16a34a);
  box-shadow: 0 4px 14px rgba(34,197,94,0.3);
}
.action.btn-bet:hover { filter: brightness(1.1); }
.action.btn-bet.pending {
  background: linear-gradient(180deg, #6b7280, #4b5563);
  box-shadow: none;
}
.action.btn-cashout {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 4px 14px rgba(255,90,40,0.4);
  animation: pulse 1.2s ease-in-out infinite;
}
.action.btn-cashout:hover { filter: brightness(1.1); }
.action.btn-cashout .cash-mult { font-variant-numeric: tabular-nums; font-size: 11px; opacity: 0.9; }
.action .cash-amt { display: inline-block; font-size: 14px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.action.btn-cashout .cash-amt { color: #fff; }
.action.btn-cashed .cash-amt { color: #111; font-size: 13px; }
.action.btn-lost .cash-amt { font-size: 12px; }
.action.btn-cancel { background: linear-gradient(180deg, #ef4444, #dc2626); }
.action.btn-cashed {
  background: linear-gradient(180deg, #facc15, #ca8a04);
  color: #111;
  box-shadow: 0 4px 14px rgba(250,204,21,0.3);
}
.action.btn-lost { background: linear-gradient(180deg, #4b5563, #374151); opacity: 0.7; }
/* button never disabled — any state is clickable */
@keyframes pulse {
  0%,100% { box-shadow: 0 4px 14px rgba(255,90,40,0.4); }
  50% { box-shadow: 0 4px 24px rgba(255,90,40,0.7); }
}

/* =========================================================
   Mobile bottom tabs (hidden on desktop)
   ========================================================= */
.mobile-tabs {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  z-index: 100;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.mobile-tabs button {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 10px 4px;
  font-size: 11px;
  font-weight: 700;
}
.mobile-tabs button.active { color: var(--accent-2); }

/* =========================================================
   Stats modal
   ========================================================= */
.modal {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(5,7,15,0.82);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
  padding: 20px;
  animation: modalFade 0.2s;
}
.modal[hidden] { display: none; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 18px; letter-spacing: 0.06em; }
.modal-close {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  width: 34px; height: 34px;
  border-radius: 8px;
  font-size: 20px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.stat {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.stat label { display: block; font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 2px; }
.stat b { font-size: 18px; font-variant-numeric: tabular-nums; }
.stat b.pos { color: var(--green); }
.stat b.neg { color: var(--red); }
.stats-chart-wrap {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
}
.chart-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
#balanceChart { width: 100%; height: 120px; display: block; }
.modal-btn {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
}
.modal-btn:hover { background: var(--bg-4); }

/* =========================================================
   Fair footer
   ========================================================= */
.fair { flex: 0 0 auto; padding: 0 12px 10px 12px; }
.fair-btn {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
}
.fair-btn:hover { color: var(--text); border-color: var(--accent); }
.fair-panel {
  margin-top: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 12px;
}
.fair-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 20px; }
.fair-grid b { color: var(--text-dim); font-size: 10px; display: block; margin-bottom: 2px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.fair-grid code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 10px;
  color: var(--text);
  word-break: break-all;
  display: block;
}
.fair-note { margin: 14px 0 0 0; color: var(--text-dim); font-size: 11px; line-height: 1.6; }
.fair-note code { background: var(--bg-3); padding: 1px 5px; border-radius: 3px; font-family: ui-monospace, monospace; font-size: 11px; color: var(--accent-2); }
.fair-links {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--line);
}
.fair-links a {
  display: inline-block; padding: 6px 10px; border-radius: 6px;
  background: var(--bg-3); border: 1px solid var(--line);
  color: var(--accent-2); text-decoration: none;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  transition: background .15s, color .15s;
}
.fair-links a:hover { background: var(--bg-4); color: var(--accent); }
.fair-links a[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }

/* =========================================================
   RESPONSIVE — tablet
   ========================================================= */
@media (max-width: 1240px) {
  /* Drop sidecol (becomes an overlay), keep bet1 | stage | bet2 */
  .layout { grid-template-columns: 200px 1fr 200px; gap: 10px; padding: 10px; }
  .sidecol {
    position: fixed;
    top: 64px;
    left: 10px;
    bottom: 64px;
    width: 280px;
    z-index: 50;
    display: none;
  }
  .sidecol.mobile-show { display: flex; }
  .mobile-tabs { display: flex; }
  .topbar { grid-template-columns: auto 1fr auto; padding: 8px 14px; }
  .brand-text { display: none; }
}

/* =========================================================
   RESPONSIVE — mobile (portrait)
   ========================================================= */
/* =========================================================
   MOBILE BETS STRIP — compact live-bets list below the bet panels
   Hidden on desktop; shown as grid row 3 on narrow screens.
   ========================================================= */
.mobile-bets-strip {
  display: none;
}

/* =========================================================
   RESPONSIVE — tablet
   ========================================================= */
@media (max-width: 960px) {
  .layout { grid-template-columns: 220px 1fr 260px; gap: 8px; padding: 8px; }
  .betpanel { padding: 10px; }
  .advanced { display: none; }
}

/* =========================================================
   RESPONSIVE — mobile (portrait)
   ========================================================= */
@media (max-width: 820px) {
  body {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
  }
  .topbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    padding: 8px 10px;
    gap: 8px;
    align-items: center;
  }
  .brand { gap: 6px; font-size: 14px; }
  .brand-text, .brand-sub { display: none; }
  .brand-mark { font-size: 20px; }
  .balance-label { display: none; }
  .balance-val { font-size: 13px; }
  .balance-val small { display: none; }
  .top-right { gap: 6px; }
  .icon-btn { width: 30px; height: 30px; font-size: 13px; }
  .history { gap: 4px; min-width: 0; overflow-x: auto; }
  .history::-webkit-scrollbar { display: none; }
  .hist-chip { padding: 4px 8px; font-size: 10px; flex: 0 0 auto; }

  .layout {
    grid-template-columns: 1fr 1fr;
    /* Row 1: stage (fills), Row 2: bet panels, Row 3: live bets strip */
    grid-template-rows: minmax(180px, 1fr) auto minmax(90px, 130px);
    padding: 6px;
    gap: 6px;
    overflow: hidden;
    padding-bottom: 58px; /* mobile tab bar */
  }

  /* Stage spans full width on top row */
  .stage {
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 200px;
    height: 100%;
    align-self: stretch;
  }
  /* Bets flank in bottom row */
  .betcol.bet1col { grid-column: 1; grid-row: 2; }
  .betcol.bet2col { grid-column: 2; grid-row: 2; }

  /* Mobile stage overlay tuning — smaller text, tighter slots */
  .mult-display { font-size: clamp(42px, 13vw, 64px); }
  .status { top: 6px; font-size: 9px; }
  .status.crashed { font-size: 13px; }
  .round-id { font-size: 9px; bottom: 6px; right: 10px; }
  .round-stats {
    bottom: 4px;
    right: 4px;
    padding: 3px 7px;
    min-width: 0;
    border-radius: 6px;
    background: rgba(10,13,26,0.6);
  }
  .round-stats .rs-head { font-size: 6px; }
  .round-stats .rs-body { font-size: 8px; gap: 3px; margin-top: 1px; }
  .round-stats .rs-count b, .round-stats .rs-total b { font-size: 10px; }
  .dest-hud {
    top: 24px;
    padding: 4px 10px;
    gap: 6px;
    border-radius: 100px;
  }
  .dest-hud .dest-label { font-size: 6px; }
  .dest-hud .dest-name { font-size: 10px; }
  .dest-hud .dest-distance { font-size: 9px; }
  .dest-hud::before { font-size: 10px; }
  .preflight { top: 84%; padding: 5px 10px; gap: 8px; border-radius: 8px; }
  .preflight-row .pf-label { font-size: 7px; }
  .preflight-row .pf-val { font-size: 10px; }
  .debrief {
    top: 78%;
    padding: 5px 10px;
    gap: 6px;
    border-radius: 8px;
    max-width: calc(100% - 20px);
    white-space: nowrap;
    overflow: hidden;
  }
  .debrief-head { font-size: 8px; }
  .debrief-dest { font-size: 9px; }
  .debrief-mult { font-size: 13px; }
  .debrief-detail { display: none; }  /* saved for desktop */
  .callout-name { font-size: 14px; }
  .callout-desc { font-size: 9px; }
  .countdown-bar { top: 72%; width: 180px; }

  /* Toasts — move inside stage area */
  .mission-toast, .title-toast {
    top: 64px;
    right: 10px;
    left: 10px;
    max-width: none;
    padding: 8px 12px;
  }
  .title-toast { top: 120px; }
  .mt-icon, .tt-icon { width: 30px; height: 30px; font-size: 16px; }
  .mt-head, .tt-head { font-size: 8px; }
  .mt-name, .tt-name { font-size: 12px; }

  /* Mobile-only live bets strip below bet panels */
  .mobile-bets-strip {
    display: flex;
    flex-direction: column;
    grid-column: 1 / -1;
    grid-row: 3;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    min-height: 0;
  }
  .mbs-head {
    display: grid;
    grid-template-columns: 1.4fr 0.9fr 0.7fr 0.9fr;
    gap: 6px;
    padding: 5px 10px;
    font-size: 8px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 800;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
  }
  .mbs-head span:nth-child(2),
  .mbs-head span:nth-child(3),
  .mbs-head span:nth-child(4) { text-align: right; }
  .mbs-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
  }
  .mbs-row {
    display: grid;
    grid-template-columns: 1.4fr 0.9fr 0.7fr 0.9fr;
    gap: 6px;
    padding: 4px 10px;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    align-items: baseline;
  }
  .mbs-row .mbs-user {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mbs-row .mbs-bet,
  .mbs-row .mbs-at,
  .mbs-row .mbs-win { text-align: right; }
  .mbs-row.you .mbs-user { color: var(--gold); font-weight: 800; }
  .mbs-row.you { background: rgba(250,204,21,0.04); }
  .mbs-row.cashed { background: rgba(34,197,94,0.06); }
  .mbs-row.cashed .mbs-at,
  .mbs-row.cashed .mbs-win { color: var(--green); font-weight: 700; }
  .mbs-row.lost { opacity: 0.45; }
  .mbs-row.lost .mbs-win { color: var(--red); }

  /* Bet columns on mobile — the action button ALWAYS wins the space fight.
     Panel is a column flex; chips/advanced hidden; action pushed to bottom. */
  .betcol { overflow: visible; min-height: 0; }
  .betpanel {
    flex: 1 1 0;
    padding: 8px;
    gap: 6px;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .betpanel .panel-title { padding: 0 0 2px; }
  .betpanel .panel-title span:first-child { font-size: 11px; }
  .betpanel .panel-hint { font-size: 9px; }
  .stake-row { grid-template-columns: 30px 1fr 30px; gap: 4px; }
  .stake-row input { font-size: 13px; padding: 7px 3px; }
  .qbtn { font-size: 12px; padding: 0; }
  /* Hide the increment chip row on mobile — +/- buttons cover the same need.
     Keep the quick-set row (500/1000/2000) since it sets bigger amounts fast. */
  .betpanel .chips:not(.chips-set) { display: none; }
  .betpanel .chips.chips-set {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
  }
  .betpanel .chips.chips-set button {
    padding: 5px 0;
    font-size: 10px;
  }
  .auto-row { grid-template-columns: 1fr 58px; gap: 5px; }
  .auto-row .toggle { font-size: 10px; }
  .auto-row .toggle span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .auto-row input.target { font-size: 12px; padding: 6px 2px; }
  .advanced { display: none; }
  /* Action button is always at the bottom and always visible */
  .action {
    margin-top: auto;
    padding: 12px 6px;
    font-size: 12px;
    flex-shrink: 0;
  }
  .action .cash-amt { font-size: 11px; }
  .action .cash-mult { font-size: 9px; }
  /* Cashed badge shrinks */
  .betpanel[data-cashed-badge]::before {
    font-size: 9px;
    padding: 3px 6px;
    margin-bottom: 3px;
  }

  /* Side column — full overlay on mobile */
  .sidecol {
    position: fixed;
    inset: 54px 8px 62px 8px;
    width: auto;
    z-index: 50;
    display: none;
  }
  .sidecol.mobile-show { display: flex; }

  .mobile-tabs { display: flex; }
  .fair { display: none; }
}

/* =========================================================
   RESPONSIVE — small phone
   ========================================================= */
@media (max-width: 480px) {
  .topbar { padding: 6px 8px; gap: 6px; }
  .hist-chip { padding: 3px 7px; font-size: 9px; }
  .balance-val { font-size: 12px; }
  .icon-btn { width: 28px; height: 28px; font-size: 12px; }

  .stage { min-height: 180px; }
  .mult-display { font-size: 40px; }
  .dest-hud {
    top: 18px;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 100px;
  }
  .dest-hud .dest-label { font-size: 6px; }
  .dest-hud .dest-name { font-size: 9px; }
  .dest-hud .dest-distance { font-size: 8px; }
  .preflight { display: none; }  /* keep the stage clean on tiny phones */
  .status { top: 4px; font-size: 8px; }

  /* Bet panels stay in grid cols (set by main mobile rule); compact them */
  .betpanel { padding: 8px 6px; gap: 5px; }
  .betpanel .panel-title { padding: 0; }
  .betpanel .panel-title span:first-child { font-size: 10px; }
  .betpanel .panel-hint { display: none; }
  .stake-row { grid-template-columns: 26px 1fr 26px; gap: 3px; }
  .stake-row input { font-size: 11px; padding: 7px 2px; }
  .qbtn { font-size: 10px; }
  .chips { grid-template-columns: repeat(2, 1fr); gap: 3px; }
  .chips button { font-size: 9px; padding: 4px 0; }
  .auto-row { grid-template-columns: 1fr 48px; gap: 4px; }
  .auto-row .toggle { font-size: 9px; gap: 3px; }
  .auto-row input.target { font-size: 10px; padding: 6px 2px; }
  .action { padding: 10px 4px; font-size: 10px; }
  .action .cash-amt { font-size: 10px; }
  .action .cash-mult { font-size: 8px; }

  .intro-title { font-size: 40px; }
  .intro-mark { font-size: 50px; }
  .intro-content { padding: 16px; }
  .intro-stats b { font-size: 16px; }
  .intro-tag { font-size: 12px; }
  .chips button { font-size: 9px; padding: 4px 0; }
}

/* =========================================================
   RESPONSIVE — landscape phone (short height)
   ========================================================= */
@media (max-height: 520px) and (max-width: 900px) {
  .mult-display { font-size: 40px; }
  .preflight, .debrief { top: 82%; }
  .dest-hud { top: 14%; padding: 4px 10px; }
}

/* =========================================================
   CREATIVE LAYER — destinations, pilot, rituals, flight plan
   ========================================================= */

/* Destination HUD — single compact horizontal pill at the top edge of the stage */
.dest-hud {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(10,13,26,0.72);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 100px;
  padding: 6px 14px;
  pointer-events: none;
  z-index: 5;
  font-variant-numeric: tabular-nums;
  max-width: 92%;
  white-space: nowrap;
}
.dest-hud .dest-current,
.dest-hud .dest-next {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}
.dest-hud .dest-label {
  font-size: 8px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}
.dest-hud .dest-name {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.dest-hud .dest-current .dest-name { color: var(--accent-2); }
.dest-hud .dest-distance {
  font-size: 10px;
  color: var(--text-dim);
}
.dest-hud::before {
  content: "→";
  color: var(--text-dim);
  font-size: 12px;
  opacity: 0.5;
  order: 1;
}
/* Order items so the arrow sits between current and next */
.dest-hud .dest-current { order: 0; }
.dest-hud .dest-next    { order: 2; }

/* Destination callout — brief whisper just below the multiplier */
.dest-callout {
  position: absolute;
  top: 68%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  z-index: 10;
  transition: opacity 0.3s ease-out;
  max-width: 90%;
}
.dest-callout.show {
  opacity: 1;
  animation: calloutIn 0.4s cubic-bezier(.22,.9,.3,1);
}
@keyframes calloutIn {
  from { opacity: 0; transform: translate(-50%, 10px) scale(0.92); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
.callout-line {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.22em;
}
.callout-name {
  font-size: clamp(16px, 3vw, 22px);
  font-weight: 900;
  letter-spacing: 0.05em;
  margin: 2px 0;
  color: #fff;
  text-shadow: 0 0 20px rgba(255,144,40,0.6);
}
.callout-desc {
  font-size: 10px;
  color: var(--text-dim);
  font-style: italic;
}

/* Pre-flight briefing panel — bottom slot during betting window */
.preflight {
  position: absolute;
  left: 50%;
  top: 86%;
  transform: translate(-50%, -50%);
  background: rgba(10,13,26,0.75);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 6px 14px;
  display: flex;
  gap: 14px;
  pointer-events: none;
  z-index: 4;
  animation: preflightIn 0.4s ease-out;
  max-width: 92%;
  white-space: nowrap;
  overflow: hidden;
}
.preflight[hidden] { display: none; }
.debrief[hidden] { display: none; }
.dest-callout[hidden] { display: none; }
.dest-hud[hidden] { display: none; }
.dawn-overlay[hidden] { display: none; }
.mission-toast[hidden], .title-toast[hidden] { display: none; }
@keyframes preflightIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.preflight-row {
  display: flex;
  gap: 6px;
  font-size: 10px;
  align-items: baseline;
}
.preflight-row .pf-label {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 8px;
}
.preflight-row .pf-val {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

/* Debrief card — shown after crash, bottom slot so it never overlays the mult */
.debrief {
  position: absolute;
  left: 50%;
  top: 84%;
  transform: translate(-50%, -50%);
  background: rgba(10,13,26,0.9);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 18px;
  text-align: center;
  z-index: 6;
  display: flex;
  gap: 14px;
  align-items: baseline;
  max-width: 92%;
  opacity: 0;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.debrief.show {
  opacity: 1;
  animation: debriefIn 0.45s cubic-bezier(.22,.9,.3,1);
}
@keyframes debriefIn {
  from { opacity: 0; transform: translate(-50%, 20px) scale(0.9); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
.debrief.success { border-color: rgba(34,197,94,0.4); box-shadow: 0 6px 22px rgba(34,197,94,0.18); }
.debrief.failure { border-color: rgba(239,68,68,0.4); box-shadow: 0 6px 22px rgba(239,68,68,0.15); }
.debrief.witness { border-color: rgba(138,144,173,0.25); }
.debrief-head {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-weight: 800;
}
.debrief.success .debrief-head { color: var(--green); }
.debrief.failure .debrief-head { color: var(--red); }
.debrief-dest {
  font-size: 11px;
  color: var(--text-dim);
}
.debrief-mult {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #fff;
}
.debrief.success .debrief-mult { color: var(--green); }
.debrief.failure .debrief-mult { color: var(--red); }
.debrief-detail {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Landing cinematic — full-screen */
.landing {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: radial-gradient(ellipse at center, #0b2a3a 0%, #020308 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s;
}
.landing[hidden] { display: none; }
.landing.show {
  opacity: 1;
  pointer-events: auto;
}
.land-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(500px 200px at 50% 80%, rgba(255,144,40,0.18), transparent 70%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.015) 0 1px, transparent 1px 48px);
  animation: landHorizon 30s linear infinite;
}
@keyframes landHorizon { from { background-position: 0 0, 0 0; } to { background-position: 0 0, 0 500px; } }
.land-content {
  position: relative;
  max-width: 440px;
  text-align: center;
  padding: 40px 30px;
  animation: landRise 1.2s cubic-bezier(.22,.9,.3,1);
}
@keyframes landRise {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}
.land-icon {
  font-size: 56px;
  color: var(--accent-2);
  filter: drop-shadow(0 0 30px var(--accent));
  margin-bottom: 10px;
  animation: landDescend 2s ease-out;
  display: inline-block;
  transform-origin: center;
}
@keyframes landDescend {
  0%   { transform: translateY(-200px) rotate(-12deg) scale(0.6); opacity: 0; }
  40%  { opacity: 1; }
  70%  { transform: translateY(12px) rotate(0) scale(1); }
  100% { transform: translateY(0); }
}
.landing h1 {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.06em;
  margin: 10px 0 4px;
}
.land-sub {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 0 26px;
}
.land-sub span { color: var(--gold); font-weight: 700; }
.land-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 10px 0 24px;
}
.land-summary > div {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 12px 6px;
  font-variant-numeric: tabular-nums;
}
.land-summary b { display: block; font-size: 18px; color: var(--text); font-weight: 800; margin-bottom: 2px; }
.land-summary b.pos { color: var(--green); }
.land-summary b.neg { color: var(--red); }
.land-summary span { font-size: 9px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.land-reason {
  color: var(--text);
  font-size: 14px;
  margin: 0 0 22px;
  font-weight: 500;
}
.land-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 18px;
}
.land-note {
  color: var(--text-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0;
}

/* Dawn overlay — subtle dawn-light ritual */
.dawn-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top, rgba(255,160,100,0.25) 0%, transparent 50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 28%;
  pointer-events: none;
  opacity: 0;
  z-index: 7;
  transition: opacity 0.5s;
}
.dawn-overlay.show { opacity: 1; animation: dawnFade 2.2s ease-out; }
@keyframes dawnFade {
  0% { opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
.dawn-line {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: #ffd5a0;
  text-shadow: 0 0 30px rgba(255,180,80,0.6);
  text-transform: uppercase;
}
.dawn-sub {
  color: #ffd5a0;
  opacity: 0.7;
  font-size: 13px;
  font-style: italic;
  margin-top: 4px;
}
body.dawn-ritual .stage {
  background:
    radial-gradient(800px 500px at 50% 100%, rgba(255,160,100,0.08), transparent 60%),
    linear-gradient(180deg, #0d0810 0%, #1a0d0c 100%);
}

/* Mission + title toasts — top-right corner (stacked vertically) */
.mission-toast, .title-toast {
  position: fixed;
  top: 72px;
  right: 16px;
  z-index: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(10,13,26,0.94);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 10px 14px;
  max-width: 280px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.3s, transform 0.3s;
}
.title-toast { top: 130px; }
.mission-toast[hidden], .title-toast[hidden] { display: none; }
.mission-toast.show, .title-toast.show { opacity: 1; transform: translateX(0); }
.mission-toast { border-color: rgba(34,197,94,0.4); }
.title-toast { border-color: rgba(250,204,21,0.4); }
.mt-icon, .tt-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
}
.mt-icon { background: rgba(34,197,94,0.2); color: var(--green); }
.tt-icon { background: rgba(250,204,21,0.2); color: var(--gold); }
.mt-head, .tt-head {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}
.mt-name, .tt-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

/* Pilot panel in sidebar */
.pilot-panel {
  overflow-y: auto;
  padding: 14px;
}
.pilot-header { margin-bottom: 14px; }
.pilot-callsign {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.pilot-callsign label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.pilot-callsign input {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  outline: none;
}
.pilot-callsign input:focus { border-color: var(--accent); }
.pilot-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.pilot-stats > div {
  background: var(--bg-3);
  border-radius: 6px;
  padding: 8px 10px;
  text-align: center;
}
.pilot-stats b {
  display: block;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.pilot-stats span {
  font-size: 8px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.logbook-section {
  border-top: 1px solid var(--line);
  padding: 14px 0 4px;
  margin-top: 14px;
}
.section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 8px;
}
.destinations-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dest-row {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  opacity: 0.45;
}
.dest-row.visited { opacity: 1; background: rgba(255,255,255,0.02); }
.dest-row .dx { color: var(--text-dim); font-weight: 600; }
.dest-row .dname { color: var(--text); }
.dest-row .dcount { color: var(--accent-2); font-weight: 700; }
.titles-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.title-chip {
  background: rgba(250,204,21,0.12);
  border: 1px solid rgba(250,204,21,0.3);
  color: var(--gold);
  padding: 4px 9px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.today-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.today-stats > div {
  background: var(--bg-3);
  padding: 8px 10px;
  border-radius: 6px;
  text-align: center;
}
.today-stats b {
  display: block;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.today-stats span {
  font-size: 8px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.btn-plan {
  width: 100%;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(255,90,40,0.3);
  transition: filter 0.12s;
}
.btn-plan:hover { filter: brightness(1.1); }
.btn-plan.primary { flex: 1; }

/* Missions panel */
.missions-panel {
  padding: 0;
  overflow-y: auto;
}
.missions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 14px 14px;
}
.mission-row {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.mission-row.done {
  border-color: rgba(34,197,94,0.4);
  background: rgba(34,197,94,0.05);
}
.mission-row .m-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.mission-row .m-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.mission-row.done .m-name { color: var(--green); }
.mission-row .m-count {
  font-size: 10px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.mission-row.done .m-count { color: var(--green); font-weight: 700; }
.mission-row .m-desc {
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.4;
  margin-bottom: 6px;
}
.mission-row .m-bar {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.mission-row .m-bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.4s ease-out;
}
.mission-row.done .m-bar > div { background: var(--green); }
.missions-foot {
  padding: 10px 14px 14px;
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.5;
  font-style: italic;
  border-top: 1px solid var(--line);
}

/* Flight plan modal */
.plan-card { max-width: 440px; }
.plan-intro {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 16px;
}
.plan-row { margin-bottom: 12px; }
.plan-row.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.plan-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.plan-row input {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.plan-row input:focus { border-color: var(--accent); }
.plan-foot { margin-top: 16px; }
.plan-note {
  color: var(--text-dim);
  font-size: 11px;
  font-style: italic;
  margin: 0 0 12px;
  line-height: 1.5;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
