/* ═══════════════════════════════════════════════════════════
   AVIATOR
   The crash game's screen. Reads tokens.css; shares the chip, button and
   card vocabulary of the board. docs/aviator-design.md is the design.
   ═══════════════════════════════════════════════════════════ */

/* The game takes the main column whole: no sports sidebar, no slip. */
body.view-aviator .sports-sidebar,
body.view-aviator .betslip { display: none; }
body.view-aviator .page-layout { grid-template-columns: 1fr; }
body.view-aviator .main-content { border-right: none; }

.aviator {
  --av-panel-w: 300px;
  --av-red: var(--red-400);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 16px 24px;
  min-height: calc(100vh - var(--header-total) - var(--ticker-h));
}

/* ── Bar ──────────────────────────────────────────────────── */
.av-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 4px;
}
.av-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 6px;
  border-radius: var(--r-sm);
}
.av-back:hover { background: var(--surface-raised); }
.av-bar-status {
  text-align: center;
  font-size: 12px;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.av-wordmark {
  font-size: 20px;
  font-weight: 700;
  font-style: italic;
  letter-spacing: -0.02em;
  color: var(--av-red);
}

/* ── History strip ────────────────────────────────────────── */
.av-history-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.av-history {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
}
.av-history::-webkit-scrollbar { display: none; }
.av-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: none;
  background: var(--surface-raised);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  flex: 0 0 auto;
}
.av-chip-low  { color: var(--blue-400); }
.av-chip-mid  { color: var(--purple-400); }
.av-chip-high { color: var(--pink-400); }
.av-history .av-chip:hover { background: var(--border); }
.av-history-more {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--chip-bg);
  color: var(--ink-secondary);
  font-size: 16px;
  line-height: 1;
}

/* ── Layout ───────────────────────────────────────────────── */
.av-layout {
  display: grid;
  grid-template-columns: var(--av-panel-w) 1fr;
  gap: 12px;
  align-items: start;
}
.av-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* ── Live bets panel ──────────────────────────────────────── */
.av-panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  padding: 10px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--header-total) - var(--ticker-h) - 140px);
  min-height: 320px;
}
.av-panel-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface-raised);
  border-radius: var(--r-md);
}
.av-tab {
  flex: 1;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 600;
}
.av-tab.active { background: var(--card-bg); color: var(--ink); }
.av-panel-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 6px 4px;
}
.av-panel-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink);
}
.av-panel-count { font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); }
.av-panel-cols,
.av-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr 0.9fr 1fr;
  gap: 6px;
  align-items: center;
  padding: 0 6px;
}
.av-panel-cols {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-muted);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}
.av-panel-cols span:nth-child(n+2), .av-row > :nth-child(n+2) { text-align: right; }
.av-panel-rows {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  flex: 1;
}
.av-row {
  min-height: 36px;
  font-size: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.av-row:last-child { border-bottom: none; }
.av-row-name { color: var(--ink-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av-row-stake, .av-row-win { font-family: var(--font-mono); color: var(--ink); }
.av-row-won .av-row-win { color: var(--accent-ink); font-weight: 700; }
.av-row-won { background: color-mix(in srgb, var(--accent-dim) 55%, transparent); }
.av-row-dash { color: var(--ink-muted); }
.av-row.is-mine .av-row-name { color: var(--ink); font-weight: 700; }
.av-row .av-chip { height: 20px; padding: 0 7px; font-size: 11px; }
.av-empty { padding: 32px 8px; text-align: center; color: var(--ink-muted); font-size: 12px; }

/* ── Stage ────────────────────────────────────────────────── */
.av-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 520px;
  background: var(--navy-950);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
/* Radial rays from the bottom-left, where the curve starts. Static. */
.av-rays {
  position: absolute;
  inset: -50% -50% -50% -50%;
  background: repeating-conic-gradient(from 0deg at 25% 100%,
    var(--navy-950) 0deg 7.5deg,
    color-mix(in srgb, var(--navy-900) 70%, var(--navy-950)) 7.5deg 15deg);
  opacity: .9;
}
.av-stage[data-phase="crashed"] .av-rays {
  background: repeating-conic-gradient(from 0deg at 25% 100%,
    var(--navy-950) 0deg 7.5deg,
    color-mix(in srgb, var(--red-950) 60%, var(--navy-950)) 7.5deg 15deg);
}
.av-curve { position: absolute; inset: 0; width: 100%; height: 100%; }
.av-curve-line { fill: none; stroke: var(--av-red); stroke-width: 4; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.av-curve-fill { fill: url(#avFill); }
.av-plane {
  position: absolute;
  width: 44px; height: 44px;
  margin: -22px 0 0 -22px;
  filter: drop-shadow(0 4px 12px rgb(0 0 0 / .5));
}
.av-plane[hidden] { display: none; }

.av-centre {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  pointer-events: none;
  text-align: center;
  padding: 16px;
}
.av-state {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--ink);
  min-height: 1.2em;
}
.av-state.is-crash { color: var(--av-red); }
.av-multiplier {
  font-family: var(--font-mono);
  font-size: clamp(48px, 9vw, 84px);
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  text-shadow: 0 2px 24px rgb(0 0 0 / .5);
}
.av-multiplier.is-crash { color: var(--av-red); }
.av-stage[data-phase="crashed"] .av-curve,
.av-stage[data-phase="crashed"] .av-plane { opacity: .35; }

.av-wait { width: min(320px, 70%); }
.av-wait-label { font-size: 13px; font-weight: 600; color: var(--ink-secondary); margin-bottom: 8px; }
.av-wait-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-raised);
  overflow: hidden;
}
.av-wait-bar span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: 999px;
}
.av-offline {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--amber-dim);
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
}

/* ── Bet panels ───────────────────────────────────────────── */
.av-bets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.av-bet {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.av-bet-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface-raised);
  border-radius: 999px;
  align-self: center;
  width: min(220px, 100%);
}
.av-bet-tab {
  flex: 1;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 700;
}
.av-bet-tab.active { background: var(--card-bg); color: var(--ink); }

.av-stake {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 6px;
}
.av-step {
  height: 44px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--chip-bg);
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
}
.av-step:hover { border-color: var(--border); }
.av-stake-input {
  height: 44px;
  width: 100%;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--ink);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  outline: none;
  -moz-appearance: textfield;
}
.av-stake-input::-webkit-inner-spin-button, .av-stake-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.av-stake-input:focus { border-color: var(--accent); }
.av-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.av-quick .stake-quick-btn { min-height: 32px; }

.av-auto { display: flex; flex-direction: column; gap: 6px; }
.av-auto-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-secondary);
}
.av-auto-field { display: inline-flex; align-items: center; gap: 4px; color: var(--ink); font-family: var(--font-mono); }
.av-auto-input {
  width: 76px;
  height: 32px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--ink);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
}
.av-auto-toggle { justify-content: flex-start; }
.av-auto-on { accent-color: var(--accent); width: 18px; height: 18px; }

.av-action {
  height: 56px;
  border: none;
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--accent);
  color: var(--on-accent);
  transition: background .15s, transform .1s;
}
.av-action:active:not(:disabled) { transform: scale(.98); }
.av-action-label { font-size: 15px; font-weight: 700; }
.av-action-amount { font-family: var(--font-mono); font-size: 12px; font-weight: 600; opacity: .85; }
.av-action[data-state="cashout"] { background: var(--amber); }
.av-action[data-state="cashout"]:hover { background: color-mix(in srgb, var(--amber) 85%, white); }
.av-action[data-state="waiting"],
.av-action[data-state="done"],
.av-action[data-state="lost"] { background: var(--surface-raised); color: var(--ink-secondary); }
.av-action[data-state="done"] { color: var(--accent-ink); }
.av-action[data-state="lost"] { color: var(--av-red); }
.av-action[data-state="queued"] { background: var(--surface-raised); color: var(--ink); border: 1px solid var(--border); }
.av-action:disabled { cursor: default; }
.av-bet.is-locked .av-stake, .av-bet.is-locked .av-quick, .av-bet.is-locked .av-auto { opacity: .5; pointer-events: none; }
.av-bet-msg { font-size: 11px; min-height: 1.4em; color: var(--ink-muted); text-align: center; margin: 0; }
.av-bet-msg.is-err { color: var(--red); }
.av-bet-msg.is-ok { color: var(--accent-ink); }
.av-bet-msg.is-info { color: var(--amber); }

.av-terms { font-size: 11px; color: var(--ink-muted); text-align: center; line-height: 1.5; }

/* ── Fairness sheet ───────────────────────────────────────── */
.av-sheet {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.av-sheet[hidden] { display: none; }
.av-sheet-inner {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  max-height: 90vh;
  overflow-y: auto;
}
.av-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.av-sheet-title { font-size: 15px; font-weight: 700; }
.av-fair-row { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--border-subtle); font-size: 12px; color: var(--ink-secondary); }
.av-fair-row code, .av-fair-how code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink);
  word-break: break-all;
  background: var(--surface-raised);
  padding: 2px 4px;
  border-radius: 4px;
}
.av-fair-row .av-chip { align-self: flex-start; }
.av-fair-how { font-size: 12px; color: var(--ink-secondary); line-height: 1.6; padding-top: 10px; }

/* ── Phones ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .aviator { padding: 10px 12px 24px; }
  .av-layout { grid-template-columns: 1fr; }
  .av-panel { order: 3; max-height: 420px; min-height: 0; }
  .av-main { order: 2; }
  .av-wordmark { font-size: 17px; }
}
@media (max-width: 640px) {
  .av-bets { grid-template-columns: 1fr; }
  .av-stage { aspect-ratio: 16 / 10; }
  .av-multiplier { font-size: 48px; }
  .av-state { font-size: 20px; }
  .av-plane { width: 34px; height: 34px; margin: -17px 0 0 -17px; }
  .av-plane svg { width: 34px; height: 34px; }
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .av-curve, .av-plane { display: none; }
  .av-action { transition: none; }
}
