/* ═══════════════════════════════════════════════════════════════════════════
   MATH TUG OF WAR — CSS (Optimized & Fixed)
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0f0f23;
  --bg-secondary: #1a1a3e;
  --bg-card: #252550;
  --bg-surface: #2d2d5a;
  --text-primary: #ffffff;
  --text-secondary: #b8b8d0;
  --accent-primary: #6c5ce7;
  --accent-secondary: #a29bfe;
  --accent-success: #00d2a0;
  --accent-warning: #ffc048;
  --accent-danger: #ff6b6b;
  --accent-info: #48dbfb;
  --p1-color: #ff6b6b;
  --p1-color-light: #ff8e8e;
  --p2-color: #48dbfb;
  --p2-color-light: #7de5ff;
  --rope-color: #ffc048;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(108, 92, 231, 0.5);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --font-display: 'Fredoka', sans-serif;
  --font-body: 'Nunito', sans-serif;
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
}

#app {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 0.75rem;
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BACKGROUND & PARTICLES
   ═══════════════════════════════════════════════════════════════════════════ */

#particles-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SCREENS
   ═══════════════════════════════════════════════════════════════════════════ */

.screen {
  display: none;
  opacity: 0;
  transform: scale(0.98);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  min-height: calc(100vh - 1.5rem);
  min-height: calc(100dvh - 1.5rem);
  flex: 1;
}

.screen.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: scale(1);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MAIN MENU
   ═══════════════════════════════════════════════════════════════════════════ */

#main-menu {
  position: relative;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 1rem 0;
}

.menu-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.floating-shape {
  position: absolute;
  border-radius: 50%;
  opacity: 0.08;
  animation: float 20s infinite ease-in-out;
}

.shape-1 {
  width: 200px;
  height: 200px;
  background: var(--p1-color);
  top: -50px;
  right: -50px;
  animation-delay: 0s;
}

.shape-2 {
  width: 150px;
  height: 150px;
  background: var(--p2-color);
  bottom: -30px;
  left: -30px;
  animation-delay: -5s;
}

.shape-3 {
  width: 100px;
  height: 100px;
  background: var(--accent-warning);
  top: 40%;
  right: 5%;
  animation-delay: -10s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(10px, -15px) rotate(90deg); }
  50% { transform: translate(-5px, 10px) rotate(180deg); }
  75% { transform: translate(15px, 5px) rotate(270deg); }
}

.menu-container {
  position: relative;
  text-align: center;
  padding: 1rem;
  max-width: 400px;
  width: 100%;
}

.game-logo {
  margin-bottom: 1.5rem;
  animation: logoEntrance 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes logoEntrance {
  from { opacity: 0; transform: scale(0.5) translateY(-20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.logo-icon {
  font-size: 3rem;
  margin-bottom: 0.25rem;
  animation: logoBounce 2s infinite;
}

@keyframes logoBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.game-logo h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 2px 10px rgba(108, 92, 231, 0.5);
  margin-bottom: 0.15rem;
}

.logo-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.logo-badge {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.2rem 0.8rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: white;
  box-shadow: var(--shadow-glow);
}

/* Menu Buttons */

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  animation: fadeInUp 0.6s ease-out 0.3s both;
}

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

.btn-row {
  display: flex;
  gap: 0.6rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  text-transform: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s, height 0.4s;
}

.btn:active::before {
  width: 200px;
  height: 200px;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #5a4bd1);
  color: white;
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.6);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 2px solid var(--bg-surface);
}

.btn-secondary:hover {
  border-color: var(--accent-secondary);
  background: var(--bg-surface);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.btn-large {
  padding: 1rem 1.5rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn-glow {
  animation: glowPulse 2s infinite;
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4); }
  50% { box-shadow: 0 4px 25px rgba(108, 92, 231, 0.8); }
}

.btn-icon {
  font-size: 1.1rem;
}

.btn-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.btn-label {
  font-weight: 700;
}

.btn-desc {
  font-size: 0.7rem;
  opacity: 0.8;
  font-weight: 600;
}

.btn-row .btn {
  flex: 1;
}

/* Difficulty Select */

.difficulty-select {
  margin-bottom: 1rem;
  animation: fadeInUp 0.6s ease-out 0.5s both;
}

.diff-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.diff-options {
  display: flex;
  gap: 0.4rem;
}

.diff-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.6rem 0.4rem;
  background: var(--bg-card);
  border: 2px solid var(--bg-surface);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
  min-height: 50px;
}

.diff-btn:hover {
  border-color: var(--accent-secondary);
  transform: translateY(-2px);
}

.diff-btn.active {
  background: var(--bg-surface);
  border-color: var(--accent-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-glow);
}

.diff-emoji {
  font-size: 1.25rem;
}

.diff-name {
  font-size: 0.7rem;
  font-weight: 700;
}

.diff-desc {
  font-size: 0.6rem;
  opacity: 0.7;
}

/* Menu Footer */

.menu-footer {
  margin-top: 0.75rem;
  animation: fadeInUp 0.6s ease-out 0.7s both;
}

.online-count {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-success);
  box-shadow: 0 0 6px var(--accent-success);
  animation: onlinePulse 2s infinite;
}

@keyframes onlinePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════════════════ */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.modal.active {
  display: flex;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--bg-surface);
  animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  text-align: center;
  margin-bottom: 1rem;
}

.modal-icon {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.form-group {
  margin-bottom: 0.75rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.form-group input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--bg-surface);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-body);
  transition: border-color var(--transition-fast);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.form-group input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.toggle-group {
  display: flex;
  gap: 0.3rem;
  background: var(--bg-primary);
  padding: 0.2rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--bg-surface);
}

.toggle-btn {
  flex: 1;
  padding: 0.5rem 0.6rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 32px;
}

.toggle-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}

.toggle-btn.active {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.4);
}

.toggle-btn span {
  font-size: 0.9rem;
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   WAITING ROOM
   ═══════════════════════════════════════════════════════════════════════════ */

#waiting-room {
  justify-content: center;
}

.waiting-container {
  max-width: 450px;
  width: 100%;
  margin: 0 auto;
  padding: 0.5rem;
}

.waiting-header {
  text-align: center;
  margin-bottom: 1.5rem;
  animation: fadeInUp 0.5s ease-out;
}

.waiting-header h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}

.room-code-display {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-lg);
  border: 2px solid var(--bg-surface);
}

.code-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.code-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 6px;
  color: var(--accent-warning);
  text-shadow: 0 0 15px rgba(255, 192, 72, 0.5);
}

.btn-copy {
  padding: 0.3rem 0.8rem;
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-copy:hover {
  background: var(--accent-primary);
  color: white;
}

/* Arena Preview */

.arena-preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  animation: fadeInUp 0.5s ease-out 0.2s both;
}

.player-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 2px solid var(--bg-surface);
  transition: all var(--transition-normal);
  min-height: 100px;
}

.player-card.connected {
  border-color: var(--accent-success);
}

.player-card.ready {
  border-color: var(--accent-warning);
  box-shadow: 0 0 15px rgba(255, 192, 72, 0.3);
}

.player-char {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.char-body {
  font-size: 2rem;
  animation: charIdle 1s infinite alternate;
}

@keyframes charIdle {
  from { transform: translateY(0); }
  to { transform: translateY(-3px); }
}

.char-platform {
  width: 35px;
  height: 6px;
  background: var(--bg-surface);
  border-radius: 50%;
  margin-top: -3px;
}

.player-details {
  text-align: center;
  width: 100%;
}

.player-name {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.4rem;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.player-badge.ready {
  background: rgba(255, 192, 72, 0.2);
  color: var(--accent-warning);
}

.vs-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.vs-line {
  width: 2px;
  height: 20px;
  background: linear-gradient(to bottom, transparent, var(--text-secondary), transparent);
}

.vs-text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-warning);
}

/* Waiting Actions */

.waiting-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 1rem;
  animation: fadeInUp 0.5s ease-out 0.4s both;
}

.share-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  animation: fadeInUp 0.5s ease-out 0.6s both;
  padding: 0.5rem;
}

.hint-icon {
  font-size: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   GAME SCREEN
   ═══════════════════════════════════════════════════════════════════════════ */

#game-screen {
  padding: 0;
  gap: 0.5rem;
}

/* Game HUD */

.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  min-height: 36px;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
}

.hud-room {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-secondary);
  font-size: 0.7rem;
}

.hud-icon {
  font-size: 0.8rem;
}

.hud-timer {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 1rem;
  font-family: var(--font-display);
  color: var(--accent-warning);
}

.timer-icon {
  font-size: 0.8rem;
}

.hud-ping {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-secondary);
  font-size: 0.7rem;
}

.ping-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-success);
}

/* Game Arena */

.game-arena-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}

.game-arena {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.game-arena::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--p1-color), var(--rope-color), var(--p2-color));
}

.arena-player {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: auto;
  width: 100%;
}

.arena-p1 {
  order: 1;
}

.rope-section {
  order: 2;
  width: 100%;
}

.arena-p2 {
  order: 3;
}

.arena-char {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.char-sprite {
  font-size: 1.75rem;
  animation: charPull 0.3s infinite alternate;
}

@keyframes charPull {
  from { transform: scale(1); }
  to { transform: scale(1.03); }
}

.char-shadow {
  width: 30px;
  height: 5px;
  background: rgba(0,0,0,0.3);
  border-radius: 50%;
  margin-top: -3px;
}

.arena-info {
  text-align: center;
}

.arena-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.1rem;
}

.arena-score {
  display: flex;
  align-items: baseline;
  gap: 0.15rem;
  justify-content: center;
}

.score-num {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.score-label {
  font-size: 0.6rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.arena-streak {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-warning);
  opacity: 0.7;
  transition: all var(--transition-fast);
}

.arena-streak.hot {
  opacity: 1;
  transform: scale(1.1);
}

.streak-flame {
  font-size: 0.8rem;
}

/* Rope Section */

.rope-section {
  display: flex;
  align-items: center;
  min-width: 0;
}

.rope-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.zone-marker {
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.zone-triangle {
  width: 0;
  height: 0;
  border-style: solid;
}

.zone-left .zone-triangle {
  border-width: 6px 10px 6px 0;
  border-color: transparent var(--p1-color) transparent transparent;
}

.zone-right .zone-triangle {
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent var(--p2-color);
}

.rope-track-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0.4rem;
}

.rope-track {
  width: 100%;
  height: 40px;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(0,0,0,0.2));
  border-radius: var(--radius-md);
  position: relative;
  display: flex;
  align-items: center;
  border: 2px solid var(--bg-surface);
  overflow: hidden;
}

.rope-line {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--rope-color);
  transform: translateY(-50%);
  box-shadow: 0 2px 6px rgba(255, 192, 72, 0.5);
}

.rope-flag {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: left 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 2;
}

.flag-banner {
  font-size: 1.5rem;
  animation: flagWave 0.5s infinite alternate;
}

@keyframes flagWave {
  from { transform: rotate(-5deg); }
  to { transform: rotate(5deg); }
}

.rope-indicator {
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 6px;
  background: rgba(255,255,255,0.5);
  border-radius: 1px;
}

/* Question Section */

.question-section {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 1rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.question-bubble {
  text-align: center;
  padding: 0.25rem;
}

.question-category {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  background: var(--accent-primary);
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 0.3rem;
}

.question-prompt {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  min-height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 1.5px;
}

.timer-section {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.timer-track {
  width: 100%;
  height: 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent-success), var(--accent-warning), var(--accent-danger));
  border-radius: var(--radius-full);
  transform-origin: left;
  transition: transform 0.1s linear;
}

.timer-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.force-display {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--accent-success);
}

.time-display {
  color: var(--text-secondary);
}

/* Answer Grid */

.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.answer-btn {
  position: relative;
  padding: 0.75rem;
  background: var(--bg-surface);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  overflow: hidden;
  min-height: 50px;
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--accent-secondary);
  transform: scale(1.02);
}

.answer-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.answer-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.answer-btn.correct {
  border-color: var(--accent-success);
  background: rgba(0, 210, 160, 0.2);
  animation: answerCorrect 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes answerCorrect {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.answer-btn.incorrect {
  border-color: var(--accent-danger);
  background: rgba(255, 107, 107, 0.2);
  animation: answerWrong 0.5s;
}

@keyframes answerWrong {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* Numpad */

.numpad-container {
  max-width: 240px;
  margin: 0 auto;
}

.numpad-display {
  background: var(--bg-primary);
  border: 2px solid var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  text-align: right;
  margin-bottom: 0.4rem;
  color: var(--text-primary);
  min-height: 2.5rem;
}

.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

.numpad-btn {
  padding: 0.6rem;
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 40px;
}

.numpad-btn:hover {
  background: var(--accent-primary);
}

.numpad-btn:active {
  transform: scale(0.92);
}

.numpad-clear {
  background: var(--accent-danger) !important;
}

.numpad-enter {
  background: var(--accent-success) !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FEEDBACK & EFFECTS
   ═══════════════════════════════════════════════════════════════════════════ */

.feedback-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
}

.feedback-overlay.show {
  opacity: 1;
  animation: feedbackPopIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes feedbackPopIn {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.feedback-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--accent-success);
}

.feedback-icon {
  font-size: 2rem;
}

.feedback-text {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.feedback-points {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-warning);
}

/* Stun Overlay */

.stun-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 107, 107, 0.4);
  backdrop-filter: blur(2px);
  z-index: 60;
}

.stun-overlay.active {
  display: flex;
}

.stun-content {
  text-align: center;
  animation: stunShake 0.3s;
}

@keyframes stunShake {
  0%, 100% { transform: translate(0); }
  25% { transform: translate(-3px, 3px); }
  50% { transform: translate(3px, -3px); }
  75% { transform: translate(-2px, -2px); }
}

.stun-icon {
  font-size: 3rem;
}

.stun-text {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 4px 8px rgba(0,0,0,0.5);
}

.stun-timer {
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  margin-top: 0.3rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MATCH OVER
   ═══════════════════════════════════════════════════════════════════════════ */

#match-over {
  justify-content: center;
}

.result-container {
  max-width: 400px;
  width: 100%;
  margin: 0 auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.result-celebration {
  text-align: center;
  position: relative;
  padding: 1rem;
}

.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

#game-confetti {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

.result-trophy {
  position: relative;
  margin-bottom: 0.5rem;
}

.trophy-icon {
  font-size: 3rem;
  animation: trophySpin 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes trophySpin {
  from { transform: scale(0) rotate(-180deg); }
  to { transform: scale(1) rotate(0deg); }
}

.result-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-warning);
  text-shadow: 0 0 15px rgba(255, 192, 72, 0.5);
  margin-bottom: 0.25rem;
}

.result-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.result-summary {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.summary-card {
  flex: 1;
  max-width: 120px;
  text-align: center;
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 2px solid var(--bg-surface);
}

.summary-icon {
  font-size: 1.25rem;
  margin-bottom: 0.15rem;
}

.summary-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.summary-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.result-stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stats-player {
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 2px solid var(--bg-surface);
}

.stats-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--bg-surface);
}

.stats-avatar {
  font-size: 1.25rem;
}

.stats-name {
  font-weight: 700;
  font-size: 0.85rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.3rem;
}

.stat {
  text-align: center;
}

.stat-val {
  display: block;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-key {
  font-size: 0.55rem;
  color: var(--text-secondary);
  font-weight: 700;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CONNECTION STATUS
   ═══════════════════════════════════════════════════════════════════════════ */

.connection-status {
  position: fixed;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  z-index: 200;
  backdrop-filter: blur(8px);
}

.connection-status.connecting {
  background: rgba(255, 192, 72, 0.2);
  color: var(--accent-warning);
}

.connection-status.connected {
  background: rgba(0, 210, 160, 0.2);
  color: var(--accent-success);
}

.connection-status.disconnected {
  background: rgba(255, 107, 107, 0.2);
  color: var(--accent-danger);
}

.status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.connection-status.connecting .status-dot { background: var(--accent-warning); }
.connection-status.connected .status-dot { background: var(--accent-success); }
.connection-status.disconnected .status-dot { background: var(--accent-danger); }

/* Sound Toggle */

.sound-toggle {
  position: fixed;
  bottom: 0.75rem;
  right: 0.75rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--bg-surface);
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-md);
}

.sound-toggle:hover {
  border-color: var(--accent-primary);
  transform: scale(1.1);
}

.sound-toggle:active {
  transform: scale(0.9);
}

.sound-toggle.muted {
  opacity: 0.5;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE DESIGN
   ═══════════════════════════════════════════════════════════════════════════ */

/* Small mobile */
@media (max-width: 380px) {
  html { font-size: 14px; }
  
  #app { padding: 0.5rem; }
  
  .menu-container { padding: 0.75rem; }
  
  .game-logo h1 { font-size: 1.5rem; }
  
  .logo-icon { font-size: 2.5rem; }
  
  .btn { padding: 0.6rem 1rem; font-size: 0.85rem; }
  
  .btn-large { padding: 0.8rem 1.2rem; }
  
  .diff-btn { padding: 0.5rem 0.3rem; }
  
  .question-prompt { font-size: 1.5rem; }
  
  .answer-btn { padding: 0.6rem; font-size: 1.1rem; min-height: 45px; }
  
  .code-value { font-size: 1.75rem; }
  
  .char-sprite { font-size: 1.5rem; }
  
  .score-num { font-size: 1.1rem; }
}

/* Very small mobile */
@media (max-width: 320px) {
  html { font-size: 13px; }
  
  .diff-options { flex-direction: column; }
  
  .diff-btn { flex-direction: row; gap: 0.3rem; padding: 0.4rem; }
  
  .btn-row { flex-direction: column; }
  
  .btn-text { display: none; }
  
  .btn-large .btn-text { display: flex; }
}

/* Tablet and desktop */
@media (min-width: 768px) {
  #app { max-width: 500px; }
}

/* Landscape mode */
@media (max-height: 500px) and (orientation: landscape) {
  #app { padding: 0.25rem; }
  
  .screen { min-height: auto; }
  
  .menu-container { padding: 0.5rem; }
  
  .game-logo { margin-bottom: 0.5rem; }
  
  .logo-icon { font-size: 2rem; }
  
  .game-logo h1 { font-size: 1.25rem; }
  
  .logo-badge { display: none; }
  
  .menu-buttons { flex-direction: row; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
  
  .menu-buttons .btn { flex: 1; min-width: 100px; }
  
  .difficulty-select { margin-bottom: 0.4rem; }
  
  .game-arena { padding: 0.5rem; }
  
  .question-prompt { font-size: 1.25rem; }
  
  .question-section { padding: 0.6rem; gap: 0.4rem; }
  
  .answer-btn { padding: 0.4rem; font-size: 1rem; min-height: 35px; }
}

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