:root {
  --bg-deep: #0b0d13;
  --bg-panel: #131722;
  --bg-elevated: #1b2131;
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-bright: rgba(245, 196, 81, 0.45);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-amber: #f59e0b;
  --accent-gold: #fbbf24;
  --accent-cyan: #38bdf8;
  --accent-emerald: #10b981;
  --accent-crimson: #ef4444;
  --accent-violet: #a855f7;
  --card-black: #0f1117;
  --card-white: #f8f6f0;
  --card-ink: #111318;
  --radius-lg: 16px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: radial-gradient(circle at 50% 0%, #1d233a 0%, var(--bg-deep) 70%);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.9em;
}

.hidden {
  display: none !important;
}

.tv-shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
}

/* Header */
.tv-header {
  display: grid;
  grid-template-columns: 1.1fr 1.6fr auto;
  align-items: center;
  gap: 18px;
  background: rgba(19, 23, 34, 0.92);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-emblem {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
}

.brand-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.brand-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-center {
  background: rgba(27, 33, 49, 0.85);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  text-align: center;
}

.arena-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--accent-gold);
}

.arena-name {
  font-size: 17px;
  font-weight: 800;
  margin-top: 2px;
}

.arena-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.arena-hazards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
}

.hazard-pill {
  font-size: 11px;
  background: rgba(245, 158, 11, 0.15);
  color: #fde68a;
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0f131d;
  border: 1px solid var(--border-bright);
  padding: 6px 12px;
  border-radius: 10px;
}

.room-pill-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

.room-pill-code {
  font-size: 20px;
  font-weight: 900;
  color: var(--accent-gold);
  letter-spacing: 0.08em;
}

/* Buttons & Inputs */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 15px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-main);
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.btn-lg {
  padding: 13px 22px;
  font-size: 16px;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn-primary {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #fff;
  box-shadow: 0 4px 14px rgba(234, 88, 12, 0.35);
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: rgba(255, 255, 255, 0.16);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.input-text,
.input-select {
  background: #0d1018;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px;
}

/* Panels */
.panel {
  background: rgba(19, 23, 34, 0.92);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.panel-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent-gold);
  text-transform: uppercase;
}

.panel-title {
  font-size: 19px;
  font-weight: 800;
  margin-top: 3px;
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

/* Lobby Layout */
.lobby-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
}

.lobby-join-panel {
  grid-column: 1 / 2;
}

.lobby-wizards-panel {
  grid-column: 2 / 3;
}

.lobby-deck-panel {
  grid-column: 1 / -1;
}

.qr-row {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-top: 12px;
}

.qr-box {
  background: #fff;
  padding: 12px;
  border-radius: 14px;
  width: 184px;
  height: 184px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-box img {
  width: 100%;
  height: 100%;
  display: block;
}

.big-code-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.big-code {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--accent-gold);
  line-height: 1.05;
}

.join-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  color: var(--accent-cyan);
  margin: 6px 0 10px;
}

.lobby-hint {
  font-size: 13.5px;
  line-height: 1.45;
  color: #cbd5e1;
  margin-bottom: 14px;
}

.lobby-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.lobby-players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 10px;
}

.lobby-player-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.wizard-avatar {
  font-size: 28px;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}

.deck-chip-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 195px;
  overflow-y: auto;
  padding-right: 4px;
}

.deck-chip {
  background: var(--card-white);
  color: var(--card-ink);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 13px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.deck-chip.modifier {
  background: #1e1b4b;
  color: #e0e7ff;
  border: 1px solid rgba(168, 85, 247, 0.45);
}

.deck-chip-file {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.6;
}

/* Active Brawl Layout */
.brawl-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.brawl-top-columns {
  display: grid;
  grid-template-columns: 1.05fr 1.25fr;
  gap: 16px;
}

.turn-banner {
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fde68a;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.wizards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.wizard-card {
  background: var(--bg-elevated);
  border: 2px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.wizard-card.active-turn {
  border-color: var(--accent-gold);
  box-shadow: 0 0 22px rgba(251, 191, 36, 0.22);
}

.wizard-card.defeated {
  opacity: 0.42;
  filter: grayscale(0.8);
}

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

.wizard-id-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wizard-name {
  font-size: 16px;
  font-weight: 800;
}

.wizard-role-tag {
  font-size: 11px;
  color: var(--text-muted);
}

.shield-badge {
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #bae6fd;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.hp-bar-outer {
  background: #090b10;
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.hp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  transition: width 0.3s ease;
}

.hp-bar-fill.low {
  background: linear-gradient(90deg, #ef4444, #f97316);
}

.hp-bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.summon-slot {
  background: rgba(168, 85, 247, 0.14);
  border: 1px dashed rgba(168, 85, 247, 0.45);
  color: #e9d5ff;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.status-pill {
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Played Cards + Jev Judgment Stage */
.jev-meta-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  background: #0d1018;
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--accent-cyan);
  padding: 5px 10px;
  border-radius: 999px;
}

.played-cards-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 145px;
  padding: 12px;
  background: rgba(11, 13, 19, 0.65);
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  flex-wrap: wrap;
}

.empty-stage-prompt {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  max-width: 440px;
}

/* CAH-meets-Spellbook Minimalist Card (No rules text!) */
.cah-card {
  width: 148px;
  min-height: 132px;
  background: var(--card-white);
  color: var(--card-ink);
  border-radius: 12px;
  padding: 13px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  border: 2px solid transparent;
  user-select: none;
  position: relative;
}

.cah-card.modifier {
  background: #17153b;
  color: #f8fafc;
  border-color: rgba(168, 85, 247, 0.55);
}

.cah-card-title {
  font-size: 19px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.cah-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.62;
  margin-top: 12px;
}

.combo-plus {
  font-size: 26px;
  font-weight: 900;
  color: var(--accent-gold);
}

/* Jev Matrix */
.jev-matrix {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.verdict-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.22), rgba(239, 68, 68, 0.22));
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fde68a;
  text-align: center;
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.jev-gauges-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.jev-gauge-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 10px;
}

.gauge-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
}

.gauge-value {
  font-size: 18px;
  font-weight: 900;
  margin: 3px 0 5px;
}

.gauge-bar {
  height: 6px;
  background: #090b10;
  border-radius: 999px;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  background: var(--accent-emerald);
  width: 0%;
  transition: width 0.35s ease;
}

.gauge-fill.synergy {
  background: var(--accent-cyan);
}

.gauge-fill.danger {
  background: var(--accent-crimson);
}

.gauge-fill.gold {
  background: var(--accent-gold);
}

.jev-choices-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 8px;
}

.jev-choice-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.choice-kicker {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
}

.mini-prob-list {
  font-size: 11px;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.resolution-events {
  list-style: none;
  background: #0d1018;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13.5px;
}

.history-box {
  margin-top: 12px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
  max-height: 95px;
  overflow-y: auto;
  font-size: 12.5px;
  color: #cbd5e1;
}

/* Bottom TV Hand Dock */
.tv-caster-dock {
  padding: 14px 18px;
}

.dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.dock-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 8px;
}

.dock-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dock-target-label {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tv-hand-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tv-hand-row .cah-card {
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
  flex-shrink: 0;
}

.tv-hand-row .cah-card:hover {
  transform: translateY(-4px);
}

.tv-hand-row .cah-card.selected {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.45);
  transform: translateY(-6px);
}

.order-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent-gold);
  color: #111;
  font-weight: 900;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Drawers / Modals */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, 0.78);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.drawer-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 22px;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
}

.markdown-pre {
  background: #090b10;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  color: #e2e8f0;
  white-space: pre-wrap;
}

.drawer-note {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.45;
}

.forge-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.forge-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.forge-feedback {
  font-size: 13px;
  color: var(--accent-emerald);
  min-height: 18px;
}

.podium-card {
  text-align: center;
  max-width: 500px;
}

.podium-winner {
  font-size: 36px;
  font-weight: 900;
  color: var(--accent-gold);
  margin: 8px 0;
}

.podium-sub {
  color: var(--text-muted);
  margin-bottom: 20px;
}

.podium-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}
