/* ===================================================================
   TRIVIA BREAKOUT — Master Stylesheet
   
   Structure:
   1. CSS Variables / Theme
   2. Reset & Base
   3. Screen System
   4. Splash Screen
   5. Options Screen
   6. Game Setup Screen
   7. Game Screen (Board + Questions)
   8. Ice Block Styling & Animations
   9. Win Screen & Confetti
   10. Components (Buttons, Toggles, etc.)
   11. Responsive / Mobile
   12. Utility & Animations
   =================================================================== */

/* ----- 1. CSS VARIABLES ----- */
:root {
  /* Category colors */
  --cat-history: #8B5E3C;
  --cat-science: #2E8B57;
  --cat-entertainment: #3A7BD5;
  --cat-sports: #E67E22;
  --cat-math: #C0392B;
  --cat-current-events: #8E44AD;

  /* UI colors */
  --bg-dark: #0a0e1a;
  --bg-card: #131929;
  --bg-card-light: #1a2238;
  --text-primary: #e8eaf0;
  --text-secondary: #8892a8;
  --accent: #00d4ff;
  --accent-glow: rgba(0, 212, 255, 0.3);
  --success: #2ecc71;
  --danger: #e74c3c;
  --warning: #f39c12;

  /* Sizing */
  --block-size: 96px;
  --block-gap: 12px;
  --border-radius: 10px;
  --transition-speed: 0.3s;
}

/* ----- 2. RESET & BASE ----- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

h1, h2, h3 {
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ----- 3. SCREEN SYSTEM ----- */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.4s ease;
}

.screen-inner {
  width: 100%;
  max-width: 700px;
  padding: .2rem 1.5rem;
  margin: auto;
}

.screen-title {
  text-align: center;
  font-size: 1.8rem;
  margin-bottom: .2rem;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
}

.screen-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* ----- 4. SPLASH SCREEN ----- */
#splash-screen {
  background: linear-gradient(135deg, #0a0e1a 0%, #0f1b3d 50%, #0a1628 100%);
  position: relative;
  min-height: 100vh;
  height: 100%;
}

.splash-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(0,100,200,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(0,212,255,0.06) 0%, transparent 50%);
  pointer-events: none;
}

.splash-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 2rem;
}

#particle-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* Logo */
.logo-container {
  position: relative;
  margin-bottom: 1rem;
}

.game-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  user-select: none;
}

.title-trivia {
  font-size: 3.5rem;
  font-weight: 300;
  letter-spacing: 0.5em;
  color: #b0c4de;
  text-transform: uppercase;
  text-shadow: 0 0 30px rgba(176,196,222,0.3);
  animation: shimmer 4s ease-in-out infinite alternate;
}

.title-breakout {
  font-size: 4.5rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  background: linear-gradient(180deg, #00d4ff 0%, #0088cc 50%, #005fa3 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(0,212,255,0.4));
  animation: titlePulse 3s ease-in-out infinite alternate;
}

/* Ice shards decoration */
.ice-shards-deco {
  position: absolute;
  inset: -20px;
  pointer-events: none;
}

.shard {
  position: absolute;
  background: linear-gradient(135deg, rgba(0,212,255,0.3), rgba(255,255,255,0.1));
  border-radius: 2px;
  animation: shardFloat 6s ease-in-out infinite;
}
.shard.s1 { width: 8px; height: 20px; top: 10%; left: 5%; animation-delay: 0s; }
.shard.s2 { width: 6px; height: 16px; top: 20%; right: 8%; animation-delay: 1.2s; }
.shard.s3 { width: 10px; height: 24px; bottom: 15%; left: 10%; animation-delay: 2.4s; }
.shard.s4 { width: 5px; height: 14px; bottom: 25%; right: 5%; animation-delay: 0.8s; }
.shard.s5 { width: 7px; height: 18px; top: 50%; left: 50%; animation-delay: 3.6s; }

.tagline {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 2rem;
  font-style: italic;
}


/* ----- Shared Form Elements (used across multiple screens) ----- */
.styled-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-card-light);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 0.55rem 2.2rem 0.55rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238892a8' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
}

.styled-select:hover,
.styled-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.styled-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

.splash-buttons {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  justify-content: center;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}

.splash-buttons .btn {
  flex: 1;
  min-width: 140px;
  white-space: nowrap;
}

.splash-footer {
  margin-top: 2rem;
}

/* ----- 5. OPTIONS (in options-screen) ----- */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .2rem;
  margin-top: 0.5rem;
}

.option-group {
  /*background: var(--bg-card);
  */
  border-radius: var(--border-radius);
  padding: .5rem;
  /*border: 1px solid rgba(255,255,255,0.05);
*/
  }

.option-group.wide {
  grid-column: 1 / -1;
}

.option-group > label:first-child {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.2rem;
  font-weight: 600;
}

.option-group small {
  opacity: 0.6;
}

/* Mode toggle row (Bots / Friends) */
.mode-toggle-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding-bottom: 0.2rem;
}

.mode-toggle-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color var(--transition-speed);
}

.mode-toggle-label.active-label {
  color: var(--accent);
}

/* Bot Intelligence row inside mode group */
.bot-intelligence-row {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 0.2rem;
}

.bot-intelligence-row > label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.2rem;
  font-weight: 600;
}

/* Round completion row inside questions-per-turn group */
.round-completion-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.round-completion-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.btn-toggle {
  padding: 0.45rem 0.85rem;
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--bg-card-light);
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all var(--transition-speed);
}

.btn-toggle:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.btn-toggle.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 700;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* Toggle switch */
.toggle-switch {
  display: inline-flex;
  align-items: center;
}

.toggle-switch input[type="checkbox"] {
  display: none;
}

.toggle-label {
  position: relative;
  width: 50px;
  height: 26px;
  background: #333;
  border-radius: 13px;
  cursor: pointer;
  transition: background var(--transition-speed);
}

.toggle-label::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition-speed);
}

.toggle-switch input:checked + .toggle-label {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-label::after {
  transform: translateX(24px);
}

/* Category checkboxes */
/* Subcategory area — 3-column grid of category panels */
.subcategory-area {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
}

.subcat-group {
  background: linear-gradient(145deg,
    color-mix(in srgb, var(--group-color) 75%, black 25%) 0%,
    color-mix(in srgb, var(--group-color) 55%, black 45%) 100%);
  border: 1px solid color-mix(in srgb, var(--group-color) 60%, white 40%);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  transition: opacity var(--transition-speed), filter var(--transition-speed);
}

.subcat-group.cat-disabled {
  opacity: 0.4;
  filter: grayscale(0.6);
}

.subcat-group-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.4rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: default;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.subcat-list {
  padding-top: 0.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
}

.subcat-group-title input {
  accent-color: #fff;
  width: 15px;
  height: 15px;
  cursor: pointer;
  /* Hidden — uncomment display:inline to restore */
  display: none;
}

.subcat-list label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.76rem;
  color: rgba(255,255,255,0.88);
  cursor: default;
  padding: 0.1rem 0;
}

.subcat-list label input {
  accent-color: rgba(255,255,255,0.9);
  /* Hidden — uncomment display:inline to restore */
  display: none;
}


/* ----- 6. OPTIONS SCREEN ----- */
#options-screen {
  background: var(--bg-dark);
  justify-content: flex-start;
  padding-top: 1.5rem;
}

#options-screen.active {
  justify-content: flex-start;
  align-items: flex-start;
}

#options-screen .setup-screen-inner {
  max-width: 1180px;
}

.setup-screen-inner {
  max-width: 720px;
  padding-top: 1.5rem;
  padding-bottom: 2rem;
  margin: 0 auto;
}

/* Combined players/mode/turn row */
.players-mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
  justify-content: center;
}

.players-select-inline {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
}

.players-select-inline > label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.mode-section,
.turn-section {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  align-items: center;
}

.turn-section > label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
  font-weight: 600;
  text-align: center;
}

.turn-section .btn-group,
.mode-section .btn-group {
  justify-content: center;
}

.mode-section .mode-toggle-row {
  justify-content: center;
}

.mode-section .bot-intelligence-row {
  text-align: center;
}
.mode-section .bot-intelligence-row label {
  display: block;
  text-align: center;
}

/* Player setup grid — 4 columns wide screen, 2x2 medium, 4x1 narrow */
.player-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  width: 100%;
}

/* Solo mode: center single player card */
#options-screen .player-grid:has(.player-card:only-child) {
  grid-template-columns: repeat(4, 1fr);
}

#options-screen .player-grid .player-card:only-child {
  grid-column: 2 / 4;
}


.player-card {
  background: var(--bg-card);
  padding: 0.5rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: opacity var(--transition-speed), filter var(--transition-speed);
}

/* Multiplayer screens use the same player card styling */
.multiplayer-player-card {
  background: var(--bg-card);
  padding: 0.5rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.player-card.inactive {
  opacity: 0.3;
  filter: grayscale(0.6);
  pointer-events: none;
  display: none;
}

.player-card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.player-card-header .player-number {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  min-width: 24px;
}

.player-card-header input[type="text"] {
  flex: 1;
  padding: 0.35rem 0.5rem;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(200,210,220,0.5);
  border-radius: 6px;
  color: #1a2332;
  font-size: 0.8rem;
  outline: none;
  min-width: 0;
}

.player-card-header input[type="text"]:focus {
  border-color: var(--accent);
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
  gap: 0.2rem;
}

.avatar-option {
  width: 32px;
  height: 32px;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  background: var(--bg-card-light);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.avatar-option:hover {
  border-color: rgba(255,255,255,0.3);
  transform: scale(1.1);
}

.avatar-option.selected {
  border-color: var(--accent);
  background: rgba(0,212,255,0.15);
  box-shadow: 0 0 8px var(--accent-glow);
}

.bot-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.06);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ----- 7. GAME SCREEN ----- */
#game-screen {
  display: none;
  flex-direction: column;
  background: linear-gradient(180deg, #080c18 0%, #0f1b3d 100%);
}

#game-screen.active {
  display: flex;
}

/* Question Panel */
.question-panel {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  transition: background 0.4s;
}

/* Ice shine overlay on question panel */
.question-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: -10%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    105deg,
    transparent 30%,
    rgba(255,255,255,0.12) 45%,
    rgba(255,255,255,0.04) 55%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 1;
}

/* Remove frost texture — cleaner border look */
.question-panel::after {
  display: none;
}

.question-panel > * {
  position: relative;
  z-index: 2;
}

.question-panel-inner {
  background: #ffffff;
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

/* Category-colored panel backgrounds */
.question-panel[data-cat="history"] {
  background: linear-gradient(145deg, rgba(139,94,60,0.85) 0%, rgba(160,120,80,0.7) 40%, rgba(139,94,60,0.6) 100%);
}
.question-panel[data-cat="science"] {
  background: linear-gradient(145deg, rgba(46,139,87,0.85) 0%, rgba(80,180,120,0.7) 40%, rgba(46,139,87,0.6) 100%);
}
.question-panel[data-cat="entertainment"] {
  background: linear-gradient(145deg, rgba(58,123,213,0.85) 0%, rgba(100,160,230,0.7) 40%, rgba(58,123,213,0.6) 100%);
}
.question-panel[data-cat="sports"] {
  background: linear-gradient(145deg, rgba(230,126,34,0.85) 0%, rgba(255,170,80,0.7) 40%, rgba(230,126,34,0.6) 100%);
}
.question-panel[data-cat="math"] {
  background: linear-gradient(145deg, rgba(192,57,43,0.85) 0%, rgba(230,100,90,0.7) 40%, rgba(192,57,43,0.6) 100%);
}
.question-panel[data-cat="current_events"] {
  background: linear-gradient(145deg, rgba(142,68,173,0.85) 0%, rgba(180,120,200,0.7) 40%, rgba(142,68,173,0.6) 100%);
}

.question-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.question-header .category-badge {
  flex-shrink: 0;
}

.question-header .question-text {
  flex: 1;
  margin-bottom: 0;
  min-height: auto;
}

.hamburger-btn {
  flex-shrink: 0;
  background: rgba(26,35,50,0.08);
  border: 1px solid rgba(26,35,50,0.18);
  border-radius: 6px;
  color: #1a2332;
  font-size: 1.4rem;
  line-height: 1;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.hamburger-btn:hover {
  background: rgba(26,35,50,0.15);
}

/* Slide-out game menu */
.game-menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 900;
}

.game-menu-overlay.open {
  display: block;
}

.game-menu {
  position: fixed;
  top: 0;
  right: -260px;
  width: 260px;
  height: 100%;
  background: linear-gradient(180deg, #121b33 0%, #0f1b3d 100%);
  border-left: 1px solid rgba(255,255,255,0.1);
  z-index: 950;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  transition: right 0.3s ease;
}

.game-menu.open {
  right: 0;
}

.game-menu-close {
  align-self: flex-end;
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 1.8rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  line-height: 1;
  transition: color 0.2s;
}

.game-menu-close:hover {
  color: #fff;
}

.game-menu-code {
  text-align: center;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.05em;
}

.game-menu-code span {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 0.15em;
}

/* Player-joined toast */
.player-joined-toast {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: rgba(15, 27, 61, 0.95);
  border: 1px solid rgba(0, 212, 255, 0.35);
  border-radius: 10px;
  padding: 0.6rem 1.2rem;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  z-index: 2000;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  opacity: 0;
}

.player-joined-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.game-menu-item {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);

  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
}

.game-menu-item:hover {
  background: var(--danger);
  border-color: var(--danger);
}

.category-badge {
  padding: 0.35rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #fff;
  background: var(--cat-history);
}

.category-badge[data-cat="history"] { background: var(--cat-history); }
.category-badge[data-cat="science"] { background: var(--cat-science); }
.category-badge[data-cat="entertainment"] { background: var(--cat-entertainment); }
.category-badge[data-cat="sports"] { background: var(--cat-sports); }
.category-badge[data-cat="math"] { background: var(--cat-math); }
.category-badge[data-cat="current_events"] { background: var(--cat-current-events); }

.question-timer {
  flex-shrink: 0;
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #d63031;
  min-width: 2ch;
  text-align: center;
}

.question-timer.warning {
  animation: timerPulse 0.6s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.15); }
}

.question-text {
  font-size: 1.45rem;
  line-height: 1.6;
  color: #1a2332;
  margin-bottom: 1rem;
  min-height: 2em;
}

.answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  padding: 0;
  border-radius: 0;
  background: none;
}


.answer-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.1rem;
  background: rgba(240,243,248,0.95);
  border: 2px solid rgba(180,190,205,0.5);
  border-left: 4px solid rgba(180,190,205,0.5);
  border-radius: 8px;
  color: #1a2332;
  cursor: pointer;
  font-size: 1.15rem;
  text-align: left;
  transition: all 0.25s;
  line-height: 1.3;
  position: relative;
}

.answer-btn .answer-letter {
  font-weight: 800;
  color: #3A7BD5;
  min-width: 18px;
}

.answer-btn .answer-indicator {
  margin-left: auto;
  font-size: 1.1rem;
  line-height: 1;
  display: none;
}

/* Only apply hover effect on devices with a real pointer (not touch screens).
   On iOS Safari, tapping triggers a sticky :hover that highlights a random
   answer when the next question loads. */
@media (hover: hover) and (pointer: fine) {
  .answer-btn:hover:not(.disabled) {
    border-color: #3A7BD5;
    border-left-color: #3A7BD5;
    background: rgba(255,255,255,1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }
}

.answer-btn.correct {
  border-color: #2ECC71;
  border-left: 4px solid #2ECC71;
  background: rgba(46,204,113,0.12);
  color: #1a2332;
}

.answer-btn.correct .answer-indicator {
  display: inline;
  color: #2ECC71;
}

.answer-btn.correct .answer-letter {
  color: #2ECC71;
}

.answer-btn.incorrect {
  border-color: #E74C3C;
  border-left: 4px solid #E74C3C;
  background: rgba(231,76,60,0.10);
  color: #1a2332;
}

.answer-btn.incorrect .answer-indicator {
  display: inline;
  color: #E74C3C;
}

.answer-btn.incorrect .answer-letter {
  color: #E74C3C;
}

.answer-btn.disabled {
  pointer-events: none;
  opacity: 0.55;
}

.answer-btn.reveal-correct {
  border-color: #2ECC71;
  border-left: 4px solid #2ECC71;
  background: rgba(46,204,113,0.15);
  opacity: 1 !important;
}

.answer-btn.reveal-correct .answer-indicator {
  display: inline;
  color: #2ECC71;
}

.answer-btn.reveal-correct .answer-letter {
  color: #2ECC71;
}

/* Quit button style removed — quit is now in slide-out menu */

/* Game Board Container */
.game-board-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 0.5rem 0.5rem;
  overflow-x: auto;
  overflow-y: auto;
}

.board-player-names {
  display: none;
}


/* The grid itself */
.game-board {
  position: relative;
  margin: 0 auto;
  box-sizing: border-box;
  overflow: visible;
}

/* Path arrows between blocks */
.path-arrow {
  position: absolute;
  height: 2px;
  background: rgba(0, 212, 255, 0.18);
  transform-origin: 0 50%;
  pointer-events: none;
  z-index: 1;
}

.path-arrow::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid rgba(0, 212, 255, 0.35);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

/* ----- 8. ICE BLOCK STYLING ----- */
.ice-block {
  width: var(--block-size);
  height: var(--block-size);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s, opacity 0.3s;
}

/* Base ice gradient for each category */
.ice-block[data-cat="history"] {
  background: linear-gradient(145deg,
    rgba(139,94,60,0.85) 0%,
    rgba(160,120,80,0.7) 40%,
    rgba(139,94,60,0.6) 100%);
  border: 1px solid rgba(180,140,100,0.3);
}
.ice-block[data-cat="science"] {
  background: linear-gradient(145deg,
    rgba(46,139,87,0.85) 0%,
    rgba(80,180,120,0.7) 40%,
    rgba(46,139,87,0.6) 100%);
  border: 1px solid rgba(80,200,130,0.3);
}
.ice-block[data-cat="entertainment"] {
  background: linear-gradient(145deg,
    rgba(58,123,213,0.85) 0%,
    rgba(100,160,230,0.7) 40%,
    rgba(58,123,213,0.6) 100%);
  border: 1px solid rgba(100,170,240,0.3);
}
.ice-block[data-cat="sports"] {
  background: linear-gradient(145deg,
    rgba(230,126,34,0.85) 0%,
    rgba(255,170,80,0.7) 40%,
    rgba(230,126,34,0.6) 100%);
  border: 1px solid rgba(255,180,100,0.3);
}
.ice-block[data-cat="math"] {
  background: linear-gradient(145deg,
    rgba(192,57,43,0.85) 0%,
    rgba(230,100,90,0.7) 40%,
    rgba(192,57,43,0.6) 100%);
  border: 1px solid rgba(240,120,110,0.3);
}
.ice-block[data-cat="current_events"] {
  background: linear-gradient(145deg,
    rgba(142,68,173,0.85) 0%,
    rgba(180,120,200,0.7) 40%,
    rgba(142,68,173,0.6) 100%);
  border: 1px solid rgba(190,140,220,0.3);
}

/* Start / Finish cells on the S-path */
.path-cell {
  width: var(--block-size);
  height: var(--block-size);
  border-radius: 6px;
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  z-index: 2;
}

.start-cell {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.finish-cell {
  background: transparent;
  border: none;
  font-size: 1.8rem;
}

/* Ice shine overlay */
.ice-block::before {
  content: '';
  position: absolute;
  top: 0;
  left: -10%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    105deg,
    transparent 30%,
    rgba(255,255,255,0.15) 45%,
    rgba(255,255,255,0.05) 55%,
    transparent 70%
  );
  pointer-events: none;
}

/* Frost texture overlay */
.ice-block::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 6px,
      rgba(255,255,255,0.02) 6px,
      rgba(255,255,255,0.02) 7px
    );
  pointer-events: none;
}

/* Category initial letter on block */
.ice-block .block-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  pointer-events: none;
  z-index: 1;
}

/* Player avatar on the board */
.player-avatar-marker {
  position: absolute;
  width: var(--block-size);
  height: var(--block-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  z-index: 10;
  transition: top 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), left 0.5s ease;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
  pointer-events: none;
}

.player-avatar-marker .avatar-ring {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: none;
}

.player-avatar-marker.current-turn .avatar-ring {
  opacity: 1;
  animation: pulseRing 1.5s ease-in-out infinite;
}

.avatar-name-label {
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.player-avatar-marker.current-turn .avatar-name-label {
  color: var(--accent);
}

/* Broken ice block (fully invisible — all players have passed) */
.ice-block.broken {
  opacity: 0;
  pointer-events: none;
  border-color: transparent;
}

.ice-block.broken::before,
.ice-block.broken::after {
  display: none;
}

/* Ice crack overlay for break animation */
.crack-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.crack-line {
  position: absolute;
  background: rgba(255,255,255,0.8);
  animation: crackAppear 0.3s forwards;
}

/* Ice shard particles */
.ice-shard {
  position: absolute;
  border-radius: 2px;
  pointer-events: none;
  z-index: 15;
}


/* ----- 9. WIN SCREEN ----- */
#win-screen {
  background: radial-gradient(ellipse at center, #0f1b3d 0%, #080c18 100%);
  z-index: 50;
}

#confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.win-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 2rem;
}

.win-banner {
  margin-bottom: 2rem;
}

.win-avatar {
  font-size: 4rem;
  margin-bottom: 0.5rem;
  animation: bounceIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#win-title {
  font-size: 3rem;
  background: linear-gradient(135deg, #FFD700, #FFA500, #FF6347);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: winPulse 2s ease-in-out infinite alternate;
}

#win-subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

.final-standings {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1.5rem auto;
  max-width: 350px;
}

.standing-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem 1rem;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.05);
}

.standing-row.winner {
  border-color: #FFD700;
  background: rgba(255,215,0,0.08);
}

.standing-rank {
  font-weight: 800;
  font-size: 1.1rem;
  min-width: 28px;
  color: var(--accent);
}

.standing-row.winner .standing-rank {
  color: #FFD700;
}

.standing-avatar {
  font-size: 1.3rem;
}

.standing-name {
  flex: 1;
  text-align: left;
}

.standing-progress {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Rematch banner on win screen */
.rematch-banner {
  background: rgba(78, 205, 196, 0.12);
  border: 1px solid rgba(78, 205, 196, 0.3);
  border-radius: 10px;
  padding: 0.8rem 1.2rem;
  margin: 1rem auto;
  max-width: 360px;
  text-align: center;
}
.rematch-banner p {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
  line-height: 1.4;
}
.rematch-banner .countdown-timer {
  font-size: 1.1rem;
}

/* Rematch countdown overlay on game screen */
.rematch-countdown-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
}
.rematch-countdown-overlay .rematch-timer {
  font-size: 2.5rem;
  font-weight: 800;
  font-family: 'Courier New', monospace;
  color: var(--accent);
}
.rematch-countdown-overlay .rematch-timer.urgent {
  color: #e74c3c;
  animation: pulse-urgent 1s ease-in-out infinite;
}
.rematch-countdown-overlay .rematch-status {
  font-size: 1rem;
  color: var(--text-secondary);
}

/* ----- 10. COMPONENTS ----- */
.btn {
  display: inline-block;
  padding: 0.8rem 2.2rem;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 60%);
  pointer-events: none;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, #00b4d8, #0077b6);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0,180,216,0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #00c4e8, #0088cc);
  box-shadow: 0 6px 20px rgba(0,180,216,0.4);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--bg-card-light);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.12);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.1);
  transform: translateY(-2px);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.3rem;
  transition: color 0.2s;
}

.btn-icon:hover {
  color: var(--text-primary);
}

/* Status bar removed — turn info now in question header */

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,14,26,0.92);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ----- MODAL STYLES ----- */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: var(--border-radius);
  z-index: 1001;
  max-width: 700px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 30px rgba(0,212,255,0.1);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid rgba(0,212,255,0.1);
}

.modal-header h2 {
  color: var(--accent);
  font-size: 1.3rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: #00ffff;
}

.modal-body {
  padding: 1.5rem;
  flex: 1;
  overflow-y: auto;
}

.modal-actions {
  padding: 1rem;
  border-top: 1px solid rgba(0,212,255,0.1);
  text-align: right;
}

.modal-actions:empty {
  display: none;
}

/* ---- Contact Modal ---- */
.contact-modal {
  max-width: 500px;
}

.contact-field {
  margin-bottom: 1rem;
}

.contact-field label {
  display: block;
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.contact-field input,
.contact-field textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  background: var(--bg-card-light);
  border: 1px solid rgba(0,212,255,0.15);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: vertical;
}

.contact-field input:focus,
.contact-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.contact-field input::placeholder,
.contact-field textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.contact-actions {
  text-align: right;
  margin-top: 0.5rem;
}

.contact-status {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  text-align: center;
  min-height: 1.2em;
}

.contact-status.success {
  color: var(--success);
}

.contact-status.error {
  color: var(--danger);
}

/* AFK Modal */
.afk-modal {
  max-width: 400px;
  text-align: center;
}

.afk-modal-body {
  padding: 2rem 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.afk-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.afk-title {
  color: var(--accent);
  font-size: 1.5rem;
  margin: 0;
}

.afk-subtitle {
  color: rgba(255,255,255,0.6);
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.afk-continue-btn {
  width: 100%;
  max-width: 260px;
  padding: 0.85rem 2rem;
  font-size: 1.1rem;
}

.afk-quit-text {
  color: rgba(255,255,255,0.4);
  font-size: 0.9rem;
  margin: 0.75rem 0 0;
}

.afk-quit-text span {
  color: #d63031;
  font-weight: 700;
}

.category-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
  padding: 0;
  margin:0;
}

.category-link:hover {
  color: #00ffff;
  text-decoration: underline;
}

/* ----- 11. RESPONSIVE / MOBILE ----- */
@media (max-width: 760px) {
  :root {
    --block-size: 80px;
    --block-gap: 6px;
  }

  .title-trivia {
    font-size: 2rem;
    letter-spacing: 0.3em;
  }

  .title-breakout {
    font-size: 2.8rem;
  }

  .splash-buttons .btn {
    font-size: 0.85rem;
    min-width: 120px;
    padding: 0.8rem 1rem;
    letter-spacing: 0.04em;
  }

  .options-grid {
    grid-template-columns: 1fr;
  }

  .option-group.wide {
    grid-column: 1;
  }

  .answers-grid {
    grid-template-columns: 1fr;
  }

  .question-header {
    flex-wrap: wrap;
  }

  .question-header .question-text {
    order: 4;
    flex-basis: 100%;
  }

  .question-header .category-badge {
    order: 1;
  }

  .question-header .question-timer {
    order: 2;
  }

  .question-header .hamburger-btn {
    order: 3;
    margin-left: auto;
  }

  .screen-inner {
    padding: 1.5rem 1rem;
  }

  #game-screen.active {
    justify-content: flex-start;
  }


  .players-mode-row {
    gap: 1rem;
  }

  .players-select-inline {
    flex: 1 1 100%;
  }

  .turn-section,
  .mode-section {
    flex: 1 1 calc(50% - 0.5rem);
  }

  .subcategory-area {
    grid-template-columns: repeat(2, 1fr);
  }

  .player-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  :root {
    --block-size: 40px;
    --block-gap: 3px;
  }

  .title-trivia {
    font-size: 1.5rem;
  }

  .title-breakout {
    font-size: 2rem;
  }

  .btn {
    padding: 0.65rem 1.5rem;
    font-size: 0.95rem;
  }

  .answer-btn {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
  }

  .question-panel {
    padding: 8px;
    border-radius: 10px;
  }

  .question-panel-inner {
    padding: 0.75rem 0.9rem;
  }

  .players-select-inline,
  .turn-section,
  .mode-section {
    flex: 1 1 100%;
  }

  .subcategory-area {
    grid-template-columns: 1fr;
  }

  /* Accordion: collapse subcategories in single-column modal view */
  .modal .subcat-group .subcat-list {
    display: none;
  }

  .modal .subcat-group .subcat-group-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
    cursor: pointer;
    justify-content: space-between;
  }

  .modal .subcat-group .subcat-group-title::after {
    content: '\25BC';
    font-size: 0.65rem;
    opacity: 0.6;
    transition: transform 0.2s;
  }

  .modal .subcat-group.expanded .subcat-group-title {
    margin-bottom: 0.4rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid rgba(255,255,255,0.25);
  }

  .modal .subcat-group.expanded .subcat-group-title::after {
    transform: rotate(180deg);
  }

  .modal .subcat-group.expanded .subcat-list {
    display: flex;
  }

  .player-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  :root {
    --block-size: 34px;
    --block-gap: 2px;
  }
}

/* ----- COPYRIGHT ----- */
.copyright {
  text-align: center;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.35);
  padding: 1.5rem 0 0.5rem;
  letter-spacing: 0.03em;
}

.footer-link {
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-link:hover {
  color: rgba(0,212,255,0.8);
  text-decoration: underline;
}

/* ----- 12. KEYFRAME ANIMATIONS ----- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes shimmer {
  0% { opacity: 0.7; }
  100% { opacity: 1; }
}

@keyframes titlePulse {
  0% { filter: drop-shadow(0 0 20px rgba(0,212,255,0.3)); }
  100% { filter: drop-shadow(0 0 35px rgba(0,212,255,0.6)); }
}

@keyframes shardFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.4; }
  50% { transform: translateY(-12px) rotate(15deg); opacity: 0.8; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}



@keyframes crackAppear {
  from { opacity: 0; transform: scaleX(0); }
  to { opacity: 1; transform: scaleX(1); }
}

@keyframes pulseRing {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.15); opacity: 0.8; }
}

@keyframes bounceIn {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ----- MULTIPLAYER SCREENS ----- */

#create-game-screen.active,
#join-game-screen.active,
#multiplayer-menu-screen.active {
  justify-content: flex-start;
  padding-top: 1.5rem;
}

#create-game-screen .setup-screen-inner,
#join-game-screen .setup-screen-inner,
#multiplayer-menu-screen .setup-screen-inner {
  padding-top: 0;
}

.screen-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 2rem;
}

.multiplayer-menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.btn.btn-primary.large {
  padding: 1.5rem;
  font-size: 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width:80%;
  margin-left:10%;
}

.btn-label {
  font-weight: 700;
  display: block;
}

.btn-description {
  font-size: 0.9rem;
  opacity: 0.8;
  display: block;
}


.game-code-box {
  background: var(--bg-card-light);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 0.6rem 1rem;
  margin: 0.6rem 0;
  text-align: center;
}

.code-label {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.game-code {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  font-family: 'Courier New', monospace;
  letter-spacing: 0.2em;
  margin: 0.3rem 0;
}
#game-code-display {
  margin:0;
}
.btn.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.invite-buttons {
  display: flex;
  gap: 0.6rem;
  margin-top: 0;
  padding-top:0;
  justify-content: center;
}
.invite-buttons .btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 0.8rem 0;
  background: var(--bg-card-light);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.12);
}
.invite-buttons .btn:hover {
  background: rgba(255,255,255,0.1);
  transform: translateY(-2px);
}

.waiting-label {
  text-align: center;
  color: var(--text-secondary);
  margin: 2rem 0 1rem 0;
  font-style: italic;
}

.countdown-section {
  text-align: center;
  margin: 0.5rem 0;
}
.countdown-label {
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0;
}
.countdown-timer {
  font-weight: 700;
  color: var(--accent);
  font-family: 'Courier New', monospace;
}
.countdown-timer.urgent {
  color: #e74c3c;
  animation: pulse-urgent 1s ease-in-out infinite;
}
@keyframes pulse-urgent {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes headShake {
  0%   { transform: translateX(0); }
  12%  { transform: translateX(-6px); }
  25%  { transform: translateX(5px); }
  37%  { transform: translateX(-4px); }
  50%  { transform: translateX(3px); }
  62%  { transform: translateX(-2px); }
  75%  { transform: translateX(1px); }
  100% { transform: translateX(0); }
}
.shake {
  animation: headShake 0.5s ease-in-out;
}

.players-list-box {
  background: var(--bg-card-light);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin: 0.6rem 0;
}

.players-list-box h3 {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.players-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.players-list-header h3 {
  margin: 0;
}
.countdown-inline {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.players-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 40px;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.5rem;
  background: var(--bg-card);
  border-radius: 6px;
  font-size: 0.95rem;
}

.player-item .avatar {
  font-size: 1.5rem;
}

.player-item .name {
  flex: 1;
}

.player-item .role {
  font-size: 0.8rem;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 700;
}

.player-leave-btn {
  background: none;
  border: none;
  color: #e74c3c;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.2rem;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.player-leave-btn:hover {
  opacity: 1;
}


/* Multiplayer screen text inputs */
#create-player-name,
#join-game-code,
#join-player-name {
  width: 100%;
  max-width: 100%;
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(200,210,220,0.5);
  border-radius: 6px;
  color: #1a2332;
  outline: none;
  transition: border-color var(--transition-speed);
}

#create-player-name:focus,
#join-game-code:focus,
#join-player-name:focus {
  border-color: var(--accent);
}

/* Game code input width matches the card */
#join-game-code {
  width:200px;
  height:40px;
  margin-left: auto;
  margin-right: auto;
  display: block;
  text-transform: uppercase;
  text-align: center;
  margin-bottom:10px;
}

.info-message {
  text-align: center;
  color: var(--accent);
  padding: 1rem;
  background: rgba(0, 212, 255, 0.1);
  border-radius: 6px;
  margin: 1rem 0;
  font-size: 0.9rem;
}

@keyframes winPulse {
  0% { filter: brightness(1); }
  100% { filter: brightness(1.3); }
}

@keyframes shardFly {
  0% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translate(var(--shard-x), var(--shard-y)) rotate(var(--shard-r)) scale(0); }
}

@keyframes avatarBurst {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.5); filter: drop-shadow(0 0 12px rgba(0,212,255,0.8)); }
  60%  { transform: scale(1.15); }
  80%  { transform: scale(1.3); filter: drop-shadow(0 0 8px rgba(0,212,255,0.5)); }
  100% { transform: scale(1.2); filter: drop-shadow(0 0 6px rgba(0,212,255,0.4)); }
}

/* ===== CHAT AREA ===== */
.chat-area {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 260px;
  margin-top: 0.5rem;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 80px;
  max-height: 180px;
  scrollbar-width: thin;
}

.chat-msg {
  font-size: 0.85rem;
  line-height: 1.3;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: rgba(255,255,255,0.07);
  word-break: break-word;
  color: #1a2332;
}

.chat-msg .chat-sender {
  font-weight: 700;
  margin-right: 0.3em;
}

.chat-msg.chat-msg-self {
  background: rgba(0, 212, 255, 0.12);
}

.chat-input-row {
  display: flex;
  gap: 0.4rem;
  padding: 0.4rem 0.5rem;
}

.chat-input {
  flex: 1;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.35);
  background: #e8f4fd;
  color: #222;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: var(--accent);
}

.chat-input::placeholder {
  color: rgba(0,0,0,0.4);
}

.chat-send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-send-btn:hover {
  background: #00b8d4;
}
