/* ========== Minecraft Pixel Font ========== */
@import "https://fonts.googleapis.cn/css2?family=Press+Start+2P&display=swap";

/* ========== 全局重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { touch-action: manipulation; }

:root {
  --pixel-font: 'Press Start 2P', monospace;
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --primary: #e94560;
  --secondary: #0f3460;
  --accent: #f5c518;
  --text: #eaeaea;
  --text-dim: #8892a4;
  --success: #2ecc71;
  --danger: #e74c3c;
  --chinese: #E74C3C;
  --math: #3498DB;
  --english: #2ECC71;
  --general: #F39C12;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0,0,0,0.3);
}

body {
  font-family: var(--pixel-font), 'Noto Sans TC', monospace;
  background: var(--bg-dark);
  color: var(--text);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  user-select: none;
  -webkit-user-select: none;
}

/* ========== 遊戲畫布 ========== */
#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  z-index: 1;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

/* ========== 設置頁 ========== */
#setup-screen {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  pointer-events: auto;
}

.setup-card {
  background: rgba(22, 33, 62, 0.95);
  border: 1px solid rgba(245, 197, 24, 0.2);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 440px;
  width: 92%;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
  position: relative;
  overflow: visible;
  margin: 20px auto;
}

.setup-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--primary), var(--accent));
}

.setup-title {
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  color: var(--accent);
  margin-bottom: 4px;
  letter-spacing: 2px;
  font-family: var(--pixel-font), monospace;
}

.setup-subtitle {
  text-align: center;
  color: var(--text-dim);
  font-size: 10px;
  margin-bottom: 18px;
  font-family: var(--pixel-font), monospace;
}

/* ---- 角色選擇器（整合性別+外觀+預覽） ---- */
.char-selector {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.char-preview-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#preview-canvas {
  width: 96px; height: 96px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  border: 2px solid rgba(245,197,24,0.3);
}

.char-options {
  flex: 1;
  min-width: 0;
}

.opt-row {
  margin-bottom: 12px;
}

.opt-row:last-child { margin-bottom: 0; }

.opt-label {
  display: block;
  font-size: 8px;
  color: var(--text-dim);
  margin-bottom: 5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: var(--pixel-font), monospace;
}

.gender-row {
  display: flex; gap: 8px;
}

.gender-btn {
  flex: 1;
  padding: 8px;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.2s;
  font-family: var(--pixel-font), monospace;
  pointer-events: auto;
}

.gender-btn:hover { border-color: rgba(255,255,255,0.3); }
.gender-btn.active {
  border-color: var(--accent);
  background: rgba(245,197,24,0.1);
}

.gender-btn svg { flex-shrink: 0; }

/* Grade Selection */
.grade-row {
  display: flex; gap: 6px;
}
.grade-btn {
  flex: 1;
  padding: 7px 4px;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 8px;
  font-family: var(--pixel-font), monospace;
  transition: all 0.2s;
  pointer-events: auto;
}
.grade-btn:hover { border-color: rgba(255,255,255,0.3); }
.grade-btn.active {
  border-color: var(--accent);
  background: rgba(245,197,24,0.15);
  color: var(--accent);
}

.color-swatches {
  display: flex; gap: 6px;
}

.color-swatch {
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.2s;
}

.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(245,197,24,0.4);
}

/* 皮膚選擇器 */
.skin-select {
  display: flex; flex-wrap: wrap; gap: 5px;
}
.skin-btn {
  padding: 5px 8px;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: #ccc; font-size: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: var(--pixel-font), monospace;
  pointer-events: auto;
}
.skin-btn:hover {
  border-color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
}
.skin-btn.active {
  border-color: var(--accent);
  background: rgba(245,197,24,0.15);
  color: #fff;
}
.skin-btn.locked {
  opacity: 0.4;
  cursor: not-allowed;
  position: relative;
}
.skin-btn.locked::after {
  content: '🔒';
  font-size: 8px;
  position: absolute;
  top: 1px; right: 2px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 8px;
  color: var(--text-dim);
  margin-bottom: 5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: var(--pixel-font), monospace;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

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

#start-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent), #d4a017);
  color: #1a1a2e;
  font-size: 14px;
  font-weight: 800;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
  letter-spacing: 2px;
  font-family: var(--pixel-font), monospace;
  pointer-events: auto;
}

#start-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(245,197,24,0.4); }
#start-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

/* ========== 加載頁 ========== */
#loading-screen {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--bg-dark);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

#loading-screen.visible {
  opacity: 1;
  pointer-events: auto;
}

#loading-text {
  font-size: 18px;
  color: var(--accent);
}

.loading-bar {
  width: 200px; height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.loading-bar-inner {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  animation: loadPulse 1.5s ease-in-out infinite;
}

@keyframes loadPulse {
  0%, 100% { width: 30%; }
  50% { width: 90%; }
}

/* ========== HUD ========== */
#hud {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
}

#hud.visible { opacity: 1; }

.hud-top {
  position: absolute;
  top: 8px; left: 8px; right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.hud-hearts {
  display: flex; gap: 4px;
  background: rgba(0,0,0,0.5);
  padding: 6px 10px;
  border-radius: 10px;
  backdrop-filter: blur(6px);
}

.heart {
  display: inline-flex;
  align-items: center;
  transition: all 0.3s;
}

.heart.lost { opacity: 0.3; filter: grayscale(1); }

.heart.shake {
  animation: heartShake 0.4s ease;
}

@keyframes heartShake {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.3) rotate(-10deg); }
  50% { transform: scale(0.8) rotate(10deg); }
  75% { transform: scale(1.1) rotate(-5deg); }
}

.hud-timer-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(0,0,0,0.5);
  padding: 8px 16px;
  border-radius: 10px;
  backdrop-filter: blur(6px);
}

.hud-timer {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-family: var(--pixel-font), monospace;
}

.hud-progress {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--pixel-font), monospace;
}

/* 速度指示 */
.speed-indicator {
  position: absolute;
  top: 60px; left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  font-family: var(--pixel-font), monospace;
}

.speed-indicator.boost {
  opacity: 1;
  background: rgba(46,204,113,0.2);
  color: var(--success);
  border: 1px solid rgba(46,204,113,0.4);
}

.speed-indicator.slow {
  opacity: 1;
  background: rgba(231,76,60,0.2);
  color: var(--danger);
  border: 1px solid rgba(231,76,60,0.4);
}

.speed-indicator svg { flex-shrink: 0; }

/* ========== 漢堡選單按鈕 ========== */
.menu-btn {
  background: rgba(0,0,0,0.4);
  border: none;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  pointer-events: auto;
  z-index: 15;
}
.menu-btn:active { background: rgba(0,0,0,0.6); }

/* ========== 暫停覆蓋層 ========== */
.pause-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.pause-overlay.hidden { display: none; }
.pause-card {
  background: rgba(30,30,50,0.95);
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  min-width: 260px;
}
.pause-card h2 {
  font-family: var(--font-main);
  font-size: 28px;
  color: var(--accent);
  margin: 0 0 24px 0;
  letter-spacing: 4px;
}
.pause-btn {
  display: block;
  width: 100%;
  padding: 14px 0;
  margin-bottom: 12px;
  font-family: var(--font-main);
  font-size: 14px;
  color: #fff;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 10px;
  cursor: pointer;
  letter-spacing: 2px;
  touch-action: manipulation;
}
.pause-btn:hover, .pause-btn:active {
  background: rgba(255,255,255,0.2);
  border-color: var(--accent);
  color: var(--accent);
}
.pause-btn.quit {
  background: rgba(255,50,50,0.15);
  border-color: rgba(255,80,80,0.4);
}
.pause-btn.quit:hover, .pause-btn.quit:active {
  background: rgba(255,50,50,0.3);
  border-color: #ff5050;
  color: #ff5050;
}

/* ========== 小地圖 ========== */
#minimap {
  position: fixed;
  top: 48px;
  left: 8px;
  width: 80px;
  height: 80px;
  z-index: 14;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  background: rgba(0,0,0,0.25);
  image-rendering: pixelated;
  display: none;
  opacity: 0.55;
  pointer-events: none;
}
#minimap.visible {
  display: block;
}

/* ========== 虛擬搖桿 ========== */
#joystick-zone {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 50%;
  height: 60%;
  z-index: 14;
  display: none;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  background: transparent;
}

.joystick-base {
  position: absolute;
  width: 110px; height: 110px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
  display: none;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.joystick-base.visible { display: block; }

.joystick-thumb {
  position: absolute;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  border: 2px solid rgba(255,255,255,0.4);
  display: none;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.joystick-thumb.visible { display: block; }

/* ========== 動作按鈕 ========== */
.action-buttons {
  position: fixed;
  bottom: 24px;
  right: 20px;
  z-index: 15;
  display: none;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
}

.action-btn {
  width: 58px; height: 58px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  pointer-events: auto;
}

.action-btn:active, .action-btn.pressed {
  transform: scale(0.9);
}

.action-btn svg {
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6));
  pointer-events: none;
}

#jump-btn-action {
  background: rgba(46,204,113,0.2);
  border-color: rgba(46,204,113,0.4);
}

#jump-btn-action:active, #jump-btn-action.pressed {
  background: rgba(46,204,113,0.4);
}

#attack-btn {
  background: rgba(231,76,60,0.2);
  border-color: rgba(231,76,60,0.4);
}

#attack-btn:active, #attack-btn.pressed {
  background: rgba(231,76,60,0.4);
}

/* ========== 題目彈窗 ========== */
#question-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.75);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  backdrop-filter: blur(4px);
}

#question-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.question-card {
  background: rgba(22, 33, 62, 0.97);
  border: 1px solid rgba(245,197,24,0.25);
  border-radius: 18px;
  padding: 24px 22px;
  max-width: 480px;
  width: 92%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  position: relative;
  overflow: hidden;
}

.question-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--primary));
}

.subject-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 14px;
}

.subject-badge svg { vertical-align: middle; }

#question-text {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.8;
  margin-bottom: 18px;
  color: var(--text);
  font-family: var(--pixel-font), monospace;
}

.options-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--pixel-font), monospace;
  line-height: 1.6;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(245,197,24,0.08);
}

.option-prefix {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.option-btn.correct {
  border-color: var(--success);
  background: rgba(46,204,113,0.15);
}

.option-btn.wrong {
  border-color: var(--danger);
  background: rgba(231,76,60,0.15);
}

.feedback-area {
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  display: none;
  font-size: 14px;
  line-height: 1.6;
}

.feedback-area.visible { display: block; }

.feedback-area.correct-fb {
  background: rgba(46,204,113,0.1);
  border: 1px solid rgba(46,204,113,0.25);
  color: var(--success);
}

.feedback-area.wrong-fb {
  background: rgba(231,76,60,0.1);
  border: 1px solid rgba(231,76,60,0.25);
  color: #f0a0a0;
}

#feedback-result {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

#feedback-hint {
  margin-top: 6px;
  color: var(--text-dim);
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

#feedback-hint svg { flex-shrink: 0; margin-top: 2px; }

#feedback-ext {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
  color: var(--accent);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

#feedback-ext svg { flex-shrink: 0; margin-top: 1px; }

.continue-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--accent), #d4a017);
  color: #1a1a2e;
  font-size: 12px;
  font-weight: 800;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 14px;
  display: none;
  transition: all 0.2s;
  font-family: var(--pixel-font), monospace;
  pointer-events: auto;
}

.continue-btn.visible { display: block; }
.continue-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(245,197,24,0.3); }

/* ========== 結算頁 ========== */
#result-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.8);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
  backdrop-filter: blur(6px);
}

#result-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.result-card {
  background: rgba(22, 33, 62, 0.97);
  border: 1px solid rgba(245,197,24,0.3);
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 440px;
  width: 92%;
  text-align: center;
  box-shadow: 0 16px 64px rgba(0,0,0,0.6);
}

.result-title {
  font-size: 18px;
  font-weight: 900;
  margin-bottom: 16px;
  font-family: var(--pixel-font), monospace;
}

.result-title.victory { color: var(--accent); }
.result-title.gameover { color: var(--danger); }

.rating-display {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px; height: 80px;
  border-radius: 16px;
  font-size: 40px;
  font-weight: 900;
  margin-bottom: 16px;
  border: 3px solid;
  font-family: var(--pixel-font), monospace;
}

.rating-S { background: rgba(255,215,0,0.15); border-color: #FFD700; color: #FFD700; }
.rating-A { background: rgba(192,192,192,0.15); border-color: #C0C0C0; color: #C0C0C0; }
.rating-B { background: rgba(205,127,50,0.15); border-color: #CD7F32; color: #CD7F32; }
.rating-C { background: rgba(156,39,176,0.15); border-color: #9C27B0; color: #9C27B0; }
.rating-D { background: rgba(33,150,243,0.15); border-color: #2196F3; color: #2196F3; }
.rating-E { background: rgba(76,175,80,0.15); border-color: #4CAF50; color: #4CAF50; }
.rating-F { background: rgba(121,85,72,0.15); border-color: #795548; color: #795548; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-item {
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  padding: 10px 8px;
}

.stat-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--pixel-font), monospace;
}

.stat-label {
  font-size: 8px;
  color: var(--text-dim);
  margin-top: 2px;
  font-family: var(--pixel-font), monospace;
}

.treasure-area {
  margin: 16px 0;
  padding: 16px;
  background: rgba(245,197,24,0.08);
  border: 1px dashed rgba(245,197,24,0.3);
  border-radius: 12px;
  display: none;
}

.treasure-area.visible { display: block; }

.treasure-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.treasure-icon svg { vertical-align: middle; }

.treasure-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.treasure-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}

.treasure-hint {
  font-size: 12px;
  color: var(--accent);
  margin-top: 6px;
  font-weight: 600;
}

.retry-btn {
  padding: 14px 40px;
  background: linear-gradient(135deg, var(--accent), #d4a017);
  color: #1a1a2e;
  font-size: 17px;
  font-weight: 800;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 1px;
}

.retry-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(245,197,24,0.4); }

/* ========== 提示浮窗 ========== */
.hint-toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(22, 33, 62, 0.95);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 50;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  border: 1px solid rgba(245,197,24,0.2);
  backdrop-filter: blur(8px);
  max-width: 85%;
  text-align: center;
}

.hint-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ========== 響應式 ========== */
@media (max-width: 600px) {
  .setup-card {
    padding: 20px 16px;
  }

  .setup-title { font-size: 22px; }
  .setup-subtitle { font-size: 12px; }

  .char-selector { gap: 10px; }
  #preview-canvas { width: 72px; height: 72px; }
  .color-swatch { width: 26px; height: 26px; }
  .skin-btn { padding: 4px 6px; font-size: 10px; }

  .question-card {
    padding: 18px 16px;
    max-width: 340px;
  }

  #question-text { font-size: 16px; }
  .option-btn { font-size: 14px; padding: 10px 12px; }

  .result-card {
    padding: 24px 18px;
    max-width: 340px;
  }

  .rating-display { width: 64px; height: 64px; font-size: 38px; }

  .hud-timer { font-size: 18px; }

  .action-btn { width: 52px; height: 52px; }
  .action-buttons { bottom: 18px; right: 16px; gap: 10px; }
}

@media (max-width: 380px) {
  .setup-card { padding: 16px 12px; }
  .question-card { padding: 14px 12px; }
  #question-text { font-size: 15px; }
  .option-btn { font-size: 13px; }
  .char-selector { flex-direction: column; align-items: center; }
}

/* ========== 桌面端隱藏移動端控制 ========== */
@media (hover: hover) and (pointer: fine) {
  #joystick-zone { display: none !important; }
  .action-buttons { display: none !important; }
}

/* ========== 排行榜 ========== */
.leaderboard-section {
  margin-top: 16px;
  width: 100%;
}

.lb-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--text);
  margin-bottom: 8px;
  justify-content: center;
  font-family: var(--pixel-font), monospace;
}

.lb-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 8px;
  padding: 12px 0;
  font-family: var(--pixel-font), monospace;
}

.lb-list-scroll {
  max-height: 160px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  margin-bottom: 3px;
  background: rgba(255,255,255,0.04);
  font-size: 8px;
  color: var(--text);
  transition: background 0.2s;
  font-family: var(--pixel-font), monospace;
}

.lb-row:hover {
  background: rgba(255,255,255,0.08);
}

.lb-row.top3 {
  background: rgba(255,215,0,0.06);
}

.lb-medal, .lb-rank {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.lb-medal.gold { background: #FFD700; color: #5a4800; }
.lb-medal.silver { background: #C0C0C0; color: #444; }
.lb-medal.bronze { background: #CD7F32; color: #fff; }
.lb-rank { background: rgba(255,255,255,0.08); color: var(--text-dim); }

.lb-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.lb-rating {
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.lb-rating.rating-S { color: #FFD700; }
.lb-rating.rating-A { color: #C0C0C0; }
.lb-rating.rating-B { color: #CD7F32; }
.lb-rating.rating-C { color: #9B59B6; }
.lb-rating.rating-D { color: #3498DB; }
.lb-rating.rating-E { color: #2ECC71; }
.lb-rating.rating-F { color: #E74C3C; }

.lb-score {
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
  min-width: 40px;
  text-align: right;
}

.lb-date {
  color: var(--text-dim);
  font-size: 10px;
  flex-shrink: 0;
}
