/* =============================================================================
   style.css — Cards Against Humanity · Premium Party Game UI

   Design system: dark card-table atmosphere with crisp physical cards as the
   visual heroes. Clean typography (Inter), restrained motion, strong contrast.

   Layout: CSS Grid (game) + Flexbox (components).
   Responsive: 768px (tablet), 640px (mobile), 480px (small mobile).
   ============================================================================= */

/* =============================================================================
   Design Tokens
   ============================================================================= */
:root {
  /* Backgrounds */
  --bg-primary:    #111113;
  --bg-secondary:  #18181b;
  --bg-surface:    #1e1e22;
  --bg-elevated:   #252529;

  /* Text */
  --text-primary:   #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted:     #555570;

  /* Accent */
  --accent:           #e94560;
  --accent-hover:     #ff5a75;
  --accent-glow:      rgba(233, 69, 96, 0.25);
  --accent-subtle:    rgba(233, 69, 96, 0.08);
  --accent-secondary: #7c5cfc;
  --accent-secondary-hover: #9478ff;
  --accent-secondary-glow:  rgba(124, 92, 252, 0.25);

  /* Semantic */
  --green:       #34d399;
  --green-glow:  rgba(52, 211, 153, 0.2);
  --yellow:      #f0c430;
  --yellow-glow: rgba(240, 196, 48, 0.2);
  --amber:       #f59e0b;
  --red:         #ef4444;

  /* Cards */
  --white-card-bg:     #f5f5f0;
  --white-card-text:   #1a1a1a;
  --black-card-bg:     #0a0a0a;
  --black-card-text:   #ffffff;
  --black-card-border: #2a2a2a;

  /* Borders & Shadows */
  --border:       rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.10);
  --border-focus: rgba(233, 69, 96, 0.5);

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.45);
  --shadow-xl:  0 16px 48px rgba(0,0,0,0.55);
  --shadow-card-hover: 0 14px 36px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  /* Radii */
  --radius:     12px;
  --radius-sm:  8px;
  --radius-xs:  4px;
  --radius-lg:  16px;
  --radius-pill: 100px;

  /* Transitions */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* =============================================================================
   Reset & Base
   ============================================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.08) transparent; }

/* =============================================================================
   Ambient Background — Subtle radial gradients for atmosphere
   ============================================================================= */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(124, 92, 252, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(233, 69, 96, 0.03) 0%, transparent 50%);
  z-index: -1;
  pointer-events: none;
}

/* =============================================================================
   Container
   ============================================================================= */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px;
}

/* =============================================================================
   Hero Section — Landing page
   ============================================================================= */
.hero {
  text-align: center;
  padding: 56px 0 32px;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -2px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  font-style: italic;
  font-weight: 400;
}

/* =============================================================================
   Buttons
   ============================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  text-align: center;
  position: relative;
  letter-spacing: 0.01em;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover {
  background: var(--bg-elevated);
  border-color: rgba(255,255,255,0.15);
}

.btn-accent {
  background: var(--accent-secondary);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-secondary-glow);
}
.btn-accent:hover {
  background: var(--accent-secondary-hover);
}

.btn-small { padding: 6px 12px; font-size: 0.8rem; }
.btn-large { padding: 14px 28px; font-size: 1rem; width: 100%; }

.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

.btn-group .btn {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-group .btn:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
}
.btn-group .btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* =============================================================================
   Glass Panels
   ============================================================================= */
.card-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
  transition: border-color 0.25s;
}
.card-panel:hover { border-color: var(--border-light); }

.card-panel h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.card-panel h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* =============================================================================
   Forms
   ============================================================================= */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
  letter-spacing: 0.2px;
}

input[type="text"],
input[type="file"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input[type="text"]::placeholder { color: var(--text-muted); }
input[type="file"] { padding: 8px 12px; cursor: pointer; }

/* =============================================================================
   Main Actions — Landing page grid
   ============================================================================= */
.main-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 640px) {
  .main-actions { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2.2rem; }
}

/* =============================================================================
   Deck List
   ============================================================================= */
.deck-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 14px;
}

.deck-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  transition: border-color 0.2s, background 0.2s;
}

.deck-item:hover {
  border-color: var(--border);
  background: var(--bg-surface);
}

.deck-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.deck-item .deck-name { flex: 1; font-weight: 500; }
.deck-item .deck-count { color: var(--text-muted); font-size: 0.75rem; }
.deck-item .deck-played { color: var(--text-muted); font-size: 0.7rem; font-style: italic; opacity: 0.7; }
.deck-item .deck-delete {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1rem; padding: 0 4px;
  transition: color 0.2s, transform 0.2s;
}
.deck-item .deck-delete:hover { color: var(--accent); transform: scale(1.15); }

/* =============================================================================
   Upload Panel
   ============================================================================= */
.upload-panel { max-width: 600px; margin: 0 auto; }

.upload-result {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  display: none;
}

.upload-result.success {
  display: block;
  background: rgba(52, 211, 153, 0.08);
  color: var(--green);
  border: 1px solid rgba(52, 211, 153, 0.15);
}
.upload-result.error {
  display: block;
  background: var(--accent-subtle);
  color: var(--accent);
  border: 1px solid rgba(233, 69, 96, 0.15);
}

.loading { color: var(--text-muted); font-style: italic; }

/* =============================================================================
   Lobby
   ============================================================================= */
.lobby-header {
  text-align: center;
  padding: 32px 0 24px;
}

.lobby-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 16px;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.game-code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.game-code-display .code {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 8px;
  color: var(--text-primary);
  background: var(--bg-surface);
  padding: 12px 28px;
  border-radius: var(--radius);
  border: 2px solid var(--border-light);
  font-variant-numeric: tabular-nums;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.game-code-display .code:hover {
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--accent-glow);
}

.lobby-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 640px) {
  .lobby-content { grid-template-columns: 1fr; }
}

/* Player list */
.player-list { list-style: none; }

.player-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-weight: 500;
  font-size: 0.9rem;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}

.player-list li:hover { border-color: var(--border); }
.player-list li.disconnected { opacity: 0.3; }

.player-name { flex: 1; }

/* Badges */
.host-badge, .czar-badge {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.host-badge {
  background: var(--accent);
  color: #fff;
}
.czar-badge {
  background: var(--yellow);
  color: #000;
}

.player-score {
  font-weight: 700;
  color: var(--accent);
  min-width: 24px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.player-count {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 10px;
}

/* =============================================================================
   Game Layout
   ============================================================================= */
.game-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

/* ---- Top bar ---- */
.game-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.game-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.round-label {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.game-code-small {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}

/* Phase indicator */
.phase-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px;
  background: var(--bg-surface);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.phase-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}

.phase-indicator[data-phase="playing"] .phase-dot { background: var(--accent); }
.phase-indicator[data-phase="judging"] .phase-dot { background: var(--yellow); }
.phase-indicator[data-phase="results"] .phase-dot { background: var(--green); }
.phase-indicator[data-phase="waiting"] .phase-dot { background: var(--text-muted); }

/* ---- Timer bar ---- */
.timer-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 2px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 100%;
  transition: width 1s linear;
}

.timer-fill.warning { background: var(--amber); }
.timer-fill.danger  { background: var(--red); }

/* ---- Scoreboard sidebar ---- */
.scoreboard {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

.scoreboard h3 {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}

.scoreboard ul { list-style: none; }

.scoreboard li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  font-size: 0.82rem;
  transition: background 0.2s;
}

.scoreboard li:hover { background: rgba(255, 255, 255, 0.03); }
.scoreboard li.is-czar { background: var(--yellow-glow); }
.scoreboard li.disconnected { opacity: 0.3; }

/* ---- Game main area ---- */
.game-main {
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
}

.black-card-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.czar-label {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.czar-label.is-self {
  color: var(--yellow);
}

/* =============================================================================
   Cards — Physical card styling
   ============================================================================= */
.card {
  border-radius: var(--radius);
  padding: 20px;
  min-width: 180px;
  max-width: 260px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  position: relative;
  cursor: default;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}

.card .card-text {
  font-size: 0.95rem;
  line-height: 1.5;
  font-weight: 700;
}

/* --- Black card --- */
.black-card {
  background: var(--black-card-bg);
  color: var(--black-card-text);
  border: 1px solid var(--black-card-border);
  min-width: 280px;
  max-width: 380px;
  min-height: 250px;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.03);
}

.black-card .card-text {
  font-size: 1.2rem;
  line-height: 1.5;
  font-weight: 700;
}

.black-card .card-blank {
  display: inline-block;
  border-bottom: 2px solid rgba(255,255,255,0.6);
  min-width: 60px;
  margin: 0 3px;
}

.black-card .pick-indicator {
  margin-top: auto;
  padding-top: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.5;
}

/* --- White card --- */
.white-card {
  background: var(--white-card-bg);
  color: var(--white-card-text);
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.9);
}

.white-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-card-hover);
}

.white-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow), var(--shadow-lg);
  transform: translateY(-12px);
}

/* Pick-order badge */
.white-card .pick-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 26px;
  height: 26px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: 0 2px 6px var(--accent-glow);
}

/* Card brand footer */
.card .card-brand {
  margin-top: auto;
  padding-top: 12px;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.25;
}

/* =============================================================================
   Player Hand
   ============================================================================= */
.hand-area {
  grid-column: 1 / -1;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 16px 20px;
}

.hand-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 12px;
  font-weight: 600;
}

.player-hand {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
}

.player-hand .card {
  min-width: 160px;
  max-width: 170px;
  min-height: 170px;
  flex-shrink: 0;
  scroll-snap-align: start;
}

.player-hand .card .card-text {
  font-size: 0.85rem;
}

#submit-cards-btn {
  margin-top: 12px;
  width: auto;
  min-width: 180px;
}

/* =============================================================================
   Game Status
   ============================================================================= */
.game-status {
  font-size: 1rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 16px;
  font-weight: 500;
}

/* =============================================================================
   Submissions — Reveal phase
   ============================================================================= */
.submissions-area {
  width: 100%;
  text-align: center;
}

.submissions-area h3 {
  color: var(--yellow);
  margin-bottom: 18px;
  font-size: 1.05rem;
  font-weight: 700;
}

.submissions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}

.submission-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  cursor: pointer;
  padding: 10px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  transition: border-color 0.2s var(--ease-out), background 0.2s, transform 0.2s var(--ease-out);
}

.submission-group:hover {
  border-color: rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.02);
  transform: translateY(-3px);
}

.submission-group.selected {
  border-color: var(--accent);
  background: var(--accent-subtle);
  box-shadow: 0 0 16px var(--accent-glow);
}

.submission-group .card {
  min-height: 140px;
  min-width: 140px;
  max-width: 155px;
}

.submission-group .card .card-text {
  font-size: 0.85rem;
}

/* =============================================================================
   Round Result
   ============================================================================= */
.round-result {
  text-align: center;
  padding: 28px;
  background: rgba(52, 211, 153, 0.04);
  border: 1px solid rgba(52, 211, 153, 0.12);
  border-radius: var(--radius-lg);
  max-width: 620px;
  width: 100%;
  animation: fadeInUp 0.4s var(--ease-out);
}

.round-result h3 {
  color: var(--green);
  font-size: 1.15rem;
  margin-bottom: 16px;
  font-weight: 700;
}

.round-result .winning-cards {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.round-result .all-submissions-reveal {
  margin-top: 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.round-result .submission-reveal { margin: 3px 0; }
.round-result .winner-name { color: var(--green); font-weight: 700; }

/* =============================================================================
   Game Over
   ============================================================================= */
.gameover-panel {
  text-align: center;
  max-width: 520px;
  margin: 60px auto;
  animation: fadeInUp 0.5s var(--ease-out);
}

.gameover-panel h1 {
  font-size: 2.4rem;
  margin-bottom: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text-primary);
}

.final-scoreboard { margin-bottom: 28px; }

.final-scoreboard .score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-weight: 500;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.final-scoreboard .score-row:first-child {
  background: var(--accent-subtle);
  border: 1px solid rgba(233, 69, 96, 0.2);
  font-size: 1.05rem;
  font-weight: 700;
  box-shadow: 0 0 20px var(--accent-glow);
}

.final-scoreboard .score-row .rank { width: 32px; color: var(--text-muted); font-size: 0.85rem; }
.final-scoreboard .score-row .name { flex: 1; text-align: left; }
.final-scoreboard .score-row .score { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

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

/* =============================================================================
   Round History Sidebar
   ============================================================================= */
.history-toggle {
  position: fixed;
  top: 56px;
  right: 12px;
  width: 36px;
  height: 36px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  z-index: 100;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.history-toggle:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}

.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  z-index: 99;
  transform: translateX(100%);
  transition: transform 0.3s var(--ease-out);
}

.history-panel.visible { transform: translateX(0); }

.history-panel h3 {
  margin-bottom: 14px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.history-item {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}

.history-item:hover { border-color: var(--border-light); }

.history-item .history-round {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.history-item .history-black {
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 0.85rem;
  line-height: 1.4;
}

.history-item .history-winner {
  color: var(--green);
  font-size: 0.8rem;
}

/* =============================================================================
   Toast Notifications
   ============================================================================= */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s var(--ease-out), toastOut 0.3s ease 2.7s forwards;
  font-size: 0.85rem;
  max-width: 320px;
  font-weight: 500;
}

.toast.success { border-left-color: var(--green); }
.toast.warning { border-left-color: var(--amber); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(6px); }
}

/* =============================================================================
   Utility Classes
   ============================================================================= */
.hidden { display: none !important; }
.view { display: block; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =============================================================================
   Responsive — Tablet (768px)
   ============================================================================= */
@media (max-width: 768px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
  }

  .scoreboard {
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 14px;
    overflow-x: auto;
  }

  .scoreboard h3 { margin-bottom: 0; white-space: nowrap; }
  .scoreboard ul { display: flex; gap: 4px; }
  .scoreboard li { margin-bottom: 0; white-space: nowrap; }

  .game-main { padding: 20px 16px; }

  .card {
    min-width: 140px;
    min-height: 155px;
    padding: 16px;
  }

  .black-card {
    min-width: 220px;
    max-width: 300px;
    min-height: 200px;
  }

  .player-hand .card {
    min-width: 140px;
    min-height: 150px;
  }

  .submissions-list { gap: 10px; }

  .submission-group .card {
    min-width: 125px;
    min-height: 125px;
  }

  .history-panel { width: 260px; }
}

/* =============================================================================
   Responsive — Small mobile (480px)
   ============================================================================= */
@media (max-width: 480px) {
  .hero h1 { font-size: 1.8rem; }
  .game-code-display .code { font-size: 1.6rem; padding: 10px 18px; letter-spacing: 5px; }
  .card-panel { padding: 20px; }
  .container { padding: 16px; }
  .game-main { padding: 16px 12px; }
  .black-card { min-width: 200px; max-width: 260px; min-height: 180px; }
  .black-card .card-text { font-size: 1rem; }
}
