@import url('https://fonts.googleapis.com/css2?family=Zcool+KuaiLe&display=swap');

* { margin:0; padding:0; box-sizing:border-box; }
html {
  height:100%; overflow:hidden;
}
body {
  font-family:'Zcool KuaiLe','Microsoft YaHei',sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  height:100vh; height:100dvh; display:flex; justify-content:center; align-items:center;
  color:#333; overflow:hidden; position:fixed; width:100%; top:0; left:0;
}
.game-container {
  width:95%; max-width:900px; background:#fff8f0; border-radius:24px;
  box-shadow:0 25px 80px rgba(0,0,0,0.6); padding:20px 16px;
  text-align:center; position:relative; max-height:92vh; max-height:92dvh; min-height:0; height:92vh; height:92dvh;
  display:flex; flex-direction:column; overflow:hidden;
  /* screen绝对定位的参照 */
}
.hidden { display:none !important; }

/* ===== screen系统 ===== */
.screen {
  display:none; flex-direction:column; flex:1;
  position:absolute; top:0; left:0; width:100%; height:100%;
  background:#fff8f0; z-index:1;
}
.screen.active { display:flex; z-index:2; }

/* ===== 年级选择界面 ===== */
.grade-select-screen-inner { display:flex; flex-direction:column; align-items:center; gap:12px; animation:popIn 0.6s; flex:1; justify-content:center; }
/* ===== 角色选择界面 ===== */
.char-select-screen-inner { display:flex; flex-direction:column; align-items:center; gap:14px; animation:popIn 0.6s; flex:1; justify-content:center; }
/* ===== 怪物介绍界面 ===== */
.monster-intro-screen-inner { display:flex; flex-direction:column; align-items:center; gap:16px; animation:popIn 0.5s; flex:1; justify-content:center; }
/* ===== 奖励结算界面 ===== */
.reward-screen-inner { display:flex; flex-direction:column; align-items:center; gap:14px; animation:popIn 0.5s; flex:1; justify-content:center; }
/* ===== 结算界面 ===== */
.result-screen-inner { display:flex; flex-direction:column; align-items:center; gap:14px; animation:popIn 0.5s; flex:1; justify-content:center; }

@keyframes popIn { from{transform:scale(0.8);opacity:0} to{transform:scale(1);opacity:1} }
.title { font-size:38px; background:linear-gradient(90deg,#ff6b6b,#feca57,#1dd1a1,#54a0ff); -webkit-background-clip:text; color:transparent; font-weight:bold; }
.subtitle { font-size:17px; color:#777; }

.next-btn {
  background:linear-gradient(90deg,#6c5ce7,#a29bfe); color:#fff; border:none;
  border-radius:50px; padding:14px 48px; font-size:22px; font-family:inherit; cursor:pointer;
  box-shadow:0 8px 0 #4834d4,0 10px 20px rgba(0,0,0,0.15); margin-top:10px;
}
.next-btn:active { transform:translateY(4px); }

.role-select { display:flex; gap:18px; margin:8px 0; flex-wrap:wrap; justify-content:center; }
.role-card {
  width:170px; background:#fff; border-radius:16px; padding:14px 8px; cursor:pointer;
  border:3px solid transparent; box-shadow:0 4px 12px rgba(0,0,0,0.1); transition:0.2s;
  display:flex; flex-direction:column; align-items:center;
}
.role-card:hover { transform:translateY(-4px); }
.role-card.selected { border-color:#6c5ce7; box-shadow:0 0 0 4px rgba(108,92,231,0.2); }
.role-portrait {
  width:120px; height:140px; display:flex; align-items:center; justify-content:center;
  position:relative; margin-bottom:6px;
}
.role-portrait img {
  max-width:100%; max-height:100%; object-fit:contain;
  filter:drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}
.role-emoji-fallback { font-size:72px; line-height:1; filter:drop-shadow(0 4px 8px rgba(0,0,0,0.2)); }
.role-name { font-size:17px; margin-top:4px; color:#2c3e50; font-weight:bold; }
.role-desc { font-size:12px; color:#888; }
.role-stats { font-size:12px; color:#6c5ce7; margin-top:4px; font-weight:bold; }

.gender-select { display:flex; gap:12px; }
.gender-btn {
  padding:8px 24px; border-radius:50px; border:2px solid #ddd; background:#fff; cursor:pointer;
  font-size:16px; font-family:inherit; transition:0.2s;
}
.gender-btn.selected { border-color:#ff6b6b; background:#ffe0e0; color:#c0392b; font-weight:bold; }

/* 年级选择布局 */
.grade-select {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
    width: 100%;
    max-width: 560px;
}

.grade-row {
    display: flex;
    justify-content: center;
    gap: 12px;
}


.grade-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 20px;
    min-width: 160px;
    flex: 1;
    max-width: 260px;
    border: 2px solid #e0e0e0;
    border-radius: 16px;
    background: rgba(255,255,255,0.95);
    cursor: pointer;
    transition: all 0.3s ease;
    gap: 4px;
    position: relative;
    overflow: visible;
}

.grade-btn:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102,126,234,0.2);
}

.grade-btn.selected {
    border: 3px solid #FFD700;
    box-shadow: 
        0 0 0 3px #FFF,
        0 0 0 6px #FFD700,
        0 0 15px rgba(255, 215, 0, 0.4);
    background: linear-gradient(135deg, #FFF8E1, #FFFDE7);
    transform: scale(1.05);
    z-index: 1;
}

/* 花边装饰 - 虚线边框 */
.grade-btn.selected::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 2px dashed #FFD700;
    border-radius: inherit;
    pointer-events: none;
    animation: borderPulse 1.5s ease-in-out infinite;
}

/* 选中角标 ✓ */
.grade-btn.selected::after {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    background: #FFD700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* 花边闪烁动画 */
@keyframes borderPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.grade-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.grade-emoji {
    font-size: 24px;
    line-height: 1;
}

.grade-name {
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.grade-types {
    font-size: 12px;
    color: #888;
    text-align: center;
    line-height: 1.3;
}

.grade-btn.selected .grade-name {
    color: #E6A700;
}

.grade-btn.selected .grade-types {
    color: #E6A700;
}

.start-btn {
  background:linear-gradient(90deg,#ff6b6b,#feca57); color:#fff; border:none;
  border-radius:50px; padding:14px 48px; font-size:22px; font-family:inherit; cursor:pointer;
  box-shadow:0 8px 0 #e67e22,0 10px 20px rgba(0,0,0,0.15); margin-top:10px;
}
.start-btn:active { transform:translateY(4px); }
.start-btn:disabled { opacity:0.5; cursor:not-allowed; }

/* ===== 年级测试预览界面 ===== */
.grade-preview-screen {
  display:flex; flex-direction:column; align-items:center; gap:12px;
  animation:popIn 0.5s; flex:1; justify-content:center;
}
.preview-badge {
  background:linear-gradient(90deg,#6c5ce7,#a29bfe); color:#fff;
  padding:8px 28px; border-radius:50px; font-size:20px; font-weight:bold;
  box-shadow:0 4px 12px rgba(0,0,0,0.15);
}
.preview-desc { font-size:15px; color:#666; margin-top:2px; }
.preview-tip { font-size:14px; color:#888; margin-top:6px; }
.preview-list {
  display:flex; flex-direction:column; gap:10px;
  width:90%; max-width:420px; margin-top:4px;
}
.preview-item {
  background:#fff; border-radius:14px; padding:14px 16px;
  box-shadow:0 4px 12px rgba(0,0,0,0.08);
  border-left:4px solid #ff9f43;
  text-align:left;
}
.preview-q { font-size:18px; color:#2c3e50; font-weight:bold; }
.preview-a { font-size:14px; color:#27ae60; margin-top:4px; }

/* ===== 怪物介绍界面 ===== */
.intro-badge {
  background:linear-gradient(90deg,#ff6b6b,#feca57); color:#fff;
  padding:8px 28px; border-radius:50px; font-size:18px; font-weight:bold;
  box-shadow:0 4px 12px rgba(0,0,0,0.15);
}
.intro-monster-card {
  background:#fff; border-radius:20px; padding:24px 20px;
  box-shadow:0 8px 24px rgba(0,0,0,0.12); max-width:320px; width:90%;
  display:flex; flex-direction:column; align-items:center; gap:10px;
  border:3px solid #ffeaa7;
}
.intro-monster-portrait {
  width:150px; height:180px; display:flex; align-items:center; justify-content:center;
}
.intro-monster-portrait img {
  max-width:100%; max-height:100%; object-fit:contain;
  filter:drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}
.intro-monster-emoji { font-size:100px; line-height:1; filter:drop-shadow(0 4px 8px rgba(0,0,0,0.2)); }
.intro-monster-name { font-size:24px; font-weight:bold; color:#2c3e50; }
.intro-monster-desc { font-size:14px; color:#666; line-height:1.5; padding:0 8px; }
.intro-monster-stats {
  display:flex; gap:16px; margin-top:6px;
}
.intro-stat {
  display:flex; flex-direction:column; align-items:center; gap:2px;
  font-size:13px; color:#888;
}
.intro-stat b { font-size:16px; color:#2c3e50; }
.challenge-btn {
  background:linear-gradient(90deg,#ff6b6b,#ee5a24); color:#fff; border:none;
  border-radius:50px; padding:14px 48px; font-size:22px; font-family:inherit; cursor:pointer;
  box-shadow:0 8px 0 #c0392b,0 10px 20px rgba(0,0,0,0.15); margin-top:8px;
}
.challenge-btn:active { transform:translateY(4px); }

/* ===== 奖励结算界面 ===== */
.reward-title { font-size:32px; background:linear-gradient(90deg,#feca57,#ff6b6b); -webkit-background-clip:text; color:transparent; font-weight:bold; }
.reward-monster-name { font-size:18px; color:#555; }
.reward-stars { font-size:48px; margin:4px 0; }
.reward-board {
  display:flex; justify-content:space-around; width:100%; max-width:480px;
  margin-top:6px; gap:10px;
}
.reward-item {
  background:#fff; border-radius:16px; padding:14px 10px; flex:1;
  box-shadow:0 4px 12px rgba(0,0,0,0.08); font-size:14px; color:#666;
  border:2px solid #ffeaa7;
}
.reward-item span { font-size:22px; color:#ff6b6b; font-weight:bold; display:block; margin-top:4px; }
.reward-tip { font-size:15px; color:#888; margin-top:4px; }
.next-level-btn {
  background:linear-gradient(90deg,#1dd1a1,#10ac84); color:#fff; border:none;
  border-radius:50px; padding:14px 48px; font-size:20px; font-family:inherit; cursor:pointer;
  box-shadow:0 8px 0 #0e7c5c,0 10px 20px rgba(0,0,0,0.15); margin-top:8px;
}
.next-level-btn:active { transform:translateY(4px); }

/* ===== 战斗界面 ===== */
.battle-screen { display:flex; flex-direction:column; height:100%; flex:1; position:relative; }
.battle-scene-bg {
  position:absolute; top:0; left:0; width:100%; height:100%;
  background-size:cover; background-position:center; opacity:0.25;
  z-index:0; pointer-events:none; border-radius:24px;
}
.battle-header { font-size:18px; color:#555; margin-bottom:4px; font-weight:bold; position:relative; z-index:1; }

/* 战斗信息条 */
.battle-info-bar {
  display:flex; justify-content:center; gap:20px; margin-bottom:4px;
  position:relative; z-index:1;
}
.info-combo, .info-attack {
  background:#fff; border-radius:20px; padding:4px 14px;
  font-size:14px; font-weight:bold; box-shadow:0 2px 6px rgba(0,0,0,0.1);
}
.info-combo { color:#e74c3c; border:2px solid #fab1a0; }
.info-attack { color:#2c3e50; border:2px solid #74b9ff; }

/* 计时条 */
.timer-wrap {
  width:90%; max-width:500px; height:22px; background:#dfe6e9;
  border-radius:12px; overflow:hidden; border:2px solid #b2bec3;
  position:relative; margin:4px auto; z-index:1;
}
.timer-fill {
  height:100%; width:100%; background:linear-gradient(90deg,#1dd1a1,#10ac84);
  transition:width 0.1s linear;
}
.timer-fill.warning { background:linear-gradient(90deg,#feca57,#e67e22); }
.timer-fill.danger { background:linear-gradient(90deg,#ff6b6b,#c0392b); }
.timer-text {
  position:absolute; top:0; left:0; width:100%; height:100%;
  display:flex; align-items:center; justify-content:center;
  font-size:12px; color:#2c3e50; font-weight:bold; text-shadow:0 1px 0 rgba(255,255,255,0.8);
}

/* 左右横板战斗区 */
.battle-arena {
  flex:1; display:flex; align-items:center; justify-content:space-between;
  padding:10px 20px; position:relative; min-height:220px; z-index:1;
}
.combatant { width:38%; display:flex; flex-direction:column; align-items:center; position:relative; }
.combatant-name { font-size:16px; font-weight:bold; color:#444; margin-bottom:6px; }

.combatant-image {
  width:140px; height:170px; display:flex; align-items:center; justify-content:center;
  position:relative;
}
.combatant-image img {
  max-width:100%; max-height:100%; object-fit:contain;
  filter:drop-shadow(0 4px 8px rgba(0,0,0,0.2));
  transition:transform 0.3s;
}
.combatant-image .placeholder-emoji {
  font-size:90px; line-height:1; filter:drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

/* 血条/蓝条 */
.bar-wrap {
  width:85%; height:18px; background:#e0e0e0; border-radius:10px;
  overflow:hidden; border:2px solid #bbb; position:relative; margin-top:6px;
}
.bar-fill { height:100%; transition:width 0.4s ease; }
.bar-fill.hp-fill { background:linear-gradient(90deg,#27ae60,#2ecc71); }
.bar-fill.mp-fill { background:linear-gradient(90deg,#3498db,#5dade2); }
.bar-fill.monster-hp-fill { background:linear-gradient(90deg,#e74c3c,#c0392b); }
.bar-text {
  position:absolute; top:0; left:0; width:100%; height:100%;
  display:flex; align-items:center; justify-content:center;
  font-size:11px; color:#fff; text-shadow:0 1px 2px rgba(0,0,0,0.6); font-weight:bold;
}

.battle-center { width:20%; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.vs-text { font-size:28px; font-weight:bold; color:#bbb; text-shadow:0 2px 4px rgba(0,0,0,0.2); }
.battle-log { font-size:16px; color:#666; margin-top:8px; margin-bottom:8px; min-height:20px; text-align:center; line-height:1.4; }
.execute-bar { font-size:14px; color:#c0392b; font-weight:bold; margin-top:6px; }
.boss-badge { position:absolute; top:-4px; right:10px; background:#c0392b; color:#fff; padding:2px 10px; border-radius:12px; font-size:11px; font-weight:bold; }

/* ===== 攻击动画 ===== */
@keyframes playerLunge {
  0% { transform:translateX(0) scale(1); }
  40% { transform:translateX(80px) scale(1.08); }
  100% { transform:translateX(0) scale(1); }
}
@keyframes monsterLunge {
  0% { transform:translateX(0) scale(1); }
  40% { transform:translateX(-80px) scale(1.08); }
  100% { transform:translateX(0) scale(1); }
}
@keyframes hitShake {
  0%,100% { transform:translateX(0); }
  20% { transform:translateX(-12px); }
  40% { transform:translateX(12px); }
  60% { transform:translateX(-8px); }
  80% { transform:translateX(8px); }
}
@keyframes screenShake {
  0%,100% { transform:translate(0,0); }
  20% { transform:translate(-4px,3px); }
  40% { transform:translate(4px,-3px); }
  60% { transform:translate(-3px,2px); }
}
@keyframes slashFlash {
  0% { opacity:0; transform:scale(0.5) rotate(-20deg); }
  30% { opacity:1; transform:scale(1.2) rotate(0deg); }
  100% { opacity:0; transform:scale(1.5) rotate(20deg); }
}
@keyframes healRise {
  0% { opacity:0.8; transform:translateY(0) scale(1); }
  100% { opacity:0; transform:translateY(-60px) scale(1.3); }
}
@keyframes fireBurst {
  0% { opacity:0; transform:scale(0); }
  50% { opacity:1; transform:scale(1.2); }
  100% { opacity:0; transform:scale(1.5); }
}

.attack-lunge-player { animation:playerLunge 0.4s ease-in-out; }
.attack-lunge-monster { animation:monsterLunge 0.4s ease-in-out; }
.hit-shake { animation:hitShake 0.4s ease-in-out; }
.screen-shake { animation:screenShake 0.35s ease-in-out; }

/* 技能特效层 */
.effect-overlay {
  position:absolute; top:0; left:0; width:100%; height:100%;
  pointer-events:none; display:flex; align-items:center; justify-content:center;
}
.effect-fire::before {
  content:"🔥"; font-size:80px; opacity:0;
  animation:fireBurst 0.6s forwards;
}
.effect-holy::before {
  content:"✨"; font-size:80px; opacity:0;
  animation:healRise 0.8s forwards;
}
.effect-shield::before {
  content:"⚡"; font-size:80px; opacity:0;
  animation:slashFlash 0.5s forwards;
}
.effect-heal::before {
  content:"💚"; font-size:60px; opacity:0;
  animation:healRise 1s forwards;
}

/* ===== 题目区 ===== */
.question-area { margin-top:4px; position:relative; z-index:1; }
.question-card {
  background:linear-gradient(135deg,#dff9fb,#c7ecee); border-radius:16px;
  padding:18px 14px; margin-bottom:10px; border:3px dashed #22a6b3; position:relative;
}
.question-type {
  position:absolute; top:-10px; left:50%; transform:translateX(-50%);
  background:#ff9f43; color:#fff; padding:3px 14px; border-radius:20px; font-size:14px;
}
.question-text { font-size:32px; color:#2c3e50; margin-top:4px; letter-spacing:2px; }

.options { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:8px 0; }
.option-btn {
  background:linear-gradient(135deg,#ff6b6b,#ee5a24); color:#fff; border:none;
  border-radius:12px; padding:14px; font-size:22px; font-family:inherit; cursor:pointer;
  box-shadow:0 5px 0 #c0392b,0 6px 12px rgba(0,0,0,0.12); transition:0.1s;
}
.option-btn:nth-child(2){background:linear-gradient(135deg,#1dd1a1,#10ac84);box-shadow:0 5px 0 #0e7c5c,0 6px 12px rgba(0,0,0,0.12)}
.option-btn:nth-child(3){background:linear-gradient(135deg,#54a0ff,#2e86de);box-shadow:0 5px 0 #1a6fc4,0 6px 12px rgba(0,0,0,0.12)}
.option-btn:nth-child(4){background:linear-gradient(135deg,#feca57,#f39c12);box-shadow:0 5px 0 #d35400,0 6px 12px rgba(0,0,0,0.12)}
.option-btn:active{transform:translateY(3px);box-shadow:0 2px 0 #aaa,0 3px 5px rgba(0,0,0,0.1)}
.option-btn.correct{background:linear-gradient(135deg,#1dd1a1,#10ac84)!important;box-shadow:0 0 16px #1dd1a1}
.option-btn.wrong{background:linear-gradient(135deg,#ff4757,#c0392b)!important;box-shadow:0 0 16px #ff4757}
.option-btn:disabled{cursor:not-allowed;opacity:0.9}

.feedback{font-size:18px;min-height:24px;margin:4px 0;font-weight:bold;text-align:center}
.feedback.good{color:#27ae60}
.feedback.bad{color:#e74c3c}

.skill-bar{display:flex;justify-content:center;gap:12px;margin-top:8px}
.skill-btn{
  padding:8px 18px;border-radius:12px;border:none;font-family:inherit;font-size:14px;
  cursor:pointer;color:#fff;box-shadow:0 4px 0 rgba(0,0,0,0.2);transition:0.15s;
}
.skill-btn:active{transform:translateY(2px)}
.skill-btn.heal{background:linear-gradient(135deg,#1dd1a1,#10ac84)}
.skill-btn.attack{background:linear-gradient(135deg,#ff6b6b,#ee5a24)}
.skill-btn:disabled{opacity:0.4;cursor:not-allowed;transform:none!important}

/* ===== 浮动伤害数字 ===== */
#floatingContainer{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:200}
.floating-text{
  position:absolute;font-size:24px;font-weight:bold;pointer-events:none;
  animation:floatUp 1.2s forwards;z-index:200;
  text-shadow:0 2px 4px rgba(0,0,0,0.4), 0 0 2px rgba(255,255,255,0.8);
  white-space:nowrap;
}
@keyframes floatUp{
  0%{transform:translate(-50%, 0) scale(1);opacity:1}
  100%{transform:translate(-50%, -55px) scale(1.3);opacity:0}
}

/* ===== 结算界面 ===== */
.result-stars{font-size:52px;margin:6px 0}
.result-msg{font-size:18px;color:#555}
.score-board{display:flex;justify-content:space-around;width:100%;margin-top:6px;font-size:15px;color:#555}
.score-item span{font-size:20px;color:#ff6b6b;font-weight:bold}
.restart-btn{background:linear-gradient(90deg,#ff6b6b,#feca57);color:#fff;border:none;border-radius:50px;padding:14px 40px;font-size:20px;font-family:inherit;cursor:pointer;box-shadow:0 6px 0 #e67e22}
.restart-btn:active{transform:translateY(3px)}

/* 闪红 */
.flash-red{animation:flashRed 0.3s}
@keyframes flashRed{0%,100%{box-shadow:inset 0 0 0 rgba(255,0,0,0)}50%{box-shadow:inset 0 0 50px rgba(231,76,60,0.35)}}

/* ===== 登录界面样式 ===== */
.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    background: #fff8f0;
}
.logo-container {
    margin-bottom: 40px;
}
.main-logo {
    max-width: 380px;
    width: 85vw;
    height: auto;
    filter: drop-shadow(0 6px 16px rgba(0,0,0,0.15));
    animation: logoFloat 3s ease-in-out infinite;
}
@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.start-game-btn {
    padding: 16px 60px;
    font-size: 22px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 0 #4834d4, 0 8px 20px rgba(108, 92, 231, 0.3);
    transition: all 0.3s ease;
    letter-spacing: 4px;
    font-family: inherit;
}
.start-game-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 0 #4834d4, 0 10px 30px rgba(108, 92, 231, 0.4);
}
.start-game-btn:active {
    transform: scale(0.98);
}
.btn-primary {
    width: 100%;
    padding: 12px;
    margin-top: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s;
    font-family: inherit;
}
.btn-primary:hover { transform: scale(1.02); }
.top-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    position: absolute;
    top: 0;
    right: 0;
    z-index: 10;
}
.user-display {
    font-size: 14px;
    color: #666;
}
.btn-small {
    padding: 6px 12px;
    border: 1px solid #667eea;
    border-radius: 6px;
    background: white;
    color: #667eea;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}
.btn-small:hover { background: #667eea; color: white; }

/* ===== 历史战绩样式 ===== */
.history-container {
    padding: 40px 20px;
    max-width: 600px;
    margin: 0 auto;
    flex: 1;
}
.history-container h2 {
    font-size: 28px;
    background: linear-gradient(90deg,#ff6b6b,#feca57,#1dd1a1,#54a0ff);
    -webkit-background-clip:text;
    color:transparent;
    margin-bottom: 16px;
}
.history-list {
    max-height: 60vh;
    overflow-y: auto;
    margin: 20px 0;
}
.history-item {
    background: rgba(255,255,255,0.9);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.history-item .info { flex: 1; }
.history-item .info h4 { margin: 0 0 4px; color: #333; }
.history-item .info p { margin: 0; font-size: 12px; color: #999; }
.history-item .score {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
}
.history-item .victory { color: #27ae60; }
.history-item .defeat { color: #e74c3c; }

/* 音乐控制按钮 */
.music-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 9999;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(102,126,234,0.3);
    background: rgba(255,255,255,0.9);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 0;
    line-height: 1;
}
.music-toggle:hover {
    transform: scale(1.1);
    border-color: #667eea;
}
.music-toggle.muted {
    opacity: 0.5;
}

/* ===== 移动端适配 ===== */

/* 触摸优化 */
* {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* 防止iOS上输入框放大 */
input, select, textarea {
    font-size: 16px !important;
}

/* 小屏幕适配 */
@media screen and (max-width: 768px) {
    /* 登录界面 */
    .main-logo {
        max-width: 320px;
    }
    .start-game-btn {
        padding: 14px 50px;
        font-size: 20px;
    }
    
    /* 年级选择页面 - 紧凑布局 */
    .grade-select-screen-inner {
        padding: 10px 12px;
        display: flex;
        flex-direction: column;
        align-items: center;
        min-height: 100%;
        justify-content: center;
    }
    .grade-select-screen-inner .title {
        font-size: 20px;
        margin-bottom: 4px;
    }
    .grade-select-screen-inner .subtitle {
        font-size: 12px;
        margin-bottom: 12px;
    }
    
    /* 年级按钮改为单列 */
    .grade-select {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        width: 100%;
        max-width: 340px;
        margin: 8px 0;
    }
    .grade-row, .kindergarten-row {
        display: contents;
    }
    .grade-btn {
        padding: 10px 8px;
        min-width: auto;
        width: 90%;
        max-width: 320px;
        flex: none;
        border-radius: 12px;
    }
    .grade-header {
        gap: 6px;
        margin-bottom: 2px;
    }
    .grade-emoji {
        font-size: 20px;
    }
    .grade-name {
        font-size: 14px;
    }
    .grade-types {
        font-size: 11px;
        line-height: 1.2;
    }
    
    /* 下一步按钮 */
    .next-btn {
        margin-top: 12px;
        padding: 12px 24px;
        font-size: 15px;
        width: 80%;
        max-width: 200px;
    }
    
    /* 顶部栏紧凑 */
    .top-bar {
        position: relative;
        padding: 4px 8px;
    }
    
    /* 角色选择页面 - flex全屏适配，确保按钮可见 */
    #charSelectScreen.active {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }
    .char-select-screen-inner {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100%;
        padding: 12px 16px;
        gap: 12px;
    }
    .char-select-screen-inner .title {
        font-size: 20px;
        flex-shrink: 0;
    }
    .char-select-screen-inner .subtitle {
        font-size: 13px;
        flex-shrink: 0;
    }
    .role-select {
        display: flex;
        flex-direction: row;
        justify-content: center;
        gap: 16px;
        width: 100%;
        flex-shrink: 1;
        min-height: 0;
    }
    .role-card {
        width: 45%;
        max-width: 170px;
        padding: 12px;
        display: flex;
        flex-direction: column;
        align-items: center;
        flex-shrink: 1;
        min-height: 0;
    }
    .role-portrait {
        width: 100%;
        max-width: 120px;
        height: auto;
        max-height: 28vh;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .role-portrait img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }
    .role-emoji-fallback {
        font-size: min(56px, 10vh);
    }
    .role-name {
        font-size: 15px;
        margin: 6px 0 2px;
        flex-shrink: 0;
    }
    .role-desc {
        font-size: 12px;
        flex-shrink: 0;
    }
    .role-stats {
        font-size: 11px;
    }
    .gender-select {
        flex-shrink: 0;
    }
    .gender-btn {
        padding: 6px 18px;
        font-size: 14px;
    }
    .start-btn {
        flex-shrink: 0;
        padding: 12px 28px;
        font-size: 16px;
        margin-top: 8px;
    }
    
    /* 怪物介绍 */
    .intro-monster-card {
        width: 90%;
        max-width: 300px;
    }
    
    /* ===== 手机端战斗界面重新设计 ===== */
    
    /* 战斗界面整体 - 只在active时生效 */
    #battleScreen.active {
        flex-direction: column;
        height: 100%;
        overflow-y: auto;
        padding-top: 0;
    }
    
    /* 关卡标题 */
    .battle-header {
        font-size: 13px;
        padding: 8px 12px;
        text-align: center;
        flex-shrink: 0;
    }
    
    /* 计时条 */
    .timer-wrap {
        height: 6px;
        margin: 0 12px 4px;
        flex-shrink: 0;
    }
    .timer-text {
        font-size: 0;
    }
    
    /* 战斗区域 - 角色居中显示 */
    .battle-arena {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 12px;
        padding: 8px 16px;
        min-height: auto;
        flex-shrink: 0;
    }
    
    /* 玩家和怪物区域 */
    .combatant {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        width: auto;
    }
    
    /* 角色头像 - 尽可能大且对称 */
    .combatant-image, .character-portrait, .monster-portrait {
        width: 110px;
        height: 110px;
    }
    .combatant-image img, .character-portrait img, .monster-portrait img {
        max-width: 100px;
        max-height: 100px;
    }
    .combatant-image .placeholder-emoji {
        font-size: 56px;
    }

    /* 确保玩家和怪物区域对称 */
    .player-section, .monster-section {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        max-width: 140px;
    }
    
    /* VS标志 */
    .battle-center {
        width: auto;
    }
    .vs-text {
        font-size: 16px;
        padding: 4px;
    }
    
    /* HP/MP条 */
    .bar-wrap {
        width: 100px;
        height: 8px;
    }
    .bar-text {
        font-size: 0;
    }
    
    /* 战斗信息条 */
    .battle-info-bar {
        display: flex;
        justify-content: center;
        gap: 16px;
        font-size: 12px;
        padding: 4px 12px;
        flex-shrink: 0;
    }
    
    /* 题目卡片 */
    .question-card {
        margin: 6px 12px;
        padding: 10px 14px;
        flex-shrink: 0;
    }
    .question-type {
        font-size: 11px;
    }
    .question-text {
        font-size: 20px;
        font-weight: bold;
    }
    
    /* 选项网格 */
    .options {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 4px 12px;
        flex-shrink: 0;
    }
    .option-btn {
        padding: 14px 8px;
        font-size: 18px;
        font-weight: bold;
        min-height: 48px;
        border-radius: 12px;
    }
    
    /* 技能栏 */
    .skill-bar {
        display: flex;
        justify-content: center;
        gap: 12px;
        padding: 6px 12px;
        flex-shrink: 0;
    }
    .skill-btn {
        padding: 8px 16px;
        font-size: 12px;
        min-height: 36px;
    }
    
    /* 战斗日志 - 放最底部 */
    .battle-log {
        font-size: 14px;
        padding: 4px 12px;
        margin-bottom: 8px;
        max-height: 30px;
        overflow: hidden;
        text-align: center;
        flex-shrink: 0;
    }
    
    /* 反馈信息 */
    .feedback {
        font-size: 13px;
        padding: 4px;
        text-align: center;
    }
    
    /* 斩杀进度条 */
    .execute-bar {
        margin: 0 12px;
        height: 6px;
    }
    
    /* 结算界面 */
    .reward-screen-inner, .result-screen-inner {
        padding: 20px;
    }
    
    /* 历史战绩 */
    .history-container {
        padding: 20px 12px;
    }
    .history-item {
        padding: 12px;
    }
    .history-item .score {
        font-size: 20px;
    }
    
    /* 顶部工具栏 */
    .top-bar {
        padding: 6px 10px;
        gap: 6px;
    }
    .btn-small {
        padding: 4px 8px;
        font-size: 11px;
    }
    .user-display {
        font-size: 12px;
    }
    
    /* 音乐按钮 */
    .music-toggle {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }
    
    /* 战斗日志（已在上方战斗界面重设计中处理） */
}

/* 超小屏幕（iPhone SE等） */
@media screen and (max-width: 375px) {
    .main-logo {
        max-width: 280px;
    }
    .grade-select {
        gap: 6px;
        max-width: 300px;
    }
    .grade-row, .kindergarten-row {
        display: contents;
    }
    .grade-btn {
        padding: 8px 6px;
        width: 90%;
        max-width: 300px;
    }
    .grade-header {
        gap: 4px;
        margin-bottom: 2px;
    }
    .grade-emoji {
        font-size: 16px;
    }
    .grade-name {
        font-size: 12px;
    }
    .grade-types {
        font-size: 9px;
    }
    .grade-select-screen-inner .title {
        font-size: 18px;
    }
    /* 角色选择 - 超小屏 flex适配 */
    .role-portrait {
        max-height: 22vh;
        max-width: 100px;
    }
    .role-emoji-fallback {
        font-size: min(44px, 8vh);
    }
    .role-card {
        padding: 8px;
    }
    .role-name {
        font-size: 13px;
    }
    .role-desc {
        font-size: 10px;
    }
    .question-text {
        font-size: 18px;
    }
    .option-btn {
        font-size: 16px;
        padding: 12px 6px;
        min-height: 44px;
    }
    .options {
        gap: 6px;
    }
    .combatant-image, .character-portrait, .monster-portrait {
        width: 90px;
        height: 90px;
    }
    .combatant-image img, .character-portrait img, .monster-portrait img {
        max-width: 80px;
        max-height: 80px;
    }
    .combatant-image .placeholder-emoji {
        font-size: 48px;
    }
    .player-section, .monster-section {
        max-width: 120px;
    }
    .bar-wrap {
        width: 80px;
    }
    .battle-log {
        font-size: 13px;
    }
}

/* 横屏适配 */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .battle-arena {
        flex-direction: row;
        padding: 4px;
    }
    .combatant {
        flex-direction: column;
    }
    .question-card {
        padding: 8px;
        margin-bottom: 4px;
    }
    .question-text {
        font-size: 16px;
    }
    .options {
        grid-template-columns: 1fr 1fr 1fr 1fr;
        gap: 4px;
    }
    .option-btn {
        padding: 8px 4px;
        font-size: 14px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .grade-btn, .option-btn, .skill-btn, .btn-primary, .challenge-btn, .next-btn {
        min-height: 44px; /* Apple推荐的最小触摸目标 */
    }
    .option-btn:active {
        transform: scale(0.95);
    }
    .grade-btn:active {
        transform: scale(0.97);
    }
}
