:root {
  --bg: #fff8e7;
  --panel: #ffffff;
  --panel-2: #fff0d6;
  --text: #2a1a14;
  --muted: #8a7568;
  --accent: #ff5e7d;
  --accent-ink: #ffffff;
  --good: #2ea854;
  --bad: #d63a3f;
  --border: #ead8b8;
  --radius: 10px;
  --max-w: 560px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 10px 10px, rgba(255, 94, 125, 0.22) 3.5px, transparent 4px),
    radial-gradient(circle at 35px 22px, rgba(255, 154, 60, 0.22) 3.5px, transparent 4px),
    radial-gradient(circle at 60px 10px, rgba(255, 210, 63, 0.26) 3.5px, transparent 4px),
    radial-gradient(circle at 10px 50px, rgba(78, 192, 122, 0.20) 3.5px, transparent 4px),
    radial-gradient(circle at 35px 62px, rgba(63, 169, 245, 0.20) 3.5px, transparent 4px),
    radial-gradient(circle at 60px 50px, rgba(184, 107, 255, 0.20) 3.5px, transparent 4px);
  background-size: 72px 72px;
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

.game-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 7px 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.7);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.game-nav a {
  padding: 4px 11px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.game-nav a:hover { background: rgba(42, 26, 20, 0.06); color: var(--text); }
.game-nav a.current {
  background: var(--text);
  color: var(--panel);
}

#app {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 20px 16px 40px;
}

header { text-align: center; margin-bottom: 18px; }
header h1 {
  margin: 0;
  font-size: 2.4rem;
  letter-spacing: 0.04em;
  font-weight: 800;
  background: linear-gradient(90deg, #ff5e7d, #ff9a3c, #ffd23f, #4ec07a, #3fa9f5, #b86bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
header .tagline { margin: 4px 0 0; color: var(--muted); font-size: 0.95rem; }

main { display: flex; flex-direction: column; gap: 26px; }

.stats-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  padding: 9px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 600;
}
.stats-bar[hidden] { display: none; }
.stats-bar .stat {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}
.stats-bar .stat-label {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
}
.stats-bar .stat b {
  font-weight: 800;
  color: var(--text);
  font-size: 1.05rem;
}
.stats-bar .stat-best {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.result-share {
  display: flex;
  justify-content: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.share-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 7px 16px;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.share-btn:hover:not(:disabled) {
  background: var(--panel-2);
  color: var(--text);
}
.share-btn:active:not(:disabled) { transform: scale(0.98); }
.share-btn:disabled { opacity: 0.6; cursor: default; }

#rounds {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.round-pip {
  height: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: background 0.2s;
}
.round-pip.active { background: var(--accent); }
.round-pip.miss { background: var(--bad); }
.round-pip.hit { background: var(--good); }

#player {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
}

#play-btn {
  appearance: none;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1.05rem;
  font-weight: 700;
  padding: 14px 22px;
  border-radius: 999px;
  cursor: pointer;
  min-width: 200px;
  transition: transform 0.05s, opacity 0.2s;
}
#play-btn:active:not(:disabled) { transform: scale(0.98); }
#play-btn:disabled { opacity: 0.55; cursor: not-allowed; }
#play-btn.playing { background: #3fa9f5; }
#play-btn.new-song { background: linear-gradient(90deg, #ff5e7d, #ff9a3c, #ffd23f, #4ec07a, #3fa9f5, #b86bff); }

#progress-track {
  margin: 14px auto 0;
  height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  overflow: hidden;
  max-width: 320px;
}
#progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.05s linear;
}
#status { margin: 12px 0 0; color: var(--muted); font-size: 0.9rem; min-height: 1.2em; }

#guess-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.combo { position: relative; }

#guess-input {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 1rem;
  outline: none;
}
#guess-input:focus { border-color: var(--accent); }
#guess-input:disabled { opacity: 0.6; }

#suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  list-style: none;
  margin: 0;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 260px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
#suggestions li {
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  touch-action: manipulation;
}
#suggestions li.active,
#suggestions li:hover { background: var(--panel-2); }
#suggestions .s-title { font-weight: 600; }
#suggestions .s-meta { font-size: 0.8rem; color: var(--muted); }

.actions {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: stretch;
}
.actions #skip-btn,
.actions #giveup-btn {
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--border);
}
.actions #skip-btn:hover:not(:disabled),
.actions #giveup-btn:hover:not(:disabled) {
  color: var(--bad);
  border-color: var(--bad);
  background: rgba(214, 58, 63, 0.06);
}
.actions button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 12px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.actions button:disabled { opacity: 0.5; cursor: not-allowed; }
#submit-btn:not(:disabled) {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

#history {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.history-row {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 0.92rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.history-row.skip { color: var(--muted); }
.history-row.miss { border-left: 4px solid var(--bad); }
.history-row.hit { border-left: 4px solid var(--good); }
.history-row .badge {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

#result {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}
#result.win h2 { color: var(--good); }
#result.lose h2 { color: var(--bad); }
#result h2 { margin: 0 0 6px; }
#result p { margin: 0 0 12px; color: var(--muted); }
#result-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}
#result-meta img {
  width: 120px;
  height: 120px;
  border-radius: 8px;
  object-fit: cover;
}
#play-again {
  appearance: none;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 16px 36px;
  font-weight: 700;
  font-size: 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  min-width: 220px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.08s, box-shadow 0.15s;
}
#play-again:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22); }
#play-again:active { transform: translateY(1px); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18); }

footer {
  margin-top: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}
footer a { color: var(--muted); }

@media (max-width: 420px) {
  header h1 { font-size: 2rem; }
  #play-btn { min-width: 0; width: 100%; }
}
