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

:root {
  --bg: #0a0a14;
  --bg-card: rgba(22,22,42,0.85);
  --bg-card-solid: #16162a;
  --bg-hover: #1f1f3a;
  --primary: #00d4d8;
  --primary-dark: #00a8ab;
  --primary-glow: rgba(0,212,216,0.15);
  --accent: #7c5cfc;
  --accent-dark: #6344e0;
  --danger: #ff4757;
  --danger-dark: #e03e4e;
  --success: #2ed573;
  --warning: #ffa502;
  --text: #f0f0f8;
  --text-muted: #7a7a9e;
  --border: rgba(255,255,255,0.08);
  --border-light: rgba(255,255,255,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.5);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── Glass morphism ───────────────────────────────────────────────────────── */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
}

/* ── Screens ──────────────────────────────────────────────────────────────── */
.screen { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Login ─────────────────────────────────────────────────────────────────── */
#login-screen {
  justify-content: center;
  align-items: center;
  background: radial-gradient(ellipse at 30% 20%, rgba(0,212,216,0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(124,92,252,0.06) 0%, transparent 50%),
              var(--bg);
}

.login-card {
  text-align: center;
  padding: 3.5rem 4rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.login-logo {
  font-size: 4.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 0.2rem;
}

.login-card h1 { font-size: 2.2rem; font-weight: 800; margin-bottom: 0.5rem; letter-spacing: -0.5px; }
.login-card p { color: var(--text-muted); margin-bottom: 2.5rem; font-size: 1.05rem; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.7rem 1.4rem; border: none; border-radius: var(--radius-sm);
  font-size: 0.95rem; font-weight: 600; font-family: inherit;
  cursor: pointer; text-decoration: none;
  transition: all 0.2s ease;
}
.btn:active { transform: scale(0.97); }

.btn-login {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-size: 1.1rem; padding: 1rem 2.5rem;
  border-radius: var(--radius-sm); box-shadow: 0 4px 20px rgba(0,212,216,0.3);
}
.btn-login:hover { box-shadow: 0 6px 28px rgba(0,212,216,0.45); transform: translateY(-1px); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }

.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border-light);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-small { padding: 0.5rem 1.1rem; font-size: 0.88rem; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); }

.btn-idk {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  padding: 0.65rem 1.5rem; font-size: 0.95rem;
}
.btn-idk:hover { background: var(--bg-hover); color: var(--text); border-color: var(--warning); }

/* ── Action row (below input) ───────────────────────────────────────────────────────────────── */
.action-row {
  display: flex; gap: 0.6rem; margin-top: 0.6rem;
  width: 100%; max-width: 480px; justify-content: center;
}

/* ── Category tabs ────────────────────────────────────────────────────────── */
.lb-tabs { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.8rem; }
.lb-tab {
  padding: 0.3rem 0.7rem; font-size: 0.75rem; font-weight: 600;
  border: 1px solid var(--border); border-radius: 6px;
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: all 0.15s; font-family: inherit;
}
.lb-tab:hover { background: var(--bg-hover); color: var(--text); }
.lb-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Top bar ──────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 1.5rem;
  background: var(--bg-card); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.logo { font-size: 1.2rem; font-weight: 800; letter-spacing: -0.3px; }
.logo-42 {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-right: 1px;
}
.user-info { display: flex; align-items: center; gap: 0.6rem; }
.avatar-sm { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.game-stats { display: flex; gap: 1.2rem; }
.stat { font-size: 1rem; font-weight: 600; }
.stat-timer { transition: color 0.3s; }
.stat-timer.urgent { color: var(--danger); animation: pulse 0.5s ease infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.6} }

/* ── Home ─────────────────────────────────────────────────────────────────────── */
.home-layout {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 2rem 2rem;
}
.home-layout.has-sidebar {
  display: grid; grid-template-columns: 280px 1fr 280px;
  gap: 1rem; padding: 1rem 1.2rem; align-items: start; justify-content: stretch;
}
.home-side { position: sticky; top: 1.2rem; }
.home-side .lb-panel { max-height: calc(100vh - 100px); overflow-y: auto; }
.home-center {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 1.5rem 2rem;
}
.home-center h2 { font-size: 1.8rem; margin-bottom: 0.2rem; font-weight: 800; letter-spacing: -0.5px; }
.home-center .subtitle { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.95rem; }
.campus-input-wrapper { position: relative; width: 100%; max-width: 460px; }
.input-campus {
  width: 100%; padding: 0.9rem 1.1rem; font-size: 1.05rem;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card-solid); color: var(--text); outline: none;
  font-family: inherit; transition: border-color 0.2s;
}
.input-campus:focus { border-color: var(--primary); }

/* ── Year range & category tags ───────────────────────────────────────────── */
.year-range { margin-top: 1.5rem; width: 100%; max-width: 460px; }
.year-range label { display: block; margin-bottom: 0.5rem; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); }
.category-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.3rem; }
.cat-tag {
  padding: 0.35rem 0.8rem; font-size: 0.82rem; font-weight: 600;
  border: 1.5px solid var(--border); border-radius: 20px;
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: all 0.15s; user-select: none; font-family: inherit;
}
.cat-tag:hover { background: var(--bg-hover); color: var(--text); }
.cat-tag.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.cat-tag.cat-all { font-weight: 700; border-color: var(--accent); }
.cat-tag.cat-all.active { background: var(--accent); border-color: var(--accent); }
.cat-tag .cat-count { font-size: 0.7rem; opacity: 0.6; margin-left: 0.15rem; }
.month-group {
  width: 100%; display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.3rem; margin-top: 0.5rem; padding-top: 0.4rem;
  border-top: 1px solid var(--border);
}
.month-group-label {
  font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
  min-width: 36px; margin-right: 0.2rem; letter-spacing: 0.3px;
}
.cat-tag.cat-month { border-color: #7c5cbf; font-size: 0.74rem; padding: 0.25rem 0.6rem; }
.cat-tag.cat-month.active { background: #7c5cbf; color: #fff; border-color: #7c5cbf; }
.spinner-sm { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; }

/* ── Room list ─────────────────────────────────────────────────────────────── */
.lobby-rooms-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 300px; overflow-y: auto; }
.room-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1.2rem; background: var(--bg-card-solid);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.room-card:hover { background: var(--bg-hover); border-color: var(--primary); }
.room-info { display: flex; flex-direction: column; gap: 0.15rem; }
.room-host { font-weight: 600; font-size: 0.92rem; }
.room-meta { font-size: 0.76rem; color: var(--text-muted); }
.room-join-btn {
  padding: 0.55rem 1.3rem; font-size: 0.9rem; font-weight: 600;
  border: none; border-radius: 8px; background: var(--primary);
  color: #fff; cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.room-join-btn:hover { background: var(--primary-dark); transform: scale(1.03); }

/* ── Loading ──────────────────────────────────────────────────────────────── */
.loading,.loading-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; text-align: center; }
#loading-screen { justify-content: center; align-items: center; }
.loading-card { padding: 3rem; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.spinner { width: 44px; height: 44px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Game layout ────────────────────────────────────────────────────────────── */
.game-layout,.pvp-layout {
  display: grid; grid-template-columns: 240px 1fr 240px;
  gap: 1rem; padding: 1rem 1.2rem; flex: 1; min-height: 0; align-items: start;
}
.game-center { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0.5rem 0; flex: 1; }
.side-panel { position: sticky; top: 1.2rem; }
.side-panel .lb-panel { max-height: calc(100vh - 100px); overflow-y: auto; }

/* ── Photo ───────────────────────────────────────────────────────────────── */
.photo-wrapper { position: relative; width: 340px; height: 340px; margin-bottom: 1rem; border-radius: var(--radius); }
.photo-clip { width: 100%; height: 100%; overflow: hidden; border-radius: var(--radius); }
.student-photo {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: var(--radius); border: 2px solid var(--border-light);
  box-shadow: var(--shadow);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.student-photo.photo-fade { opacity: 0; transform: scale(0.96); }

/* ── Photo mode modifiers ──────────────────────────────────────────────────────────── */
.student-photo.photo-blur {
  filter: blur(var(--blur-amount, 28px));
  transition: filter 0.6s ease, opacity 0.25s ease, transform 0.25s ease;
}
.student-photo.photo-zoom {
  object-fit: none;
  object-position: var(--zoom-x, 50%) var(--zoom-y, 30%);
  transform: scale(var(--zoom-scale, 2.4));
  transition: transform 0.3s ease, opacity 0.25s ease;
}
.student-photo.photo-zoom.photo-fade { opacity: 0; transform: scale(var(--zoom-scale, 2.4)) scale(0.96); }

/* Compact modifier cards */
.submode-card-sm { padding: 0.6rem 0.5rem; }
.submode-card-sm .submode-icon { font-size: 1.2rem; }
.submode-card-sm strong { font-size: 0.85rem; }

.photo-mode-picker { width: 100%; text-align: center; }
.photo-mode-picker label {
  display: block; margin-bottom: 0.6rem;
  font-size: 0.9rem; font-weight: 600; color: var(--text-muted);
}

/* Modifier badge in lobby/room info */
.modifier-badge {
  display: inline-block; font-size: 0.7rem; font-weight: 700;
  padding: 0.15rem 0.5rem; border-radius: 20px;
  background: rgba(124,92,252,0.15); color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.5px;
}

/* ── Hint badge ───────────────────────────────────────────────────────────── */
.hint-badge {
  position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%); z-index: 5;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #fff; font-weight: 800; font-size: 1.1rem;
  padding: 0.35rem 1rem; border-radius: 20px;
  box-shadow: 0 4px 16px rgba(124,92,252,0.4);
  letter-spacing: 1px; animation: hintPop 0.3s ease;
}
@keyframes hintPop { from { transform: translateX(-50%) scale(0.5); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

/* ── Penalty / result overlay ─────────────────────────────────────────────── */
.penalty-overlay {
  position: absolute; inset: 0;
  background: rgba(231,76,60,0.92); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: #fff; animation: fadeIn 0.2s ease;
}
.penalty-overlay.overlay-correct { background: rgba(46,213,115,0.92); }
.penalty-overlay.overlay-wrong { background: rgba(255,71,87,0.92); }
.penalty-content { text-align: center; line-height: 1.4; }
.penalty-answer { font-size: 0.9rem; margin-bottom: 0.2rem; opacity: 0.8; }
.reveal-login { font-size: 1.5rem; font-weight: 800; letter-spacing: 0.5px; }
.reveal-name { font-size: 0.88rem; opacity: 0.75; margin-bottom: 0.2rem; }
.reveal-pool { font-size: 0.82rem; opacity: 0.6; margin-bottom: 0.5rem; }
.reveal-timer { font-size: 0.9rem; font-weight: 600; opacity: 0.85; }

/* ── Answer section ───────────────────────────────────────────────────────── */
.answer-section { display: flex; gap: 0.6rem; width: 100%; max-width: 480px; }
.input-wrapper { position: relative; flex: 1; }
.input-guess {
  width: 100%; padding: 0.75rem 1rem; font-size: 1rem;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card-solid); color: var(--text); outline: none;
  font-family: inherit; transition: border-color 0.2s;
}
.input-guess:focus { border-color: var(--primary); }
.input-guess:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Autocomplete ─────────────────────────────────────────────────────────── */
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--bg-card-solid); border: 1px solid var(--border-light);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 220px; overflow-y: auto; list-style: none; z-index: 100;
}
.autocomplete-list li {
  padding: 0.6rem 1rem; cursor: pointer; font-size: 0.9rem; transition: background 0.15s;
}
.autocomplete-list li:hover,.autocomplete-list li.active { background: var(--bg-hover); color: var(--primary); }
.autocomplete-list li .full-name,.autocomplete-list li .campus-country { color: var(--text-muted); font-size: 0.78rem; margin-left: 0.4rem; }

/* ── Feedback ─────────────────────────────────────────────────────────────── */
.feedback {
  margin-top: 1rem; padding: 0.5rem 1.2rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.95rem; animation: slideUp 0.25s ease;
  text-align: center; line-height: 1.5;
  transition: opacity 0.3s ease;
}
.feedback strong { font-size: 1.05rem; }
.fb-name { font-size: 0.82rem; opacity: 0.75; font-weight: 400; }
.fb-pool { font-size: 0.78rem; opacity: 0.6; font-weight: 400; }
.feedback.correct { background: rgba(46,213,115,0.15); color: var(--success); border: 1px solid var(--success); }
.feedback.wrong { background: rgba(255,71,87,0.15); color: var(--danger); border: 1px solid var(--danger); }
.feedback.skip { background: rgba(255,165,2,0.12); color: var(--warning); border: 1px solid var(--warning); }
.feedback.idk { background: rgba(122,122,158,0.12); color: var(--text-muted); border: 1px solid var(--text-muted); }
.feedback.reveal { background: rgba(124,92,252,0.12); color: var(--accent); border: 1px solid var(--accent); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Leaderboard panels ──────────────────────────────────────────────────── */
.lb-panel { border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow); background: var(--bg-card); }
.lb-panel h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.8rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.lb-list { display: flex; flex-direction: column; gap: 0.1rem; }
.lb-item { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.6rem; border-radius: 6px; transition: background 0.15s; flex-wrap: wrap; position: relative; }
.lb-item:hover { background: var(--bg-hover); }
.lb-rank { width: 26px; font-weight: 700; color: var(--text-muted); font-size: 0.85rem; }
.lb-item:nth-child(1) .lb-rank { color: #ffd700; }
.lb-item:nth-child(2) .lb-rank { color: #c0c0c0; }
.lb-item:nth-child(3) .lb-rank { color: #cd7f32; }
.lb-login { flex: 1; font-weight: 600; font-size: 0.9rem; }
.lb-value { font-weight: 700; color: var(--primary); min-width: 36px; text-align: right; font-size: 0.9rem; }
.lb-pct { font-size: 0.78rem; color: var(--text-muted); margin-left: 0.3rem; min-width: 36px; text-align: right; }
.text-muted { color: var(--text-muted); font-size: 0.88rem; }

/* ── Mode selection ───────────────────────────────────────────────────────── */
.mode-selection { margin-top: 1.5rem; width: 100%; max-width: 620px; text-align: center; }
.mode-selection h3 { margin-bottom: 0.8rem; font-size: 1.1rem; font-weight: 700; }
.mode-cards { display: flex; gap: 1rem; }
.mode-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  padding: 1.5rem 1rem; background: var(--bg-card-solid);
  border: 2px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all 0.2s; color: var(--text); font-family: inherit;
}
.mode-card:hover { border-color: var(--primary); background: var(--bg-hover); transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,212,216,0.15); }
.mode-card:active { transform: translateY(0); }
.mode-card.mode-ranked:hover { border-color: #ffd700; box-shadow: 0 8px 24px rgba(255,215,0,0.2); }
.mode-card.mode-freeplay:hover { border-color: var(--accent); box-shadow: 0 8px 24px rgba(124,92,252,0.2); }
.mode-card.mode-multi:hover { border-color: var(--danger); box-shadow: 0 8px 24px rgba(255,71,87,0.2); }
.mode-icon { font-size: 2.2rem; }
.mode-title { font-size: 1.15rem; font-weight: 800; }
.mode-desc { font-size: 0.78rem; color: var(--text-muted); line-height: 1.3; }
.mode-tooltip {
  display: block; font-size: 0.72rem; color: var(--text-muted);
  font-weight: 400; line-height: 1.4; margin-top: 0.4rem;
  opacity: 0; max-height: 0; overflow: hidden;
  transition: all 0.25s ease;
}
.mode-card:hover .mode-tooltip { opacity: 1; max-height: 60px; }

/* ── Mode Detail Screen ───────────────────────────────────────────────────── */
.mode-detail-layout {
  display: grid; grid-template-columns: 280px 1fr 280px;
  gap: 1rem; padding: 1rem 1.2rem; flex: 1; min-height: 0; align-items: start;
}
.mode-detail-layout.no-sidebar {
  grid-template-columns: minmax(240px, 300px) 1fr minmax(240px, 300px);
}
.mode-detail-side { position: sticky; top: 1.2rem; }
.mode-detail-side .lb-panel { max-height: calc(100vh - 100px); overflow-y: auto; }

/* Alt side panels for freeplay / multi */
.md-alt-panel {
  padding: 1.2rem; border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 1rem;
  max-height: calc(100vh - 100px); overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.md-alt-panel .mode-detail-filters { max-width: none; width: 100%; text-align: left; }
.md-alt-panel .mode-detail-filters label { text-align: center; }
.md-alt-panel .category-tags { justify-content: flex-start; }
.md-alt-side { position: sticky; top: 1.2rem; }

/* Right alt panel: center content vertically when little content */
#md-alt-right .md-alt-panel {
  align-items: center; justify-content: center; min-height: 200px;
}
#md-alt-right .btn-start-game { width: 100%; }

/* Submode cards stacked vertically in the right panel */
.submode-cards-alt { display: flex; flex-direction: column; gap: 0.6rem; }

.mode-detail-center {
  display: flex; flex-direction: column; align-items: center;
  gap: 1.2rem; padding: 1rem 0;
}

.mode-detail-header {
  text-align: center; padding: 1.5rem 2rem;
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 560px;
}
.mode-detail-icon { font-size: 3rem; margin-bottom: 0.3rem; }
.mode-detail-header h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 0.2rem; }
.mode-detail-subtitle { color: var(--text-muted); font-size: 0.92rem; }

.mode-detail-rules {
  padding: 1rem 1.5rem; border-radius: var(--radius-sm);
  font-size: 0.88rem; line-height: 1.6; color: var(--text-muted);
  width: 100%; max-width: 560px;
}
.mode-detail-rules strong { color: var(--text); }
.rules-list {
  list-style: none; padding: 0; margin: 0;
}
.rules-list li {
  position: relative; padding-left: 1.2rem; margin-bottom: 0.3rem;
}
.rules-list li::before {
  content: '•'; position: absolute; left: 0;
  color: var(--primary); font-weight: 700;
}

.mode-detail-filters {
  width: 100%; max-width: 560px; text-align: center;
}
.mode-detail-filters label {
  display: block; margin-bottom: 0.5rem;
  font-size: 0.9rem; font-weight: 600; color: var(--text-muted);
}

/* ── Free-play submode picker ─────────────────────────────────────────────── */
.freeplay-submode {
  width: 100%; text-align: center;
}
.freeplay-submode label {
  display: block; margin-bottom: 0.6rem;
  font-size: 0.9rem; font-weight: 600; color: var(--text-muted);
}
.submode-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  padding: 1rem 0.8rem; background: var(--bg-card-solid);
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.2s; color: var(--text); font-family: inherit;
}
.submode-card:hover { border-color: var(--accent); background: var(--bg-hover); }
.submode-card.active { border-color: var(--accent); background: rgba(124,92,252,0.12); }
.submode-icon { font-size: 1.6rem; }
.submode-card strong { font-size: 1rem; }
.submode-card span:last-child { font-size: 0.72rem; color: var(--text-muted); }

/* ── Start Game button ────────────────────────────────────────────────────── */
.btn-start-game {
  padding: 0.9rem 3rem; font-size: 1.15rem; font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; border: none; border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(0,212,216,0.3);
  cursor: pointer; font-family: inherit;
  transition: all 0.2s;
}
.btn-start-game:hover { box-shadow: 0 6px 28px rgba(0,212,216,0.45); transform: translateY(-2px); }
.btn-start-game:active { transform: translateY(0); }

/* ── PvP Lobby / Room Screen ───────────────────────────────────────────────── */
.pvp-room-layout {
  display: grid; grid-template-columns: 280px 1fr 280px;
  gap: 1rem; padding: 1rem 1.2rem; flex: 1; min-height: 0; align-items: start;
}
.pvp-room-side { position: sticky; top: 1.2rem; }
.pvp-room-center {
  display: flex; flex-direction: column; align-items: center;
  gap: 1.2rem; padding: 2rem 0;
}
.pvp-room-center h2 { font-size: 1.6rem; font-weight: 800; }
.room-filter-info { font-size: 0.82rem; color: var(--text-muted); }
.lobby-players { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; max-width: 420px; }
.lobby-player { display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 1.2rem; background: var(--bg-card-solid); border-radius: var(--radius-sm); font-weight: 600; border: 1px solid var(--border); font-size: 1rem; }
.lobby-player .badge { margin-left: auto; background: var(--accent); color: #fff; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.72rem; font-weight: 700; }

/* Multi rooms panel on mode-detail right side */
.multi-rooms-panel { width: 100%; }
.multi-rooms-panel label {
  display: block; margin-bottom: 0.5rem;
  font-size: 0.9rem; font-weight: 600; color: var(--text-muted); text-align: center;
}

/* ── Prominent start game button ──────────────────────────────────────────── */
#btn-pvp-start {
  padding: 0.9rem 2.5rem; font-size: 1.1rem; font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 4px 20px rgba(0,212,216,0.3); border-radius: var(--radius-sm);
}
#btn-pvp-start:hover { box-shadow: 0 6px 28px rgba(0,212,216,0.45); transform: translateY(-2px); }

/* ── Solo lives ───────────────────────────────────────────────────────────── */
.solo-lives { font-size: 1.1rem; letter-spacing: 2px; }

/* ── Results Page ─────────────────────────────────────────────────────────── */
.results-page {
  display: flex; align-items: center; justify-content: center;
  flex: 1; padding: 2rem 1rem; overflow-y: auto;
}
.results-card {
  width: 100%; max-width: 520px; padding: 2.5rem 2rem;
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 1.5rem;
  animation: resultsSlideIn 0.5s ease;
}
@keyframes resultsSlideIn {
  from { opacity: 0; transform: translateY(30px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.results-title {
  font-size: 1.8rem; font-weight: 900; text-align: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.results-campus {
  font-size: 0.85rem; color: var(--text-muted); margin: -0.8rem 0 0; font-weight: 500;
}

/* Accuracy ring */
.accuracy-ring-wrapper {
  position: relative; width: 140px; height: 140px;
  display: flex; align-items: center; justify-content: center;
}
.accuracy-ring { width: 140px; height: 140px; transform: rotate(-90deg); }
.accuracy-ring-bg {
  fill: none; stroke: var(--bg-hover); stroke-width: 8;
}
.accuracy-ring-fill {
  fill: none; stroke: var(--primary); stroke-width: 8;
  stroke-linecap: round; stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73; transition: stroke-dashoffset 1s ease, stroke 0.5s ease;
}
.accuracy-ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.accuracy-pct { font-size: 1.8rem; font-weight: 900; color: var(--text); }
.accuracy-sub { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }

/* Stats grid */
.results-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; width: 100%;
}
.result-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  padding: 0.9rem 0.5rem; border-radius: var(--radius-sm);
  background: var(--bg-card-solid); border: 1px solid var(--border);
  transition: transform 0.2s;
}
.result-card:hover { transform: translateY(-2px); }
.rc-value { font-size: 1.8rem; font-weight: 900; }
.rc-label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); }
.rc-correct .rc-value { color: var(--success); }
.rc-wrong .rc-value { color: var(--danger); }
.rc-streak .rc-value { color: var(--warning); }
.rc-idk .rc-value { color: var(--text-muted); }
.rc-reveal .rc-value { color: var(--accent); }

/* Meta info row */
.results-meta {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem 1.2rem;
  font-size: 0.82rem; color: var(--text-muted); font-weight: 500;
}
.results-badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.15rem 0.6rem; border-radius: 20px; font-size: 0.75rem;
  font-weight: 700; letter-spacing: 0.3px;
}
.results-badge.badge-ranked {
  background: rgba(0,212,216,0.15); color: var(--primary); border: 1px solid rgba(0,212,216,0.3);
}
.results-badge.badge-unranked {
  background: var(--bg-hover); color: var(--text-muted); border: 1px solid var(--border);
}

/* Actions */
.results-actions {
  display: flex; gap: 0.8rem; margin-top: 0.5rem;
}
.results-actions .btn { padding: 0.75rem 1.8rem; font-size: 1rem; font-weight: 700; }

/* ── PvP Standings ────────────────────────────────────────────────────────── */
.pvp-standings { display: flex; flex-direction: column; gap: 0.6rem; width: 100%; max-width: 480px; margin: 0.5rem auto; }
.pvp-standing { display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 1rem; background: var(--bg-card-solid); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.pvp-standing:first-child { border-color: rgba(255,215,0,0.4); background: rgba(255,215,0,0.05); }
.pvp-medal { font-size: 1.4rem; width: 36px; text-align: center; }
.pvp-standing-login { flex: 1; font-weight: 700; font-size: 1.05rem; }
.pvp-standing-score { color: var(--primary); font-weight: 700; }
#pvp-results-screen { align-items: center; overflow-y: auto; }

/* ── Toast notifications ──────────────────────────────────────────────────── */
#toast-container { position: fixed; top: 60px; right: 1.2rem; z-index: 1000; display: flex; flex-direction: column; gap: 0.4rem; pointer-events: none; }
.toast {
  background: var(--bg-card-solid); border: 1px solid var(--border-light);
  border-left: 3px solid var(--primary); border-radius: var(--radius-sm);
  padding: 0.6rem 1rem; color: var(--text); font-size: 0.9rem; font-weight: 600;
  box-shadow: var(--shadow); transform: translateX(120%); opacity: 0;
  transition: all 0.3s ease; pointer-events: auto; max-width: 280px;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast.hide { transform: translateX(120%); opacity: 0; }
.toast-icon { margin-right: 0.2rem; }

/* ── PvP round result rows ────────────────────────────────────────────────── */
.round-correct { background: rgba(46,213,115,0.1); border-left: 3px solid var(--success); }
.round-wrong { background: rgba(255,71,87,0.08); border-left: 3px solid var(--danger); }
.round-answer { font-size: 0.78rem; font-weight: 400; color: var(--text-muted); font-style: italic; }
.round-correct .round-answer { color: var(--success); font-style: normal; font-weight: 700; }

/* ── Score pop animation ──────────────────────────────────────────────────── */
.score-pop { animation: scorePop 0.35s ease; }
@keyframes scorePop { 0% { transform: scale(1); } 40% { transform: scale(1.4); color: var(--success); } 100% { transform: scale(1); } }

/* ── Rate bar (easiest/hardest panels) ────────────────────────────────────── */
.rate-bar {
  width: 100%; height: 4px; background: var(--bg-hover);
  border-radius: 2px; margin-top: 0.3rem; overflow: hidden;
}
.rate-fill {
  height: 100%; border-radius: 2px; transition: width 0.4s ease;
}

/* ── Progress stat ────────────────────────────────────────────────────────── */
.stat-progress { font-size: 0.88rem; color: var(--text-muted); }

/* ── Countdown overlay ────────────────────────────────────────────────────── */
.countdown-overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 12, 20, 0.85);
  border-radius: var(--radius);
}
.countdown-number {
  font-size: 5rem; font-weight: 900; color: var(--primary);
  text-shadow: 0 0 40px rgba(108, 92, 231, 0.5);
  animation: none;
}
.countdown-number.cd-pop {
  animation: cdPop 0.4s ease-out;
}
@keyframes cdPop {
  0% { transform: scale(1.8); opacity: 0; }
  50% { transform: scale(0.95); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Training: centered layout without side panels ────────────────────────── */
#training-screen .game-layout { grid-template-columns: 1fr; max-width: 600px; margin: 0 auto; }
#training-screen .side-panel { display: none; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .game-layout,.pvp-layout,.mode-detail-layout,.mode-detail-layout.no-sidebar,.pvp-room-layout { grid-template-columns: 1fr; }
  .home-layout.has-sidebar { grid-template-columns: 1fr; }
  .side-panel,.mode-detail-side,.home-side { position: static; }
  .side-panel,.home-side { display: none; }
  .pvp-room-side { position: static; }
  .pvp-room-side:empty { display: none; }
  .md-alt-side:not(.hidden) { display: block; position: static; }
  .mode-detail-side:not(.md-alt-side) { display: none; }
  .home-layout.has-sidebar .home-side { display: none; }
  .game-center { padding: 0.8rem 0; }
}
@media (max-width: 700px) {
  .photo-wrapper { width: 260px; height: 260px; }
  .game-stats { gap: 0.5rem; font-size: 0.85rem; }
  .results-card { padding: 1.5rem 1.2rem; }
  .results-grid { gap: 0.5rem; }
  .rc-value { font-size: 1.4rem; }
  .results-title { font-size: 1.4rem; }
  .accuracy-ring-wrapper { width: 110px; height: 110px; }
  .accuracy-ring { width: 110px; height: 110px; }
  .accuracy-pct { font-size: 1.4rem; }
  .results-actions { flex-direction: column; width: 100%; }
  .results-actions .btn { width: 100%; text-align: center; }
  .mode-cards { flex-direction: column; }
  .action-row { flex-direction: column; align-items: stretch; }
  .lobby-players { max-width: 100%; }
  .topbar { padding: 0.5rem 1rem; }
}

/* ── Logo as home button ──────────────────────────────────────────────────── */
.logo-home {
  border: none; background: none; cursor: pointer;
  font-family: inherit; color: var(--text); padding: 0;
  transition: opacity 0.15s;
}
.logo-home:hover { opacity: 0.7; }
.logo-home:active { transform: scale(0.97); }

/* ── Mode-detail Home button ──────────────────────────────────────────────── */
.btn-home-md {
  display: inline-flex; align-items: center; gap: 0.45rem;
  margin-top: 1.4rem; padding: 0.55rem 1.4rem;
  font-size: 0.85rem; font-weight: 600; font-family: inherit;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  transition: all 0.25s ease;
}
.btn-home-md svg { opacity: 0.7; transition: opacity 0.25s; }
.btn-home-md:hover {
  color: var(--primary); border-color: rgba(0,212,216,0.35);
  background: rgba(0,212,216,0.06);
  box-shadow: 0 0 16px rgba(0,212,216,0.12);
  transform: translateY(-1px);
}
.btn-home-md:hover svg { opacity: 1; }
.btn-home-md:active { transform: translateY(0) scale(0.97); }

/* ── Streak indicator ─────────────────────────────────────────────────────── */
.stat-streak { transition: all 0.3s ease; }
.stat-streak.streak-hot { color: #ff6b35; text-shadow: 0 0 8px rgba(255,107,53,0.6); animation: streakPulse 0.8s ease infinite; }
@keyframes streakPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.15); } }

/* ── Streak heal feedback ─────────────────────────────────────────────────── */
.streak-heal { color: #ff6b35; font-weight: 700; font-size: 0.9rem; animation: streakPulse 0.6s ease; }

/* ── HP shake animation ───────────────────────────────────────────────────── */
.hp-shake { animation: hpShake 0.5s ease; }
@keyframes hpShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(5px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}
.hp-flash { animation: hpShake 0.5s ease, hpFlash 0.5s ease; }
@keyframes hpFlash {
  0% { background: rgba(231,76,60,0.3); }
  100% { background: transparent; }
}

/* ── HP heal animation ────────────────────────────────────────────────────── */
.hp-heal { animation: hpHealGlow 0.8s ease; }
@keyframes hpHealGlow {
  0% { background: rgba(46,204,113,0.4); box-shadow: 0 0 12px rgba(46,204,113,0.6); }
  100% { background: transparent; box-shadow: none; }
}

/* ── PvP Game Log ─────────────────────────────────────────────────────────── */
.pvp-game-log {
  max-height: 400px; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.log-entry {
  padding: 0.6rem 0.8rem; border-radius: 8px;
  background: var(--bg-hover); border: 1px solid var(--border);
  animation: slideUp 0.3s ease;
}
.log-round { font-size: 0.85rem; margin-bottom: 0.3rem; color: var(--text-muted); }
.log-round strong { color: var(--accent); }
.log-players { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.log-player { font-size: 0.8rem; padding: 0.15rem 0.5rem; border-radius: 4px; }
.log-correct { background: rgba(46,204,113,0.15); color: var(--success); }
.log-wrong { background: rgba(231,76,60,0.15); color: var(--danger); }

/* ── Leave room button ────────────────────────────────────────────────────── */
.btn-danger {
  background: var(--danger); color: #fff; border: none;
  transition: background 0.2s, transform 0.1s;
}
.btn-danger:hover { background: #c0392b; transform: scale(1.02); }

/* ── Sudden Death ─────────────────────────────────────────────────────────── */
.sudden-death-badge {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  animation: sd-pulse 1s ease-in-out infinite;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
@keyframes sd-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(231,76,60,0.4); }
  50% { box-shadow: 0 0 18px rgba(231,76,60,0.8); }
}

.sudden-death-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}
.sudden-death-overlay.show {
  opacity: 1;
}
.sudden-death-text {
  font-size: 3rem;
  font-weight: 900;
  color: #e74c3c;
  text-shadow: 0 0 30px rgba(231,76,60,0.8), 0 0 60px rgba(231,76,60,0.4);
  animation: sd-shake 0.4s ease-in-out infinite;
  letter-spacing: 0.1em;
}
.sudden-death-sub {
  margin-top: 1rem;
  font-size: 1.1rem;
  color: #ecf0f1;
  opacity: 0.9;
  text-align: center;
}
@keyframes sd-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px) rotate(-1deg); }
  75% { transform: translateX(4px) rotate(1deg); }
}

/* ── Keyboard hints ───────────────────────────────────────────────────────── */
.keys-hint {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
  opacity: 0.45;
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: opacity 0.2s;
}
.keys-hint:hover { opacity: 0.75; }
.keys-hint span { display: flex; align-items: center; gap: 0.25rem; }
.keys-hint kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06);
}

/* ── PvP waiting message ──────────────────────────────────────────────────── */
.pvp-waiting-msg {
  text-align: center;
  animation: waitPulse 2s ease-in-out infinite;
}
@keyframes waitPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

