:root {
  --bg: #090609;
  --panel: rgba(20, 14, 17, 0.92);
  --panel-solid: #171014;
  --border: rgba(214, 166, 86, 0.34);
  --border-strong: rgba(255, 209, 102, 0.72);
  --gold: #ffd166;
  --bronze: #c89b4b;
  --crimson: #ff3d5a;
  --cyan: #22e5ff;
  --mint: #34f5c5;
  --text: #f7f1e5;
  --muted: #b8a898;
  --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;
}

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

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

/* Compact top telemetry HUD (never a duplicate Arcade header) */
.hud-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(12, 8, 11, 0.95), rgba(12, 8, 11, 0.65));
  border-bottom: 1px solid rgba(214, 166, 86, 0.22);
  flex-shrink: 0;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(34, 23, 25, 0.92);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.pill-gold {
  border-color: rgba(255, 209, 102, 0.55);
  color: var(--gold);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.pill-delta {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.pill-delta.show { opacity: 1; }
.pill-delta.pos { background: rgba(52, 245, 197, 0.18); color: var(--mint); }
.pill-delta.neg { background: rgba(255, 61, 90, 0.2); color: var(--crimson); }

.icon-btn {
  min-height: 36px;
  min-width: 36px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(28, 19, 22, 0.92);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.icon-btn:hover { border-color: var(--gold); color: var(--gold); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn.active { border-color: var(--gold); background: rgba(255, 209, 102, 0.18); color: var(--gold); }

/* Stage wraps canvas + live overlays */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

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

/* Live bout top fighter HP bar overlay */
.bout-hud {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  z-index: 6;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.bout-hud.hidden { display: none; }

.hp-panel {
  background: rgba(15, 10, 13, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 6px 8px;
  min-width: 0;
}

.hp-panel.backed {
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(255, 209, 102, 0.22);
}

.hp-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.hp-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hp-num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  flex-shrink: 0;
}

.hp-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  transition: width 0.12s linear;
}

.hp-fill.left { background: linear-gradient(90deg, #ff6b35, #ffd166); }
.hp-fill.right { background: linear-gradient(90deg, #22e5ff, #34f5c5); }

.clock-box {
  background: rgba(15, 10, 13, 0.9);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 10px;
  text-align: center;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.clock-time {
  font-size: 15px;
  font-weight: 800;
  color: var(--gold);
}

.clock-sub {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.clock-box.overtime {
  border-color: var(--crimson);
}
.clock-box.overtime .clock-sub { color: var(--crimson); font-weight: 800; }

/* Bottom interactive bar during live bout */
.live-controls {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-right: 52px; /* keep bottom-right clear of platform feedback control */
}

.live-controls.hidden { display: none; }

.ticker-bar {
  flex: 1 1 auto;
  min-width: 0;
  background: rgba(14, 9, 12, 0.88);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--text);
  overflow-wrap: anywhere;
}

.ticker-label {
  color: var(--crimson);
  font-weight: 800;
  font-family: var(--mono);
  margin-right: 6px;
}

.roar-btn {
  flex-shrink: 0;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--gold);
  background: linear-gradient(135deg, #b83227, #e07a24);
  color: #fff9eb;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  box-shadow: 0 4px 18px rgba(224, 122, 36, 0.35);
}

.roar-btn:active { transform: scale(0.95); }

.hype-track {
  width: 82px;
  height: 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.hype-fill {
  height: 100%;
  width: 20%;
  background: var(--gold);
  transition: width 0.14s ease;
}

/* Pre-bout Wager Card & Settlement Modal 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(10, 6, 9, 0.56), rgba(6, 4, 7, 0.82));
  overflow-y: auto;
}

.overlay.hidden { display: none; }

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

.card-kicker {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--crimson);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.card-title {
  margin: 0 0 4px;
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 900;
  letter-spacing: 0.03em;
  color: var(--gold);
}

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

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

.fighter-card {
  text-align: left;
  padding: 10px;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  background: rgba(29, 20, 24, 0.9);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  transition: border-color 0.15s ease, transform 0.12s ease, background 0.15s ease;
}

.fighter-card:hover { border-color: rgba(255, 209, 102, 0.6); }

.fighter-card.selected {
  border-color: var(--gold);
  background: rgba(255, 209, 102, 0.12);
  box-shadow: 0 0 0 1px rgba(255, 209, 102, 0.35), 0 8px 20px rgba(0, 0, 0, 0.35);
}

.fc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.fc-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

.fc-name {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.fc-odds {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 800;
  color: var(--gold);
  background: rgba(255, 209, 102, 0.14);
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.fc-weapon {
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
}

.fc-trait {
  font-size: 11px;
  line-height: 1.3;
  color: var(--muted);
}

.fc-elo {
  font-family: var(--mono);
  font-size: 11px;
  color: #dfd3c3;
}

.fc-bars {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-top: 2px;
}

.stat-chip {
  background: rgba(0, 0, 0, 0.32);
  border-radius: 6px;
  padding: 3px 5px;
  font-family: var(--mono);
  font-size: 10px;
  text-align: center;
}

.stat-chip span { color: var(--muted); display: block; font-size: 9px; }

/* Controls rows */
.control-section {
  margin-bottom: 10px;
}

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

.control-label strong {
  color: var(--gold);
  font-family: var(--mono);
}

.pill-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.pill-row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-btn {
  min-height: 40px;
  padding: 6px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(28, 19, 22, 0.9);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  line-height: 1.2;
}

.choice-btn.active {
  border-color: var(--gold);
  background: rgba(255, 209, 102, 0.18);
  color: var(--gold);
}

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

.payout-preview strong {
  font-family: var(--mono);
  color: var(--mint);
  font-size: 14px;
}

.primary-btn {
  width: 100%;
  min-height: 46px;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1.5px solid #ffe599;
  background: linear-gradient(135deg, #c92a2a, #e87a1e);
  color: #fffaf0;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(201, 42, 42, 0.4);
}

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

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

/* Settlement ledger */
.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;
  color: var(--text);
}

.result-cell strong.win { color: var(--mint); }
.result-cell strong.loss { color: var(--crimson); }

/* Dialogs */
dialog {
  max-width: min(500px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: var(--panel-solid);
  color: var(--text);
  padding: 16px;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.78);
}

dialog::backdrop {
  background: rgba(4, 3, 6, 0.76);
  backdrop-filter: blur(4px);
}

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

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

.codex-list {
  display: grid;
  gap: 8px;
}

.codex-row {
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.codex-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

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

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

@media (max-width: 520px) {
  .hud-bar { padding: 5px 7px; gap: 5px; flex-wrap: wrap; }
  .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; min-width: 30px; white-space: nowrap; }
  .matchup-grid { gap: 7px; }
  .fighter-card { padding: 8px; }
  .fc-top { flex-wrap: wrap; gap: 4px; }
  .fc-name { font-size: 12px; }
  .fc-odds { font-size: 11.5px; padding: 2px 6px; }
  .card { padding: 11px; }
  .live-controls { padding-right: 48px; }
  .ticker-bar { font-size: 11px; padding: 6px 9px; }
  .roar-btn { padding: 6px 10px; font-size: 12px; }
  .hype-track { width: 64px; }
}
