:root {
  --bg: #0d0f14;
  --bg-soft: #13161d;
  --card: #1a1f29;
  --card-2: #222936;
  --border: #2b3342;
  --text: #f2f4f8;
  --muted: #9aa3b2;
  --accent: #ffd166;
  --accent-2: #ff8e6e;
  --hit: #4cd964;
  --miss: #ff5a5f;
  --radius: 16px;
  --font: "Chiron GoRound TC", "Noto Sans TC", "PingFang TC", sans-serif;
  --mono: "DM Mono", "SFMono-Regular", Consolas, monospace;
}

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

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 20px calc(48px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* ---------- Header / logo ---------- */
.app-header {
  text-align: center;
  padding: 24px 0 20px;
}

.app-header.small {
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 4px;
}

.logo {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.logo .logo-sub {
  color: var(--accent);
}

.logo.small {
  font-size: 1.25rem;
}

.tagline {
  color: var(--muted);
  margin-top: 6px;
  font-size: 0.95rem;
}

/* ---------- Modes ---------- */
.mode-grid {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.mode-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
  color: var(--text);
  font-family: var(--font);
}

.mode-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.mode-icon {
  font-size: 1.6rem;
  display: block;
  margin-bottom: 8px;
}

.mode-name {
  display: block;
  font-size: 1.15rem;
  font-weight: 900;
}

.mode-desc {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ---------- Mode tabs (取代 cover page) ---------- */
.mode-tabs {
  display: flex;
  gap: 8px;
  margin: 8px 0 16px;
}

.mode-tab {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 900;
  border-radius: 12px;
  padding: 10px 6px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.mode-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1505;
}

/* ---------- Lobby ---------- */
.battle-intro {
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.battle-intro b {
  color: var(--accent);
}

.lobby {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.lobby-hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.filter-label {
  font-weight: 900;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.12s ease;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1505;
  font-weight: 900;
}

.filter-error {
  color: var(--miss);
  font-size: 0.85rem;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  border-radius: 12px;
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1505;
  font-weight: 900;
}

.btn-primary:disabled {
  background: var(--card-2);
  border-color: var(--border);
  color: var(--muted);
}

.btn-back {
  padding: 6px 12px;
  font-size: 1.1rem;
  border-radius: 10px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  padding: 6px;
}

.wide {
  width: 100%;
}

.lobby-actions {
  margin-top: 8px;
}

/* ---------- Game ---------- */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 4px;
}

.round-ind {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}

.score-ind {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--accent);
  font-size: 0.95rem;
}

.game-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 6px;
}

.album-disc {
  width: min(280px, 70vw);
  aspect-ratio: 1;
  border-radius: 100%;
  overflow: hidden;
  border: 4px solid var(--card-2);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  position: relative;
}

.album-disc img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.disc-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4.5rem;
  background: var(--card);
}

.disc-art.hidden {
  display: none;
}

/* ---------- Reveal overlay ---------- */
.reveal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8, 9, 13, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.reveal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px 22px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reveal-status {
  color: var(--accent);
  font-weight: 900;
  font-size: 1.05rem;
}

.reveal-cover {
  width: 160px;
  height: 160px;
  margin: 6px auto;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid var(--border);
}

.reveal-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reveal-title {
  font-size: 1.4rem;
  font-weight: 900;
}

.reveal-artist {
  color: var(--muted);
}

.reveal-apple {
  color: var(--accent);
  font-size: 0.85rem;
  text-decoration: none;
  margin-bottom: 4px;
}

.listen-label {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.2em;
}

.controls {
  display: flex;
  gap: 10px;
  width: 100%;
}

.btn-play {
  flex: 1.4;
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1505;
  font-weight: 900;
}

.btn-more {
  flex: 1;
}

/* Guess box */
.guess-box {
  width: 100%;
  position: relative;
}

.guess-input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
}

.guess-input:focus {
  outline: none;
  border-color: var(--accent);
}

.guess-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-height: 240px;
  overflow-y: auto;
  list-style: none;
  z-index: 20;
  display: none;
}

.guess-list.open {
  display: block;
}

.guess-list li {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}

.guess-list li + li {
  border-top: 1px solid var(--border);
}

.guess-list li:hover,
.guess-list li.selected {
  background: var(--card-2);
}

.guess-list .gs-art {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.guess-list .gs-title {
  font-weight: 700;
}

.guess-list .gs-artist {
  color: var(--muted);
  font-size: 0.8rem;
}

.guess-result {
  font-size: 0.9rem;
  min-height: 1.2em;
}

.guess-result.hit {
  color: var(--hit);
}

.guess-result.miss {
  color: var(--miss);
}

.game-actions {
  width: 100%;
}

.btn-giveup {
  width: 100%;
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn-giveup.confirm {
  border-color: var(--miss);
  color: var(--miss);
}

/* ---------- Summary ---------- */
.summary {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.summary-title {
  color: var(--muted);
}

.total-score {
  font-family: var(--mono);
  font-size: 4rem;
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
}

.total-unit {
  color: var(--muted);
  margin-top: -8px;
}

.round-list {
  list-style: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.round-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}

.round-list img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
}

.round-list .song-name {
  flex: 1;
  min-width: 0;
}

.round-list .song-name b {
  display: block;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.round-list .song-name span {
  color: var(--muted);
  font-size: 0.78rem;
}

.mark {
  font-family: var(--mono);
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--card-2);
  color: var(--muted);
  font-size: 0.85rem;
}

.mark.hit {
  background: rgba(76, 217, 100, 0.15);
  color: var(--hit);
}

.mark.miss {
  background: rgba(255, 90, 95, 0.15);
  color: var(--miss);
}

.battle-compare {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 0.9rem;
}

.battle-compare .bc-title {
  font-weight: 900;
  margin-bottom: 8px;
  color: var(--accent);
}

.battle-compare .bc-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
}

.battle-compare .bc-row.win {
  color: var(--hit);
  font-weight: 900;
}

.battle-compare .bc-row.lose {
  color: var(--miss);
}

.summary-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

/* ---------- Party ---------- */
.party-players {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.party-player {
  display: flex;
  align-items: center;
  gap: 8px;
}

.party-player input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
}

.party-player .btn-remove {
  background: none;
  border: none;
  color: var(--miss);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 6px;
}

.party-winner-pick {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px;
}

.party-ranking {
  list-style: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.party-ranking li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
}

.party-ranking .rank-no {
  font-family: var(--mono);
  font-size: 1.2rem;
  color: var(--accent);
  width: 32px;
}

.party-ranking .rank-name {
  flex: 1;
  font-weight: 900;
}

.party-ranking .rank-pts {
  font-family: var(--mono);
  color: var(--accent);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
}

/* ---------- Footer ---------- */
.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 20px 0 8px;
}

.app-footer a {
  color: var(--muted);
}

/* ---------- Hidden ---------- */
.hidden {
  display: none !important;
}
