/* ============================================
   QUIZ GAME - Kahoot-Style UI/UX
   Optimized with UI/UX Pro Max Design System
   ============================================ */

/* Google Fonts - Gaming Typography */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

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

/* Design System Variables */
:root {
  /* Kahoot Brand Colors */
  --primary-purple: #46178f;
  --primary-blue: #1368ce;

  /* Option Colors - Vibrant & Accessible */
  --option-red: #e21b3c;
  --option-blue: #1368ce;
  --option-yellow: #ffa602;
  --option-green: #26890c;

  /* Feedback Colors */
  --correct-green: #66bf39;
  --wrong-red: #e21b3c;

  /* Neutral Colors */
  --white: #ffffff;
  --light-gray: #f2f2f2;
  --dark-gray: #333333;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 30px rgba(70, 23, 143, 0.4);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 30px;
}

html,
body {
  height: 100%;
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: #306263;
  color: var(--white);
  overflow-x: hidden;
  min-height: 100vh;
}

/* Animated Background Pattern */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ==================== SCREEN MANAGEMENT ==================== */
.screen {
  display: none;
  min-height: 100vh;
  padding: 20px;
  position: relative;
  z-index: 1;
}

.screen.active {
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}

/* Host question screen - fit in viewport */
.host-page #question-screen.active {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.host-page #question-screen .question-header {
  flex-shrink: 0;
  padding: 8px 15px;
  margin-bottom: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}

.host-page #question-screen .question-content {
  flex-shrink: 0;
  padding: 12px 20px;
  margin-bottom: 8px;
  min-height: auto;
  border-radius: 10px;
}

.host-page #question-screen .question-text {
  font-size: 28px;
  font-weight: 800;
}

.host-page #question-screen .question-image-container {
  margin-top: 10px;
}

.host-page #question-screen .question-image-container img {
  max-height: 80px;
}

.host-page #question-screen .options-grid {
  flex: 1;
  min-height: 0;
  gap: 10px;
}

.host-page #question-screen .option {
  padding: 8px;
}

.host-page #question-screen .option-label {
  font-size: 32px;
  margin-bottom: 4px;
}

.host-page #question-screen .option-image {
  max-height: none;
  flex: 1;
  min-height: 0;
  object-fit: contain;
}

.host-page #question-screen .option-text {
  font-size: 18px;
  font-weight: 700;
}

.host-page #question-screen .option-count {
  font-size: 20px;
  padding: 4px 12px;
  bottom: 8px;
  right: 10px;
}

.host-page #question-screen .host-controls {
  flex-shrink: 0;
  padding: 10px;
  gap: 10px;
}

.host-page #question-screen .host-controls .btn {
  padding: 10px 20px;
  font-size: 14px;
}

.host-page #question-screen .timer-container {
  width: 60px;
  height: 60px;
}

.host-page #question-screen .timer-text {
  font-size: 24px;
}

.host-page #question-screen .answer-count,
.host-page #question-screen .question-progress {
  font-size: 14px;
  padding: 6px 12px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==================== BUTTONS ==================== */
.btn {
  padding: 16px 32px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.btn:hover::before {
  left: 100%;
}

.btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.btn:active {
  transform: translateY(-1px);
}

.btn-start,
.btn-join {
  background: linear-gradient(135deg, var(--correct-green) 0%, #4caf50 100%);
  color: var(--white);
  width: 100%;
  max-width: 320px;
  font-size: 20px;
  padding: 20px 40px;
  box-shadow: 0 4px 0 #2d7a1a, var(--shadow-md);
}

.btn-start:hover,
.btn-join:hover {
  box-shadow: 0 6px 0 #2d7a1a, var(--shadow-lg);
}

.btn-start:active,
.btn-join:active {
  box-shadow: 0 2px 0 #2d7a1a;
  transform: translateY(2px);
}

.btn-start:disabled {
  background: linear-gradient(135deg, #666 0%, #555 100%);
  box-shadow: 0 4px 0 #444;
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-start:disabled:hover {
  transform: none;
}

.btn-reveal {
  background: linear-gradient(135deg, var(--option-yellow) 0%, #ff8c00 100%);
  color: var(--dark-gray);
  box-shadow: 0 4px 0 #cc7a00, var(--shadow-md);
}

.btn-leaderboard {
  background: linear-gradient(135deg, var(--primary-blue) 0%, #0d5ab8 100%);
  color: var(--white);
  box-shadow: 0 4px 0 #0a4a9a, var(--shadow-md);
}

.btn-next {
  background: linear-gradient(135deg, var(--correct-green) 0%, #4caf50 100%);
  color: var(--white);
  box-shadow: 0 4px 0 #2d7a1a, var(--shadow-md);
}

.btn-end {
  background: linear-gradient(135deg, var(--wrong-red) 0%, #c41530 100%);
  color: var(--white);
  box-shadow: 0 4px 0 #a01228, var(--shadow-md);
}

.btn-restart {
  background: transparent;
  color: var(--white);
  border: 3px solid var(--white);
  box-shadow: none;
}

.btn-restart:hover {
  background: var(--white);
  color: var(--primary-purple);
}

/* ==================== HOST PAGE ==================== */
.host-page {
  background: #306263;
}

.host-page::before {
  background-image:
    radial-gradient(circle at 10% 20%, rgba(70, 23, 143, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(19, 104, 206, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(255, 166, 2, 0.05) 0%, transparent 60%);
}

/* ==================== HOST PAGE - LOBBY ==================== */
.lobby-container {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
  padding: 30px 20px;
  animation: slideUp 0.5s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.game-title {
  font-size: 56px;
  font-weight: 900;
  margin-bottom: 10px;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.3), 0 8px 20px rgba(0, 0, 0, 0.2);
  letter-spacing: -1px;
  background: linear-gradient(180deg, #fff 0%, #e0e0e0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-subtitle {
  font-size: 20px;
  opacity: 0.9;
  margin-bottom: 40px;
  font-weight: 600;
}

.qr-section {
  background: linear-gradient(145deg, #ffffff 0%, #f8f9ff 100%);
  border-radius: var(--radius-xl);
  padding: 35px 40px;
  margin-bottom: 30px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 40px;
}

.qr-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--option-red), var(--option-yellow), var(--option-green), var(--option-blue));
}

#qr-code {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

#qr-code img,
#qr-code canvas {
  width: 180px;
  height: 180px;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  border: 3px solid var(--primary-purple);
}

.join-info {
  color: var(--dark-gray);
  position: relative;
  z-index: 1;
  text-align: left;
  flex: 1;
}

.join-info p:first-child {
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.join-url {
  font-size: 28px;
  font-weight: 900;
  color: var(--primary-purple);
  word-break: break-all;
  padding: 16px 24px;
  background: linear-gradient(135deg, rgba(70, 23, 143, 0.1) 0%, rgba(19, 104, 206, 0.1) 100%);
  border-radius: var(--radius-md);
  display: block;
  border: 2px dashed rgba(70, 23, 143, 0.3);
  transition: all var(--transition-normal);
}

.join-url:hover {
  background: linear-gradient(135deg, rgba(70, 23, 143, 0.15) 0%, rgba(19, 104, 206, 0.15) 100%);
  border-color: var(--primary-purple);
}

.player-count {
  font-size: 24px;
  margin: 30px 0 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.player-count span {
  font-size: 72px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--option-yellow) 0%, #ffcc00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 4px 8px rgba(255, 166, 2, 0.4));
  line-height: 1;
}

.player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 30px;
  max-height: 200px;
  overflow-y: auto;
  padding: 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.player-list::-webkit-scrollbar {
  width: 6px;
}

.player-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.player-list:empty::before {
  content: '等待玩家加入...';
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
  padding: 20px;
}

.player-item {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
  backdrop-filter: blur(10px);
  padding: 10px 20px;
  border-radius: 50px;
  font-size: 15px;
  font-weight: 700;
  animation: popIn 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all var(--transition-fast);
}

.player-item:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.15) 100%);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

@keyframes popIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  70% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ==================== HOST PAGE - QUESTION ==================== */
.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.question-progress {
  font-size: 22px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.1);
  padding: 8px 20px;
  border-radius: var(--radius-md);
}

.timer-container {
  display: flex;
  justify-content: center;
}

.timer-circle {
  width: 90px;
  height: 90px;
  background: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 900;
  color: var(--primary-purple);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.3), var(--shadow-lg);
  position: relative;
}

.timer-circle::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 4px solid transparent;
  border-top-color: var(--primary-purple);
  animation: timerSpin 1s linear infinite;
}

@keyframes timerSpin {
  to {
    transform: rotate(360deg);
  }
}

.timer-circle.warning {
  background: var(--wrong-red);
  color: var(--white);
  animation: timerPulse 0.5s ease infinite;
  box-shadow: 0 0 0 4px rgba(226, 27, 60, 0.4), 0 0 30px rgba(226, 27, 60, 0.5);
}

.timer-circle.warning::before {
  border-top-color: var(--white);
}

@keyframes timerPulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
  }
}

.answer-count {
  font-size: 18px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  padding: 12px 24px;
  border-radius: var(--radius-md);
}

.question-content {
  text-align: center;
  padding: 15px 25px;
  background: var(--white);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  color: var(--dark-gray);
  min-height: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.question-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--option-red), var(--option-blue), var(--option-yellow), var(--option-green));
}

.question-text {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.4;
}

.question-image-container {
  margin-top: 20px;
  display: none;
}

.question-image-container img {
  max-width: 100%;
  max-height: 180px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

/* ==================== OPTIONS GRID ==================== */
.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  flex: 1;
}

.option {
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  transition: all var(--transition-normal);
  min-height: 0;
  cursor: default;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2), var(--shadow-sm);
  overflow: hidden;
}

.option-a {
  background: linear-gradient(135deg, var(--option-red) 0%, #c41530 100%);
}

.option-b {
  background: linear-gradient(135deg, var(--option-blue) 0%, #0d5ab8 100%);
}

.option-c {
  background: linear-gradient(135deg, var(--option-yellow) 0%, #e69500 100%);
}

.option-d {
  background: linear-gradient(135deg, var(--option-green) 0%, #1e7209 100%);
}

.option-label {
  font-size: 36px;
  font-weight: 900;
  margin-bottom: 6px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.option-image-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

.option-image {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-sm);
  object-fit: contain;
  box-shadow: var(--shadow-sm);
}

.option-text {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  padding: 5px;
  word-break: break-word;
  line-height: 1.3;
}

.option-count {
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-size: 26px;
  font-weight: 800;
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 18px;
  border-radius: var(--radius-xl);
}

.option.reveal.wrong {
  opacity: 0.4;
  transform: scale(0.95);
  filter: grayscale(50%);
  box-shadow: none;
}

.option.reveal.correct {
  box-shadow: 0 0 0 6px var(--white), 0 0 40px rgba(102, 191, 57, 0.8);
  transform: scale(1.03);
  animation: correctPulse 0.5s ease;
}

@keyframes correctPulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1.03);
  }
}

/* ==================== HOST CONTROLS ==================== */
.host-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 20px;
  flex-wrap: wrap;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-lg);
  margin-top: auto;
}

.host-controls .btn {
  min-width: 140px;
  font-size: 16px;
  padding: 14px 28px;
}

/* ==================== LEADERBOARD ==================== */
.leaderboard-title {
  text-align: center;
  font-size: 56px;
  font-weight: 900;
  margin-bottom: 35px;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  background: linear-gradient(180deg, #fff 0%, #e0e0e0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.leaderboard-list {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 20px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.05) 100%);
  backdrop-filter: blur(10px);
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  font-size: 18px;
  font-weight: 600;
  animation: slideInRight 0.4s ease;
  animation-fill-mode: both;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all var(--transition-fast);
}

.leaderboard-item:hover {
  transform: translateX(5px);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0.08) 100%);
}

.leaderboard-item:nth-child(1) {
  animation-delay: 0.1s;
}

.leaderboard-item:nth-child(2) {
  animation-delay: 0.15s;
}

.leaderboard-item:nth-child(3) {
  animation-delay: 0.2s;
}

.leaderboard-item:nth-child(4) {
  animation-delay: 0.25s;
}

.leaderboard-item:nth-child(5) {
  animation-delay: 0.3s;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(50px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.leaderboard-item.top-1 {
  background: linear-gradient(135deg, #ffd700 0%, #f0c000 50%, #ffb347 100%);
  color: #1a1a2e;
  font-size: 24px;
  padding: 20px 28px;
  box-shadow: 0 8px 30px rgba(255, 215, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  border: none;
}

.leaderboard-item.top-1:hover {
  transform: translateX(5px) scale(1.02);
}

.leaderboard-item.top-2 {
  background: linear-gradient(135deg, #e8e8e8 0%, #c0c0c0 50%, #a8a8a8 100%);
  color: #1a1a2e;
  font-size: 22px;
  padding: 18px 26px;
  border: none;
  box-shadow: 0 6px 20px rgba(192, 192, 192, 0.3);
}

.leaderboard-item.top-3 {
  background: linear-gradient(135deg, #cd7f32 0%, #b87333 50%, #a0522d 100%);
  font-size: 20px;
  padding: 16px 24px;
  border: none;
  box-shadow: 0 4px 15px rgba(205, 127, 50, 0.3);
}

.leaderboard-item .rank {
  width: 50px;
  font-weight: 900;
  font-size: 1.3em;
}

.leaderboard-item .nickname {
  flex: 1;
  font-weight: 700;
}

.leaderboard-item .score {
  font-weight: 900;
}

/* ==================== FINAL SCREEN ==================== */
.final-title {
  text-align: center;
  font-size: 60px;
  font-weight: 900;
  margin-bottom: 30px;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  animation: bounceIn 0.6s ease;
}

@keyframes bounceIn {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

  70% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.winner-section {
  text-align: center;
  margin-bottom: 40px;
}

.crown {
  font-size: 100px;
  animation: crownBounce 1s ease infinite;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

@keyframes crownBounce {

  0%,
  100% {
    transform: translateY(0) rotate(-5deg);
  }

  50% {
    transform: translateY(-25px) rotate(5deg);
  }
}

.winner-name {
  font-size: 52px;
  font-weight: 900;
  margin: 20px 0;
  color: #ffd700;
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.5), 0 4px 0 rgba(0, 0, 0, 0.2);
}

.winner-score {
  font-size: 32px;
  font-weight: 700;
}

.final-leaderboard {
  max-width: 600px;
  margin: 0 auto 35px;
}

/* ==================== PLAYER PAGE ==================== */
.player-page {
  background: #306263;
}

.player-page::before {
  display: none;
}

/* Join Screen */
.join-container {
  max-width: 400px;
  margin: auto;
  text-align: center;
  padding: 40px 25px;
}

.join-container .game-title {
  font-size: 36px;
  margin-bottom: 50px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
}

#join-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#nickname-input {
  padding: 20px 24px;
  font-size: 20px;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 50px;
  text-align: center;
  outline: none;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.2),
    inset 0 2px 0 rgba(255, 255, 255, 0.8),
    inset 0 -2px 4px rgba(0, 0, 0, 0.05);
  transition: all var(--transition-normal);
  background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
}

#nickname-input:focus {
  box-shadow:
    0 0 0 4px var(--option-yellow),
    0 15px 40px rgba(0, 0, 0, 0.25);
  transform: scale(1.03);
}

#nickname-input::placeholder {
  color: #aaa;
  font-weight: 600;
}

.error-message {
  color: var(--white);
  background: var(--wrong-red);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  display: none;
  font-weight: 600;
  animation: shake 0.4s ease;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-10px);
  }

  75% {
    transform: translateX(10px);
  }
}

/* Waiting Screen */
.waiting-container {
  text-align: center;
  margin: auto;
  padding: 50px;
}

.waiting-container h2 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 40px;
}

.waiting-container h2 span {
  color: var(--option-yellow);
}

.waiting-animation {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 50px 0;
}

.waiting-animation .dot {
  width: 22px;
  height: 22px;
  background: var(--white);
  border-radius: 50%;
  animation: dotBounce 1.4s ease infinite;
}

.waiting-animation .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.waiting-animation .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dotBounce {

  0%,
  80%,
  100% {
    transform: translateY(0);
  }

  40% {
    transform: translateY(-30px);
  }
}

.waiting-container p {
  font-size: 20px;
  opacity: 0.9;
}

/* Player Question Screen */
.player-question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.15) 100%);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.question-info {
  font-size: 16px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 50px;
}

.player-timer {
  font-size: 32px;
  font-weight: 900;
  background: linear-gradient(180deg, #ffffff 0%, #f0f0f0 100%);
  color: #264653;
  width: 65px;
  height: 65px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.2),
    inset 0 2px 0 rgba(255, 255, 255, 0.8);
  border: 3px solid rgba(255, 255, 255, 0.3);
}

.player-timer.warning {
  background: linear-gradient(180deg, var(--wrong-red) 0%, #c41530 100%);
  color: var(--white);
  animation: timerPulse 0.5s ease infinite;
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 25px rgba(226, 27, 60, 0.5);
}

/* Player Question Content - 玩家端題目顯示 */
.player-question-content {
  background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 10px;
  text-align: center;
  flex-shrink: 0;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.5);
  position: relative;
  overflow: hidden;
}

.player-question-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--option-red), var(--option-blue), var(--option-yellow), var(--option-green));
}

.player-question-text {
  font-size: 36px;
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1.3;
  margin: 0;
}

.player-question-image {
  max-width: 100%;
  max-height: 70px;
  margin-top: 8px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Answer Buttons */
.answer-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  flex: 1;
  padding: 10px;
}

.answer-btn {
  border: none;
  border-radius: var(--radius-lg);
  font-size: 56px;
  font-weight: 900;
  font-family: inherit;
  color: var(--white);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.answer-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.btn-a {
  background: linear-gradient(180deg, var(--option-red) 0%, #c41530 100%);
  box-shadow: 0 6px 0 #a01228, var(--shadow-md);
}

.btn-b {
  background: linear-gradient(180deg, var(--option-blue) 0%, #0d5ab8 100%);
  box-shadow: 0 6px 0 #0a4a9a, var(--shadow-md);
}

.btn-c {
  background: linear-gradient(180deg, var(--option-yellow) 0%, #e69500 100%);
  box-shadow: 0 6px 0 #cc7a00, var(--shadow-md);
}

.btn-d {
  background: linear-gradient(180deg, var(--option-green) 0%, #1e7209 100%);
  box-shadow: 0 6px 0 #165606, var(--shadow-md);
}

.answer-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

.answer-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Player Answer Button Content - Label in top-right corner */
.answer-btn {
  flex-direction: column;
  padding: 6px;
  gap: 0;
  position: relative;
  align-items: center;
  justify-content: center;
}

.answer-label {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  background: rgba(0, 0, 0, 0.25);
  padding: 3px 6px;
  border-radius: 4px;
  z-index: 2;
}

.answer-content {
  font-size: 36px;
  font-weight: 700;
  text-align: center;
  word-break: break-word;
  line-height: 1.2;
  max-height: none;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  padding: 2px 4px;
}

.answer-image {
  max-width: 90%;
  max-height: 90%;
  flex: 1;
  min-height: 0;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Answered Screen */
.answered-container {
  text-align: center;
  margin: auto;
  animation: fadeIn 0.3s ease;
  padding: 30px;
}

.selected-answer {
  width: 130px;
  height: 130px;
  border-radius: 25px;
  font-size: 64px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 30px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
  animation: selectedPop 0.4s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

@keyframes selectedPop {
  0% {
    transform: scale(0.5) rotate(-10deg);
  }

  70% {
    transform: scale(1.1) rotate(5deg);
  }

  100% {
    transform: scale(1) rotate(0);
  }
}

.selected-answer.answer-a {
  background: linear-gradient(135deg, var(--option-red) 0%, #c41530 100%);
  box-shadow: 0 10px 30px rgba(226, 27, 60, 0.4);
}

.selected-answer.answer-b {
  background: linear-gradient(135deg, var(--option-blue) 0%, #0d5ab8 100%);
  box-shadow: 0 10px 30px rgba(19, 104, 206, 0.4);
}

.selected-answer.answer-c {
  background: linear-gradient(135deg, var(--option-yellow) 0%, #e69500 100%);
  box-shadow: 0 10px 30px rgba(255, 166, 2, 0.4);
}

.selected-answer.answer-d {
  background: linear-gradient(135deg, var(--option-green) 0%, #1e7209 100%);
  box-shadow: 0 10px 30px rgba(38, 137, 12, 0.4);
}

.answered-container p {
  font-size: 22px;
  font-weight: 700;
}

.answer-time {
  font-size: 16px;
  margin-top: 20px;
  opacity: 0.8;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
  padding: 10px 20px;
  border-radius: 50px;
  display: inline-block;
}

/* Result Screen */
.result-container {
  text-align: center;
  margin: auto;
  animation: fadeIn 0.3s ease;
  padding: 30px;
}

.result-icon {
  font-size: 100px;
  margin-bottom: 15px;
  animation: resultBounce 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  margin: 0 auto 20px;
}

@keyframes resultBounce {
  0% {
    transform: scale(0);
  }

  60% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

.result-icon.correct {
  color: var(--white);
  background: linear-gradient(135deg, var(--correct-green) 0%, #4caf50 100%);
  box-shadow: 0 10px 40px rgba(102, 191, 57, 0.5);
}

.result-icon.wrong {
  color: var(--white);
  background: linear-gradient(135deg, var(--wrong-red) 0%, #c41530 100%);
  box-shadow: 0 10px 40px rgba(226, 27, 60, 0.5);
}

.result-text {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 25px;
}

.result-text.correct {
  color: var(--correct-green);
}

.result-text.wrong {
  color: var(--wrong-red);
}

.points-earned {
  font-size: 56px;
  font-weight: 900;
  margin-bottom: 20px;
  animation: pointsCount 0.5s ease;
}

@keyframes pointsCount {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.points-earned.correct {
  color: var(--correct-green);
  text-shadow: 0 0 30px rgba(102, 191, 57, 0.4);
}

.points-earned.wrong {
  color: var(--wrong-red);
  opacity: 0.6;
}

.total-score {
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
  backdrop-filter: blur(10px);
  padding: 16px 30px;
  border-radius: 50px;
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Player Leaderboard Screen */
.player-leaderboard-container {
  text-align: center;
  margin: auto;
}

.player-leaderboard-container h2 {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 30px;
}

.player-rank {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 35px 55px;
  border-radius: var(--radius-xl);
  margin: 30px 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.player-rank .rank-number {
  font-size: 56px;
  font-weight: 900;
  display: block;
  margin-bottom: 12px;
  color: var(--option-yellow);
}

.player-rank .rank-score {
  font-size: 26px;
  font-weight: 700;
}

/* Player Final Screen */
.player-final-container {
  text-align: center;
  margin: auto;
}

.player-final-container h2 {
  font-size: 40px;
  font-weight: 900;
  margin-bottom: 30px;
}

.final-rank {
  margin: 35px 0;
}

.final-rank-number {
  font-size: 90px;
  font-weight: 900;
}

.final-rank.winner .final-rank-number {
  color: #ffd700;
  text-shadow: 0 0 40px rgba(255, 215, 0, 0.6), 0 4px 0 rgba(0, 0, 0, 0.2);
  animation: winnerGlow 1.5s ease infinite;
}

@keyframes winnerGlow {

  0%,
  100% {
    text-shadow: 0 0 40px rgba(255, 215, 0, 0.6), 0 4px 0 rgba(0, 0, 0, 0.2);
  }

  50% {
    text-shadow: 0 0 60px rgba(255, 215, 0, 0.9), 0 4px 0 rgba(0, 0, 0, 0.2);
  }
}

.final-score {
  font-size: 40px;
  font-weight: 800;
  margin-bottom: 30px;
}

.player-final-container p {
  font-size: 22px;
  opacity: 0.9;
}

/* Timeout Screen */
.timeout-container {
  text-align: center;
  margin: auto;
}

.timeout-icon {
  font-size: 100px;
  margin-bottom: 25px;
  animation: timeoutShake 0.5s ease;
}

@keyframes timeoutShake {

  0%,
  100% {
    transform: rotate(0);
  }

  25% {
    transform: rotate(-15deg);
  }

  75% {
    transform: rotate(15deg);
  }
}

.timeout-container h2 {
  font-size: 36px;
  font-weight: 800;
  color: var(--wrong-red);
  margin-bottom: 15px;
}

.timeout-container p {
  font-size: 20px;
  opacity: 0.8;
}

/* ==================== ADMIN PAGE ==================== */
.admin-page {
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
  color: var(--dark-gray);
  min-height: 100vh;
}

.admin-page::before {
  display: none;
}

.admin-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 25px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 35px;
  flex-wrap: wrap;
  gap: 15px;
  padding-bottom: 20px;
  border-bottom: 2px solid #dee2e6;
}

.admin-header h1 {
  color: var(--primary-purple);
  font-size: 32px;
  font-weight: 900;
}

.admin-actions {
  display: flex;
  gap: 12px;
}

.btn-save {
  background: linear-gradient(135deg, var(--correct-green) 0%, #4caf50 100%);
  color: var(--white);
  box-shadow: 0 3px 0 #2d7a1a;
}

.btn-host {
  background: linear-gradient(135deg, var(--primary-purple) 0%, #5a2d9e 100%);
  color: var(--white);
  box-shadow: 0 3px 0 #3a1070;
}

.btn-add {
  background: linear-gradient(135deg, var(--primary-blue) 0%, #0d5ab8 100%);
  color: var(--white);
  width: 100%;
  padding: 22px;
  font-size: 20px;
  box-shadow: 0 4px 0 #0a4a9a;
}

/* Question Card */
.question-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid #e9ecef;
  transition: all var(--transition-normal);
}

.question-card:hover {
  box-shadow: var(--shadow-lg);
}

.question-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--light-gray);
}

.question-number {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary-purple);
}

.btn-delete {
  background: linear-gradient(135deg, var(--wrong-red) 0%, #c41530 100%);
  color: var(--white);
  padding: 10px 18px;
  font-size: 14px;
  box-shadow: 0 2px 0 #a01228;
}

.question-field {
  margin-bottom: 22px;
}

.question-field label {
  display: block;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--dark-gray);
  font-size: 15px;
}

.question-text-input {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  font-family: inherit;
  border: 2px solid #dee2e6;
  border-radius: var(--radius-md);
  resize: vertical;
  min-height: 90px;
  transition: all var(--transition-normal);
}

.question-text-input:focus {
  outline: none;
  border-color: var(--primary-purple);
  box-shadow: 0 0 0 3px rgba(70, 23, 143, 0.1);
}

.image-upload-area {
  border: 3px dashed #ced4da;
  border-radius: var(--radius-md);
  padding: 35px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-upload-area:hover {
  border-color: var(--primary-purple);
  background: rgba(70, 23, 143, 0.03);
}

.image-upload-area img {
  max-width: 100%;
  max-height: 150px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.image-upload-area span {
  color: #868e96;
  font-weight: 600;
}

/* Options Grid Admin */
.options-grid-admin {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.option-upload {
  border-radius: var(--radius-md);
  padding: 18px;
  background: #f8f9fa;
  transition: all var(--transition-normal);
}

.option-upload[data-label="A"] {
  border-left: 6px solid var(--option-red);
}

.option-upload[data-label="B"] {
  border-left: 6px solid var(--option-blue);
}

.option-upload[data-label="C"] {
  border-left: 6px solid var(--option-yellow);
}

.option-upload[data-label="D"] {
  border-left: 6px solid var(--option-green);
}

.option-upload.correct-answer {
  background: rgba(102, 191, 57, 0.12);
  border: 2px solid var(--correct-green);
  border-left-width: 6px;
}

.option-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.option-label-text {
  font-size: 26px;
  font-weight: 900;
}

.btn-correct {
  background: transparent;
  border: 2px solid var(--correct-green);
  color: var(--correct-green);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-correct:hover {
  background: rgba(102, 191, 57, 0.1);
}

.btn-correct.active {
  background: var(--correct-green);
  color: var(--white);
}

.question-settings {
  display: flex;
  gap: 22px;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid #dee2e6;
}

.setting-field {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setting-field label {
  font-size: 14px;
  font-weight: 600;
  color: #495057;
}

.time-limit-input {
  width: 85px;
  padding: 10px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 700;
  border: 2px solid #dee2e6;
  border-radius: var(--radius-sm);
  text-align: center;
  transition: all var(--transition-normal);
}

.time-limit-input:focus {
  outline: none;
  border-color: var(--primary-purple);
}

/* Option Color Picker */
.option-color-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

.option-color-picker label {
  font-size: 14px;
  font-weight: 600;
  color: #495057;
  min-width: 50px;
}

.option-color-picker input[type="color"] {
  width: 40px;
  height: 40px;
  border: 2px solid #dee2e6;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 2px;
}

.color-hex-input {
  width: 90px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: monospace;
  border: 2px solid #dee2e6;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.color-hex-input:focus {
  outline: none;
  border-color: var(--primary-purple);
}

/* Option Mode Toggle */
.option-mode-toggle {
  display: flex;
  gap: 15px;
  margin-bottom: 12px;
  padding: 8px 0;
}

.mode-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #495057;
}

.mode-label input[type="radio"] {
  cursor: pointer;
}

.option-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-text-input {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
  border: 2px solid #dee2e6;
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
}

.option-text-input:focus {
  outline: none;
  border-color: var(--primary-purple);
  box-shadow: 0 0 0 3px rgba(70, 23, 143, 0.1);
}

.image-upload-area.small {
  min-height: 60px;
  padding: 15px;
  border-width: 2px;
}

.image-upload-area.small span {
  font-size: 13px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--white);
  padding: 35px;
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.modal-content h3 {
  margin-bottom: 25px;
  color: var(--primary-purple);
  font-size: 24px;
  font-weight: 800;
}

.modal-content input[type="file"] {
  width: 100%;
  padding: 12px;
  margin-bottom: 22px;
  border: 2px solid #dee2e6;
  border-radius: var(--radius-md);
}

.modal-preview {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
  background: #f8f9fa;
  border-radius: var(--radius-md);
}

.modal-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-md);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.btn-cancel {
  background: #6c757d;
  color: var(--white);
  box-shadow: 0 3px 0 #545b62;
}

.btn-confirm {
  background: linear-gradient(135deg, var(--correct-green) 0%, #4caf50 100%);
  color: var(--white);
  box-shadow: 0 3px 0 #2d7a1a;
}

/* ==================== SVG TIMER ==================== */
.timer-container {
  position: relative;
  width: 100px;
  height: 100px;
}

.timer-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 8;
}

.timer-progress {
  fill: none;
  stroke: var(--white);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s ease, stroke 0.3s ease;
}

.timer-progress.warning {
  stroke: var(--wrong-red);
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 38px;
  font-weight: 900;
  color: var(--white);
}

.timer-container.warning .timer-text {
  color: var(--wrong-red);
  animation: timerPulse 0.5s ease infinite;
}

/* ==================== LIVE BARS (During Question) ==================== */
.option-bar-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  overflow: hidden;
}

.option-bar {
  height: 100%;
  width: 0%;
  background: rgba(255, 255, 255, 0.6);
  transition: width 0.3s ease;
  border-radius: 0 4px 4px 0;
}

.option-count.pulse {
  animation: countPulse 0.3s ease;
}

@keyframes countPulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.3);
  }

  100% {
    transform: scale(1);
  }
}

/* ==================== RESULTS SCREEN (Bar Chart) ==================== */
.results-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 30px 20px;
}

.results-header {
  text-align: center;
  margin-bottom: 40px;
}

.results-title {
  font-size: 42px;
  font-weight: 900;
  margin-bottom: 15px;
}

.results-question {
  font-size: 22px;
  opacity: 0.9;
  line-height: 1.4;
}

.results-chart {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 40px;
}

.chart-bar-row {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  transition: all 0.3s ease;
}

.chart-bar-row.correct {
  background: rgba(102, 191, 57, 0.3);
  box-shadow: 0 0 20px rgba(102, 191, 57, 0.3);
}

.chart-bar-row.wrong {
  opacity: 0.6;
}

.chart-label {
  font-size: 32px;
  font-weight: 900;
  width: 50px;
  text-align: center;
}

.chart-bar-row[data-option="A"] .chart-label {
  color: var(--option-red);
}

.chart-bar-row[data-option="B"] .chart-label {
  color: var(--option-blue);
}

.chart-bar-row[data-option="C"] .chart-label {
  color: var(--option-yellow);
}

.chart-bar-row[data-option="D"] .chart-label {
  color: var(--option-green);
}

.chart-bar-wrapper {
  flex: 1;
  height: 50px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.chart-bar {
  height: 100%;
  width: 0%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 15px;
  border-radius: var(--radius-md);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 0;
}

.chart-bar-a {
  background: linear-gradient(90deg, var(--option-red) 0%, #ff4757 100%);
}

.chart-bar-b {
  background: linear-gradient(90deg, var(--option-blue) 0%, #3498db 100%);
}

.chart-bar-c {
  background: linear-gradient(90deg, var(--option-yellow) 0%, #f1c40f 100%);
}

.chart-bar-d {
  background: linear-gradient(90deg, var(--option-green) 0%, #2ecc71 100%);
}

.chart-bar-count {
  font-size: 24px;
  font-weight: 800;
  color: var(--white);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.chart-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-icon svg {
  width: 32px;
  height: 32px;
}

.icon-correct {
  color: var(--correct-green);
  animation: iconPop 0.4s ease;
}

.icon-wrong {
  color: var(--wrong-red);
  opacity: 0.5;
}

@keyframes iconPop {
  0% {
    transform: scale(0);
  }

  70% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

.results-summary {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 30px;
}

.summary-item {
  text-align: center;
  background: rgba(255, 255, 255, 0.1);
  padding: 20px 40px;
  border-radius: var(--radius-lg);
}

.summary-label {
  display: block;
  font-size: 16px;
  opacity: 0.8;
  margin-bottom: 8px;
}

.summary-value {
  font-size: 36px;
  font-weight: 900;
  color: var(--correct-green);
}

/* ==================== PODIUM ==================== */
.leaderboard-podium {
  margin-bottom: 30px;
}

.podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 10px;
  padding: 20px;
}

.podium-place {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: podiumRise 0.6s ease forwards;
  opacity: 0;
}

.podium-place.first {
  animation-delay: 0.4s;
}

.podium-place.second {
  animation-delay: 0.2s;
}

.podium-place.third {
  animation-delay: 0.6s;
}

@keyframes podiumRise {
  from {
    opacity: 0;
    transform: translateY(50px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.podium-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 10px;
}

.podium-place.first .podium-avatar {
  width: 80px;
  height: 80px;
  font-size: 36px;
  background: linear-gradient(135deg, #ffd700 0%, #ffb347 100%);
  color: var(--dark-gray);
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

.podium-place.second .podium-avatar {
  background: linear-gradient(135deg, #c0c0c0 0%, #a8a8a8 100%);
  color: var(--dark-gray);
}

.podium-place.third .podium-avatar {
  background: linear-gradient(135deg, #cd7f32 0%, #b87333 100%);
  color: var(--white);
}

.podium-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 5px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-place.first .podium-name {
  font-size: 22px;
  color: #ffd700;
}

.podium-score {
  font-size: 16px;
  font-weight: 600;
  opacity: 0.8;
  margin-bottom: 15px;
}

.podium-place.first .podium-score {
  font-size: 20px;
}

.podium-stand {
  width: 100px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.podium-place.first .podium-stand {
  height: 120px;
  width: 120px;
  background: linear-gradient(180deg, #ffd700 0%, #b8860b 100%);
}

.podium-place.second .podium-stand {
  height: 90px;
  background: linear-gradient(180deg, #c0c0c0 0%, #808080 100%);
}

.podium-place.third .podium-stand {
  height: 60px;
  background: linear-gradient(180deg, #cd7f32 0%, #8b4513 100%);
}

/* ==================== CONFETTI ==================== */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 100;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 20px;
  top: -20px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotateZ(0deg);
    opacity: 1;
  }

  100% {
    transform: translateY(100vh) rotateZ(720deg);
    opacity: 0;
  }
}

/* ==================== RESPONSIVE ==================== */

/* ===== PLAYER MOBILE OPTIMIZATIONS ===== */
@media (max-width: 768px) {

  /* Player Page - Full Screen Experience */
  .player-page .screen {
    padding: 10px;
    padding-top: env(safe-area-inset-top, 10px);
    padding-bottom: env(safe-area-inset-bottom, 10px);
  }

  .player-page .join-container {
    padding: 30px 20px;
  }

  .player-page .game-title {
    font-size: 32px;
    margin-bottom: 40px;
  }

  .player-page #nickname-input {
    padding: 18px;
    font-size: 20px;
    border-radius: 12px;
  }

  .player-page .btn-join {
    padding: 18px 30px;
    font-size: 18px;
  }

  /* Waiting Screen - Better Mobile Display */
  .waiting-container {
    padding: 40px 20px;
  }

  .waiting-container h2 {
    font-size: 26px;
    line-height: 1.4;
  }

  .waiting-container h2 span {
    display: inline;
    font-size: inherit;
  }

  .waiting-animation {
    margin: 40px 0;
  }

  .waiting-animation .dot {
    width: 18px;
    height: 18px;
  }

  /* Player Question Header - Compact */
  .player-page .player-question-header {
    flex-shrink: 0;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 10px;
  }

  .question-info {
    font-size: 14px;
    padding: 6px 12px;
  }

  .player-timer {
    width: 50px;
    height: 50px;
    font-size: 24px;
  }

  /* Player Question Screen - use fixed position to fill screen */
  .player-page #question-screen.active {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 8px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  /* Player Question Content - Mobile */
  .player-page .player-question-content {
    flex-shrink: 0;
    padding: 8px 10px;
    margin-bottom: 6px;
  }

  .player-page .player-question-text {
    font-size: 24px;
    line-height: 1.25;
  }

  .player-page .player-question-image {
    max-height: 50px;
    margin-top: 4px;
  }

  /* Answer Buttons - fill remaining space */
  .player-page .answer-buttons {
    flex: 1;
    min-height: 0;
    gap: 5px;
    padding: 2px;
  }

  .player-page .answer-btn {
    min-height: 0;
    border-radius: 10px;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    padding: 4px;
    gap: 0;
  }

  .player-page .answer-btn .answer-label {
    font-size: 12px;
    top: 3px;
    right: 4px;
    padding: 2px 5px;
  }

  .player-page .answer-btn .answer-content {
    font-size: 24px;
    -webkit-line-clamp: 2;
    line-height: 1.2;
  }

  .player-page .answer-btn .answer-image {
    flex: 1;
    min-height: 0;
    max-height: 85%;
    max-width: 85%;
    object-fit: contain;
  }

  .answer-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.25);
  }

  /* Answered Screen */
  .answered-container {
    padding: 30px 20px;
  }

  .selected-answer {
    width: 120px;
    height: 120px;
    font-size: 60px;
    border-radius: 20px;
  }

  .answered-container p {
    font-size: 20px;
  }

  .answer-time {
    font-size: 16px;
  }

  /* Result Screen */
  .result-container {
    padding: 30px 20px;
  }

  .result-icon {
    font-size: 90px;
  }

  .result-text {
    font-size: 32px;
  }

  .points-earned {
    font-size: 50px;
  }

  .total-score {
    font-size: 20px;
    padding: 15px 30px;
  }

  /* Player Leaderboard Screen */
  .player-leaderboard-container h2 {
    font-size: 28px;
  }

  .player-rank {
    padding: 25px 40px;
  }

  .player-rank .rank-number {
    font-size: 48px;
  }

  .player-rank .rank-score {
    font-size: 22px;
  }

  /* Player Final Screen */
  .player-final-container h2 {
    font-size: 32px;
  }

  .final-rank-number {
    font-size: 72px;
  }

  .final-score {
    font-size: 32px;
  }

  /* Timeout Screen */
  .timeout-icon {
    font-size: 80px;
  }

  .timeout-container h2 {
    font-size: 28px;
  }

  /* ===== HOST PAGE MOBILE ===== */
  .game-title {
    font-size: 36px;
  }

  .question-text {
    font-size: 20px;
  }

  .option-label {
    font-size: 40px;
  }

  .options-grid {
    gap: 12px;
  }

  .option {
    min-height: 150px;
    padding: 15px;
  }

  .timer-circle {
    width: 75px;
    height: 75px;
    font-size: 34px;
  }

  .admin-header {
    flex-direction: column;
    text-align: center;
  }

  .options-grid-admin {
    grid-template-columns: 1fr;
  }

  .host-controls {
    flex-direction: column;
    padding: 15px;
  }

  .host-controls .btn {
    width: 100%;
  }

  .leaderboard-item {
    padding: 14px 20px;
    font-size: 16px;
  }

  .leaderboard-item.top-1 {
    font-size: 22px;
  }

  .qr-section {
    padding: 30px 20px;
  }

  #qr-code img {
    width: 180px;
    height: 180px;
  }

  .join-url {
    font-size: 14px;
    word-break: break-all;
  }
}

@media (max-width: 480px) {
  .screen {
    padding: 8px;
  }

  .game-title {
    font-size: 28px;
  }

  .player-count span {
    font-size: 50px;
  }

  /* Player question screen - use fixed position */
  .player-page #question-screen.active {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 6px;
    padding-top: max(6px, env(safe-area-inset-top));
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }

  .player-page .player-question-header {
    flex-shrink: 0;
    padding: 5px 8px;
    margin-bottom: 4px;
  }

  .player-page .question-info {
    font-size: 11px;
    padding: 4px 8px;
  }

  .player-page .player-timer {
    width: 40px;
    height: 40px;
    font-size: 18px;
    border-width: 2px;
  }

  .player-page .player-question-content {
    flex-shrink: 0;
    padding: 6px 8px;
    margin-bottom: 4px;
  }

  .player-page .player-question-text {
    font-size: 24px;
  }

  .player-page .player-question-image {
    max-height: 40px;
  }

  /* Answer buttons take remaining space */
  .player-page .answer-buttons {
    flex: 1;
    min-height: 0;
    gap: 4px;
    padding: 0;
  }

  .player-page .answer-btn {
    border-radius: 6px;
    padding: 3px;
    gap: 0;
    min-height: 0;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  }

  .player-page .answer-btn .answer-label {
    font-size: 10px;
    top: 2px;
    right: 3px;
    padding: 2px 4px;
  }

  .player-page .answer-btn .answer-content {
    font-size: 24px;
    -webkit-line-clamp: 2;
    line-height: 1.15;
  }

  .player-page .answer-btn .answer-image {
    flex: 1;
    min-height: 0;
    max-height: 80%;
    max-width: 90%;
    object-fit: contain;
  }

  .question-header {
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
  }

  /* Host small screen */
  .host-page .answer-btn {
    font-size: 36px;
    min-height: 110px;
  }

  .host-page .answer-buttons {
    gap: 12px;
    padding: 5px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}