:root {
  --bg: #070b14;
  --panel: rgba(12, 18, 32, 0.94);
  --panel-solid: #0c1220;
  --border: rgba(52, 245, 197, 0.28);
  --border-gold: rgba(255, 209, 102, 0.72);
  --mint: #34f5c5;
  --cyan: #22e5ff;
  --gold: #ffd166;
  --coral: #ff4d6d;
  --text: #edf4ff;
  --muted: #8fa2c4;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button, canvas, [role="button"], .hud-bar, .meter-strip {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

#app {
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hud-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(7, 11, 20, 0.94);
  border-bottom: 1px solid rgba(52, 245, 197, 0.18);
  flex-shrink: 0;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(17, 26, 46, 0.92);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.pill-gold {
  border-color: rgba(255, 209, 102, 0.55);
  color: var(--gold);
}

.pill-elo {
  border-color: rgba(34, 229, 255, 0.45);
  color: var(--cyan);
}

.icon-btn {
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(17, 26, 46, 0.92);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.icon-btn:hover { border-color: var(--mint); color: var(--mint); }
.icon-btn:active { transform: scale(0.96); }

/* Live trial meter strip right under HUD */
.meter-strip {
  position: relative;
  z-index: 8;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: rgba(9, 14, 26, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.meter-strip.hidden { display: none; }

.score-readout {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 900;
  color: var(--mint);
  min-width: 82px;
}

.score-readout.over { color: var(--gold); }

.score-readout small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  margin-left: 3px;
}

.gauge-wrap {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: visible;
}

.gauge-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22e5ff, #34f5c5);
  transition: width 0.08s linear;
}

.gauge-fill.over {
  background: linear-gradient(90deg, #34f5c5, #ffd166);
  box-shadow: 0 0 14px rgba(255, 209, 102, 0.55);
}

.gauge-marker {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
  border-radius: 2px;
}

.gauge-marker-tag {
  position: absolute;
  top: -1px;
  left: 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 1px 4px #000;
  white-space: nowrap;
}

.trial-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.streak-chip {
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(34, 229, 255, 0.14);
  border: 1px solid rgba(34, 229, 255, 0.4);
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
}

.timer-chip {
  font-size: 16px;
  font-weight: 900;
  color: var(--text);
  min-width: 52px;
  text-align: right;
}

.timer-chip.urgent { color: var(--coral); }

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

#arena {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: radial-gradient(circle at center, rgba(7, 11, 20, 0.62), rgba(5, 8, 16, 0.88));
  overflow-y: auto;
}

.overlay.hidden { display: none; }

.card {
  width: min(520px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
}

.kicker {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--mint);
  text-transform: uppercase;
  margin-bottom: 3px;
}

.title {
  margin: 0 0 5px;
  font-size: clamp(20px, 4.4vw, 26px);
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--text);
}

.title span { color: var(--gold); }

.sub {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.42;
  color: var(--muted);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.section-head strong { color: var(--gold); font-family: var(--mono); }

.line-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 12px;
}

.line-btn {
  min-height: 62px;
  padding: 8px 6px;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  background: rgba(16, 25, 44, 0.92);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.line-btn:hover { border-color: var(--mint); }

.line-btn.active {
  border-color: var(--gold);
  background: rgba(255, 209, 102, 0.14);
  box-shadow: 0 0 16px rgba(255, 209, 102, 0.2);
}

.line-num {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 900;
  color: var(--gold);
}

.line-mult {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  color: var(--mint);
}

.line-tier {
  font-size: 10px;
  color: var(--muted);
  font-weight: 700;
}

.stake-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 11px;
}

.choice-btn {
  min-height: 42px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(16, 25, 44, 0.92);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.choice-btn.active {
  border-color: var(--mint);
  background: rgba(52, 245, 197, 0.16);
  color: var(--mint);
}

.rakeback-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(34, 229, 255, 0.08);
  border: 1px solid rgba(34, 229, 255, 0.25);
  margin-bottom: 11px;
  font-size: 12px;
}

.rakeback-bar strong { font-family: var(--mono); color: var(--cyan); }

.claim-btn {
  min-height: 34px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--cyan);
  background: rgba(34, 229, 255, 0.18);
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.claim-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.summary-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  margin-bottom: 10px;
}

.summary-bar strong {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--gold);
}

.primary-btn {
  width: 100%;
  min-height: 46px;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1.5px solid #96ffe2;
  background: linear-gradient(135deg, #0ea57a, #1ac99b);
  color: #031512;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(26, 201, 155, 0.35);
}

.primary-btn:hover { filter: brightness(1.06); }
.primary-btn:active { transform: scale(0.98); }

.disclaimer {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.result-cell {
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 9px 10px;
}

.result-cell span {
  display: block;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.result-cell strong {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 16px;
}

.win { color: var(--mint); }
.loss { color: var(--coral); }

dialog {
  max-width: min(470px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  border-radius: 16px;
  border: 1px solid var(--border-gold);
  background: var(--panel-solid);
  color: var(--text);
  padding: 16px;
}

dialog::backdrop { background: rgba(4, 7, 14, 0.78); }

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.dialog-head h2 { margin: 0; font-size: 18px; color: var(--gold); }

.rules-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: #dbe7fb;
}

.paused-badge {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 11, 20, 0.75);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--gold);
}
.paused-badge.hidden { display: none; }

@media (max-width: 500px) {
  .hud-bar { padding: 5px 7px; gap: 4px; }
  .hud-group { gap: 4px; flex-wrap: nowrap; }
  .pill { padding: 4px 6px; font-size: 10.5px; }
  .icon-btn { padding: 4px 7px; font-size: 10.5px; min-height: 30px; }
  .meter-strip { padding: 6px 8px; gap: 6px; }
  .score-readout { font-size: 15px; min-width: 68px; }
  .line-grid { gap: 5px; }
  .line-num { font-size: 15px; }
  .card { padding: 12px; }
}
