/* ============================================
   问答对战游戏 - H5 样式 v2.0
   设计：活力智慧蓝 · 卡通休闲 · 大圆角
   参考 docs/05-art-style-guide.md
   ============================================ */

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

:root {
  --primary: #6366F1; --primary-light: #818CF8; --primary-dark: #4F46E5;
  --secondary: #14B8A6; --accent: #F97316;
  --success: #22C55E; --danger: #F43F5E; --warning: #F59E0B;
  --bg: linear-gradient(180deg, #E0F2FE 0%, #FFFFFF 100%);
  --bg-card: #FFFFFF; --surface: #F1F5F9;
  --text: #1E293B; --text-secondary: #64748B;
  --border: #E2E8F0;
  --shadow: 0 4px 14px rgba(99,102,241,0.15);
  --shadow-lg: 0 8px 30px rgba(99,102,241,0.22);
  --shadow-btn: 0 6px 0 var(--primary-dark), 0 8px 20px rgba(79,70,229,0.3);
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 24px;
}

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; }

/* ===== Page ===== */
.page { display: none; padding: 24px 20px; min-height: 100vh; }
.page.active { display: block; }

/* ===== 3D Title ===== */
.title-3d {
  font-size: clamp(36px,10vw,52px); font-weight: 900; color: #fff;
  letter-spacing: 1px; text-align: center;
  -webkit-text-stroke: 2px var(--primary-dark);
  text-shadow: 0 1px 0 #4338CA, 0 2px 0 #3730A3, 0 3px 0 #312E81,
               0 4px 0 #27296D, 0 5px 0 #1E1B4B,
               0 6px 0 rgba(67,56,202,.8), 0 8px 7px rgba(67,56,202,.4),
               0 12px 20px rgba(0,0,0,.25);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; border: none; border-radius: var(--radius-lg);
  padding: 16px 24px; font-size: 18px; font-weight: 700;
  cursor: pointer; transition: transform .1s, box-shadow .1s;
  touch-action: manipulation;
}
.btn:active { transform: translateY(4px); }

.btn-primary {
  width: 100%; color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: var(--shadow-btn);
}
.btn-primary:active { box-shadow: 0 2px 0 var(--primary-dark), 0 4px 10px rgba(79,70,229,.3); }

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

.btn-text { background: transparent; color: var(--text-secondary); font-size: 14px; }

.btn-light {
  width: 100%; padding: 18px 24px; border: none; border-radius: var(--radius-lg);
  font-size: 18px; font-weight: 700; color: var(--primary); background: #fff;
  box-shadow: 0 4px 0 rgba(255,255,255,.4), 0 8px 24px rgba(0,0,0,.15);
}
.btn-light:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(255,255,255,.4), 0 4px 12px rgba(0,0,0,.15); }

.btn-badge {
  display: inline-block; padding: 2px 10px; background: rgba(255,255,255,.2);
  border-radius: 999px; font-size: 11px; font-weight: 400;
}
.btn-accent {
  background: linear-gradient(135deg, #8B5CF6, #6366F1); color: #fff;
}
.btn-icon { font-size: 1.2em; }

/* ===== Header ===== */
.header { text-align: center; padding: 32px 0 20px; }
.header h1 { font-size: 28px; font-weight: 800; margin-bottom: 6px; }
.subtitle { color: var(--text-secondary); font-size: 15px; }

/* ===== Nickname ===== */
.nickname-section { text-align: center; padding: 0 8px 16px; }
.nickname-label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.nickname-input {
  width: 100%; max-width: 260px; padding: 12px 16px;
  border: 2px solid var(--border); border-radius: var(--radius-md);
  font-size: 18px; text-align: center; outline: none; transition: border-color .15s;
}
.nickname-input:focus { border-color: var(--primary); }

/* ===== Menu Cards (Lobby) ===== */
.menu { display: flex; flex-direction: column; gap: 14px; }
.menu-card {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 20px 18px; border: none; border-radius: var(--radius-xl);
  color: #fff; cursor: pointer; touch-action: manipulation;
  transition: transform .15s, box-shadow .15s;
  position: relative; overflow: hidden;
  text-align: left; font-family: inherit;
}
.menu-card:active { transform: scale(0.97); }
.menu-card::after {
  content: ""; position: absolute; right: -20px; top: -20px;
  width: 90px; height: 90px; border-radius: 50%; background: rgba(255,255,255,.12);
}
.menu-card-glow { /* 装饰光晕右下 */ }
.menu-card .card-icon { font-size: 36px; flex-shrink: 0; }
.menu-card .card-info { flex: 1; }
.menu-card .card-title { font-size: 18px; font-weight: 800; }
.menu-card .card-desc { font-size: 13px; opacity: .85; margin-top: 2px; }
.menu-card .card-arrow { font-size: 24px; opacity: .7; flex-shrink: 0; }
.menu-divider { height: 1px; background: var(--border); margin: 6px 0; }

.bg-pvp { background: linear-gradient(135deg, #6366F1 0%, #14B8A6 100%); }
.bg-room { background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%); }
.bg-daily { background: linear-gradient(135deg, #F59E0B 0%, #F97316 100%); }

.user-info { text-align: center; padding: 16px 0; color: var(--text-secondary); font-size: 13px; }

/* ===== Modal ===== */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,.5); display: flex; align-items: center;
  justify-content: center; z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--bg-card); border-radius: var(--radius-xl);
  padding: 28px; width: 90%; max-width: 360px; box-shadow: var(--shadow-lg);
}
.modal-content h3 { margin-bottom: 16px; font-size: 20px; }
.modal-content input {
  width: 100%; padding: 14px; border: 2px solid var(--border);
  border-radius: var(--radius-lg); font-size: 28px; text-align: center;
  letter-spacing: 10px; outline: none;
}
.modal-content input:focus { border-color: var(--primary); }
.modal-buttons { display: flex; gap: 12px; margin-top: 18px; }
.modal-buttons .btn { flex: 1; }

/* ===== Waiting Room ===== */
.room-header { text-align: center; padding: 24px 0; }
.room-header h2 { font-size: 22px; }
.room-code-card {
  font-size: 40px; font-weight: 900; color: var(--primary);
  letter-spacing: 12px; text-align: center;
  padding: 24px; background: var(--bg-card);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  margin: 12px 0;
}
.room-hint { color: var(--text-secondary); font-size: 14px; text-align: center; }
.players-list { display: flex; flex-direction: column; gap: 12px; padding: 16px 0; }
.player-card {
  display: flex; align-items: center; gap: 12px; padding: 16px;
  background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.player-card .avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary-light); display: flex; align-items: center;
  justify-content: center; font-size: 22px; color: #fff; flex-shrink: 0;
}
.player-card .name { font-size: 16px; font-weight: 600; }
.player-card .tag {
  margin-left: auto; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; background: var(--primary-light); color: #fff;
}
.player-card .tag.host { background: var(--warning); }
.room-actions { display: flex; flex-direction: column; gap: 12px; padding: 20px 0; text-align: center; }
.question-count-selector {
  background: var(--bg-card); border-radius: var(--radius-xl); padding: 16px;
  text-align: center; box-shadow: var(--shadow);
}
.count-options { display: flex; justify-content: center; gap: 8px; padding-top: 10px; }
.count-option {
  padding: 10px 18px; border: 2px solid var(--border); border-radius: var(--radius-lg);
  cursor: pointer; background: var(--bg-card); font-weight: 700;
  transition: all .15s;
}
.count-option.active { border-color: var(--primary); background: var(--primary); color: #fff; }

/* Countdown overlay */
.countdown-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(79,70,229,.85); display: flex; flex-direction: column;
  align-items: center; justify-content: center; z-index: 200;
}
.countdown-overlay.hidden { display: none; }
.countdown-number {
  font-size: clamp(72px,20vw,120px); font-weight: 900; color: #fff;
  -webkit-text-stroke: 3px var(--primary-dark);
  text-shadow: 0 4px 0 #3730A3, 0 8px 20px rgba(0,0,0,.3);
}
.countdown-text { color: rgba(255,255,255,.8); font-size: 20px; margin-top: 12px; }

/* ===== Game Page (Dark Background) ===== */
.game-bg {
  background: linear-gradient(180deg, #4F46E5 0%, #3730A3 100%);
}
#game-page .scoreboard {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 12px 0; margin-bottom: 12px;
}
#game-page .scoreboard .score-value { font-size: 32px; font-weight: 900; color: #fff; }
#game-page .scoreboard .score-name { font-size: 13px; color: rgba(255,255,255,.7); display: block; }
#game-page .scoreboard .score-vs { font-size: 16px; color: rgba(255,255,255,.5); font-weight: 700; }

/* Timer badge (circular) */
.timer-badge {
  width: 60px; height: 60px; border-radius: 50%;
  background: rgba(255,255,255,.12); border: 3px solid rgba(255,255,255,.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 900; color: #fff; margin: 0 auto 12px;
  transition: all .3s;
}
.timer-badge.warning { border-color: var(--warning); color: var(--warning); animation: pulse-scale 1s infinite; }
.timer-badge.danger { border-color: var(--danger); color: var(--danger); animation: pulse-scale .6s infinite; }

@keyframes pulse-scale {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Lives indicator */
.lives-indicator {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(255,255,255,.12); color: #fff; font-weight: 700; font-size: 14px;
}

/* Question card on dark bg */
.question-card {
  background: var(--bg-card); border-radius: var(--radius-xl);
  padding: 24px 20px; margin-bottom: 14px; box-shadow: var(--shadow-lg);
}
.question-category {
  display: inline-block; padding: 3px 12px; background: var(--primary-light);
  color: #fff; border-radius: 999px; font-size: 12px; margin-bottom: 10px;
}
.question-text { font-size: clamp(17px,4vw,20px); font-weight: 700; line-height: 1.6; }

/* Options */
.options-area { display: flex; flex-direction: column; gap: 10px; }
.option-btn {
  width: 100%; padding: 16px; border: 2px solid var(--border);
  border-radius: var(--radius-lg); background: var(--bg-card);
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; transition: all .15s; font-size: 16px; text-align: left;
  touch-action: manipulation; box-shadow: var(--shadow);
}
.option-btn:active { transform: scale(0.98); }
.option-label {
  width: 34px; height: 34px; border-radius: 50%; background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--text); flex-shrink: 0;
}
.option-text { flex: 1; }

/* Selected (just clicked) */
.option-btn.selected {
  border-color: var(--accent); background: #FFFBEB; transform: scale(1.02);
  box-shadow: 0 0 0 4px rgba(249,115,22,.2);
}
.option-btn.selected .option-label { background: var(--accent); color: #fff; }

.option-btn.correct {
  border-color: var(--success); background: #F0FDF4;
}
.option-btn.correct .option-label { background: var(--success); color: #fff; }

.option-btn.wrong {
  border-color: var(--danger); background: #FFF1F2;
  animation: shake .4s ease;
}
.option-btn.wrong .option-label { background: var(--danger); color: #fff; }

.option-btn.disabled { pointer-events: none; }

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

.opponent-status {
  text-align: center; padding: 10px; color: rgba(255,255,255,.6);
  font-size: 13px; margin-top: 8px;
}
.opponent-status .dot { display: inline-block; animation: blink .8s infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ===== Result Page ===== */
.result-header { text-align: center; padding: 32px 0 20px; }
.result-header h2 { font-size: 32px; }
.result-winner { text-shadow: 0 4px 0 #059669; }
.result-loser { text-shadow: 0 4px 0 #BE123C; }

.result-details { display: flex; flex-direction: column; gap: 12px; padding: 0 0 20px; }
.result-player {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px; background: var(--bg-card); border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}
.result-player .name { font-size: 17px; font-weight: 600; }
.result-player .score { font-size: 22px; font-weight: 700; color: var(--primary); }
.result-player.winner {
  border: 3px solid var(--accent);
  background: linear-gradient(180deg, #FFF7ED 0%, #FFFFFF 100%);
}
.crown-icon { font-size: 28px; animation: bounce .6s ease infinite alternate; }

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.result-actions { display: flex; flex-direction: column; gap: 12px; padding: 0; }

/* ===== Daily Challenge ===== */

/* Mode select page */
.daily-mode-options { display: flex; flex-direction: column; gap: 14px; padding: 20px 0; }
.mode-card {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 22px 20px; border: none; border-radius: var(--radius-xl);
  color: #fff; cursor: pointer; touch-action: manipulation;
  transition: transform .15s;
  position: relative; overflow: hidden;
  text-align: left; font-family: inherit;
}
.mode-card:active { transform: scale(0.97); }
.mode-card::after {
  content: ""; position: absolute; right: -15px; top: -15px;
  width: 80px; height: 80px; border-radius: 50%; background: rgba(255,255,255,.1);
}
.mode-card .mode-card-icon { font-size: 32px; flex-shrink: 0; }
.mode-card .mode-card-info { flex: 1; }
.mode-card .mode-card-title { font-size: 18px; font-weight: 800; }
.mode-card .mode-card-desc { font-size: 13px; opacity: .85; margin-top: 2px; }
.mode-card .mode-card-arrow { font-size: 22px; opacity: .6; flex-shrink: 0; }

.mode-ten { background: linear-gradient(135deg, #6366F1 0%, #14B8A6 100%); }
.mode-endless { background: linear-gradient(135deg, #F59E0B 0%, #EC4899 100%); }

/* Daily game page (light bg) */
.daily-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 0 12px;
}
.daily-title-row { display: flex; align-items: center; gap: 8px; }
.daily-title-row h2 { font-size: 20px; }
.daily-progress { font-size: 13px; color: var(--text-secondary); font-weight: 700; }
.daily-mode-badge {
  display: inline-block; padding: 2px 10px; background: var(--primary-light);
  color: #fff; border-radius: 999px; font-size: 11px; font-weight: 500; margin-left: 6px;
}
.daily-lives { text-align: center; font-size: 22px; padding: 4px 0 10px; letter-spacing: 4px; }
.daily-score-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--bg-card); border-radius: var(--radius-xl);
  margin-top: 14px; box-shadow: var(--shadow); font-size: 14px; color: var(--text-secondary);
}
.daily-score-bar strong { color: var(--primary); font-size: 18px; }

/* Daily result page */
.daily-result-header { text-align: center; padding: 28px 0 16px; }
.daily-result-icon { font-size: 56px; margin-bottom: 6px; }
.daily-result-header h2 { font-size: 26px; }
.daily-result-player { font-size: 15px; color: var(--text-secondary); margin-top: 4px; font-weight: 600; }

.daily-result-stats {
  display: flex; align-items: center; justify-content: center;
  padding: 20px 0; background: var(--bg-card); border-radius: var(--radius-xl);
  box-shadow: var(--shadow); margin-bottom: 18px;
}
.daily-stat-item { flex: 1; text-align: center; }
.daily-stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.daily-stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.daily-stat-divider { width: 1px; height: 36px; background: var(--border); }

.daily-ranking-section { margin-bottom: 18px; }
.daily-ranking-title { font-size: 17px; margin-bottom: 10px; text-align: center; }
.daily-ranking-list { display: flex; flex-direction: column; gap: 8px; }
.daily-ranking-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--bg-card);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); font-size: 14px;
}
.daily-ranking-item .rank { width: 26px; text-align: center; font-weight: 700; font-size: 15px; }
.daily-ranking-item .rank.gold { color: #F59E0B; }
.daily-ranking-item .rank.silver { color: #94A3B8; }
.daily-ranking-item .rank.bronze { color: #D97706; }
.daily-ranking-item .name { flex: 1; font-weight: 600; }
.daily-ranking-item .daily-score { color: var(--primary); font-weight: 700; }
.daily-ranking-item.is-me { background: #EEF2FF; border: 2px solid var(--primary); }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 20px;
  border-radius: var(--radius-md); font-size: 14px; z-index: 200;
  opacity: 0; transition: opacity .3s;
}
.toast.show { opacity: 1; }

/* ===== Loading ===== */
.loading {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(180deg, #4F46E5 0%, #3730A3 100%);
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; z-index: 300;
}
.loading p { margin-top: 16px; color: rgba(255,255,255,.7); font-size: 16px; }
.spinner {
  width: 40px; height: 40px; border: 3px solid rgba(255,255,255,.2);
  border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }
