@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&display=swap');

/* ===== CSS VARIABLES — DARK THEME (default) ===== */
:root {
  --bg-primary: #1A1A2E;
  --bg-secondary: #16213E;
  --bg-card: rgba(255, 255, 255, 0.05);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --bg-hover: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.10);
  --border-accent: rgba(79, 195, 247, 0.4);

  --accent: #4FC3F7;
  --accent-glow: rgba(79, 195, 247, 0.3);
  --accent-light: #81D4FA;
  --success: #4CAF50;
  --success-glow: rgba(76, 175, 80, 0.3);
  --warning: #FFB74D;
  --warning-glow: rgba(255, 183, 77, 0.3);
  --danger: #EF5350;
  --danger-glow: rgba(239, 83, 80, 0.3);

  --text-primary: #E0E0E0;
  --text-secondary: rgba(224, 224, 224, 0.70);
  --text-muted: rgba(224, 224, 224, 0.45);

  --gradient-main: linear-gradient(135deg, #4FC3F7 0%, #7C4DFF 50%, #E040FB 100%);
  --gradient-success: linear-gradient(135deg, #4CAF50, #2E7D32);
  --gradient-card: linear-gradient(135deg, rgba(79,195,247,0.12) 0%, rgba(124,77,255,0.05) 100%);

  --header-bg: rgba(26, 26, 46, 0.90);
  --chat-header-bg: rgba(79, 195, 247, 0.06);

  --focus-color: #4FC3F7;
  --focus-outline: 3px solid #4FC3F7;

  --radius: 16px;
  --radius-sm: 8px;
  --radius-lg: 24px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-accent: 0 8px 32px rgba(79, 195, 247, 0.2);

  --font-base-size: 16px;
}

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
  --bg-primary: #F5F5F5;
  --bg-secondary: #EEEEEE;
  --bg-card: rgba(0, 0, 0, 0.03);
  --bg-card-hover: rgba(0, 0, 0, 0.06);
  --bg-hover: rgba(0, 0, 0, 0.04);
  --border: rgba(0, 0, 0, 0.12);
  --border-accent: rgba(21, 101, 192, 0.4);

  --accent: #1565C0;
  --accent-glow: rgba(21, 101, 192, 0.2);
  --accent-light: #1976D2;
  --success: #2E7D32;
  --success-glow: rgba(46, 125, 50, 0.2);
  --warning: #F57F17;
  --warning-glow: rgba(245, 127, 23, 0.2);
  --danger: #C62828;
  --danger-glow: rgba(198, 40, 40, 0.2);

  --text-primary: #212121;
  --text-secondary: rgba(33, 33, 33, 0.70);
  --text-muted: rgba(33, 33, 33, 0.50);

  --gradient-main: linear-gradient(135deg, #1565C0 0%, #6A1B9A 50%, #AD1457 100%);
  --gradient-success: linear-gradient(135deg, #2E7D32, #1B5E20);
  --gradient-card: linear-gradient(135deg, rgba(21,101,192,0.08) 0%, rgba(106,27,154,0.03) 100%);

  --header-bg: rgba(245, 245, 245, 0.92);
  --chat-header-bg: rgba(21, 101, 192, 0.06);

  --focus-color: #1565C0;
  --focus-outline: 3px solid #1565C0;

  --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-accent: 0 8px 32px rgba(21, 101, 192, 0.15);
}

[data-theme="light"] body::before {
  background: radial-gradient(ellipse at 20% 20%, rgba(21,101,192,0.05) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 80%, rgba(173,20,87,0.03) 0%, transparent 50%);
}

[data-theme="light"] .login-card {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .login-input-wrap .form-input {
  background: rgba(0, 0, 0, 0.04);
}
[data-theme="light"] .login-input-underline {
  background: var(--accent);
}
[data-theme="light"] .login-bg-effect::before,
[data-theme="light"] .login-bg-effect::after {
  opacity: 0.5;
}

[data-theme="light"] #main-header {
  background: rgba(245, 245, 245, 0.85);
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
  border-bottom-color: rgba(0,0,0,0.08);
}

[data-theme="light"] body {
  background-image: radial-gradient(circle at 2px 2px, rgba(21,101,192,0.04) 1px, transparent 0);
  background-size: 40px 40px;
}

[data-theme="light"] .card {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(0,0,0,0.06);
}
[data-theme="light"] .card:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(21,101,192,0.2);
}

[data-theme="light"] .chat-container {
  background: rgba(255,255,255,0.75);
  border-color: rgba(0,0,0,0.08);
}

[data-theme="light"] .chat-header {
  background: rgba(21,101,192,0.04);
  border-bottom-color: rgba(0,0,0,0.06);
}

[data-theme="light"] .chat-input {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.1);
}

[data-theme="light"] .challenge-banner {
  background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(21,101,192,0.06) 100%);
  border-color: rgba(21,101,192,0.15);
}

[data-theme="light"] .rank-item {
  background: rgba(0,0,0,0.02);
}
[data-theme="light"] .rank-item:first-child {
  background: rgba(21,101,192,0.06);
  border-color: rgba(21,101,192,0.12);
}
[data-theme="light"] .rank-item.my-group {
  background: rgba(21,101,192,0.06);
  border-color: rgba(21,101,192,0.2);
}

[data-theme="light"] .member-item.online {
  background: rgba(46,125,50,0.06);
}

[data-theme="light"] .finished-overlay {
  background: rgba(255, 255, 255, 0.85);
}

[data-theme="light"] .finished-modal {
  background: #FAFAFA;
}

[data-theme="light"] .msg.user .msg-bubble {
  color: #FFFFFF;
}

[data-theme="light"] .wordle-kb-key {
  background: rgba(0, 0, 0, 0.08);
}

/* ===== HIGH CONTRAST THEME ===== */
[data-theme="high-contrast"] {
  --bg-primary: #000000;
  --bg-secondary: #0A0A0A;
  --bg-card: rgba(255, 255, 0, 0.04);
  --bg-card-hover: rgba(255, 255, 0, 0.08);
  --bg-hover: rgba(255, 255, 0, 0.05);
  --border: rgba(255, 255, 0, 0.30);
  --border-accent: rgba(255, 255, 0, 0.6);

  --accent: #FFFF00;
  --accent-glow: rgba(255, 255, 0, 0.3);
  --accent-light: #FFFF00;
  --success: #00FF00;
  --success-glow: rgba(0, 255, 0, 0.3);
  --warning: #FFD700;
  --warning-glow: rgba(255, 215, 0, 0.3);
  --danger: #FF4444;
  --danger-glow: rgba(255, 68, 68, 0.3);

  --text-primary: #FFFF00;
  --text-secondary: rgba(255, 255, 0, 0.85);
  --text-muted: rgba(255, 255, 0, 0.60);

  --gradient-main: linear-gradient(135deg, #FFFF00, #FFD700);
  --gradient-success: linear-gradient(135deg, #00FF00, #00CC00);
  --gradient-card: linear-gradient(135deg, rgba(255,255,0,0.06) 0%, rgba(255,215,0,0.03) 100%);

  --header-bg: rgba(0, 0, 0, 0.95);
  --chat-header-bg: rgba(255, 255, 0, 0.06);

  --focus-color: #FFFFFF;
  --focus-outline: 3px solid #FFFFFF;

  --shadow: 0 4px 16px rgba(255, 255, 0, 0.1);
  --shadow-accent: 0 4px 16px rgba(255, 255, 0, 0.2);
}

[data-theme="high-contrast"] body::before { display: none; }
[data-theme="high-contrast"] body { background-image: none; }

[data-theme="high-contrast"] #main-header {
  background: rgba(0,0,0,0.95);
  border-bottom-color: #FFFF00;
  box-shadow: none;
}

[data-theme="high-contrast"] .card {
  background: rgba(255,255,0,0.04);
  border-color: rgba(255,255,0,0.3);
}

[data-theme="high-contrast"] .chat-container {
  background: #000;
  border-color: #FFFF00;
}

[data-theme="high-contrast"] .chat-input {
  background: #0A0A0A;
  border-color: #FFFF00;
}

[data-theme="high-contrast"] .challenge-banner {
  background: #000;
  border-color: #FFFF00;
}

[data-theme="high-contrast"] .rank-item,
[data-theme="high-contrast"] .rank-item:first-child {
  background: rgba(255,255,0,0.04);
  border-color: rgba(255,255,0,0.3);
}
[data-theme="high-contrast"] .rank-item.my-group {
  border-color: #FFFF00;
}

[data-theme="high-contrast"] .member-item.online {
  border-left-color: #00FF00;
}

[data-theme="high-contrast"] .msg.user .msg-bubble {
  background: #FFFF00;
  color: #000000;
}

[data-theme="high-contrast"] .btn-primary {
  background: #FFFF00;
  color: #000000;
}

[data-theme="high-contrast"] .login-card {
  background: #000000;
  border-color: #FFFF00;
}
[data-theme="high-contrast"] .login-input-wrap .form-input {
  background: #111;
  border: 1px solid #FFFF00;
}
[data-theme="high-contrast"] .login-input-underline {
  background: #FFFF00;
}

[data-theme="high-contrast"] .finished-overlay {
  background: rgba(0, 0, 0, 0.95);
}

[data-theme="high-contrast"] .finished-modal {
  background: #000000;
  border-color: #FFFF00;
}

/* ===== DYSLEXIA FONT ===== */
[data-font="dyslexia"] {
  font-family: 'Atkinson Hyperlegible', 'OpenDyslexic', sans-serif !important;
}
[data-font="dyslexia"] * {
  font-family: inherit !important;
}

/* ===== WIDE SPACING ===== */
[data-spacing="wide"] {
  line-height: 1.8 !important;
  letter-spacing: 0.05em !important;
  word-spacing: 0.16em !important;
}
[data-spacing="wide"] p,
[data-spacing="wide"] .msg-bubble,
[data-spacing="wide"] .chat-input {
  line-height: 2 !important;
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
[data-reduce-motion="true"] *,
[data-reduce-motion="true"] *::before,
[data-reduce-motion="true"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

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

html { font-size: var(--font-base-size, 16px); scroll-behavior: smooth; }

body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  background-image: radial-gradient(circle at 2px 2px, rgba(79,195,247,0.04) 1px, transparent 0);
  background-size: 40px 40px;
}

/* Background animated gradient */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 20% 20%, rgba(79,195,247,0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 80%, rgba(224,64,251,0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ===== SKIP LINK ===== */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--accent);
  color: #000;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  z-index: 1000;
  text-decoration: none;
  transition: top 0.15s;
}
.skip-link:focus {
  top: 0.75rem;
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* ===== GLOBAL FOCUS STYLES ===== */
*:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}
/* Remove default outline only where focus-visible is supported */
*:focus:not(:focus-visible) {
  outline: none;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3 { font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.8rem); }
h3 { font-size: 1.1rem; font-weight: 600; }
p { color: var(--text-secondary); }

/* ===== LAYOUT ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; position: relative; z-index: 1; }
.page { min-height: 100vh; display: flex; flex-direction: column; }

/* ===== GLASS CARD ===== */
.card {
  background: rgba(25, 37, 64, 0.5);
  border: 1px solid rgba(129, 236, 255, 0.08);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.25s ease;
}
.card:hover { background: rgba(25, 37, 64, 0.65); border-color: rgba(129, 236, 255, 0.2); }
.card.glow { box-shadow: 0 0 20px var(--accent-glow); border-color: var(--border-accent); }

/* ===== HEADER ===== */
#main-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(6, 14, 32, 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding: 0.875rem 0;
  box-shadow: 0 0 20px rgba(79,195,247,0.08);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}
.brand-icon {
  width: 36px; height: 36px;
  background: var(--gradient-main);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.header-phase {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-light);
}
.phase-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 0 6px transparent; }
}
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.header-a11y-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
#timer-badge {
  display: none;
  font-family: 'Space Mono', monospace;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid var(--warning);
  color: var(--warning);
  min-width: 80px;
  text-align: center;
  box-shadow: 0 0 10px rgba(245,158,11,0.15);
}
#timer-badge.urgent {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
  color: var(--danger);
  animation: flash 0.8s ease-in-out infinite;
  box-shadow: 0 0 14px rgba(239,68,68,0.3);
}
@keyframes flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.member-badges { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.member-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--success-glow);
  border: 1px solid var(--success);
  color: var(--success);
  font-weight: 500;
}
.member-badge.me {
  background: var(--accent-glow);
  border-color: var(--accent-light);
  color: var(--accent-light);
}
.member-badge.offline {
  background: rgba(240, 240, 255, 0.05);
  border-color: var(--text-muted);
  color: var(--text-muted);
  opacity: 0.7;
}

/* ===== THEME & A11Y TOGGLE BUTTONS ===== */
.a11y-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1.15rem;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.a11y-icon-btn:hover { background: var(--accent-glow); border-color: var(--accent); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
  min-height: 44px;
  min-width: 44px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--gradient-main);
  color: white;
  box-shadow: 0 4px 20px rgba(79,195,247,0.2);
  font-weight: 700;
  letter-spacing: 0.05em;
}
.btn-primary:hover:not(:disabled) {
  transform: scale(1.02);
  box-shadow: 0 0 24px rgba(79,195,247,0.4);
}
.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
}
.btn-success {
  background: var(--gradient-success);
  color: white;
}
.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.2);
  transform: scale(1.02);
}
.btn-danger:active:not(:disabled) {
  transform: scale(0.98);
}
.btn-lg { padding: 0.875rem 2rem; font-size: 1rem; border-radius: var(--radius-sm); }
.btn-full { width: 100%; }

/* ===== FORM ELEMENTS ===== */
.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
.form-label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.form-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  outline: none;
  width: 100%;
  min-height: 44px;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-input::placeholder { color: var(--text-muted); }

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  overflow: hidden;
}
.login-bg-effect {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(79,195,247,0.15) 0%, transparent 40%),
    radial-gradient(circle at bottom left, rgba(124,77,255,0.12) 0%, transparent 40%);
  pointer-events: none;
}
.login-bg-effect::before,
.login-bg-effect::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(100px);
}
.login-bg-effect::before {
  width: 300px;
  height: 300px;
  top: -80px;
  left: -80px;
  background: var(--accent-glow);
}
.login-bg-effect::after {
  width: 300px;
  height: 300px;
  bottom: -80px;
  right: -80px;
  background: rgba(124,77,255,0.15);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(22, 33, 62, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow), 0 0 40px rgba(79,195,247,0.1);
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.login-logo {
  text-align: center;
  margin-bottom: 2.5rem;
}
.login-logo h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}
.login-logo p {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.2em;
}
.login-form { display: flex; flex-direction: column; gap: 1.25rem; width: 100%; }

/* Login form labels */
.login-form .form-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-left: 0.25rem;
}

/* Login form input with icon */
.login-input-wrap {
  position: relative;
}
.login-input-wrap .login-input-icon {
  position: absolute;
  top: 50%;
  left: 0.75rem;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: var(--text-muted);
  pointer-events: none;
}
.login-input-wrap .form-input {
  padding-left: 2.5rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(9, 19, 40, 0.8);
  transition: all 0.3s ease;
}
.login-input-wrap .form-input:focus {
  outline: none;
  box-shadow: none;
}

/* Animated underline on focus */
.login-input-underline {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  transition: width 0.3s ease;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.login-input-wrap:focus-within .login-input-underline {
  width: 100%;
}

/* Login primary button */
.login-form .btn-primary {
  padding: 1rem;
  background: var(--gradient-main);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  border-radius: var(--radius);
  border: none;
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 24px rgba(79,195,247,0.2);
}
.login-form .btn-primary:hover {
  transform: scale(1.02);
}
.login-form .btn-primary:active {
  transform: scale(0.98);
}

/* Divider */
.login-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin-top: 2rem;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  opacity: 0.3;
}
.login-divider span {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  white-space: nowrap;
}

/* PlayChallenges logo button */
.login-pc-logo {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}
.login-pc-logo button {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.login-pc-logo button:hover {
  border-color: rgba(79,195,247,0.4);
}

/* Coordinator hint */
.login-hint {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.login-hint strong {
  color: var(--accent-light);
}

.error-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: #fca5a5;
  font-size: 0.875rem;
  display: none;
}

/* ===== DASHBOARD LAYOUT ===== */
.dashboard-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.5rem;
  padding: 1.5rem 0 2rem;
  min-height: calc(100vh - 64px);
}
.main-panel { display: flex; flex-direction: column; gap: 1.25rem; }
.side-panel { display: flex; flex-direction: column; gap: 1.25rem; }

/* ===== PROGRESS BAR (CHALLENGE) ===== */
.challenge-progress-wrap {
  padding: 0.5rem 0;
}
.challenge-progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.challenge-progress-fill {
  height: 100%;
  background: var(--gradient-main);
  border-radius: 999px;
  transition: width 0.5s ease;
  box-shadow: 0 0 12px rgba(79,195,247,0.5), 0 0 4px rgba(79,195,247,0.3);
}
.challenge-progress-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 0.4rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ===== CHALLENGE STATE ===== */
.challenge-banner {
  background: linear-gradient(135deg, rgba(25,37,64,0.8) 0%, rgba(79,195,247,0.08) 100%);
  border: 1px solid rgba(129,236,255,0.15);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(79,195,247,0.06);
}
.challenge-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(6,14,32,0.7) 0%, transparent 50%, rgba(6,14,32,0.5) 100%);
  pointer-events: none;
}
.challenge-number {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(79,195,247,0.12);
  border: 1px solid rgba(79,195,247,0.25);
  border-radius: 999px;
  padding: 0.25rem 0.9rem;
  margin-bottom: 0.75rem;
  position: relative;
  z-index: 1;
}
.challenge-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
  position: relative;
  z-index: 1;
}
.challenge-desc { color: var(--text-secondary); font-size: 0.95rem; position: relative; z-index: 1; max-width: 500px; margin: 0 auto; }

.waiting-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem;
}
.waiting-icon {
  font-size: 4rem;
  animation: bounce 2s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

/* ===== CHAT ===== */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(25, 37, 64, 0.4);
  border: 1px solid rgba(129, 236, 255, 0.1);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 450px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 0 20px rgba(79,195,247,0.04);
}
.chat-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(129, 236, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(79, 195, 247, 0.04);
}
.chat-icon {
  width: 36px; height: 36px;
  background: var(--gradient-main);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: msg-in 0.3s ease;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; align-items: flex-start; }
.msg-sender {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  padding: 0 0.5rem;
}
.msg-bubble {
  padding: 0.75rem 1rem;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
}
.msg.user .msg-bubble {
  background: var(--gradient-main);
  color: white;
  border-bottom-right-radius: 4px;
}
.msg.assistant .msg-bubble {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}
.msg.system .msg-bubble {
  background: rgba(79,195,247,0.08);
  border: 1px solid rgba(79,195,247,0.2);
  color: var(--accent-light);
  font-size: 0.82rem;
  text-align: center;
  border-radius: var(--radius-sm);
  max-width: 100%;
}
#chat-lang-select,
#tts-rate-select {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
#chat-lang-select option,
#tts-rate-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
}

.chat-input-area {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(129, 236, 255, 0.08);
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: rgba(9, 19, 40, 0.6);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  max-height: 120px;
  min-height: 44px;
}
.chat-input:focus { border-color: rgba(79,195,247,0.4); box-shadow: 0 0 0 3px rgba(79,195,247,0.1); }
.chat-input::placeholder { color: var(--text-muted); }
.send-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--gradient-main);
  border: none;
  color: white;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: all 0.15s;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(79,195,247,0.2);
}
.send-btn:hover { transform: scale(1.08); box-shadow: 0 0 20px rgba(79,195,247,0.4); }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.typing-indicator {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.typing-dots { display: flex; gap: 3px; }
.typing-dots span {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: typing 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ===== UI BLOCKS (interactive chat components) ===== */
.ui-blocks-wrapper { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.75rem; }
.ui-block { display: flex; flex-direction: column; gap: 0.35rem; }
.ui-block-label { font-weight: 600; font-size: 0.82rem; color: var(--text-primary); }
.ui-select-group { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ui-option-btn { padding: 0.4rem 0.9rem; border: 1.5px solid var(--border); border-radius: 999px; background: var(--bg-card); color: var(--text-primary); font-size: 0.82rem; cursor: pointer; transition: all 0.15s; white-space: nowrap; font-family: inherit; }
.ui-option-btn:hover { border-color: var(--accent); background: rgba(79,195,247,0.08); }
.ui-option-btn.selected { border-color: var(--accent); background: var(--accent); color: #fff; }
.ui-multi .ui-option-btn.selected { background: rgba(79,195,247,0.15); color: var(--accent-light); }
.ui-text-input { width: 100%; padding: 0.5rem 0.75rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; font-family: inherit; resize: vertical; min-height: 40px; background: var(--bg-secondary); color: var(--text-primary); transition: border-color 0.15s; box-sizing: border-box; outline: none; }
.ui-text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.ui-text-input::placeholder { color: var(--text-muted); }
.ui-blocks-confirm { align-self: flex-end; padding: 0.5rem 1.5rem; border: none; border-radius: var(--radius-sm); background: var(--gradient-main); color: #fff; font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.15s; font-family: inherit; }
.ui-blocks-confirm:hover { transform: translateY(-1px); }
.ui-blocks-submitted .ui-option-btn, .ui-blocks-submitted .ui-text-input { opacity: 0.5; pointer-events: none; }
.ui-blocks-submitted .ui-option-btn.selected { opacity: 1; }
.ui-block-error .ui-select-group { padding: 0.4rem; border: 1.5px solid var(--danger); border-radius: var(--radius-sm); }
.ui-block-error .ui-block-label { color: var(--danger); }
.ui-block-error-msg { font-size: 0.72rem; color: var(--danger); display: none; }
.ui-block-error .ui-block-error-msg { display: block; }

/* ===== GEO CHALLENGE ===== */
.geo-challenge { text-align: center; padding: 2rem 1.5rem; }
.geo-badge { display: inline-flex; align-items: center; gap: 0.5rem; background: rgba(76,175,80,0.12); border: 1px solid rgba(76,175,80,0.35); color: var(--success); border-radius: 999px; padding: 0.3rem 1rem; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 1rem; }
.geo-confirm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 1rem 2.5rem; border: none; border-radius: var(--radius); background: linear-gradient(135deg, #4CAF50, #2E7D32); color: #fff; font-size: 1.1rem; font-weight: 700; cursor: pointer; transition: all 0.2s; font-family: inherit; min-height: 56px; box-shadow: 0 4px 20px rgba(76,175,80,0.3); }
.geo-confirm-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(76,175,80,0.4); }
.geo-confirm-btn:active { transform: translateY(0); }
.geo-confirm-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.geo-confirm-btn.locating { animation: geo-pulse 1.5s ease-in-out infinite; }
@keyframes geo-pulse { 0%, 100% { box-shadow: 0 4px 20px rgba(76,175,80,0.3); } 50% { box-shadow: 0 4px 30px rgba(76,175,80,0.6); } }
.geo-result { padding: 1rem; border-radius: var(--radius-sm); margin: 1rem 0; font-weight: 600; }
.geo-result.success { background: rgba(76,175,80,0.12); border: 1px solid rgba(76,175,80,0.35); color: var(--success); }
.geo-result.fail { background: rgba(239,83,80,0.1); border: 1px solid rgba(239,83,80,0.3); color: var(--danger); }

/* ===== SIDE PANEL ===== */
.group-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}
.member-list { display: flex; flex-direction: column; gap: 0.5rem; }
.member-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  position: relative;
}
.member-item.online {
  background: rgba(16,185,129,0.06);
  border-left-color: var(--success);
}
.member-item.offline { opacity: 0.45; border-left-color: transparent; }
.member-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--gradient-main);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.member-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
}
.member-status-dot.online { background: var(--success); box-shadow: 0 0 8px var(--success); }
.member-status-dot.offline { background: var(--text-muted); }

/* ===== RESULTS / SCORING ===== */
.results-table { width: 100%; border-collapse: collapse; }
.results-table th, .results-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.875rem;
}
.results-table th {
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.results-table tr:last-child td { border-bottom: none; }
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.badge-pending { background: rgba(79,195,247,0.15); color: var(--accent-light); border: 1px solid rgba(79,195,247,0.3); }

/* ===== RANKING ===== */
.ranking-list { display: flex; flex-direction: column; gap: 0.5rem; }
.rank-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(25,37,64,0.3);
  border: 1px solid transparent;
  transition: all 0.2s;
  position: relative;
}
.rank-item:hover { background: rgba(255,255,255,0.04); }
.rank-item.my-group {
  border-color: rgba(79,195,247,0.2);
  background: rgba(79,195,247,0.08);
}
.rank-item.my-group::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 999px 999px 0;
}
.rank-number {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--text-muted);
  min-width: 28px;
  opacity: 0.4;
}
.rank-item:first-child .rank-number { opacity: 1; }
.rank-number.gold { color: #fbbf24; opacity: 1; }
.rank-number.silver { color: #9ca3af; opacity: 0.7; }
.rank-number.bronze { color: #d97706; opacity: 0.7; }
.rank-item:first-child {
  background: rgba(79,195,247,0.08);
  border-color: rgba(79,195,247,0.15);
}
.rank-name { flex: 1; font-weight: 600; font-size: 0.875rem; letter-spacing: 0.01em; }
.rank-score {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 800;
  color: var(--accent-light);
  font-size: 0.875rem;
}
.rank-challenge { font-size: 0.7rem; color: var(--text-muted); letter-spacing: 0.02em; }

/* ===== FINISHED STATE ===== */
.finished-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.finished-overlay.show { display: flex; }
.finished-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  max-width: 600px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-accent);
  animation: modal-in 0.4s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.finished-icon { font-size: 4rem; margin-bottom: 1rem; }
.finished-score {
  font-family: 'Space Mono', monospace;
  font-size: 3rem;
  font-weight: 700;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== ADMIN PANEL ===== */
.admin-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; padding: 1.5rem 0 2rem; }
.admin-groups-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.admin-group-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: all 0.2s;
}
.admin-group-card .group-name { font-weight: 700; margin-bottom: 0.5rem; }
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.75rem 0;
}
.progress-fill {
  height: 100%;
  background: var(--gradient-main);
  border-radius: 999px;
  transition: width 0.5s ease;
}
.admin-controls { display: flex; flex-direction: column; gap: 0.75rem; }
.event-status-big {
  font-family: 'Space Mono', monospace;
  font-size: 2rem;
  font-weight: 700;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== TOAST NOTIFICATIONS ===== */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}
.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1.25rem;
  font-size: 0.875rem;
  box-shadow: var(--shadow);
  animation: toast-in 0.3s ease;
  pointer-events: all;
  max-width: 320px;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast.success { border-color: var(--success); }
.toast.warning { border-color: var(--warning); }
.toast.error { border-color: var(--danger); }

/* ===== ACCESSIBILITY PANEL ===== */
.a11y-panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
}
.a11y-panel-overlay.show { display: block; }

.a11y-panel {
  display: none;
  position: fixed;
  top: 60px;
  right: 1rem;
  z-index: 160;
  width: 340px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.a11y-panel.show { display: block; }
.a11y-panel h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.a11y-panel-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.a11y-panel-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.a11y-panel-section label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  min-height: 44px;
}
.a11y-panel-section .a11y-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.a11y-font-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.a11y-font-controls button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.a11y-font-controls button:hover { background: var(--bg-card-hover); }
.a11y-font-controls span {
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 40px;
  text-align: center;
}

/* Toggle switch */
.a11y-toggle {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}
.a11y-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.a11y-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.a11y-toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s, background 0.2s;
}
.a11y-toggle input:checked + .a11y-toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}
.a11y-toggle input:checked + .a11y-toggle-slider::before {
  transform: translateX(22px);
  background: white;
}
.a11y-toggle input:focus-visible + .a11y-toggle-slider {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* ===== HELP MODAL ===== */
.help-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 180;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.help-modal-overlay.show { display: flex; }
.help-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.help-modal h2 { margin-bottom: 1rem; font-size: 1.3rem; }
.help-modal h4 { margin: 1rem 0 0.5rem; color: var(--accent-light); font-size: 0.9rem; }
.help-modal p, .help-modal li { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.6; }
.help-modal ul { padding-left: 1.25rem; margin-bottom: 0.75rem; }
.help-modal li { margin-bottom: 0.3rem; }
.help-modal .help-shortcut {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.85rem;
}
.help-modal .help-shortcut kbd {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  color: var(--accent-light);
}
.help-modal-close {
  display: block;
  width: 100%;
  margin-top: 1.5rem;
}

/* ===== ACCESSIBILITY STATEMENT ===== */
.a11y-statement-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 180;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.a11y-statement-overlay.show { display: flex; }
.a11y-statement {
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.a11y-statement h2 { margin-bottom: 1rem; font-size: 1.3rem; }
.a11y-statement h4 { margin: 1rem 0 0.5rem; color: var(--accent-light); font-size: 0.9rem; }
.a11y-statement p, .a11y-statement li { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.6; }
.a11y-statement ul { padding-left: 1.25rem; margin-bottom: 0.75rem; }
.a11y-statement li { margin-bottom: 0.3rem; }

/* ===== LIVE REGION for screen readers ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ===== UTILITIES ===== */
.text-gradient {
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .dashboard-layout { grid-template-columns: 1fr; }
  .side-panel { display: grid; grid-template-columns: 1fr 1fr; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-groups-grid { grid-template-columns: 1fr; }
  .a11y-panel { width: calc(100vw - 2rem); right: 1rem; }
}
/* Mobile language selector — hidden on desktop, shown on mobile in header row 1 */
.dash-lang-mobile { display: none; }

@media (max-width: 600px) {
  .container { padding: 0 0.75rem; }
  .header-inner { flex-wrap: wrap; gap: 0.35rem; }
  /* Row 1: burger + group name + event logo + lang selector */
  .header-brand { font-size: 0.9rem; gap: 0.4rem; flex: 1; min-width: 0; }
  #group-name-header { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
  #header-logo-wrap img { max-height: 44px !important; max-width: 100px !important; }
  /* Row 2: phase + timer (left), a11y controls (right) — all in one row */
  .header-right { flex-wrap: nowrap; gap: 0.35rem; width: 100%; justify-content: space-between; }
  .header-phase { font-size: 0.72rem; padding: 0.25rem 0.6rem; }
  .header-a11y-controls { gap: 0.15rem; margin-left: auto; }
  .dash-logout-desktop { display: none; }
  .dash-lang-desktop { display: none; }
  .dash-lang-mobile { display: inline-block; margin-left: auto; }
  .dash-lang-mobile .i18n-lang-select { font-size: 0.72rem; padding: 0.2rem 0.35rem; }
  .member-badges { display: none; }
  .side-panel { grid-template-columns: 1fr; }
  .login-card { padding: 1.75rem; max-width: 100%; }
  .a11y-panel { width: calc(100vw - 2rem); }
  .card { padding: 1rem; }
  .challenge-banner { padding: 1.25rem; }
  .challenge-title { font-size: 1.25rem; }
  .chat-container { min-height: 350px; }
  /* Prevent iOS Safari auto-zoom on input focus */
  .chat-input { font-size: 16px; }
  .form-input { font-size: 16px; }
  .chat-messages { padding: 0.75rem; }
  .chat-input-area { padding: 0.75rem; }
  .chat-header { padding: 0.75rem; }
  .msg-bubble { font-size: 0.88rem; padding: 0.6rem 0.85rem; }
  .finished-modal { padding: 1.5rem; }
  .finished-score { font-size: 2.2rem; }
  #timer-badge { font-size: 0.88rem; min-width: 70px; padding: 0.25rem 0.65rem; }
}

/* Small phones (iPhone SE, etc.) */
@media (max-width: 380px) {
  .container { padding: 0 0.5rem; }
  .header-brand { font-size: 0.95rem; }
  .brand-icon { width: 30px; height: 30px; font-size: 0.9rem; }
  .a11y-icon-btn { width: 38px; height: 38px; font-size: 1rem; }
  .card { padding: 0.85rem; }
  .challenge-title { font-size: 1.1rem; }
  .btn-lg { padding: 0.75rem 1.5rem; font-size: 0.9rem; }
}

/* ===== SPEED TYPING RACE ===== */
.typing-race-wrap {
  position: relative;
  margin-bottom: 0.75rem;
}
.typing-passage {
  font-family: 'Space Mono', 'Courier New', monospace;
  font-size: 1.15rem;
  line-height: 1.85;
  padding: 1.5rem 1.25rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  word-break: break-word;
  letter-spacing: 0.02em;
  user-select: none;
  position: relative;
  z-index: 1;
}
.typing-passage .tp-pending { color: var(--text-muted); opacity: 0.55; }
.typing-passage .tp-correct { color: var(--success, #4caf50); }
.typing-passage .tp-cursor {
  color: #fff;
  background: var(--accent, #4fc3f7);
  border-radius: 2px;
  animation: tp-cursor-blink 1.1s ease-in-out infinite;
}
.typing-passage .tp-wrong {
  color: #fff;
  background: var(--danger, #ef4444);
  border-radius: 2px;
}
@keyframes tp-cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
/*
  Invisible textarea overlay covering the passage.
  CRITICAL: must be in-flow (NOT off-screen) so iOS Safari opens the keyboard on tap.
  Text/caret/background are transparent so the styled passage below shows through.
*/
.typing-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 1.5rem 1.25rem;
  margin: 0;
  font-family: 'Space Mono', 'Courier New', monospace;
  font-size: 1.15rem;
  line-height: 1.85;
  letter-spacing: 0.02em;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  outline: none;
  resize: none;
  z-index: 2;
  cursor: text;
  -webkit-user-select: text;
  user-select: text;
  -webkit-tap-highlight-color: transparent;
}
.typing-input:focus {
  border-color: rgba(79, 195, 247, 0.4);
  box-shadow: 0 0 0 2px rgba(79, 195, 247, 0.15);
}
/*
  Tap-to-focus hint — small banner ABOVE the passage area.
  Critical: NOT positioned over the passage so the user can read the text at all times.
  Tapping this hint focuses the textarea (real user gesture → iOS opens keyboard).
  Tapping the passage area itself ALSO works because the textarea overlay is there.
*/
.typing-tap-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(79, 195, 247, 0.12);
  border: 1px solid rgba(79, 195, 247, 0.35);
  border-radius: var(--radius-sm);
  color: var(--accent-light, #81ecff);
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  animation: tp-hint-pulse 2s ease-in-out infinite;
}
.typing-tap-hint:active {
  transform: scale(0.985);
}
.typing-tap-hint.hidden {
  display: none;
}
@keyframes tp-hint-pulse {
  0%, 100% {
    background: rgba(79, 195, 247, 0.10);
    border-color: rgba(79, 195, 247, 0.30);
    box-shadow: 0 0 0 0 rgba(79, 195, 247, 0);
  }
  50% {
    background: rgba(79, 195, 247, 0.20);
    border-color: rgba(79, 195, 247, 0.55);
    box-shadow: 0 0 14px 0 rgba(79, 195, 247, 0.25);
  }
}
.typing-lanes {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-width: 640px;
  margin: 1rem auto 0;
}
.typing-lane {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 3fr minmax(110px, auto);
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}
.typing-lane.typing-lane-done {
  background: rgba(76, 175, 80, 0.08);
  border-color: rgba(76, 175, 80, 0.3);
}
.typing-lane-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.typing-lane-me {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.45rem;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(79, 195, 247, 0.18);
  color: var(--accent-light, #81ecff);
  border-radius: 999px;
  border: 1px solid rgba(79, 195, 247, 0.35);
  vertical-align: middle;
}
.typing-lane-bar {
  height: 10px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.typing-lane-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent, #4fc3f7), var(--accent-light, #81ecff));
  border-radius: 999px;
  /* CRITICAL: smooth transition between polling updates so it feels live */
  transition: width 1500ms linear;
  box-shadow: 0 0 10px rgba(79, 195, 247, 0.4);
}
.typing-lane-done .typing-lane-fill {
  background: linear-gradient(90deg, #4caf50, #81c784);
  box-shadow: 0 0 10px rgba(76, 175, 80, 0.4);
}
.typing-lane-stats {
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}
@media (max-width: 600px) {
  .typing-passage { font-size: 1rem; line-height: 1.75; padding: 1rem 0.85rem; }
  .typing-lane {
    grid-template-columns: 1fr;
    gap: 0.3rem;
    padding: 0.5rem 0.7rem;
  }
  .typing-lane-stats { text-align: left; }
}

/* ===== i18n LANGUAGE SELECTOR ===== */
.i18n-lang-select{background:rgba(15,25,48,0.6);border:1px solid rgba(255,255,255,0.1);border-radius:8px;padding:0.3rem 0.5rem;color:rgba(163,170,196,0.9);font-size:0.78rem;cursor:pointer;outline:none;transition:border-color 0.2s}
.i18n-lang-select:hover,.i18n-lang-select:focus{border-color:rgba(79,195,247,0.4)}
[data-theme="light"] .i18n-lang-select{background:rgba(255,255,255,0.8);border-color:rgba(0,0,0,0.12);color:#333}
[data-theme="high-contrast"] .i18n-lang-select{background:#000;border-color:#ff0;color:#ff0}
