/* ═══════════════════════════════════════════
   狸尾滑鼠節奏 · Mouse Rhythm Club
   美術借鏡 RhythmLab（狸尾節奏公寓）的深夜酒吧語彙
   ═══════════════════════════════════════════ */
:root {
  --ink: #1d2725;
  --paper: #fff8e8;
  --coral: #ef725f;
  --coral-dark: #aa463c;
  --cyan: #65b8aa;
  --cyan-dark: #256f68;
  --yellow: #f2c85b;
  --violet: #758ab5;
  --track: #152c2c;
  --track-soft: #23403d;
  --wood: #9b613d;
  --font-display: "Arial Black", "Noto Sans TC", system-ui, sans-serif;
  --font-body: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  --font-mono: "Cascadia Mono", "Consolas", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--paper);
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(101, 184, 170, .14), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(239, 114, 95, .12), transparent 60%),
    linear-gradient(180deg, #0d1d1c 0%, var(--track) 55%, #0f2220 100%);
  overflow-x: hidden;
  cursor: default;
}

.screen { min-height: 100dvh; display: flex; flex-direction: column; }
.screen[hidden] { display: none; }

/* ── 選歌畫面 ─────────────────────────── */
#screen-menu { padding: 34px 20px 30px; max-width: 760px; margin: 0 auto; }

.masthead { text-align: center; margin-bottom: 22px; }

.logo {
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 3.2rem);
  letter-spacing: .06em;
  color: var(--paper);
  text-shadow: 0 0 18px rgba(242, 200, 91, .35), 0 3px 0 rgba(0, 0, 0, .45);
}
.logo::after {
  content: "♪";
  color: var(--coral);
  margin-left: 10px;
  text-shadow: 0 0 14px rgba(239, 114, 95, .8);
}

.logo-sub {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: .78rem;
  letter-spacing: .22em;
  color: var(--cyan);
}

.howto {
  margin: 16px auto 0;
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: .85rem;
  color: #cfd9c8;
}
.howto span b {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--coral-dark);
  color: var(--paper);
  font-size: .72rem;
  margin-right: 4px;
}

.menu-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(21, 44, 44, .72);
  border: 1px solid rgba(255, 248, 232, .14);
  border-radius: 18px;
  padding: 22px;
  backdrop-filter: blur(6px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .4);
}

/* 表演者 */
.performer-wrap {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}
.performer-wrap img {
  width: 132px;
  height: 132px;
  object-fit: cover;
  border-radius: 16px;
  border: 2px solid rgba(255, 248, 232, .22);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  background: var(--track-soft);
}
.performer-caption {
  font-size: .9rem;
  color: var(--yellow);
  padding-bottom: 8px;
}

/* 歌單：單欄垂直（不並排卡片） */
.song-panel { display: flex; flex-direction: column; gap: 8px; }

.song-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid rgba(255, 248, 232, .16);
  padding-bottom: 6px;
}
.song-head-label { font-family: var(--font-display); font-size: 1rem; letter-spacing: .1em; }
.song-head-count { font-family: var(--font-mono); color: var(--cyan); font-size: .8rem; }

.song-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 4px;
}

.song-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 248, 232, .1);
  background: rgba(35, 64, 61, .5);
  color: var(--paper);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
}
.song-card:hover { background: rgba(35, 64, 61, .95); border-color: rgba(101, 184, 170, .5); }
.song-card.is-selected {
  background: var(--coral-dark);
  border-color: var(--coral);
  box-shadow: 0 0 16px rgba(239, 114, 95, .35);
}
.song-card .song-num { font-family: var(--font-mono); color: var(--cyan); font-size: .8rem; }
.song-card.is-selected .song-num { color: #ffe9d8; }
.song-card .song-title { font-weight: 800; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-card .song-meta { font-family: var(--font-mono); font-size: .7rem; color: rgba(255, 248, 232, .78); }
.song-card.is-selected .song-meta { color: rgba(255, 248, 232, .85); }

/* 難度 */
.difficulty-panel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.difficulty-option {
  padding: 12px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 248, 232, .16);
  background: rgba(21, 44, 44, .8);
  color: var(--paper);
  font: 800 .9rem var(--font-body);
  cursor: pointer;
  transition: all .15s;
}
.difficulty-option small { display: block; font-family: var(--font-mono); font-weight: 400; font-size: .62rem; color: rgba(255, 248, 232, .5); margin-top: 2px; }
.difficulty-option.is-selected { background: var(--cyan-dark); border-color: var(--cyan); box-shadow: 0 0 14px rgba(101, 184, 170, .4); }
.difficulty-option.is-selected small { color: #d8fff4; }

/* 開始按鈕 */
.start-button {
  margin-top: 4px;
  padding: 16px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(180deg, var(--coral), var(--coral-dark));
  color: var(--paper);
  font: 900 1.15rem var(--font-display);
  letter-spacing: .3em;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(239, 114, 95, .35);
  transition: transform .12s, opacity .15s;
}
.start-button:hover:not(:disabled) { transform: translateY(-2px); }
.start-button:disabled { opacity: .4; cursor: not-allowed; }

.copyright {
  margin-top: 20px;
  text-align: center;
  font-size: .72rem;
  color: rgba(255, 248, 232, .45);
}

/* ── 遊戲畫面 ─────────────────────────── */
#screen-game { padding: 14px 16px max(16px, env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }

.game-hud {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 14px;
  align-items: baseline;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(21, 44, 44, .8);
  border: 1px solid rgba(255, 248, 232, .12);
  font-family: var(--font-mono);
  font-size: .78rem;
  color: rgba(255, 248, 232, .7);
}
.game-hud b { color: var(--paper); font-size: 1rem; }
.hud-song { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; color: var(--paper); }
.hud-grade { font-family: var(--font-display); font-size: 1.2rem; color: var(--yellow); }

.stage {
  position: relative;
  margin-top: 12px;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(500px 300px at 50% 30%, rgba(101, 184, 170, .08), transparent 70%),
    linear-gradient(180deg, rgba(13, 29, 28, .9), rgba(21, 44, 44, .95));
  border: 1px solid rgba(255, 248, 232, .1);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, .5);
}
#lane { display: block; width: 100%; height: min(56dvh, 480px); }

.judge-line {
  position: absolute;
  left: 8%; right: 8%;
  bottom: 12%;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--coral) 18%, var(--coral) 82%, transparent);
  box-shadow: 0 0 14px rgba(239, 114, 95, .8);
  pointer-events: none;
}
.judge-line-text {
  position: absolute;
  right: 0;
  bottom: 12px;
  font-family: var(--font-mono);
  font-size: .6rem;
  letter-spacing: .3em;
  color: rgba(242, 200, 91, .8);
  white-space: nowrap;
}

.judge-pop {
  position: absolute;
  left: 50%;
  bottom: 9%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: .1em;
  pointer-events: none;
  opacity: 0;
}
.judge-pop.is-show { animation: judge-pop .4s ease-out; }
.judge-pop.p-perfect { color: var(--yellow); text-shadow: 0 0 18px rgba(242, 200, 91, .9); }
.judge-pop.p-great { color: var(--cyan); text-shadow: 0 0 14px rgba(101, 184, 170, .9); }
.judge-pop.p-good { color: var(--violet); text-shadow: 0 0 10px rgba(117, 138, 181, .8); }
.judge-pop.p-miss { color: var(--coral); text-shadow: 0 0 10px rgba(239, 114, 95, .8); }
@keyframes judge-pop {
  0% { opacity: 0; transform: translateX(-50%) scale(.5); }
  25% { opacity: 1; transform: translateX(-50%) scale(1.15); }
  60% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(.9) translateY(-26px); }
}

.reaction {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 74px;
  height: 74px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid rgba(255, 248, 232, .25);
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.reaction.is-show { opacity: 1; }

.progress-track {
  margin-top: 10px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 248, 232, .12);
  overflow: hidden;
}
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--cyan), var(--yellow)); border-radius: 3px; }

.game-hint {
  margin-top: 10px;
  text-align: center;
  font-size: .8rem;
  color: rgba(255, 248, 232, .6);
}

.game-exit {
  position: fixed;
  right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 248, 232, .2);
  background: rgba(21, 44, 44, .85);
  color: rgba(255, 248, 232, .7);
  font-size: .78rem;
  cursor: pointer;
  transition: all .15s;
  z-index: 5;
}
.game-exit:hover { color: var(--paper); border-color: var(--coral); }

/* ── 結算畫面 ─────────────────────────── */
#screen-result { padding: 30px 20px; max-width: 520px; margin: 0 auto; justify-content: center; }

.result-card {
  background: rgba(21, 44, 44, .9);
  border: 1px solid rgba(255, 248, 232, .16);
  border-radius: 20px;
  padding: 30px 26px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}
.result-title { font-family: var(--font-display); font-size: 1.1rem; letter-spacing: .3em; color: var(--cyan); }

.result-grade {
  font-family: var(--font-display);
  font-size: 5rem;
  line-height: 1;
  margin: 14px 0 6px;
  color: var(--yellow);
  text-shadow: 0 0 30px rgba(242, 200, 91, .5);
}
.result-score { font-family: var(--font-mono); font-size: .9rem; color: rgba(255, 248, 232, .75); }
.result-score b { color: var(--paper); font-size: 1.3rem; }

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}
.result-stats div {
  background: rgba(35, 64, 61, .6);
  border-radius: 10px;
  padding: 10px 6px;
}
.result-stats span { display: block; font-size: .68rem; color: rgba(255, 248, 232, .55); }
.result-stats b { font-size: .95rem; color: var(--paper); }

.result-judges {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  font-family: var(--font-mono);
  font-size: .68rem;
}
.result-judges span { padding: 6px 2px; border-radius: 6px; }
.j-perfect { color: var(--yellow); background: rgba(242, 200, 91, .1); }
.j-great { color: var(--cyan); background: rgba(101, 184, 170, .1); }
.j-good { color: var(--violet); background: rgba(117, 138, 181, .1); }
.j-miss { color: var(--coral); background: rgba(239, 114, 95, .1); }

.result-reaction {
  width: 108px;
  height: 108px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid rgba(255, 248, 232, .25);
  margin: 16px auto 4px;
}

.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.result-actions button {
  padding: 14px;
  border-radius: 10px;
  border: none;
  font: 800 .95rem var(--font-body);
  cursor: pointer;
  transition: transform .12s;
}
.result-actions button:hover { transform: translateY(-2px); }
#btn-retry { background: linear-gradient(180deg, var(--coral), var(--coral-dark)); color: var(--paper); }
#btn-back { background: var(--track-soft); color: var(--paper); border: 1px solid rgba(255, 248, 232, .2) !important; }

/* 窄螢幕 */
@media (max-width: 520px) {
  .difficulty-panel { grid-template-columns: 1fr; }
  .result-judges { grid-template-columns: repeat(2, 1fr); }
  .game-hud { grid-template-columns: 1fr auto; row-gap: 4px; }
  .hud-song { grid-column: 1 / -1; }
}
