:root {
  /* 品牌色照 CONTRACT */
  --ink: #0B0F2C;
  --royal: #1764FF;
  --blue: #00D4FF;
  --pink: #FF2D7A;
  --yellow: #FFB800;
  --orange: #FF7A00;
  --purple: #7B2CFF;
  --panel: rgba(16, 14, 46, 0.9);
  --line: rgba(255, 255, 255, 0.14);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--ink); color: #fff;
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
canvas#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }

.screen {
  position: fixed; inset: 0; display: none;
  align-items: center; justify-content: center; flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  z-index: 10;
}
.screen.show { display: flex; }
#titleScreen { background: linear-gradient(180deg, rgba(11,15,44,.1) 0%, rgba(11,15,44,.5) 70%, rgba(11,15,44,.85) 100%); gap: 14px; }
#loading { background: var(--ink); gap: 14px; }
#selectScreen, #readyScreen, #pauseScreen, #resultScreen { background: rgba(6, 8, 24, 0.55); }

.logo { width: min(82vw, 620px); filter: drop-shadow(0 0 18px rgba(255,122,0,.6)); animation: logoDrop .7s cubic-bezier(.2,1.5,.4,1) both, pulse 1.9s ease-in-out .9s infinite; }
/* 標題畫面：LOGO 在團員上方、文字按鈕在團員下方，五個人都不被遮（--band-top / --band-bottom / --stage-bottom 由 game.js 算） */
#titleScreen .title-top, #titleScreen .title-bottom { position: absolute; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; }
#titleScreen .title-top { top: 0; height: var(--band-top, 22vh); justify-content: center; padding-top: env(safe-area-inset-top); }
#titleScreen .title-top .logo { width: auto; height: calc(100% - 14px); max-height: 180px; min-height: 40px; max-width: 82vw; object-fit: contain; transform-origin: center; }
#titleScreen .title-bottom { top: var(--band-bottom, 78vh); bottom: 0; justify-content: center; gap: 4px; padding: 0 16px env(safe-area-inset-bottom); }
#titleScreen .title-bottom .big-btn { margin: 4px 0; }
/* fix1 2026-10-15：橫式（桌機）時「開始」和「樂團播放器」並排一列，避免 1280x760 這類高度把播放器按鈕擠出畫面；
   直式維持原本由上到下：開始 → 提示 → 播放器（display:contents + order） */
#titleScreen .title-bottom .subtitle { order: 0; }
#titleScreen .title-actions { order: 1; display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 16px; }
#titleScreen .title-bottom .hint { order: 2; }
#titleScreen .title-actions #btnStart { order: 1; }
#titleScreen .title-actions #toPlayer { order: 3; margin-top: 0; }
body[data-orient="portrait"] #titleScreen .title-actions { display: contents; }
body[data-orient="portrait"] #titleScreen .title-actions #toPlayer { margin-top: 8px; }
/* 直式（手機）：舞台在上半部，LOGO＋按鈕全部排在舞台下方 */
body[data-orient="portrait"] #titleScreen .title-top { top: var(--stage-bottom, 46vh); height: auto; padding: 18px 16px 0; }
body[data-orient="portrait"] #titleScreen .title-top .logo { width: min(82vw, 420px); height: auto; max-height: none; }
body[data-orient="portrait"] #titleScreen .title-bottom { top: auto; bottom: 0; height: calc(100% - var(--stage-bottom, 46vh) - min(37vw, 175px)); gap: 10px; }
@keyframes logoDrop { from { transform: translateY(-60px) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.035); } }
.subtitle { font-size: clamp(18px, 3.4vw, 30px); font-weight: 800; letter-spacing: .06em; text-shadow: 0 0 12px var(--orange), 0 2px 0 #000; text-align: center; }
.hint { font-size: 14px; opacity: .8; text-align: center; line-height: 1.5; }

.big-btn, .mid-btn, .small-btn, .diff-btn {
  font: inherit; color: #fff; border: 0; cursor: pointer; border-radius: 999px;
}
.big-btn {
  font-size: 22px; font-weight: 800; padding: 14px 44px; margin: 8px 0;
  background: linear-gradient(90deg, var(--purple), var(--orange));
  box-shadow: 0 0 22px rgba(255,122,0,.55), inset 0 -3px 0 rgba(0,0,0,.25);
}
.big-btn:disabled { opacity: .45; cursor: default; }
.big-btn:not(:disabled):active { transform: scale(.97); }
.mid-btn { font-size: 17px; font-weight: 700; padding: 10px 30px; margin: 6px 0; background: rgba(255,255,255,.12); border: 1px solid var(--line); }
.small-btn { font-size: 14px; padding: 8px 20px; margin-top: 8px; background: transparent; border: 1px solid var(--line); opacity: .85; }

.panel {
  width: min(560px, 100%); max-height: 100%; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 20px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.panel.center { display: flex; flex-direction: column; align-items: center; text-align: center; }
.panel h2 { margin: 0 0 12px; font-size: 22px; }

.diff-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 15px; }
.diff-btn { padding: 7px 18px; font-size: 15px; font-weight: 700; background: rgba(255,255,255,.1); border: 1px solid var(--line); }
.diff-btn.on { background: var(--blue); border-color: transparent; box-shadow: 0 0 12px rgba(0,212,255,.6); }
.diff-btn[data-diff="hard"].on { background: var(--orange); box-shadow: 0 0 12px rgba(255,122,0,.6); }

.song-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.song-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: 14px; cursor: pointer; color: #fff; font: inherit;
  background: linear-gradient(90deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
  border: 1px solid var(--line); position: relative; overflow: hidden;
}
.song-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--c, var(--pink)); }
.song-card:hover, .song-card:focus-visible { border-color: var(--c, var(--pink)); outline: none; }
.song-card:active { transform: scale(.99); }
.song-card .num { font-size: 26px; font-weight: 900; color: var(--c); width: 30px; text-align: center; }
.song-card .meta { flex: 1; min-width: 0; }
.song-card .name { font-size: 20px; font-weight: 800; }
/* fix1 2026-10-15：歌名與副標（時長／音符數）改成可換行，不再被「…」截掉 */
.song-card .sub { font-size: 13px; opacity: .75; margin-top: 3px; white-space: normal; overflow-wrap: anywhere; line-height: 1.35; }
.song-card .name { white-space: normal; overflow-wrap: anywhere; line-height: 1.2; }
.song-card .best { font-size: 13px; font-weight: 800; color: var(--yellow); white-space: nowrap; }

.ready-song { font-size: 26px; font-weight: 900; margin-bottom: 6px; }
.ready-status { font-size: 14px; opacity: .85; margin-bottom: 10px; min-height: 20px; white-space: pre-line; line-height: 1.6; }

#hud { position: fixed; left: 0; right: 0; top: 0; z-index: 5; pointer-events: none;
  padding: max(8px, env(safe-area-inset-top)) 10px 0; display: flex; justify-content: space-between; align-items: flex-start; }
#hud.hidden, .hidden { display: none !important; }
.hud-left { text-shadow: 0 2px 4px #000; }
.hud-song { font-size: 13px; opacity: .85; }
.hud-score { font-size: 26px; font-weight: 900; letter-spacing: .03em; font-variant-numeric: tabular-nums; }
.hud-label { font-size: 12px; font-weight: 800; opacity: .8; margin-right: 6px; letter-spacing: .05em; vertical-align: 4px; }
.res-judges i { font-style: normal; }
.hud-right { display: flex; gap: 8px; pointer-events: auto; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(10,12,34,.7); color: #fff; font-size: 17px; font-weight: 900; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.vol-panel { position: absolute; right: 10px; top: calc(max(8px, env(safe-area-inset-top)) + 50px); pointer-events: auto;
  background: rgba(10,12,34,.92); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: flex; align-items: center; gap: 10px; }
.vol-panel { flex-direction: column; align-items: stretch; gap: 6px; }
.vol-row { display: flex; align-items: center; gap: 10px; }
.vol-name { font-size: 13px; font-weight: 800; width: 3.6em; opacity: .85; }
.vol-panel input { width: 140px; }
.link-btn { display: inline-block; margin-top: 8px; padding: 8px 20px; border-radius: 999px; font-size: 15px; font-weight: 800; color: #fff; text-decoration: none;
  background: rgba(123,44,255,.35); border: 1px solid rgba(123,44,255,.8); box-shadow: 0 0 12px rgba(123,44,255,.45); }
.link-btn:active { transform: scale(.97); }
.center-row { display: flex; justify-content: center; }
.sound-hint { position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  font: inherit; font-size: 14px; font-weight: 800; color: #fff; border: 1px solid rgba(255,184,0,.7); background: rgba(11,15,44,.85);
  border-radius: 999px; padding: 8px 18px; cursor: pointer; animation: pulse 1.4s ease-in-out infinite; }
.progress { position: absolute; left: 0; right: 0; bottom: -4px; height: 3px; background: rgba(255,255,255,.12); }
#progressFill { height: 100%; width: 0; background: linear-gradient(90deg, var(--purple), var(--orange)); }

.result-title { font-size: 16px; opacity: .8; letter-spacing: .1em; }
.res-song { font-size: 20px; font-weight: 800; margin: 4px 0; }
.rank { font-size: 96px; font-weight: 900; line-height: 1; margin: 6px 0 10px;
  background: linear-gradient(180deg, #fff, var(--yellow) 55%, var(--orange)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 16px rgba(255,184,0,.6)); animation: pop .6s cubic-bezier(.2,1.6,.4,1); }
.rank.r-A { background-image: linear-gradient(180deg, #fff, var(--orange)); }
.rank.r-B { background-image: linear-gradient(180deg, #fff, var(--blue)); }
.rank.r-C { background-image: linear-gradient(180deg, #fff, #9aa); }
@keyframes pop { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin-bottom: 10px; }
.res-grid div { background: rgba(255,255,255,.07); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.res-grid b { font-size: 22px; font-variant-numeric: tabular-nums; }
.res-judges { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; font-size: 14px; margin-bottom: 8px; }
.j-perfect b { color: var(--yellow); } .j-great b { color: var(--orange); } .j-good b { color: var(--blue); } .j-miss b { color: #aaa; }

.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255,255,255,.15); border-top-color: var(--orange); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-bar { width: min(280px, 70vw); height: 6px; background: rgba(255,255,255,.12); border-radius: 3px; overflow: hidden; }
#loadingFill { height: 100%; width: 0; background: var(--orange); transition: width .2s; }

@media (max-width: 480px) {
  .big-btn { font-size: 20px; padding: 12px 36px; }
  .song-card .name { font-size: 18px; }
  .rank { font-size: 80px; }
  .hud-score { font-size: 22px; }
  .icon-btn { width: 38px; height: 38px; }
}

/* 10/27 fix2b：日文／中文不在詞中間斷行（只在空白處換行），長字串才強制斷 */
:lang(ja) .subtitle, :lang(ja) .song-card .sub, :lang(ja) .song-card .title,
:lang(zh-Hant-TW) .subtitle { word-break: keep-all; line-break: strict; overflow-wrap: break-word; text-wrap: balance; }
#controlHint { white-space: pre-line; }
:lang(ja) .hint { word-break: keep-all; line-break: strict; overflow-wrap: break-word; }
/* 10/27 fix2b 補：準備畫面／所有面板的日文同樣只在空白處換行 */
:lang(ja) .panel, :lang(ja) .ready-song, :lang(ja) .ready-status { word-break: keep-all; line-break: strict; overflow-wrap: break-word; }
#readyStatus { white-space: pre-line; }
