/* ============================================================
   三角洲口琴 · 移动端横屏适配样式
   核心参考：三角洲行动手游口琴界面
   布局：横屏三列 — [曲谱面板] [口琴核心区] [曲目列表]
   ============================================================ */

/* ===== 启动蒙层 ===== */
.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background:
    radial-gradient(900px 500px at 50% 30%, rgba(255, 181, 71, 0.18), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: opacity .35s ease;
}
.boot-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.boot-overlay.error {
  background:
    radial-gradient(900px 500px at 50% 30%, rgba(255, 107, 107, 0.18), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}
.boot-card {
  width: min(420px, 86vw);
  padding: 28px 28px 22px;
  background: linear-gradient(180deg, #1a1d24, #11141b);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}
.boot-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
.boot-icon svg { animation: bob 1.6s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.boot-title {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--accent-2);
}
.boot-sub {
  margin: 0 0 18px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
}
.boot-bar {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  overflow: hidden;
}
.boot-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffb547, #44d39b);
  transition: width .25s ease;
}
.boot-text {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.boot-card .retry-btn {
  margin-top: 14px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.15);
  color: #ffd2d2;
  cursor: pointer;
  font-size: 13px;
}
.boot-card .retry-btn:hover { background: rgba(255, 107, 107, 0.25); }

/* ===== 变量 ===== */
:root {
  --bg-1: #0f1115;
  --bg-2: #161922;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e7eaf0;
  --muted: #8b93a7;
  --accent: #ffb547;
  --accent-2: #ffd07a;
  --success: #44d39b;
  --danger: #ff6b6b;
  --warn: #ffcb47;
  --info: #6aa9ff;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);

  /* 口琴铜色 */
  --harm-gold: #c9963a;
  --harm-gold-light: #e0b86e;
  --harm-gold-dark: #8a6420;
  /* 圆孔 */
  --hole-bg: #0a0c10;
  --hole-glow: rgba(255, 181, 71, 0.55);
  /* 模式按钮 */
  --mode-active-bg: rgba(255, 181, 71, 0.22);
  --mode-active-border: rgba(255, 181, 71, 0.7);
}

* { box-sizing: border-box; }

html, body, * {
  margin: 0;
  padding: 0;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
html {
  height: 100%;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(255, 181, 71, 0.15), transparent 60%),
    radial-gradient(900px 600px at -10% 100%, rgba(106, 169, 255, 0.12), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}
body {
  height: 100%;
}

/* ===== 主应用 ===== */
#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  gap: 8px;
}

/* ===== 顶栏 ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.topbar-center {
  flex: 1;
  text-align: center;
}
.song-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-2);
}
.topbar-right {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* 调号指示器 */
.pitch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
}
.pitch-tag {
  font-weight: 700;
  font-size: 13px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #e7eaf0;
  min-width: 40px;
  text-align: center;
}
.pitch.down .pitch-tag { background: rgba(106, 169, 255, 0.2); color: #cfe1ff; }
.pitch.up .pitch-tag { background: rgba(255, 181, 71, 0.2); color: #ffe2b0; }
.pitch.half .pitch-tag { background: rgba(255, 203, 71, 0.2); color: #ffcb47; }
.pitch-hint { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ===== 按钮 ===== */
.btn {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-callout: none;
}
.btn:active { transform: scale(0.96); }
.btn:hover { background: rgba(255, 255, 255, 0.08); }
.btn-primary {
  background: linear-gradient(135deg, #ffb547, #ff7e3a);
  color: #1c1304;
  border-color: transparent;
  font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-hollow {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ===== 移动端横屏主体布局 ===== */
.stage-mobile {
  flex: 1;
  display: grid;
  grid-template-columns: 200px 1fr 200px;
  gap: 10px;
  min-height: 0;
}

/* ===== 面板通用 ===== */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.score-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 2px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

/* ===== 左侧：曲谱面板 ===== */
.score-panel {
  gap: 0;
}
.score-line {
  font-size: 16px;
  line-height: 1.7;
  word-break: break-word;
  padding: 8px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.06);
  flex: 1;
  overflow-y: auto;
  margin-bottom: 10px;
}
.score-line .tok {
  display: inline-block;
  padding: 1px 5px;
  margin: 0 1px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: #d8dde7;
  font-size: 14px;
}
.score-line .tok.done { background: rgba(68, 211, 155, 0.18); color: #b8f5d9; }
.score-line .tok.active {
  background: linear-gradient(135deg, #ffb547, #ff7e3a);
  color: #1c1304;
  font-weight: 700;
  transform: scale(1.08);
  box-shadow: 0 0 0 3px rgba(255, 181, 71, 0.25);
}
.score-line .tok .badge-mini {
  font-size: 10px;
  margin-left: 3px;
}
.score-line .tok.bad { background: rgba(255, 107, 107, 0.2); color: #ffd2d2; }

.progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffb547, #44d39b);
  transition: width .25s ease;
  border-radius: 999px;
}
.progress-text { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.score-hint { font-size: 11px; color: var(--muted); opacity: 0.7; }

/* ===== 右侧：曲目列表 ===== */
.song-panel { gap: 0; }
.song-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
}
.song-list li {
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  cursor: pointer;
  transition: background .12s ease;
}
.song-list li:hover { background: rgba(255, 255, 255, 0.08); }
.song-list li.selected {
  background: linear-gradient(135deg, rgba(255, 181, 71, 0.25), rgba(255, 126, 58, 0.18));
  border-color: rgba(255, 181, 71, 0.4);
}
.song-list li .nm { font-weight: 600; color: #ffd07a; font-size: 13px; }
.song-list li .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ===== 中间：口琴区域 ===== */
.harmonica-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 0;
}

/* 四个模式圆按钮（三角洲风格） */
.mode-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
  touch-action: none;
}
.mode-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s ease;
  position: relative;
}
.mode-btn:hover {
  border-color: rgba(255, 181, 71, 0.4);
  color: var(--text);
}
.mode-btn.mode-active {
  background: var(--mode-active-bg);
  border-color: var(--mode-active-border);
  color: var(--accent-2);
  box-shadow: 0 0 16px rgba(255, 181, 71, 0.35), 0 0 0 1px rgba(255, 181, 71, 0.2);
}
.mode-label { letter-spacing: 1px; }

/* 口琴主体 */
.harmonica {
  width: min(580px, 100%);
  padding: 14px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, var(--harm-gold-light) 0%, var(--harm-gold) 50%, var(--harm-gold-dark) 100%);
  box-shadow:
    0 14px 36px rgba(0, 0, 0, 0.5),
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    inset 0 -3px 0 rgba(0, 0, 0, 0.3);
}
.harmonica-shell {
  background: linear-gradient(180deg, #1a1d24 0%, #0e1116 100%);
  border-radius: 12px;
  padding: 18px 14px 12px;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.6);
}
.harmonica-shell .brand {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 4px;
  color: #8a7048;
  white-space: nowrap;
}

/* 8 个圆形孔位 */
.holes {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}
.hole {
  position: relative;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 35%, #2a2d36, #0a0c10 70%);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  overflow: hidden;
  transition: transform .08s ease, box-shadow .15s ease, background .2s ease;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-callout: none;
}
.hole::after {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0.5));
}
.hole:active,
.hole.active {
  transform: scale(0.94);
  box-shadow: 0 0 0 2px var(--accent), 0 0 28px var(--hole-glow);
  background:
    radial-gradient(circle at 40% 35%, #3a2800, #5a3a00 70%);
}
.hole:active::after,
.hole.active::after {
  background: radial-gradient(circle at 40% 35%, rgba(255, 181, 71, 0.55), rgba(255, 126, 58, 0.2));
}
.hole .label {
  position: absolute;
  top: 5px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: #6e6a5a;
  letter-spacing: 0.5px;
  z-index: 2;
}
.hole .pitch {
  position: absolute;
  bottom: 5px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: rgba(255, 208, 122, 0.55);
  letter-spacing: 0.5px;
  z-index: 2;
}

/* 快捷键提示行 */
.row-keys {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  width: min(580px, 100%);
}
.rk {
  text-align: center;
  font-size: 11px;
  color: #c9b88a;
  letter-spacing: 1px;
}

/* ===== 底部工具栏 ===== */
.bottombar {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-shrink: 0;
}

/* ===== 模态 ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(480px, 88vw);
  background: linear-gradient(180deg, #1a1d24, #11141b);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-head h3 { margin: 0; font-size: 15px; letter-spacing: 1px; }
.modal-song-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 55vh;
  overflow-y: auto;
}
.modal-song-list .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  cursor: pointer;
}
.modal-song-list .row:hover { background: rgba(255, 255, 255, 0.08); }
.modal-song-list .row .nm { font-weight: 600; font-size: 13px; }
.modal-song-list .row .preview {
  font-size: 12px;
  color: var(--muted);
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.help-body { font-size: 13px; line-height: 1.8; color: #d8dde7; }
.help-body ul { padding-left: 18px; }
.help-body kbd {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
}

/* ===== 音符飘字 ===== */
.note-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}
.note-float {
  position: absolute;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-2);
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
  animation: float 1.6s ease-out forwards;
  pointer-events: none;
  transform: translate(-50%, -50%);
}
.note-float.down { color: #cfe1ff; }
.note-float.up { color: #ffd07a; }
.note-float.bad { color: var(--danger); }
@keyframes float {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -90%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(1); }
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid var(--panel-border);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 200;
  backdrop-filter: blur(6px);
  animation: toast-in .25s ease;
  pointer-events: none;
}
.toast.success { border-color: rgba(68, 211, 155, 0.4); color: #b8f5d9; }
.toast.error { border-color: rgba(255, 107, 107, 0.4); color: #ffd2d2; }
.toast.info { border-color: rgba(106, 169, 255, 0.4); color: #cfe1ff; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ===== ============================================================
   响应式断点
   ============================================================ */

/* 移动端横屏（主要目标） */
@media (max-width: 900px) {
  #app { padding: 8px 10px; gap: 6px; }
  .stage-mobile {
    grid-template-columns: 170px 1fr 170px;
    gap: 8px;
  }
  .harmonica {
    width: min(480px, 98%);
    padding: 10px;
  }
  .holes { gap: 6px; }
  .row-keys { width: min(480px, 98%); gap: 6px; }
  .mode-btn { width: 42px; height: 42px; font-size: 11px; }
  .score-line { font-size: 14px; }
}

/* 小屏横屏 */
@media (max-width: 700px) {
  .stage-mobile {
    grid-template-columns: 150px 1fr 150px;
    gap: 6px;
  }
  .topbar-right .btn { padding: 5px 8px; font-size: 12px; }
  .harmonica {
    width: min(380px, 96%);
    padding: 8px;
  }
  .holes { gap: 4px; }
  .row-keys { width: min(380px, 96%); gap: 4px; }
  .mode-buttons { gap: 8px; }
  .mode-btn { width: 38px; height: 38px; font-size: 10px; }
  .pitch { padding: 4px 8px; }
  .pitch-hint { display: none; }
}

/* 竖屏适配（尽量横屏提示） */
@media (orientation: portrait) {
  body::before {
    content: "请将手机横屏以获得最佳体验";
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-1);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    text-align: center;
    padding: 20px;
  }
}
