/* ============================================================
   Hormuz — crash-step client styling
   Dark, sodium-orange + IR-green palette. No primary colours.
   Mobile-first; desktop lays the drawer inline at ≥ 780px.
   ============================================================ */

:root {
  --bg0: #070b12;
  --bg1: #0d1826;
  --bg2: #14263a;
  --ink: #dde7f2;
  --ink-dim: #8ea0b6;
  --ink-mute: #5a6a80;
  --line: #1e324a;
  --line-bright: #30557a;
  --accent: #ff9a3c;     /* sodium flare */
  --accent-dim: #c77326;
  --ir: #70ffaf;         /* IR / CIWS radar green */
  --ir-dim: #2f9a62;
  --danger: #ff4d4d;
  --danger-dim: #8b2727;
  --safe: #54d18a;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(0,0,0,0.5);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  touch-action: manipulation;
  background: radial-gradient(ellipse at top, #10192a 0%, var(--bg0) 60%) fixed;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ===== Top bar ===== */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(7,11,18,0.85);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.brand-mark { flex: 0 0 auto; }
.brand-text { font-weight: 800; letter-spacing: 2px; font-size: 15px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: transparent; border: 1px solid var(--line-bright);
  color: var(--ink-dim); border-radius: 8px;
  width: 34px; height: 32px; font-size: 14px; cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--accent); }
.demo-badge[hidden] { display: none; }
.demo-badge {
  display: inline-flex; align-items: center; padding: 3px 10px; 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: var(--mono); animation: demo-pulse 2s ease-in-out infinite;
}
@keyframes demo-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
.balance-box {
  padding: 6px 10px; border: 1px solid var(--line-bright); border-radius: 8px;
  font-family: var(--mono); font-size: 14px; color: var(--ir); letter-spacing: 0.5px;
}
.balance-box small { color: var(--ink-mute); margin-left: 4px; font-weight: 400; }

/* ===== Session strip ===== */
.session-strip {
  display: flex; gap: 0;
  background: var(--bg1);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  overflow-x: auto;
}
.ss-cell {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 6px 12px;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}
.ss-label { font-size: 9px; color: var(--ink-mute); letter-spacing: 1.2px; }
.ss-value { font-family: var(--mono); color: var(--ink); font-size: 13px; margin-top: 1px; }
.ss-verdict { margin-left: auto; border-right: none; border-left: 1px solid var(--line); align-items: flex-end; }

/* ===== Stage ===== */
.stage {
  position: relative;
  flex: 1;
  min-height: 220px;
  display: flex;
  overflow: hidden;
  background: linear-gradient(180deg, #081221 0%, #060a13 100%);
}
#stage {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
.hud {
  position: absolute;
  top: 10px; right: 14px;
  display: flex; gap: 10px;
  pointer-events: none;
  z-index: 3;
}
.hud > div {
  background: rgba(7,11,18,0.7);
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  padding: 6px 10px;
  text-align: right;
  min-width: 64px;
}
.hud-label { display: block; font-size: 9px; color: var(--ink-mute); letter-spacing: 1.2px; }
.hud-value { display: block; font-family: var(--mono); font-size: 18px; color: var(--ink); }
.hud-now .hud-value { color: var(--ir); }
.hud-next .hud-value { color: var(--accent); }

/* ===== Mode picker ===== */
.mode-picker {
  background: var(--bg1);
  border-top: 1px solid var(--line);
  padding: 10px 12px 4px;
}
.mode-picker.hidden { display: none; }
.picker-title { font-size: 11px; letter-spacing: 1.5px; color: var(--ink-mute); margin: 0 0 8px; }
.picker-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.picker-card {
  background: var(--bg2);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.picker-card:hover { border-color: var(--accent); }
.picker-card.selected {
  border-color: var(--accent);
  background: linear-gradient(180deg, #20334a 0%, #14263a 100%);
  box-shadow: 0 0 0 1px var(--accent-dim) inset;
}
.picker-name { font-weight: 700; font-size: 13px; letter-spacing: 1px; }
.picker-stats { display: flex; gap: 10px; font-family: var(--mono); font-size: 11px; color: var(--ink-dim); margin-top: 2px; }
.picker-stats .max { color: var(--accent); }
.picker-stats .death { color: var(--danger); }
.picker-foot { font-size: 10px; color: var(--ink-mute); margin: 8px 0 2px; text-align: center; }

@media (min-width: 780px) {
  .picker-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ===== Bet panel ===== */
.bet-panel {
  padding: 10px 12px 14px;
  background: var(--bg1);
  border-top: 1px solid var(--line);
}
.stake-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.stake-btn {
  width: 42px; height: 42px;
  background: var(--bg2); color: var(--ink);
  border: 1px solid var(--line-bright); border-radius: 10px;
  font-size: 22px; font-weight: 700; cursor: pointer;
}
.stake-btn:hover { border-color: var(--accent); }
.stake-display {
  flex: 1;
  background: var(--bg2); border: 1px solid var(--line-bright); border-radius: 10px;
  padding: 6px 12px;
  display: flex; flex-direction: column; align-items: center;
}
.stake-label { font-size: 9px; color: var(--ink-mute); letter-spacing: 1.2px; }
.stake-value { font-family: var(--mono); font-size: 22px; color: var(--ir); }
.stake-chips { display: flex; gap: 4px; }
.chip {
  background: transparent; border: 1px solid var(--line-bright);
  color: var(--ink-dim); border-radius: 6px;
  padding: 6px 8px; font-family: var(--mono); font-size: 11px;
  min-width: 32px; cursor: pointer;
}
.chip:hover { color: var(--ink); border-color: var(--accent); }

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.action {
  padding: 14px 0;
  border-radius: 12px;
  font-size: 15px; font-weight: 800; letter-spacing: 2px;
  cursor: pointer;
  border: none;
  transition: transform 80ms, background 120ms, opacity 120ms;
}
.action:disabled { opacity: 0.35; cursor: not-allowed; }
.action:not(:disabled):active { transform: scale(0.97); }
.action-advance {
  background: linear-gradient(180deg, #ff9a3c 0%, #c77326 100%);
  color: #1a0e00;
  box-shadow: 0 0 18px rgba(255,154,60,0.25);
}
.action-advance.commit {
  background: linear-gradient(180deg, #ffcf7a 0%, #ff9a3c 100%);
}
.action-cashout {
  background: linear-gradient(180deg, #70ffaf 0%, #2f9a62 100%);
  color: #062012;
  box-shadow: 0 0 18px rgba(112,255,175,0.2);
}
.hint-row {
  font-size: 11px; color: var(--ink-mute);
  margin-top: 8px; text-align: center; min-height: 14px;
}
.hint-row.error { color: var(--danger); }
.hint-row.ok { color: var(--ir); }

/* ===== Drawer (fair-play) ===== */
.drawer {
  position: fixed; inset: 0 0 0 auto;
  width: min(380px, 92vw);
  background: var(--bg1);
  border-left: 1px solid var(--line-bright);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  z-index: 100;
  transform: translateX(0);
}
.drawer[hidden] { display: none; }
.drawer-head {
  padding: 12px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
  font-size: 12px; letter-spacing: 1.5px;
}
.drawer-body { padding: 14px; font-size: 13px; color: var(--ink-dim); overflow-y: auto; }
.drawer-body p { margin: 0 0 10px; line-height: 1.45; }
.drawer-body dl { margin: 10px 0; }
.drawer-body dt { font-size: 10px; color: var(--ink-mute); letter-spacing: 1.2px; margin-top: 8px; }
.drawer-body dd { margin: 2px 0 0; font-family: var(--mono); font-size: 11px; color: var(--ink); word-break: break-all; }
.drawer-body .small { font-size: 11px; color: var(--ink-mute); }
.drawer-body code { background: var(--bg2); padding: 1px 4px; border-radius: 3px; color: var(--ir); }

/* ===== Round-end modal ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(5,8,14,0.82);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
  animation: fadeIn 160ms ease-out;
}
.modal[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--bg1);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  padding: 24px 22px 18px;
  max-width: 320px; width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
}
.modal-card.hit { border-color: var(--danger-dim); }
.modal-card.port { border-color: var(--ir-dim); }
.modal-title {
  font-size: 14px; letter-spacing: 2.5px; font-weight: 800;
  color: var(--ink-dim);
  margin-bottom: 4px;
}
.modal-card.hit .modal-title { color: var(--danger); }
.modal-card.port .modal-title { color: var(--ir); }
.modal-sub { font-size: 12px; color: var(--ink-mute); margin-bottom: 12px; }
.modal-payout {
  font-family: var(--mono); font-size: 28px; font-weight: 700;
  color: var(--ink);
  margin: 6px 0 18px;
}
.modal-card.port .modal-payout { color: var(--ir); }
.modal-card.hit .modal-payout { color: var(--danger); }
.modal-ok {
  width: 100%; padding: 12px 0;
  background: var(--bg2); color: var(--ink);
  border: 1px solid var(--line-bright); border-radius: 10px;
  font-weight: 700; letter-spacing: 1.5px; cursor: pointer;
}
.modal-ok:hover { border-color: var(--accent); }
