/* ========================================
   AI Playground - ARCADE POP Theme
   Target: Korean elementary students (ages 8-12)
   Vibe: Just Dance / Pump It Up / DDR energy
   ======================================== */

/* ---- Font ---- */
/* 80" TV / 강당 뷰잉 거리 대응 — rem 기반 텍스트 전체를 +25% 확대 */
html {
  font-size: 20px;
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: rgba(249, 197, 168, 0.3);
}

/* ---- Reset + Korean 어절 단위 줄바꿈 (project-wide) ---- */
/* word-break: keep-all → 한글 단어를 글자 중간에서 끊지 않음 */
/* overflow-wrap: break-word → 단어가 너무 길어 컨테이너를 넘으면 단어 단위로만 끊음 */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* ---- Design Tokens ---- */
:root {
  /* ARCADE POP color tokens */
  --bg-deep: #0A0520;
  --bg-layer: #15092E;
  --ink: #FFFFFF;
  --ink-dim: #B8A8D8;
  --neon-cyan: #00F0FF;
  --neon-magenta: #FF2E93;
  --neon-yellow: #FFEE00;
  --neon-lime: #9FFF3D;
  --neon-red: #FF3355;
  --neon-amber: #FFA500;
  --neon-violet: #B347FF;
  --neon-orange: #FF9500;

  /* Legacy compat aliases (used by game-specific inline styles) */
  --color-peach: #F9C5A8;
  --color-peach-light: #FFDEC8;
  --color-peach-dark: #E8A07A;
  --color-rose: var(--neon-magenta);
  --color-rose-dark: #CC1070;
  --color-green: var(--neon-lime);
  --color-green-light: #B2FFB2;
  --color-gold: var(--neon-amber);
  --color-gold-light: #FFD080;
  --color-purple: #9B8FD0;
  --color-purple-light: #C8BBFF;
  --color-blue: var(--neon-cyan);
  --color-blue-light: #80F8FF;

  /* Neutrals (mapped to dark theme) */
  --color-cream: var(--bg-deep);
  --color-cream-mid: var(--bg-layer);
  --color-cream-deep: #1C0A3A;
  --color-warm-brown: var(--ink-dim);
  --color-dark-brown: var(--ink);
  --color-text-muted: var(--ink-dim);

  /* Game Theme Colors (dark versions) */
  --game-flag-bg: #0A1428;
  --game-flag-accent: var(--neon-cyan);
  --game-crosswalk-bg: #0A1A0A;
  --game-crosswalk-accent: var(--neon-lime);
  --game-piano-bg: #180A2E;
  --game-piano-accent: var(--neon-magenta);
  --game-board-bg: #1A1000;
  --game-board-accent: var(--neon-amber);
  --game-bubble-bg: #1A0A2E;
  --game-bubble-accent: var(--neon-violet);
  --game-falling-bg: #2A1405;
  --game-falling-accent: var(--neon-orange);

  /* Glass Morphism (dark) */
  --glass-bg: rgba(21, 9, 46, 0.85);
  --glass-border: rgba(0, 240, 255, 0.25);
  --glass-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --glass-shadow-hover: 0 8px 30px rgba(0, 240, 255, 0.3), 0 0 40px rgba(0, 240, 255, 0.15);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.7);
  --shadow-glow-peach: 0 0 20px rgba(0, 240, 255, 0.4);
  --shadow-glow-rose: 0 0 20px rgba(255, 46, 147, 0.4);

  /* Radius */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-2xl: 1.5rem;
  --radius-3xl: 2rem;
  --radius-pill: 9999px;
}

/* ---- Dark Arcade Background ---- */
body {
  background: radial-gradient(ellipse at 50% 40%, var(--bg-layer) 0%, var(--bg-deep) 70%);
  min-height: 100vh;
  color: var(--ink);
}

/* Scanline overlay on app container */
#app-container::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 9999;
  opacity: 1;
}

/* Legacy warm class aliases (kept for no-break) */
.bg-warm { background: var(--bg-deep); }
.text-warm-dark { color: var(--ink); }
.text-warm-brown { color: var(--ink-dim); }

/* ---- Font Utilities ---- */
.font-display { font-family: 'Black Han Sans', sans-serif; }
.font-impact  { font-family: 'Bagel Fat One', sans-serif; }
.font-hud     { font-family: 'Orbitron', sans-serif; font-weight: 600; }

/* ---- Glow Utilities ---- */
.glow-cyan    { box-shadow: 0 0 12px #00F0FF, 0 0 28px #00F0FF80; }
.glow-magenta { box-shadow: 0 0 12px #FF2E93, 0 0 28px #FF2E9380; }
.glow-yellow  { box-shadow: 0 0 12px #FFEE00, 0 0 28px #FFEE0080; }
.glow-lime    { box-shadow: 0 0 12px #9FFF3D, 0 0 28px #9FFF3D80; }

.text-glow-cyan    { text-shadow: 0 0 8px #00F0FF, 0 0 20px #00F0FF; }
.text-glow-magenta { text-shadow: 0 0 8px #FF2E93, 0 0 20px #FF2E93; }
.text-glow-yellow  { text-shadow: 0 0 8px #FFEE00, 0 0 20px #FFEE00; }

/* ---- Arcade Primitives ---- */
.arcade-pill {
  background: rgba(10, 5, 32, 0.8);
  border: 1.5px solid var(--neon-cyan);
  border-radius: 999px;
  padding: 0.5rem 1.25rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--ink);
}

.arcade-card {
  background: var(--bg-layer);
  border: 3px solid var(--neon-cyan);
  border-radius: 12px;
  box-shadow: 0 0 12px #00F0FF, 0 0 28px #00F0FF80;
}

.arcade-btn {
  font-family: 'Bagel Fat One', sans-serif;
  padding: 1rem 2.5rem;
  font-size: 1.25rem;
  border: 3px solid var(--neon-cyan);
  border-radius: var(--radius-pill);
  background: rgba(0, 240, 255, 0.1);
  color: var(--neon-cyan);
  cursor: pointer;
  box-shadow: 0 0 12px #00F0FF80;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  letter-spacing: 0.03em;
}
.arcade-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px #00F0FF, 0 0 40px #00F0FF80;
}
.arcade-btn:active { transform: scale(0.97); }

/* ---- Glass Morphism Utility (dark) ---- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* ---- Arcade Keyframes ---- */
@keyframes stamp-in {
  0%   { transform: scale(0) rotate(-5deg); opacity: 0; }
  60%  { transform: scale(1.3) rotate(-3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes neon-pulse {
  0%, 100% { box-shadow: 0 0 8px currentColor, 0 0 20px currentColor; }
  50%       { box-shadow: 0 0 20px currentColor, 0 0 50px currentColor, 0 0 80px currentColor; }
}

@keyframes text-flicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; }
  20%, 24%, 55% { opacity: 0.6; }
}

@keyframes particle-burst {
  0%   { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-60px); opacity: 0; }
}

@keyframes combo-spin {
  0%   { transform: scale(1) rotate(0deg); }
  25%  { transform: scale(1.15) rotate(-4deg); }
  75%  { transform: scale(1.15) rotate(4deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes shimmer-gradient {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes stars-drift {
  0%   { background-position: 0 0, 30px 30px; }
  100% { background-position: 100px 50px, 130px 80px; }
}

/* ---- Loading Overlay ---- */
.loading-overlay {
  background: var(--bg-deep);
}

.loading-spinner {
  width: 56px;
  height: 56px;
  border: 3px solid rgba(0, 240, 255, 0.2);
  border-top-color: var(--neon-cyan);
  border-radius: 50%;
  animation: spin 1s ease-in-out infinite;
  margin-bottom: 1.5rem;
  box-shadow: 0 0 12px var(--neon-cyan);
}

.loading-text {
  font-size: 1.125rem;
  color: var(--ink-dim);
  font-family: 'Orbitron', sans-serif;
  font-weight: 600;
  animation: pulse-text 2s ease-in-out infinite;
  text-shadow: 0 0 8px var(--neon-cyan);
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-text {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ==============================
   LOBBY SCREEN
   ============================== */

.lobby-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  /* 80" TV 강당 환경: 좌우 여백 최소화 */
  padding: 2vh 2.5vw;
  position: relative;
  overflow: hidden;
}

.lobby-content {
  position: relative;
  z-index: 1;
  text-align: center;
  width: 100%;
  /* 여백 제거: 화면 가득 채움 */
  max-width: none;
}

/* Title Area */
.lobby-header {
  margin-bottom: 2.5vh;
}

.lobby-title {
  font-family: 'Black Han Sans', sans-serif;
  /* viewport 비례 스케일 (80" TV 대응) */
  font-size: clamp(4rem, 9vw, 12rem);
  font-weight: 900;
  line-height: 1;
  margin-bottom: 0.5rem;
  background: linear-gradient(90deg, var(--neon-cyan) 0%, var(--neon-magenta) 50%, var(--neon-cyan) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer-gradient 4s linear infinite;
  letter-spacing: -0.02em;
}

@media (max-width: 1100px) {
  .lobby-title { font-size: 4rem; }
}

.lobby-title-accent { /* kept as no-op to not break HTML */ }

.lobby-subtitle {
  font-family: 'Bagel Fat One', sans-serif;
  color: var(--neon-yellow);
  font-size: clamp(1.8rem, 3vw, 4rem);
  opacity: 1;
  letter-spacing: 0.04em;
  text-shadow: 0 0 12px var(--neon-yellow), 0 0 24px #FFEE0080;
  font-weight: 700;
}

/* Decorative arcade dots background */
.lobby-deco {
  position: absolute;
  border-radius: 50%;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
  filter: blur(50px);
}

.deco-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, var(--neon-cyan) 0%, transparent 70%);
  top: -150px; left: -120px;
  animation: float-slow 8s ease-in-out infinite;
}

.deco-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, var(--neon-magenta) 0%, transparent 70%);
  bottom: -100px; right: -80px;
  animation: float-slow 10s ease-in-out infinite reverse;
}

.deco-3 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, var(--neon-lime) 0%, transparent 70%);
  top: 25%; right: 3%;
  animation: float-slow 12s ease-in-out infinite;
}

.deco-4 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, var(--neon-yellow) 0%, transparent 70%);
  bottom: 20%; left: 5%;
  animation: float-slow 9s ease-in-out infinite 2s;
}

@keyframes float-slow {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(15px, -25px) scale(1.05); }
  66% { transform: translate(-10px, 15px) scale(0.95); }
}

/* Game card grid — 1x4 horizontal row: 3 games + leaderboard tile */
.game-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(0.75rem, 1.5vw, 2rem);
  width: 100%;
  max-width: none;
  margin: 0 auto;
  justify-items: center;
  align-items: stretch;
}
.game-grid > .game-card-warm,
.game-grid > .lobby-lb-card {
  width: 100%;
  max-width: 480px;
}

@media (max-width: 1400px) {
  .game-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-width: 56rem;
  }
  .lobby-title { font-size: 3rem; }
}

@media (max-width: 600px) {
  .game-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Game Cards ---- */
.game-card-warm {
  background: var(--bg-layer);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius-3xl);
  overflow: hidden;
  border: 3px solid var(--neon-cyan);
  box-shadow: 0 0 12px #00F0FF60, 0 0 28px #00F0FF30;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  text-align: center;
  position: relative;
}

.game-card-warm::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  z-index: 1;
}

.game-card-warm:hover {
  transform: translateY(-8px) scale(1.05);
  box-shadow: 0 0 24px #00F0FF, 0 0 60px #00F0FF60;
  border-color: var(--neon-cyan);
}

.game-card-warm:hover::before {
  opacity: 1;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
}

.game-card-warm:active {
  transform: translateY(-3px) scale(0.98);
  transition-duration: 0.1s;
}

.game-card-icon-area {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  /* 카드 아이콘 영역도 TV 비례로 확대 */
  min-height: clamp(220px, 22vw, 440px);
  aspect-ratio: 1 / 1;
  position: relative;
  overflow: hidden;
}

/* Subtle pattern overlay on icon area */
.game-card-icon-area::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 70% 30%, rgba(255,255,255,0.4) 0%, transparent 50%);
  pointer-events: none;
}

.game-card-info {
  padding: clamp(1rem, 1.5vw, 2rem) clamp(1rem, 1.5vw, 2rem) clamp(1.25rem, 2vw, 2.5rem);
  background: rgba(21, 9, 46, 0.9);
  border-top: 1px solid rgba(0, 240, 255, 0.2);
  position: relative;
}

.game-card-title {
  font-family: 'Black Han Sans', sans-serif;
  font-size: clamp(1.8rem, 2.6vw, 3.4rem);
  color: var(--ink);
  margin-bottom: 0.55rem;
  text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan), 0 2px 4px rgba(0, 0, 0, 0.6);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.game-card-desc {
  font-size: clamp(1rem, 1.3vw, 1.6rem);
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 0.875rem;
  line-height: 1.5;
  min-height: 3em;
}

.game-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: clamp(0.95rem, 1.2vw, 1.5rem);
  font-family: 'Orbitron', sans-serif;
  font-weight: 600;
  padding: 0.45rem 1.15rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid;
  background: rgba(0, 0, 0, 0.5);
  transition: all 0.2s ease;
}

.game-card-warm:hover .game-card-badge {
  transform: scale(1.05);
}

/* Game card color themes (neon dark) */
.game-bg-flag      { background: linear-gradient(135deg, #020C20 0%, #06183A 100%); border-bottom: 2px solid var(--neon-cyan); }
.game-bg-crosswalk { background: linear-gradient(135deg, #020F02 0%, #061A06 100%); border-bottom: 2px solid var(--neon-lime); }
.game-bg-piano     { background: linear-gradient(135deg, #140820 0%, #200A30 100%); border-bottom: 2px solid var(--neon-magenta); }
.game-bg-board     { background: linear-gradient(135deg, #120A00 0%, #1E1000 100%); border-bottom: 2px solid var(--neon-amber); }
.game-bg-bubble    { background: linear-gradient(135deg, #160525 0%, #280A45 100%); border-bottom: 2px solid var(--neon-violet); }
.game-bg-falling   { background: linear-gradient(135deg, #200F02 0%, #351806 100%); border-bottom: 2px solid var(--neon-orange); }

/* Per-card neon accent for hover glow */
.game-card-warm:has(.game-bg-flag):hover      { border-color: var(--neon-cyan);    box-shadow: 0 0 24px var(--neon-cyan),    0 0 60px #00F0FF60; }
.game-card-warm:has(.game-bg-crosswalk):hover { border-color: var(--neon-lime);    box-shadow: 0 0 24px var(--neon-lime),    0 0 60px #9FFF3D60; }
.game-card-warm:has(.game-bg-piano):hover     { border-color: var(--neon-magenta); box-shadow: 0 0 24px var(--neon-magenta), 0 0 60px #FF2E9360; }
.game-card-warm:has(.game-bg-board):hover     { border-color: var(--neon-amber);   box-shadow: 0 0 24px var(--neon-amber),   0 0 60px #FFA50060; }
.game-card-warm:has(.game-bg-bubble):hover    { border-color: var(--neon-violet);  box-shadow: 0 0 24px var(--neon-violet),  0 0 60px #B347FF60; }
.game-card-warm:has(.game-bg-falling):hover   { border-color: var(--neon-orange);  box-shadow: 0 0 24px var(--neon-orange),  0 0 60px #FF950060; }

/* Lobby thumbnail image (replaces SVG icon when loaded) */
.game-card-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  padding: 0.5rem;
  z-index: 1;
  display: block;
}

/* SVG fallback — hidden when thumbnail loads, visible when image fails */
.game-card-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 0;
}

/* When thumbnail is present and loaded, hide the fallback SVG */
.game-card-icon-area:has(.game-card-thumb:not([style*="display:none"])) .game-card-thumb-fallback {
  display: none;
}

/* SVG Icon Styles */
.icon-svg { width: 4rem; height: 4rem; flex-shrink: 0; }
.icon-svg-lg {
  width: 4.5rem; height: 4.5rem; flex-shrink: 0;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.08));
  transition: transform 0.35s ease;
}

.game-card-warm:hover .icon-svg-lg {
  transform: scale(1.1) translateY(-4px);
}

/* Debug button — quietly tucked into the corner so kids don't accidentally tap it */
.lobby-debug-btn {
  position: fixed;
  bottom: 0.5rem;
  right: 0.5rem;
  padding: 0.3rem 0.7rem;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.35);
  background: rgba(10, 5, 32, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  cursor: pointer;
  z-index: 10;
  opacity: 0.4;
  transition: all 0.2s ease;
}

.lobby-debug-btn:hover {
  opacity: 1;
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: 0 0 8px var(--neon-cyan);
}

/* ==============================
   BUTTONS
   ============================== */

.btn-warm {
  font-family: 'Bagel Fat One', sans-serif;
  padding: 1rem 2.25rem;
  border-radius: var(--radius-2xl);
  font-size: 1.4rem;
  transition: all 0.2s ease;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.02em;
}

.btn-warm:active {
  transform: scale(0.96);
  transition-duration: 0.1s;
}

.btn-warm-primary {
  background: linear-gradient(135deg, var(--neon-magenta), #CC1070);
  color: #fff;
  border-color: var(--neon-magenta);
  box-shadow: 0 0 12px #FF2E9380;
}

.btn-warm-primary:hover {
  box-shadow: 0 0 24px var(--neon-magenta), 0 0 48px #FF2E9360;
  transform: translateY(-2px) scale(1.03);
}

.btn-warm-peach {
  background: linear-gradient(135deg, var(--neon-amber), #CC8000);
  color: #000;
  border-color: var(--neon-amber);
  box-shadow: 0 0 12px #FFA50080;
}

.btn-warm-peach:hover {
  box-shadow: 0 0 24px var(--neon-amber);
  transform: translateY(-2px) scale(1.03);
}

.btn-warm-yellow {
  background: linear-gradient(135deg, var(--neon-yellow), #CCC000);
  color: #000;
  border-color: var(--neon-yellow);
  box-shadow: 0 0 12px #FFEE0080;
}

.btn-warm-yellow:hover {
  box-shadow: 0 0 24px var(--neon-yellow);
  transform: translateY(-2px) scale(1.03);
}

.btn-warm-subtle {
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(4px);
  color: var(--ink-dim);
  font-size: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-warm-subtle:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
  transform: translateY(-1px);
}

/* ==============================
   CALIBRATION SCREEN
   ============================== */

.calibration-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  position: relative;
}

.calibration-title {
  font-family: 'Black Han Sans', sans-serif;
  font-size: clamp(3.5rem, 7vw, 9rem);
  color: var(--ink);
  margin-bottom: 0.75rem;
  animation: bounce-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-shadow: 0 0 8px var(--neon-cyan), 0 0 20px var(--neon-cyan);
}

.calibration-subtitle {
  font-family: 'Bagel Fat One', sans-serif;
  color: #fff;
  font-size: clamp(1.4rem, 2vw, 2.4rem);
  margin-bottom: 1rem;
  line-height: 1.5;
  font-weight: 700;
}

.calibration-info {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1.4rem;
  background: rgba(255, 46, 147, 0.12);
  border-radius: var(--radius-pill);
  border: 1.5px solid rgba(255, 46, 147, 0.5);
  font-size: 1.4rem;
  color: #fff;
  margin-bottom: 1.5rem;
  font-family: 'Bagel Fat One', sans-serif;
  text-shadow: 0 0 8px var(--neon-magenta);
}

/* Timer demoted to top-right corner — secondary info */
.calibration-timer {
  position: fixed;
  top: 1.25rem;
  right: 1.5rem;
  font-family: 'Orbitron', sans-serif;
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--neon-cyan);
  text-shadow: 0 0 12px var(--neon-cyan), 0 0 24px var(--neon-cyan);
  font-variant-numeric: tabular-nums;
  background: rgba(10, 5, 32, 0.78);
  border: 2px solid rgba(0, 240, 255, 0.5);
  border-radius: var(--radius-pill);
  padding: 0.4rem 1.25rem;
  z-index: 20;
}

/* Counter — slots themselves act as the counter; this is now a quiet caption */
.calibration-counter {
  font-family: 'Bagel Fat One', sans-serif;
  font-size: 1.5rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 1.5rem;
}

.calibration-counter strong {
  color: var(--neon-lime);
  font-size: 1.8rem;
  text-shadow: 0 0 10px var(--neon-lime);
}

.zone-card {
  background: var(--bg-layer);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 4px solid rgba(0, 240, 255, 0.4);
  border-radius: var(--radius-2xl);
  padding: clamp(1.5rem, 3vw, 3rem) clamp(1rem, 2vw, 2.5rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-width: clamp(130px, 14vw, 280px);
  min-height: clamp(170px, 20vh, 340px);
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.18), inset 0 0 30px rgba(0, 240, 255, 0.08);
}

.zone-card.detected {
  /* opacity:1 needed because stamp-in overrides .stagger-children slide-up,
     which would otherwise revert the card to the base opacity:0 */
  opacity: 1;
  background: rgba(159, 255, 61, 0.18);
  border-color: var(--neon-lime);
  box-shadow: 0 0 32px rgba(159, 255, 61, 0.6), inset 0 0 40px rgba(159, 255, 61, 0.2);
  transform: scale(1.08);
  animation: stamp-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.zone-card .zone-icon {
  font-size: 4.5rem;
  color: var(--ink-dim);
  transition: all 0.3s ease;
  line-height: 1;
}

.zone-card.detected .zone-icon {
  color: var(--neon-lime);
  text-shadow: 0 0 16px var(--neon-lime), 0 0 32px var(--neon-lime);
}

.zone-card .zone-label {
  font-size: 2rem;
  font-weight: 900;
  font-family: 'Orbitron', sans-serif;
  letter-spacing: 0.05em;
}

/* ==============================
   GAME UI PANELS
   ============================== */

/* Glass panel for in-game UI */
.game-panel {
  background: rgba(21, 9, 46, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  color: var(--ink);
}

.game-panel-dark {
  background: rgba(10, 5, 32, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-2xl);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  color: var(--ink);
}

/* Score display */
.game-score-panel {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: rgba(10, 5, 32, 0.9);
  backdrop-filter: blur(8px);
  border: 1.5px solid var(--neon-cyan);
  border-radius: var(--radius-pill);
  box-shadow: 0 0 12px #00F0FF60;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  color: var(--ink);
}

/* Round/Phase indicator */
.game-phase-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-pill);
  font-family: 'Orbitron', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(10, 5, 32, 0.8);
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
}

/* Command display for flag game etc */
.game-command-display {
  font-family: 'Black Han Sans', sans-serif;
  font-size: 3.5rem;
  color: var(--ink);
  text-shadow: 0 0 8px var(--neon-cyan), 0 0 20px var(--neon-cyan);
  line-height: 1.3;
  padding: 1rem;
}

/* Player tag */
.player-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.875rem;
  border-radius: var(--radius-pill);
  font-family: 'Bagel Fat One', sans-serif;
  font-size: 0.75rem;
  backdrop-filter: blur(4px);
}

/* Team colors */
.team-blue {
  background: rgba(0, 240, 255, 0.15);
  color: var(--neon-cyan);
  border: 1.5px solid rgba(0, 240, 255, 0.5);
}

.team-red {
  background: rgba(255, 46, 147, 0.15);
  color: var(--neon-magenta);
  border: 1.5px solid rgba(255, 46, 147, 0.5);
}

/* ==============================
   GAME OVERLAYS
   ============================== */

.game-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: rgba(20, 15, 10, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.game-overlay-card {
  background: var(--bg-layer);
  border: 3px solid var(--neon-cyan);
  border-radius: var(--radius-3xl);
  box-shadow: 0 0 24px var(--neon-cyan), 0 0 60px #00F0FF40, var(--shadow-xl);
  padding: clamp(2rem, 4vw, 5rem) clamp(2.5rem, 5vw, 7rem);
  text-align: center;
  /* 80" TV 대응: 작은 카드라도 충분히 크게 보이도록 */
  max-width: clamp(32rem, 50vw, 64rem);
  width: 90%;
  animation: overlay-enter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: var(--ink);
  font-size: clamp(1rem, 1.4vw, 1.8rem);
}

@keyframes overlay-enter {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Result screen */
.result-card {
  background: var(--bg-layer);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 3px solid var(--neon-cyan);
  border-radius: var(--radius-2xl);
  box-shadow: 0 0 24px var(--neon-cyan), var(--shadow-lg);
  padding: 2rem;
  text-align: center;
  color: var(--ink);
}

.result-title {
  font-family: 'Black Han Sans', sans-serif;
  font-size: 2rem;
  color: var(--ink);
  margin-bottom: 1rem;
  text-shadow: 0 0 8px var(--neon-cyan);
}

.result-score {
  font-family: 'Orbitron', sans-serif;
  font-size: 3.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.result-detail {
  font-size: 1rem;
  color: var(--ink-dim);
  margin-bottom: 2rem;
  line-height: 1.6;
}

/* ==============================
   FULLSCREEN CAMERA MODE (Flag Game)
   ============================== */

.camera-fullscreen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  z-index: 0;
}

.camera-overlay-ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.camera-overlay-panel {
  background: rgba(10, 5, 32, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  color: var(--ink);
}

/* ==============================
   PIP CAMERA
   ============================== */

.pip-camera {
  border-radius: var(--radius-xl);
  border: 2px solid rgba(0, 240, 255, 0.5);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
  overflow: hidden;
}

/* ==============================
   PROGRESS / TRACK
   ============================== */

.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(0, 240, 255, 0.1);
  border-radius: var(--radius-pill);
  overflow: hidden;
  border: 1px solid rgba(0, 240, 255, 0.2);
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.5s ease;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-magenta));
  box-shadow: 0 0 8px var(--neon-cyan);
}

/* ==============================
   PIANO KEYS
   ============================== */

.piano-key {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top: 6px solid currentColor;
  transition: all 0.12s ease;
  box-shadow: inset 0 -4px 12px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
  background: #0A0520;
}

.piano-key::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 20%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.08), transparent);
  pointer-events: none;
}

.piano-key.active, .piano-key-active {
  transform: scaleY(0.97);
  filter: brightness(2.5) saturate(1.5);
  box-shadow: inset 0 0 24px rgba(255,255,255,0.3), 0 0 20px currentColor;
}

.piano-key-label {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Black Han Sans', sans-serif;
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 0 8px currentColor;
}

/* ==============================
   BOARD GAME
   ============================== */

.board-tile {
  border: 1.5px solid rgba(62, 44, 28, 0.1);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.board-tile.active {
  border-color: var(--color-gold);
  box-shadow: 0 0 16px rgba(200, 150, 60, 0.3);
  z-index: 2;
}

.board-tile-start {
  background: linear-gradient(135deg, #FCECA1, #F5D76E);
}

.board-center-pip {
  border-radius: var(--radius-xl);
  border: 2px solid rgba(200, 150, 60, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.8);
}

/* ==============================
   CROSSWALK GAME
   ============================== */

.crosswalk-lane {
  position: relative;
  overflow: hidden;
}

.crosswalk-avatar {
  transition: left 0.3s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.traffic-light {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.875rem;
  background: #0A0520;
  border-radius: var(--radius-xl);
  border: 3px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.8), inset 0 0 12px rgba(0, 0, 0, 0.5);
}

.traffic-light-dot {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  transition: all 0.25s ease;
  opacity: 0.08;
}

.traffic-light-dot.red    { background: var(--neon-red); }
.traffic-light-dot.yellow { background: var(--neon-amber); }
.traffic-light-dot.green  { background: var(--neon-lime); }

.traffic-light-dot.active {
  opacity: 1;
  animation: neon-pulse 0.8s ease-in-out infinite;
}

/* ==============================
   FEEDBACK ANIMATIONS
   ============================== */

@keyframes bounce-in {
  0% { opacity: 0; transform: scale(0.3) translateY(20px); }
  50% { transform: scale(1.08) translateY(-4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@keyframes pop-feedback {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.4); }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(-20px) rotate(0deg); }
  100% { opacity: 0; transform: translateY(100vh) rotate(720deg); }
}

.animate-bounce-in { animation: bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
.animate-shake { animation: shake 0.5s ease; }
.animate-slide-up { animation: slide-up 0.4s ease-out; }

/* Staggered children animation */
.stagger-children > * {
  opacity: 0;
  animation: slide-up 0.4s ease-out forwards;
}
.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.3s; }

/* ==============================
   SCREEN TRANSITIONS
   ============================== */

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

@keyframes screen-exit {
  from { opacity: 1; }
  to { opacity: 0; }
}

.screen-enter { animation: screen-enter 0.35s ease-out forwards; }
.screen-exit { animation: screen-exit 0.2s ease-in forwards; }

/* ==============================
   PULSE GLOW
   ============================== */

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px var(--neon-cyan); }
  50% { box-shadow: 0 0 28px var(--neon-cyan), 0 0 50px #00F0FF80; }
}

.pulse-glow { animation: pulse-glow 2s ease-in-out infinite; }

@keyframes pulse-glow-green {
  0%, 100% { box-shadow: 0 0 8px var(--neon-lime); }
  50% { box-shadow: 0 0 24px var(--neon-lime), 0 0 48px #9FFF3D80; }
}

.pulse-glow-green { animation: pulse-glow-green 2s ease-in-out infinite; }

/* ==============================
   CANVAS
   ============================== */
canvas { display: block; }

/* ==============================
   FOCUS / ACCESSIBILITY
   ============================== */

*:focus-visible {
  outline: 3px solid var(--neon-cyan);
  outline-offset: 3px;
  border-radius: 4px;
  box-shadow: 0 0 0 6px rgba(0, 240, 255, 0.2);
}

/* Touch device optimization */
@media (hover: none) and (pointer: coarse) {
  .game-card-warm:hover {
    transform: none;
    box-shadow: var(--glass-shadow);
  }
  .game-card-warm:active {
    transform: scale(0.97);
  }
}

/* ==============================
   RETROWAVE STAGE BACKGROUND (lobby)
   Synthwave horizon + perspective grid + neon sun.
   ============================== */

.rw-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.rw-sunset {
  position: absolute;
  left: 50%;
  top: 72%;
  width: 160vw;
  height: 70vh;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse at center,
    rgba(255, 46, 147, 0.45) 0%,
    rgba(255, 46, 147, 0.20) 18%,
    rgba(155, 50, 200, 0.10) 35%,
    transparent 55%);
}

.rw-sun {
  position: absolute;
  left: 50%;
  top: 72%;
  width: 320px;
  height: 320px;
  transform: translate(-50%, -100%);
  background: radial-gradient(circle,
    #FFEE00 0%,
    #FF8A3D 35%,
    #FF2E93 65%,
    transparent 72%);
  border-radius: 50%;
  filter: blur(1.5px) drop-shadow(0 0 50px #FF2E9380);
  opacity: 0.9;
}

.rw-sun::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 12px,
    rgba(10, 5, 32, 0.95) 12px,
    rgba(10, 5, 32, 0.95) 20px
  );
  border-radius: 50%;
  clip-path: inset(55% 0 0 0);
}

.rw-horizon {
  position: absolute;
  left: 0; right: 0;
  top: 72%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--neon-cyan) 20%, #fff 50%, var(--neon-cyan) 80%, transparent);
  box-shadow: 0 0 20px var(--neon-cyan), 0 0 48px var(--neon-cyan), 0 -4px 24px var(--neon-magenta);
  z-index: 5;
}

.rw-grid-wrap {
  position: absolute;
  left: 50%;
  top: 72%;
  width: 300vw;
  height: 60vh;
  transform: translateX(-50%) perspective(340px) rotateX(70deg);
  transform-origin: 50% 0;
  z-index: 1;
}

.rw-grid {
  position: absolute; inset: 0;
  opacity: 0.6;
  background-image:
    linear-gradient(to right,
      rgba(0, 240, 255, 0.95) 0,
      rgba(0, 240, 255, 0.95) 2px,
      transparent 2px,
      transparent 100%),
    linear-gradient(to bottom,
      rgba(255, 46, 147, 0.95) 0,
      rgba(255, 46, 147, 0.95) 2px,
      transparent 2px,
      transparent 100%);
  background-size: 60px 60px, 60px 60px;
  animation: rw-grid-roll 3s linear infinite;
  mask-image: linear-gradient(to bottom, transparent 0%, #000 12%, #000 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 12%, #000 100%);
}

.rw-grid-glow {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right,
      rgba(0, 240, 255, 0.35) 0,
      rgba(0, 240, 255, 0.35) 4px,
      transparent 4px),
    linear-gradient(to bottom,
      rgba(255, 46, 147, 0.35) 0,
      rgba(255, 46, 147, 0.35) 4px,
      transparent 4px);
  background-size: 60px 60px, 60px 60px;
  animation: rw-grid-roll 3s linear infinite;
  filter: blur(6px);
  mask-image: linear-gradient(to bottom, transparent 0%, #000 12%, #000 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 12%, #000 100%);
  mix-blend-mode: screen;
}

@keyframes rw-grid-roll {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 0 60px, 0 60px; }
}

/* Calibration variant: kill the sun (was occluding P slot row) — keep grid only */
.calibration-container .rw-sun,
.calibration-container .rw-sunset { display: none; }

@media (prefers-reduced-motion: reduce) {
  .rw-grid, .rw-grid-glow { animation: none; }
}

/* ==============================
   COSMIC BACKGROUND FX (stars + meteor shower)
   Ported from wiz-world. Used by calibration.
   ============================== */

.bg-fx {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.bg-star {
  position: absolute;
  border-radius: 50%;
  opacity: 0;
  animation-name: bg-star-float;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  will-change: transform, opacity;
}

.bg-meteor {
  position: absolute;
  height: 2px;
  transform: rotate(35deg);
  opacity: 0;
  border-radius: 9999px;
  animation-name: bg-meteor-streak;
  animation-timing-function: ease-in;
  animation-iteration-count: infinite;
  will-change: transform, opacity;
  box-shadow: 0 0 6px currentColor;
}

@keyframes bg-star-float {
  0%   { opacity: 0;   transform: translateY(0)      translateX(0)    scale(0.5); }
  10%  { opacity: 0.9; transform: translateY(-10vh)  translateX(5px)  scale(1.2); }
  25%  { opacity: 0.7; transform: translateY(-25vh)  translateX(10px) scale(1);   }
  50%  { opacity: 0.5; transform: translateY(-50vh)  translateX(-5px) scale(0.9); }
  75%  { opacity: 0.3; transform: translateY(-75vh)  translateX(8px)  scale(0.7); }
  100% { opacity: 0;   transform: translateY(-100vh) translateX(0)    scale(0.5); }
}

@keyframes bg-meteor-streak {
  0%   { opacity: 0;   transform: rotate(35deg) translateX(0); }
  5%   { opacity: 1; }
  30%  { opacity: 0.6; }
  100% { opacity: 0;   transform: rotate(35deg) translateX(800px); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .bg-star, .bg-meteor { display: none; }
}

/* ==============================
   DEBUG SCREEN (stays dark)
   ============================== */

.debug-panel {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 1rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.debug-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  color: #fff;
}

.debug-btn:hover { transform: translateY(-1px); }
.debug-btn:active { transform: scale(0.96); }

.debug-btn-purple { background: var(--color-purple); }
.debug-btn-purple:hover { background: #6a58a0; box-shadow: 0 4px 12px rgba(123, 104, 174, 0.3); }
.debug-btn-blue { background: #4A7FD4; }
.debug-btn-blue:hover { background: #3d6db8; box-shadow: 0 4px 12px rgba(74, 127, 212, 0.3); }
.debug-btn-gray { background: #555; }
.debug-btn-gray:hover { background: #666; box-shadow: 0 4px 12px rgba(85, 85, 85, 0.3); }

/* ==============================
   UTILITY CLASSES
   ============================== */

.hidden { display: none !important; }
.text-gradient-warm {
  background: linear-gradient(135deg, var(--color-rose), var(--color-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ==============================
   CLASSROOM SESSION UI
   Grade/class picker, session banner, mini leaderboard,
   team prompt modal, end-class confirmation.
   80-inch TV optimized: large type + strong contrast.
   ============================== */

/* ---- Grade/Class select ---- */
.class-select-wrap {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
}
.class-select-card {
  background: rgba(10, 5, 32, 0.88);
  backdrop-filter: blur(14px);
  border: 3px solid var(--neon-cyan);
  border-radius: 2rem;
  padding: clamp(1.5rem, 3vw, 3rem) clamp(2rem, 4vw, 4rem);
  text-align: center;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.35), 0 12px 48px rgba(0, 0, 0, 0.7);
  width: min(92vw, 900px);
  animation: flag-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.class-select-icon {
  font-size: clamp(3rem, 5vw, 4.5rem);
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 0 14px rgba(0, 240, 255, 0.6));
}
.class-select-title {
  font-family: 'Black Han Sans', sans-serif;
  font-size: clamp(2rem, 3.5vw, 3.5rem);
  color: #fff;
  text-shadow: 0 0 18px var(--neon-cyan), 0 0 40px rgba(0, 240, 255, 0.5);
  margin-bottom: 0.4rem;
  line-height: 1.1;
}
.class-select-subtitle {
  font-family: 'Bagel Fat One', sans-serif;
  font-size: clamp(1rem, 1.3vw, 1.3rem);
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: clamp(1rem, 2vw, 2rem);
}
.class-select-section {
  margin-bottom: clamp(1rem, 1.5vw, 1.75rem);
}
.class-select-label {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(0.9rem, 1.1vw, 1.15rem);
  font-weight: 700;
  color: var(--neon-yellow);
  letter-spacing: 0.15em;
  margin-bottom: 0.6rem;
  text-transform: uppercase;
}
.class-select-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.6rem, 1vw, 1.2rem);
  justify-items: stretch;
  max-width: 560px;
  margin: 0 auto;
}
.class-select-grid .class-btn {
  width: 100%;
}
.class-btn {
  font-family: 'Bagel Fat One', sans-serif;
  font-size: clamp(1rem, 1.3vw, 1.4rem);
  padding: 0.7rem 1.4rem;
  min-width: 5rem;
  border-radius: 9999px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: all 0.2s ease;
}
.class-btn:not(:disabled):hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.5);
  transform: translateY(-2px);
}
.class-btn.selected {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--neon-cyan);
  color: #fff;
  box-shadow: 0 0 18px var(--neon-cyan), inset 0 0 12px rgba(0, 240, 255, 0.3);
  font-weight: 900;
}
.class-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.class-start-btn {
  margin-top: clamp(0.75rem, 1vw, 1.25rem);
  font-family: 'Black Han Sans', sans-serif;
  font-size: clamp(1.2rem, 1.5vw, 1.6rem);
  padding: 0.9rem 2.5rem;
  border-radius: 9999px;
  border: 2.5px solid var(--neon-yellow);
  background: rgba(255, 238, 0, 0.15);
  color: var(--neon-yellow);
  cursor: pointer;
  transition: all 0.2s ease;
  text-shadow: 0 0 8px var(--neon-yellow);
}
.class-start-btn:not(:disabled):hover {
  background: rgba(255, 238, 0, 0.3);
  box-shadow: 0 0 24px var(--neon-yellow);
  transform: translateY(-2px) scale(1.03);
}
.class-start-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  color: rgba(255, 255, 255, 0.5);
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
  text-shadow: none;
}

/* ---- Session banner (top) ---- */
.session-banner {
  position: fixed;
  top: 0.75rem; left: 0.75rem; right: 0.75rem;
  z-index: 15;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: rgba(10, 5, 32, 0.75);
  backdrop-filter: blur(10px);
  border: 1.5px solid rgba(0, 240, 255, 0.3);
  border-radius: 9999px;
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.4);
}
.session-banner-left { display: flex; flex-direction: column; gap: 0.15rem; }
.session-banner-grade {
  font-family: 'Black Han Sans', sans-serif;
  font-size: clamp(1.1rem, 1.4vw, 1.5rem);
  color: var(--neon-cyan);
  text-shadow: 0 0 10px var(--neon-cyan);
}
.session-banner-sub {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(0.8rem, 1vw, 1rem);
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.05em;
}
.session-banner-sub strong {
  color: var(--neon-yellow);
  text-shadow: 0 0 6px var(--neon-yellow);
}
.session-end-btn {
  font-family: 'Bagel Fat One', sans-serif;
  font-size: clamp(0.9rem, 1.15vw, 1.2rem);
  padding: 0.5rem 1.3rem;
  border-radius: 9999px;
  border: 2px solid var(--neon-red);
  background: rgba(255, 51, 85, 0.14);
  color: var(--neon-red);
  cursor: pointer;
  transition: all 0.2s ease;
}
.session-end-btn:hover {
  background: rgba(255, 51, 85, 0.28);
  box-shadow: 0 0 16px rgba(255, 51, 85, 0.5);
  transform: translateY(-1px);
}

/* ---- Leaderboard tile (lives inside game-grid as 4th cell) ---- */
.lobby-lb-card {
  background: rgba(10, 5, 32, 0.78);
  backdrop-filter: blur(12px);
  border: 2.5px solid rgba(255, 238, 0, 0.45);
  border-radius: 1.25rem;
  padding: clamp(1rem, 1.5vw, 1.5rem);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 24px rgba(255, 238, 0, 0.18), 0 8px 28px rgba(0, 0, 0, 0.45);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  /* Animation inherited from .stagger-children > * (slide-up, forwards).
     Do NOT override here with a keyframe that may not be defined in the lobby
     context, because backwards fill-mode would then keep it at opacity:0. */
}
.lobby-lb-card:hover {
  border-color: var(--neon-yellow);
  box-shadow: 0 0 30px rgba(255, 238, 0, 0.45), 0 10px 32px rgba(0, 0, 0, 0.5);
}
.lobby-lb-card-header {
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem;
  font-family: 'Black Han Sans', sans-serif;
  font-size: clamp(1.1rem, 1.4vw, 1.5rem);
  color: var(--neon-yellow);
  padding-bottom: 0.7rem;
  margin-bottom: 0.5rem;
  border-bottom: 1.5px solid rgba(255, 238, 0, 0.25);
  text-shadow: 0 0 10px var(--neon-yellow);
}
.lobby-lb-card-icon {
  font-size: 1.3em;
  filter: drop-shadow(0 0 8px rgba(255, 238, 0, 0.6));
}
.lobby-lb-card-body {
  display: flex; flex-direction: column;
  gap: clamp(0.6rem, 1vw, 1rem);
  flex: 1;
  justify-content: space-around;
}
.lobby-lb-game-block {
  padding: 0.65rem 0.75rem;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 0.75rem;
  border-left: 3px solid rgba(255, 255, 255, 0.1);
}
.lobby-lb-game-name {
  font-family: 'Black Han Sans', sans-serif;
  font-size: clamp(0.95rem, 1.15vw, 1.2rem);
  margin-bottom: 0.35rem;
  text-shadow: 0 0 8px currentColor;
}
.lobby-lb-game-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Bagel Fat One', sans-serif;
  font-size: clamp(0.9rem, 1.1vw, 1.15rem);
}
.lobby-lb-game-top.lobby-lb-second {
  opacity: 0.65;
  font-size: clamp(0.8rem, 1vw, 1.05rem);
  margin-top: 0.2rem;
}
.lobby-lb-medal { font-size: 1.15em; }
.lobby-lb-team { color: rgba(255, 255, 255, 0.9); text-align: left; }
.lobby-lb-score {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
}
.lobby-lb-game-empty {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(0.8rem, 1vw, 1rem);
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 0.03em;
  padding: 0.25rem 0;
}
.lobby-lb-game-block.lobby-lb-personal {
  border-left: 3px solid rgba(159, 255, 61, 0.45);
  background: rgba(159, 255, 61, 0.06);
}
.lobby-lb-game-block.lobby-lb-personal .lobby-lb-game-empty {
  color: rgba(159, 255, 61, 0.75);
  font-family: 'Bagel Fat One', sans-serif;
  font-size: clamp(0.85rem, 1.05vw, 1.05rem);
}

/* ---- (Legacy) Mini leaderboard — kept for backwards compat, unused in new lobby ---- */
.mini-leaderboard {
  margin-top: clamp(1rem, 2vw, 2rem);
  background: rgba(10, 5, 32, 0.6);
  backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255, 238, 0, 0.25);
  border-radius: 1.25rem;
  padding: clamp(0.75rem, 1.2vw, 1.5rem) clamp(1rem, 2vw, 2rem);
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}
.mini-lb-title {
  font-family: 'Black Han Sans', sans-serif;
  font-size: clamp(1.1rem, 1.4vw, 1.5rem);
  color: var(--neon-yellow);
  text-align: center;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 10px var(--neon-yellow);
}
.mini-lb-list {
  display: flex; flex-direction: column;
  gap: 0.35rem;
}
.mini-lb-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.9rem;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-family: 'Bagel Fat One', sans-serif;
  font-size: clamp(0.95rem, 1.15vw, 1.2rem);
}
.mini-lb-row.mini-lb-empty {
  grid-template-columns: 1fr auto;
  color: rgba(255, 255, 255, 0.4);
}
.mini-lb-game { font-weight: 700; }
.mini-lb-medal { font-size: 1.25em; }
.mini-lb-team { color: rgba(255, 255, 255, 0.9); }
.mini-lb-score {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  color: var(--neon-yellow);
}
.mini-lb-none {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85em;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 0.05em;
}

/* ---- Team-name prompt modal ---- */
.team-prompt-overlay,
.end-class-overlay {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 5, 32, 0.88);
  backdrop-filter: blur(12px);
}
.team-prompt-card,
.end-class-card {
  background: rgba(21, 9, 46, 0.95);
  border: 3px solid var(--neon-cyan);
  border-radius: 1.5rem;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  text-align: center;
  box-shadow: 0 0 32px rgba(0, 240, 255, 0.4), 0 16px 48px rgba(0, 0, 0, 0.7);
  width: min(92vw, 540px);
  animation: flag-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.end-class-card {
  border-color: var(--neon-red);
  box-shadow: 0 0 32px rgba(255, 51, 85, 0.4), 0 16px 48px rgba(0, 0, 0, 0.7);
}
.team-prompt-icon,
.end-class-icon {
  font-size: clamp(2.5rem, 4vw, 3.5rem);
  margin-bottom: 0.5rem;
}
.team-prompt-title,
.end-class-title {
  font-family: 'Black Han Sans', sans-serif;
  font-size: clamp(1.6rem, 2.2vw, 2.2rem);
  color: #fff;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 14px currentColor;
}
.team-prompt-subtitle,
.end-class-subtitle {
  font-family: 'Bagel Fat One', sans-serif;
  font-size: clamp(0.95rem, 1.15vw, 1.2rem);
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.team-prompt-subtitle strong {
  color: var(--neon-yellow);
  text-shadow: 0 0 8px var(--neon-yellow);
}
.team-prompt-input {
  width: 100%;
  font-family: 'Black Han Sans', sans-serif;
  font-size: clamp(1.3rem, 1.8vw, 1.8rem);
  padding: 0.8rem 1rem;
  border-radius: 0.75rem;
  border: 2px solid rgba(0, 240, 255, 0.45);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  text-align: center;
  margin-bottom: 1rem;
  outline: none;
}
.team-prompt-input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.5), inset 0 0 10px rgba(0, 240, 255, 0.15);
}
.team-prompt-buttons,
.end-class-buttons {
  display: flex; gap: 0.75rem; justify-content: center;
  margin-bottom: 0.75rem;
}
.team-prompt-btn {
  font-family: 'Bagel Fat One', sans-serif;
  font-size: clamp(1rem, 1.25vw, 1.3rem);
  padding: 0.65rem 1.75rem;
  border-radius: 9999px;
  border: 2px solid;
  cursor: pointer;
  transition: all 0.2s ease;
}
.team-prompt-btn-primary {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.4);
}
.team-prompt-btn-primary:hover {
  background: rgba(0, 240, 255, 0.35);
  box-shadow: 0 0 22px rgba(0, 240, 255, 0.6);
  transform: translateY(-1px);
}
.team-prompt-btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.9);
}
.team-prompt-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: #fff;
}
.team-prompt-timer {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.05em;
  min-height: 1.2em;
}
