/* ===== LineRider 键音舞者 样式 ===== */
:root {
  --bg: #111111;
  --fg: #eeeeee;
  --panel: #1c1c1e;
  --panel-2: #262628;
  --border: #333333;
  --accent: #ff6b35;
  --accent-2: #ffb347;
  --white-key: #f5f5f5;
  --white-key-active: #ffd28a;
  --black-key: #222222;
  --black-key-active: #8a6a2f;
  --toast-bg: rgba(0,0,0,0.85);
}
[data-theme="light"] {
  --bg: #f7f7f7;
  --fg: #1a1a1a;
  --panel: #ffffff;
  --panel-2: #f0f0f0;
  --border: #d0d0d0;
  --accent: #e85a2b;
  --accent-2: #e0923a;
  --white-key: #ffffff;
  --white-key-active: #ffd28a;
  --black-key: #333333;
  --black-key-active: #8a6a2f;
  --toast-bg: rgba(0,0,0,0.8);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--fg);
  user-select: none;
  touch-action: none;
}
.hidden { display: none !important; }

/* ===== Canvas ===== */
/* 注意：canvas 是替换元素，top/bottom 拉伸不生效，必须显式设置 height，
   否则高度永远等于 height 属性的陈旧值，导致轨道贴顶、与键盘之间留空 */
#stage {
  display: block;
  position: absolute;
  top: 0; left: 0; right: 0;
  bottom: 180px;
  height: calc(100% - 180px);
  width: 100%;
  background: var(--bg);
  cursor: crosshair;
}
body.is-mobile #stage { bottom: 140px; height: calc(100% - 140px); }

/* ===== 菜单按钮 ===== */
.menu-btn {
  position: fixed;
  top: 12px; right: 12px;
  z-index: 100;
  width: 44px; height: 44px;
  border: none;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
}
.menu-btn span {
  width: 22px; height: 2.5px;
  background: var(--fg);
  border-radius: 2px;
}

/* ===== 左上角 Logo ===== */
.site-brand {
  position: fixed;
  top: 10px; left: 12px;
  z-index: 100;
  pointer-events: none;
}
.site-brand img {
  width: 46px; height: 46px;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
  background: #f5f5f5; /* 兜底底色（图片本身已透明化处理） */
}

/* ===== 顶部大标题 ===== */
.site-title {
  position: fixed;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 3px;
  pointer-events: none;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--accent);
  white-space: nowrap;
}
body.is-mobile .site-title { font-size: 15px; letter-spacing: 1px; }

/* ===== 输入法提示 ===== */
.ime-tip {
  position: fixed;
  top: 48px; left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: rgba(232,90,43,0.92);
  color: #fff;
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 12px;
  pointer-events: none;
}
body.is-mobile .ime-tip { display: none; }

/* ===== 钢琴键盘 ===== */
.keyboard {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 180px;
  background: var(--panel);
  border-top: 2px solid var(--border);
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  z-index: 10;
  padding: 0;
  scrollbar-width: thin;
}
body.is-mobile .keyboard { height: 140px; }

/* 白键容器（PC两排） */
.keyboard .piano-row {
  display: flex;
  position: relative;
  width: 100%;
  height: 100%;
}

.piano-key {
  flex-shrink: 0;
  height: 100%;
  border: 1px solid var(--border);
  border-top: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 6px;
  font-size: 11px;
  color: #999;
  transition: background 0.05s;
  position: relative;
  gap: 2px;
}
.piano-key.white {
  width: 60px;
  background: var(--white-key);
  color: #666;
}
.piano-key.white.active {
  background: var(--white-key-active);
}
.piano-key.black {
  width: 38px;
  height: 62%;
  background: var(--black-key);
  color: #bbb;
  z-index: 2;
  margin-left: -19px;
  margin-right: -19px;
  border-radius: 0 0 6px 6px;
  justify-content: center;
  padding-bottom: 0;
}
.piano-key.black.active {
  background: var(--black-key-active);
}
.piano-key .key-letter {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.piano-key.black .key-letter {
  font-size: 12px;
  color: #ffd28a;
}
.piano-key .note-name {
  font-size: 10px;
  color: #999;
  line-height: 1;
}

/* 移动端单行键盘 */
body.is-mobile .piano-key.white { width: 48px; }
body.is-mobile .piano-key.black { width: 30px; margin-left: -15px; margin-right: -15px; }

/* ===== 加载遮罩 ===== */
.loading-mask {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.loading-inner { text-align: center; max-width: 320px; padding: 0 20px; }
.loading-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.loading-sub { font-size: 13px; color: #888; margin-bottom: 20px; }
.loading-bar {
  width: 100%; height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  overflow: hidden;
}
.loading-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s;
}
.loading-text { margin-top: 10px; font-size: 12px; color: #888; }

/* ===== 音频激活提示 ===== */
.audio-prompt {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 900;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.audio-prompt-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 48px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}
.audio-prompt-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.audio-prompt-tip { font-size: 13px; color: #999; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 60px; left: 50%;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 2000;
  pointer-events: none;
  animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ===== 菜单面板 ===== */
.menu-panel {
  position: fixed;
  top: 0; right: -340px;
  width: 320px;
  max-width: 85vw;
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 500;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.3);
}
.menu-panel.open { right: 0; }
.menu-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-size: 17px; font-weight: 700;
}
.menu-close {
  background: none; border: none; color: var(--fg);
  font-size: 20px; cursor: pointer; width: 32px; height: 32px;
}
.menu-body { flex: 1; overflow-y: auto; padding: 16px; }

.menu-section { margin-bottom: 20px; }
.menu-section h3 { font-size: 14px; margin-bottom: 10px; color: var(--fg); display: flex; justify-content: space-between; align-items: center; }
.menu-section .val { font-size: 13px; color: var(--accent); font-weight: 600; }

.btn {
  background: var(--panel-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: var(--border); }
.btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-block { width: 100%; }

.song-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.song-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: background 0.15s;
}
.song-item:hover { background: var(--border); }
.song-item.playing { background: var(--accent); color: #fff; border-color: var(--accent); }

.song-controls { display: flex; gap: 8px; }
.song-controls .btn { flex: 1; }

.octave-btns, .theme-btns, .device-btns, .rec-btns { display: flex; gap: 6px; }
.octave-btns .btn, .theme-btns .btn, .device-btns .btn, .rec-btns .btn { flex: 1; }

.switch-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; cursor: pointer; }
.switch-row input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent); }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ===== 帮助弹窗 ===== */
.modal { position: fixed; inset: 0; z-index: 800; display: flex; align-items: center; justify-content: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-box {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 90%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal-body h4 { font-size: 14px; margin: 12px 0 6px; color: var(--accent); }
.modal-body p { font-size: 13px; line-height: 1.7; margin-bottom: 8px; }
.modal-body .warn { color: var(--accent-2); }
.keymap { width: 100%; font-size: 13px; margin-bottom: 8px; }
.keymap td { padding: 4px 8px; border-bottom: 1px solid var(--border); }
.modal-footer { margin-top: 18px; text-align: right; }

/* 录制指示 */
.rec-btns .btn.recording { background: #d32f2f; color: #fff; border-color: #d32f2f; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

/* 移动端优化 */
body.is-mobile .keyboard { height: 140px; }
