:root {
  --bg: #0e1030;
  --bg2: #1a1c4b;
  --card: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.14);
  --text: #f2f3ff;
  --muted: #a9adda;
  --accent: #ff5b9e;
  --accent2: #5bd6ff;
  --accent3: #ffd15b;
  --good: #57e39a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  overflow: hidden;
  background: radial-gradient(1200px 800px at 50% -10%, #2a2d6e 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}

#app { position: fixed; inset: 0; }

.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
.screen.active { display: flex; }

/* 顶部栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; min-height: 44px;
}
.topbar .back {
  background: var(--card); border: 1px solid var(--card-border);
  color: var(--text); font-size: 16px; padding: 8px 14px; border-radius: 12px;
}
.topbar-title { font-size: 17px; font-weight: 600; }
.topbar-right { width: 64px; }

/* 首页 */
#screen-home { justify-content: space-between; padding: calc(var(--safe-top) + 8px) 20px calc(var(--safe-bottom) + 16px); }
.home-top { text-align: center; margin-top: 8vh; }
.logo { font-size: 64px; filter: drop-shadow(0 8px 20px rgba(255,91,158,.4)); }
.title { font-size: 34px; margin: 8px 0 4px; letter-spacing: 2px; }
.subtitle { color: var(--muted); margin: 0; font-size: 14px; }

.home-cards { display: flex; flex-direction: column; gap: 16px; margin-bottom: 4vh; }
.home-card {
  display: flex; align-items: center; gap: 16px;
  padding: 20px; border-radius: 22px;
  border: 1px solid var(--card-border);
  background: var(--card); color: var(--text);
  text-align: left; font: inherit;
  transition: transform .08s ease;
}
.home-card:active { transform: scale(.97); }
.hc-icon { font-size: 34px; }
.hc-text { display: flex; flex-direction: column; }
.hc-text b { font-size: 20px; }
.hc-text small { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-play  { background: linear-gradient(135deg, rgba(91,214,255,.22), var(--card)); }
.card-follow{ background: linear-gradient(135deg, rgba(255,91,158,.22), var(--card)); }
.card-game  { background: linear-gradient(135deg, rgba(255,209,91,.22), var(--card)); }

.parent-entry {
  align-self: center; background: transparent; border: none;
  color: var(--muted); font-size: 13px; padding: 8px 16px; opacity: .6;
}

/* 通用 chip / 按钮 */
.chip {
  background: var(--card); border: 1px solid var(--card-border);
  color: var(--text); padding: 9px 14px; border-radius: 14px; font-size: 15px;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.big-btn {
  background: var(--accent); color: #fff; border: none;
  padding: 14px 26px; border-radius: 16px; font-size: 18px; font-weight: 600;
}
.big-btn.ghost { background: var(--card); border: 1px solid var(--card-border); }

/* 自由弹控制 */
.freeplay-controls {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 4px 12px 10px; flex-wrap: wrap;
}
.ctrl-group { display: flex; gap: 8px; align-items: center; }
.octave-label { font-size: 13px; color: var(--muted); min-width: 52px; text-align: center; }

/* 键盘 */
.keyboard-wrap {
  flex: 1; display: flex; align-items: flex-end;
  padding: 8px 8px calc(var(--safe-bottom) + 10px);
}
.keyboard {
  position: relative; width: 100%; height: 100%;
  display: flex; gap: 4px;
}
.wkey {
  position: relative; flex: 1; height: 100%;
  background: linear-gradient(#fff, #eef);
  border-radius: 0 0 10px 10px;
  box-shadow: 0 6px 0 #b9bce0, 0 8px 12px rgba(0,0,0,.35);
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 10px; color: #6b6fa6; font-size: 12px; font-weight: 600;
}
.wkey.pressed { background: linear-gradient(#ffe3f0, #ffc3df); transform: translateY(2px); box-shadow: 0 3px 0 #b9bce0; }
.wkey.glow { background: linear-gradient(#c8fff0, #7bf0d0); box-shadow: 0 0 0 3px var(--good), 0 6px 0 #3fae82; }
.bkey {
  position: absolute; top: 0; width: 12%; height: 62%;
  background: linear-gradient(#333, #000);
  border-radius: 0 0 8px 8px; z-index: 5;
  box-shadow: 0 5px 0 #000, 0 7px 10px rgba(0,0,0,.5);
  transform: translateX(-50%);
}
.bkey.pressed { background: linear-gradient(#a03060, #6a1030); transform: translateX(-50%) translateY(2px); }
.bkey.glow { background: linear-gradient(#2fae82, #0d7a55); box-shadow: 0 0 0 3px var(--good); }

/* 曲库列表 */
.song-list { flex: 1; overflow-y: auto; padding: 6px 16px calc(var(--safe-bottom) + 20px); -webkit-overflow-scrolling: touch; }
.song-item {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; margin-bottom: 12px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--card-border);
}
.song-item:active { transform: scale(.98); }
.song-cover { font-size: 30px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.08); border-radius: 14px; }
.song-meta { flex: 1; }
.song-meta b { font-size: 17px; }
.song-meta small { display: block; color: var(--muted); margin-top: 3px; font-size: 12px; }
.song-diff { font-size: 12px; color: var(--accent3); }

/* 跟弹 */
.follow-stage { padding: 10px 16px 4px; text-align: center; }
.follow-hint { font-size: 16px; color: var(--accent2); margin-bottom: 10px; min-height: 22px; }
.follow-progress { height: 8px; background: rgba(255,255,255,.1); border-radius: 6px; overflow: hidden; margin-bottom: 12px; }
.follow-progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent2), var(--good)); transition: width .18s ease; }
.follow-buttons { display: flex; gap: 10px; justify-content: center; }

/* 游戏 */
.game-hud { display: flex; justify-content: space-around; padding: 6px 0 10px; font-size: 15px; color: var(--muted); }
.game-hud b { color: var(--text); font-size: 20px; }
.game-canvas-wrap { position: relative; flex: 1; margin: 0 8px calc(var(--safe-bottom) + 8px); border-radius: 18px; overflow: hidden; background: rgba(0,0,0,.25); }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.game-start-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(14,16,48,.72); backdrop-filter: blur(4px); }
.gso-inner { text-align: center; padding: 24px; }
.gso-inner p { margin-bottom: 18px; font-size: 16px; }

/* 家长 */
.parent-body { padding: 16px 20px; overflow-y: auto; }
.parent-row { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.parent-row label { min-width: 44px; }
.parent-row input[type=range] { flex: 1; }
.parent-card { background: var(--card); border: 1px solid var(--card-border); border-radius: 18px; padding: 18px; }
.parent-card h3 { margin: 0 0 10px; }
.parent-card ul { padding-left: 18px; color: var(--text); }
.parent-card li { margin: 6px 0; }
.muted { color: var(--muted); font-size: 13px; }

/* 结算 */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: none;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(6,7,25,.8); backdrop-filter: blur(6px);
}
.overlay.show { display: flex; }
.result-card {
  width: 100%; max-width: 340px; text-align: center;
  background: linear-gradient(160deg, #24276a, #15173f);
  border: 1px solid var(--card-border); border-radius: 26px; padding: 30px 24px;
  animation: pop .3s ease;
}
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.result-emoji { font-size: 56px; }
.result-card h2 { margin: 10px 0 6px; }
.result-stars { font-size: 30px; letter-spacing: 4px; margin: 6px 0; }
.result-sub, #result-sub { color: var(--muted); font-size: 14px; margin: 6px 0 20px; }
.result-buttons { display: flex; gap: 12px; justify-content: center; }
