/* === 基础重置 & 全局 === */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif; background: #0a0a1a; color: #e0e0e0; }
#app { width: 100%; height: 100%; position: relative; }
.scene { display: none; width: 100%; height: 100%; position: absolute; top: 0; left: 0; }
.scene.active { display: flex; align-items: center; justify-content: center; }

/* === 按钮 === */
.btn-primary {
  padding: 12px 32px; border: none; border-radius: 8px;
  background: linear-gradient(135deg, #6c5ce7, #a855f7); color: #fff;
  font-size: 16px; cursor: pointer; transition: all 0.3s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(168,85,247,0.4); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-choice {
  padding: 14px 40px; border: 2px solid #a855f7; border-radius: 12px;
  background: transparent; color: #a855f7; font-size: 18px; cursor: pointer;
  transition: all 0.3s; animation: pulse 2s infinite;
}
.btn-choice:hover { background: #a855f7; color: #fff; }

/* === 开场剧情 === */
#scene-intro { background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a1a 100%); }
.story-box {
  max-width: 600px; padding: 40px; text-align: center;
}
.devil-avatar { font-size: 80px; margin-bottom: 20px; animation: float 3s ease-in-out infinite; }
.story-text { font-size: 18px; line-height: 1.8; min-height: 120px; text-align: left; }
.story-choices { margin-top: 30px; }

/* === 关卡选择 === */
#scene-hub { background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a1a 100%); }
.hub-container { text-align: center; }
.hub-title { font-size: 28px; margin-bottom: 40px; color: #a855f7; text-shadow: 0 0 20px rgba(168,85,247,0.3); }
.hub-stages { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; }
.stage-card {
  width: 200px; padding: 24px; border-radius: 16px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(168,85,247,0.3);
  cursor: pointer; transition: all 0.3s;
}
.stage-card:hover:not(.locked) { transform: translateY(-4px); border-color: #a855f7; box-shadow: 0 8px 30px rgba(168,85,247,0.2); }
.stage-card.locked { opacity: 0.5; cursor: not-allowed; }
.stage-card.cleared { border-color: #22c55e; }
.stage-card.cleared .stage-status { color: #22c55e; }
.stage-icon { font-size: 48px; margin-bottom: 12px; }
.stage-name { font-size: 16px; font-weight: bold; margin-bottom: 8px; }
.stage-desc { font-size: 13px; color: #888; margin-bottom: 12px; }
.stage-status { font-size: 13px; color: #f59e0b; }

/* === 游戏1: 追逃 === */
#scene-game1 { background: #111; }
#game1-canvas { width: 100%; height: 100%; display: block; }
.game-ui { position: absolute; top: 0; left: 0; width: 100%; padding: 12px 20px; z-index: 10; }
.game-ui-top { display: flex; justify-content: space-between; align-items: center; font-size: 16px; }
.debuff-indicator { padding: 4px 12px; border-radius: 20px; background: rgba(239,68,68,0.3); color: #ef4444; font-size: 14px; }
.game-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.8); display: flex; align-items: center;
  justify-content: center; z-index: 20; flex-direction: column; gap: 20px;
}
.game-overlay h2 { font-size: 36px; }
.game-overlay p { font-size: 18px; color: #aaa; }

/* === 游戏2: 抛硬币 === */
#scene-game2 { background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a1a 100%); }
.coin-game-container { width: 100%; max-width: 600px; padding: 20px; }
.coin-game-header { text-align: center; margin-bottom: 24px; }
.devil-speech {
  display: inline-block; padding: 12px 24px; border-radius: 16px;
  background: rgba(168,85,247,0.15); border: 1px solid rgba(168,85,247,0.3);
  font-size: 16px; max-width: 500px;
}
.coin-panel { text-align: center; position: relative; }
.coin-instruction { font-size: 16px; margin-bottom: 16px; }
.coin-options { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 20px; }
.coin-option {
  padding: 10px 16px; border-radius: 8px; border: 2px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.05); cursor: pointer; font-size: 18px;
  transition: all 0.2s; user-select: none;
}
.coin-option:hover { border-color: #a855f7; }
.coin-option.selected { border-color: #a855f7; background: rgba(168,85,247,0.2); }
  .coin-secret-area {
    position: absolute; bottom: 0px; right: 0px; width: 15px; height: 15px; 
    cursor: default; opacity: 0; z-index: 10;
  }
  .coin-secret-area:hover { opacity: 0; }
.coin-info-row { display: flex; justify-content: space-around; margin-bottom: 20px; font-size: 16px; }
.coin-flip-area { display: flex; justify-content: center; margin: 20px 0; }
.coin-visual { font-size: 64px; transition: transform 0.5s; }
.coin-visual.flipping { animation: coinFlip 0.5s ease-in-out; }
.coin-history { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; min-height: 40px; }
.coin-history-item {
  width: 36px; height: 36px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 14px; font-weight: bold;
}
.coin-history-item.heads { background: #f59e0b; color: #000; }
.coin-history-item.tails { background: #6b7280; color: #fff; }

/* 后手猜模态框 */
.secret-modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.85); display: flex; align-items: center;
  justify-content: center; z-index: 100;
}
.secret-modal-content {
  background: #1a1a2e; border: 1px solid #a855f7; border-radius: 16px;
  padding: 32px; max-width: 500px; width: 90%; text-align: center;
}
.secret-modal-content h3 { color: #a855f7; margin-bottom: 16px; }
.secret-modal-content p { font-size: 14px; color: #aaa; margin-bottom: 20px; line-height: 1.6; }

/* === 游戏3: 国王奴隶 === */
#scene-game3 { background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a1a 100%); }
.card-game-container { width: 100%; max-width: 600px; padding: 20px; }
.card-game-header { text-align: center; margin-bottom: 20px; }
.card-score { display: flex; justify-content: center; gap: 24px; margin-top: 12px; font-size: 16px; }
.card-game-body { display: flex; flex-direction: column; align-items: center; gap: 24px; }
.card-hand { display: flex; gap: 12px; justify-content: center; }
.card-back { font-size: 48px; opacity: 0.5; }
.game-card {
  width: 80px; height: 120px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; flex-direction: column;
  font-size: 14px; cursor: pointer; transition: all 0.3s;
  border: 2px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.05);
}
.game-card:hover { transform: translateY(-8px); border-color: #a855f7; }
.game-card .card-emoji { font-size: 36px; margin-bottom: 4px; }
.game-card.king { border-color: #f59e0b; }
.game-card.citizen { border-color: #6b7280; }
.game-card.slave { border-color: #ef4444; }
.card-battle-area {
  min-height: 140px; display: flex; align-items: center;
  justify-content: center; gap: 40px; font-size: 24px;
}
.card-result {
  text-align: center; margin-top: 20px; padding: 16px;
  border-radius: 12px; background: rgba(255,255,255,0.05);
}

/* === 通关画面 === */
#scene-victory { background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a1a 100%); }
.victory-container { text-align: center; padding: 40px; }
.victory-fireworks { font-size: 48px; margin-bottom: 20px; animation: float 2s ease-in-out infinite; }
.victory-title { font-size: 42px; color: #f59e0b; margin-bottom: 16px; text-shadow: 0 0 30px rgba(245,158,11,0.4); }
.victory-text { font-size: 18px; color: #ccc; margin-bottom: 20px; }
.victory-time { font-size: 24px; color: #a855f7; margin-bottom: 30px; }

/* === 动画 === */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168,85,247,0.4); }
  50% { box-shadow: 0 0 0 12px rgba(168,85,247,0); }
}
@keyframes coinFlip {
  0% { transform: rotateY(0); }
  50% { transform: rotateY(900deg) scale(1.2); }
  100% { transform: rotateY(1800deg); }
}
@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* === 响应式 === */
@media (max-width: 640px) {
  .hub-stages { flex-direction: column; align-items: center; }
  .stage-card { width: 90%; }
  .story-box { padding: 20px; }
  .story-text { font-size: 15px; }
  .devil-avatar { font-size: 60px; }
}