/* ============================================================
   打字大冒险 · 样式表
   设计：圆角卡片、渐变、Emoji 角色、童趣配色
   ============================================================ */

:root {
  --bg: #f3f7ff;
  --card: #ffffff;
  --ink: #2b2d42;
  --muted: #6b7280;
  --primary: #6c5ce7;
  --primary-dark: #4834d4;
  --accent: #ff7675;
  --gold: #ffb347;
  --green: #00b894;
  --shadow: 0 8px 24px rgba(80, 90, 160, 0.12);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ===================== 登录 / 注册 ===================== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #a8edea 0%, #fed6e3 50%, #e0c3fc 100%);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 26px;
  padding: 34px 30px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-logo { font-size: 30px; margin: 0 0 6px; }
.auth-sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }

.tabs { display: flex; gap: 8px; background: #eef1fb; padding: 6px; border-radius: 14px; margin-bottom: 20px; }
.tab {
  flex: 1; border: none; background: transparent; padding: 10px;
  border-radius: 10px; font-size: 15px; cursor: pointer; color: var(--muted);
  font-weight: 600; transition: .2s;
}
.tab.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(108,92,231,.3); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form input[type=text], .auth-form input[type=password] {
  padding: 14px 16px; border: 2px solid #e6e9f5; border-radius: 14px;
  font-size: 15px; outline: none; transition: .2s;
}
.auth-form input:focus { border-color: var(--primary); }

.avatar-label { font-size: 13px; color: var(--muted); margin: 4px 0 -4px; text-align: left; }
.avatar-picker { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.avatar-opt {
  font-size: 26px; width: 46px; height: 46px; border-radius: 14px;
  border: 2px solid #e6e9f5; background: #fafbff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: .15s;
}
.avatar-opt:hover { transform: translateY(-2px); }
.avatar-opt.selected { border-color: var(--primary); background: #efeaff; box-shadow: 0 4px 10px rgba(108,92,231,.25); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff; border: none; padding: 14px; border-radius: 14px;
  font-size: 16px; font-weight: 700; cursor: pointer; transition: .2s;
  box-shadow: 0 6px 16px rgba(108,92,231,.3);
}
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary.small { padding: 10px 14px; font-size: 14px; }

.auth-message { min-height: 18px; font-size: 13px; margin: 4px 0 0; }
.auth-message.error { color: var(--accent); }
.auth-message.ok { color: var(--green); }
.auth-demo { color: var(--muted); font-size: 12px; margin-top: 16px; }

/* ===================== 顶栏 ===================== */
.game-screen { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  background: linear-gradient(135deg, #6c5ce7 0%, #4834d4 100%);
  color: #fff; box-shadow: var(--shadow); flex-wrap: wrap;
}
.brand { font-size: 20px; font-weight: 800; white-space: nowrap; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 15px; }
.stat b { font-weight: 800; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.btn-ghost {
  background: rgba(255,255,255,.18); color: #fff; border: none;
  padding: 8px 12px; border-radius: 12px; cursor: pointer; font-size: 15px; transition: .2s;
}
.btn-ghost:hover { background: rgba(255,255,255,.32); }

/* ===================== 布局 ===================== */
.layout {
  flex: 1; display: grid; grid-template-columns: 1fr 340px;
  gap: 16px; padding: 16px; overflow: hidden;
}
.game-area {
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto; padding-right: 4px;
}
.side-panel { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }

/* 场景面板 */
.scene-panel {
  background: var(--card); border-radius: var(--radius); padding: 20px 24px;
  box-shadow: var(--shadow); transition: background .6s ease; min-height: 110px;
}
.scene-head { display: flex; align-items: center; justify-content: space-between; }
.scene-title { font-size: 24px; font-weight: 800; }
.scene-stars { font-size: 20px; letter-spacing: 2px; }
.scene-desc { margin: 8px 0 0; color: var(--ink); font-size: 15px; line-height: 1.6; }

/* 打字区 */
.play-area {
  background: var(--card); border-radius: var(--radius); padding: 26px 20px;
  box-shadow: var(--shadow); text-align: center; position: relative; min-height: 150px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.word-display { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.char {
  font-size: 40px; font-weight: 800; color: #c7ccdd; transition: .12s;
  border-bottom: 4px solid transparent; padding: 0 2px;
}
.char.typed { color: var(--green); }
.char.current {
  color: var(--primary); border-bottom-color: var(--gold);
  animation: bob .8s ease-in-out infinite;
}
.char.wrong { color: var(--accent); border-bottom-color: var(--accent); }
@keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }

.prompt {
  font-size: 18px; font-weight: 700; color: var(--gold);
  background: #fff7e6; padding: 8px 18px; border-radius: 999px;
}
.feedback-pop {
  position: absolute; top: 10px; right: 16px; font-size: 22px; font-weight: 800;
  opacity: 0; transition: .3s; pointer-events: none;
}
.feedback-pop.show { opacity: 1; transform: scale(1.15); }

/* 双手 */
.hands-zone { display: flex; justify-content: space-around; gap: 20px; background: var(--card);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.hand { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.fingers { display: flex; gap: 10px; align-items: flex-end; }
.finger {
  width: 34px; border-radius: 14px 14px 16px 16px; position: relative;
  background: linear-gradient(180deg, #ffe0b2 0%, #ffcc80 50%, #ffab91 100%);
  transform-origin: bottom center; transition: transform .12s, background .2s;
}
.finger .nail {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 18px; height: 12px; background: rgba(255,255,255,.55); border-radius: 50%;
}
.finger.pinky  { height: 50px; }
.finger.ring   { height: 60px; }
.finger.middle { height: 66px; }
.finger.index  { height: 58px; }
.finger.thumb   { width: 76px; height: 30px; border-radius: 18px; margin-top: 4px;
  background: linear-gradient(180deg, #ffe0b2 0%, #ffab91 100%); }
.finger.highlight {
  animation: pulse-finger .6s ease-in-out infinite;
  background: linear-gradient(180deg, #ffe082 0%, #ffd700 100%);
}
.finger.pressing {
  transform: scaleY(.62) translateY(14px);
  background: linear-gradient(180deg, #ffd700 0%, #ffb347 100%);
}
@keyframes pulse-finger { 0%,100%{box-shadow:0 0 0 0 rgba(255,193,7,.6)} 50%{box-shadow:0 0 0 10px rgba(255,193,7,0)} }
.palm { font-size: 14px; color: var(--muted); font-weight: 700; }

/* 键盘 */
.keyboard { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; align-items: center; }
.kb-row { display: flex; gap: 8px; justify-content: center; }
.key {
  width: 52px; height: 56px; border-radius: 12px; border: 2px solid #e6e9f5;
  background: #fafbff; font-size: 20px; font-weight: 800; color: var(--ink);
  display: flex; align-items: center; justify-content: center; transition: .1s;
  text-transform: uppercase; user-select: none;
}
.key.highlight {
  border-color: var(--gold); background: #fff7e0;
  box-shadow: 0 0 0 4px rgba(255,179,71,.35);
  transform: translateY(-4px);
}
.key.active { background: var(--gold); color: #fff; transform: translateY(2px) scale(.96); border-color: var(--gold); }

/* ===================== 侧栏面板 ===================== */
.panel { background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 12px; font-size: 16px; }
.ai-analysis { font-size: 14px; line-height: 1.7; color: var(--ink); }
.ai-analysis .ai-line { margin-bottom: 6px; }
.ai-analysis b { color: var(--primary); }
.ai-encourage { margin-top: 10px; font-size: 14px; color: var(--green); font-weight: 700;
  background: #eafaf3; padding: 8px 12px; border-radius: 12px; }

.online-list, .leaderboard-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.online-list li, .leaderboard-list li {
  display: flex; align-items: center; gap: 8px; font-size: 14px;
  background: #f6f8ff; padding: 8px 10px; border-radius: 10px;
}
.leaderboard-list li .rank { font-weight: 800; color: var(--primary); width: 22px; }
.leaderboard-list li .lb-xp { margin-left: auto; color: var(--gold); font-weight: 700; }

/* 聊天 */
.chat-panel { flex: 1; display: flex; flex-direction: column; min-height: 220px; }
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; max-height: 260px; }
.chat-msg { font-size: 13px; line-height: 1.5; }
.chat-msg .who { font-weight: 700; color: var(--primary); }
.chat-msg.system { color: var(--muted); font-style: italic; text-align: center; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input { flex: 1; padding: 10px 12px; border: 2px solid #e6e9f5; border-radius: 12px; outline: none; font-size: 14px; }
.chat-input-row input:focus { border-color: var(--primary); }

/* ===================== 关卡地图弹窗 ===================== */
.modal { position: fixed; inset: 0; background: rgba(20,20,40,.5); display: flex; align-items: center;
  justify-content: center; z-index: 50; padding: 20px; }
.modal-card { background: #fff; border-radius: 22px; padding: 24px; width: 100%; max-width: 640px;
  max-height: 86vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.level-cell {
  aspect-ratio: 1; border-radius: 14px; border: 2px solid #e6e9f5; background: #fafbff;
  font-size: 18px; font-weight: 800; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; transition: .15s; color: var(--ink);
}
.level-cell:hover:not(.locked) { transform: translateY(-3px); border-color: var(--primary); }
.level-cell.locked { opacity: .45; cursor: not-allowed; }
.level-cell.done { background: #eafaf3; border-color: var(--green); }
.level-cell .lv-num { font-size: 20px; }
.level-cell .lv-star { font-size: 12px; }

/* 庆祝粒子 */
.confetti { position: fixed; top: -10px; width: 10px; height: 14px; border-radius: 2px; z-index: 60; pointer-events: none; }

/* ===================== 响应式 ===================== */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; overflow-y: auto; }
  .side-panel { flex-direction: row; flex-wrap: wrap; }
  .side-panel .panel { flex: 1 1 240px; }
  .game-screen { height: auto; min-height: 100vh; }
}
