:root {
  --bg: #ede4f5;
  --bg-2: #d4c2e8;
  --paper: #f7f0fb;
  --paper-2: #e6d6f0;
  --ink: #2a1a3a;
  --ink-soft: #4d3568;
  --ink-mute: #7a5e95;
  --orange: #b45fb8;       /* magenta-purple in place of orange */
  --gold: #c98ee0;          /* lavender in place of gold */
  --avocado: #8a6cc4;       /* lavender-violet in place of avocado */
  --teal: #5a4a8b;
  --plum: #6e3a8e;
  --plum-deep: #4a2168;
  --hot: #c84099;
  --rust: #7a3a8e;
  --good: #8a6cc4;
  --bad: #b8456a;
  --border: #b89dd0;
  --radius: 14px;
  --max-w: 560px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Quicksand", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

.psychedelic-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 15% 15%, rgba(200, 64, 153, 0.35) 0%, transparent 38%),
    radial-gradient(circle at 85% 20%, rgba(180, 141, 224, 0.50) 0%, transparent 42%),
    radial-gradient(circle at 25% 85%, rgba(110, 58, 142, 0.40) 0%, transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(199, 113, 214, 0.42) 0%, transparent 42%),
    radial-gradient(circle at 50% 50%, rgba(138, 108, 196, 0.28) 0%, transparent 55%),
    linear-gradient(180deg, #ede4f5 0%, #d4c2e8 100%);
  filter: saturate(0.95);
}
.psychedelic-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-radial-gradient(circle at 50% 50%, transparent 0, transparent 40px, rgba(255,255,255,.04) 40px, rgba(255,255,255,.04) 80px);
  mix-blend-mode: overlay;
}

.game-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 7px 10px;
  font-family: "Quicksand", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(247, 240, 251, 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(--ink-soft);
  transition: background 0.15s, color 0.15s;
}
.game-nav a:hover { background: rgba(42, 26, 58, 0.08); color: var(--ink); }
.game-nav a.current {
  background: var(--ink);
  color: var(--paper);
}

#app {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px 18px 48px;
}

header { text-align: center; margin-bottom: 22px; }
.header-flowers {
  font-size: 1.4rem;
  letter-spacing: 0.4em;
  color: var(--orange);
  opacity: .8;
  margin-bottom: 4px;
}
header h1 {
  font-family: "Bagel Fat One", "Bowlby One", "Alfa Slab One", serif;
  margin: 0;
  font-size: 3.6rem;
  line-height: 1;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, var(--hot) 0%, var(--orange) 30%, var(--gold) 55%, var(--avocado) 80%, var(--plum) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 2px 2px 0 rgba(42, 26, 58, 0.08);
  font-weight: 400;
}
header .tagline {
  font-family: "Caveat Brush", cursive;
  margin: 6px 0 0;
  color: var(--rust);
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}

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

/* ===== Phase 1: picker ===== */
#picker {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: 0 4px 0 rgba(42, 26, 58, 0.08), 0 8px 24px rgba(110, 58, 142, 0.10);
}
#picker .picked-row h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--ink-soft);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.picked-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 38px;
}
.picked-list li {
  background: linear-gradient(135deg, var(--gold), var(--orange));
  border: 2px solid var(--ink);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.92rem;
  box-shadow: 0 2px 0 var(--ink);
}
.picked-list .remove {
  background: transparent;
  border: none;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0 0 2px;
  font-weight: 700;
}
.picked-list .empty-msg {
  background: none;
  border: none;
  color: var(--ink-mute);
  padding: 6px 0;
  font-style: italic;
  box-shadow: none;
  font-weight: 500;
}

#start-btn {
  appearance: none;
  border: 2px solid var(--ink);
  background: linear-gradient(180deg, var(--avocado), var(--plum-deep));
  color: var(--paper);
  font-family: "Bagel Fat One", serif;
  font-weight: 400;
  padding: 13px 24px;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink), 0 6px 20px rgba(138, 108, 196, .35);
  transition: transform 0.08s, box-shadow 0.15s, opacity 0.2s;
}
#start-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 0 var(--ink), 0 8px 24px rgba(138, 108, 196, .45);
}
#start-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--ink);
}
#start-btn:disabled { opacity: 0.45; cursor: not-allowed; }

#band-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  list-style: none;
  margin: 0;
  padding: 6px;
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  max-height: 280px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(42, 26, 58, 0.18);
}
#band-suggestions li {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  transition: background 0.1s;
  font-weight: 700;
  touch-action: manipulation;
}
#band-suggestions li.active,
#band-suggestions li:hover {
  background: linear-gradient(90deg, rgba(201, 142, 224, 0.40), rgba(180, 95, 184, 0.30));
}
#band-suggestions .b-genre {
  font-size: 0.78rem;
  color: var(--ink-mute);
  font-weight: 500;
}

#band-search {
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: "Quicksand", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: inset 0 2px 4px rgba(42, 26, 58, 0.06);
}
#band-search:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(180, 95, 184, 0.20), inset 0 2px 4px rgba(42, 26, 58, 0.06);
}
#band-search:disabled { opacity: 0.55; }

/* ===== Phase 2: building ===== */
#building {
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  box-shadow: 0 4px 0 rgba(42, 26, 58, 0.08), 0 8px 24px rgba(110, 58, 142, 0.10);
}
#building-status {
  font-family: "Caveat Brush", cursive;
  font-size: 1.5rem;
  color: var(--rust);
  margin: 0 0 14px;
}
#building-track {
  height: 10px;
  background: rgba(42, 26, 58, 0.12);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(42, 26, 58, 0.15);
  max-width: 360px;
  margin: 0 auto;
}
#building-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--orange), var(--hot));
  transition: width 0.3s ease;
}
.building-detail {
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin: 14px 0 0;
  min-height: 1.2em;
}

/* ===== Phase 3: game (mostly copied from Beatdle) ===== */
#game {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.stats-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  padding: 10px 14px;
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.92rem;
  color: var(--ink-soft);
  font-weight: 600;
  box-shadow: 0 3px 0 rgba(42, 26, 58, 0.08);
}
.stats-bar[hidden] { display: none; }
.stats-bar .stat {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}
.stats-bar .stat-label {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.85rem;
}
.stats-bar .stat b {
  font-family: "Bagel Fat One", serif;
  font-weight: 400;
  color: var(--ink);
  font-size: 1.1rem;
}
.stats-bar .stat-best {
  color: var(--ink-mute);
  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(--ink-soft);
  font-family: "Quicksand", sans-serif;
  font-weight: 600;
  padding: 7px 16px;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.share-btn:hover:not(:disabled) {
  background: rgba(42, 26, 58, 0.06);
  color: var(--ink);
  border-color: var(--ink-soft);
}
.share-btn:active:not(:disabled) {
  background: rgba(42, 26, 58, 0.10);
}
.share-btn:disabled { opacity: 0.6; cursor: default; }

#rounds {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.round-pip {
  height: 12px;
  background: rgba(42, 26, 58, 0.12);
  border-radius: 999px;
  border: 1px solid rgba(42, 26, 58, 0.18);
  transition: background 0.2s, transform 0.2s;
}
.round-pip.active {
  background: linear-gradient(90deg, var(--gold), var(--orange));
  transform: scale(1.05);
}
.round-pip.miss { background: var(--rust); }
.round-pip.hit { background: linear-gradient(90deg, var(--avocado), var(--gold)); }

#player {
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 18px;
  text-align: center;
  box-shadow: 0 4px 0 rgba(42, 26, 58, 0.08), 0 8px 24px rgba(110, 58, 142, 0.10);
}

#play-btn {
  appearance: none;
  border: 2px solid var(--ink);
  background: linear-gradient(180deg, var(--gold) 0%, var(--orange) 100%);
  color: var(--ink);
  font-family: "Bagel Fat One", serif;
  font-size: 1.2rem;
  font-weight: 400;
  padding: 14px 28px;
  border-radius: 999px;
  cursor: pointer;
  min-width: 220px;
  letter-spacing: 0.02em;
  transition: transform 0.08s, box-shadow 0.15s, opacity 0.2s;
  box-shadow: 0 4px 0 var(--ink), 0 6px 20px rgba(180, 95, 184, .35);
}
#play-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 0 var(--ink), 0 8px 24px rgba(180, 95, 184, .45);
}
#play-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--ink), 0 3px 10px rgba(180, 95, 184, .3);
}
#play-btn:disabled { opacity: 0.5; cursor: not-allowed; }
#play-btn.playing {
  background: linear-gradient(180deg, var(--hot) 0%, var(--plum) 100%);
  color: var(--paper);
}
#play-btn.new-song {
  background: linear-gradient(180deg, var(--hot) 0%, var(--plum-deep) 100%);
  color: var(--paper);
}

#progress-track {
  margin: 16px auto 0;
  height: 8px;
  background: rgba(42, 26, 58, 0.12);
  border-radius: 999px;
  overflow: hidden;
  max-width: 320px;
  border: 1px solid rgba(42, 26, 58, 0.15);
}
#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--orange), var(--hot));
  transition: width 0.05s linear;
}
#status {
  font-family: "Caveat Brush", cursive;
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 1.15rem;
  min-height: 1.3em;
  letter-spacing: 0.01em;
}

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

.combo { position: relative; }

#guess-input {
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: "Quicksand", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: inset 0 2px 4px rgba(42, 26, 58, 0.06);
}
#guess-input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(180, 95, 184, 0.20), inset 0 2px 4px rgba(42, 26, 58, 0.06);
}
#guess-input:disabled { opacity: 0.55; }
#guess-input::placeholder { color: var(--ink-mute); font-weight: 500; }

#suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  list-style: none;
  margin: 0;
  padding: 6px;
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  max-height: 280px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(42, 26, 58, 0.18);
}
#suggestions li {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background 0.1s;
  touch-action: manipulation;
}
#suggestions li.active,
#suggestions li:hover {
  background: linear-gradient(90deg, rgba(201, 142, 224, 0.40), rgba(180, 95, 184, 0.30));
}
#suggestions .s-title { font-weight: 700; color: var(--ink); }
#suggestions .s-meta { font-size: 0.82rem; color: var(--ink-mute); font-weight: 500; }

.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(--ink-mute);
  border: 2px dashed var(--border);
  box-shadow: none;
  align-self: stretch;
  letter-spacing: 0.02em;
}
.actions #skip-btn:hover:not(:disabled),
.actions #giveup-btn:hover:not(:disabled) {
  color: var(--rust);
  border-color: var(--rust);
  background: rgba(122, 58, 142, 0.06);
  transform: none;
  box-shadow: none;
}
.actions #skip-btn:active:not(:disabled),
.actions #giveup-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: none;
}
.actions button {
  appearance: none;
  border: 2px solid var(--border);
  background: var(--paper-2);
  color: var(--ink);
  padding: 12px;
  border-radius: var(--radius);
  font-family: "Quicksand", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.05s, box-shadow 0.15s;
  box-shadow: 0 3px 0 rgba(42, 26, 58, 0.15);
}
.actions button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 rgba(42, 26, 58, 0.18);
}
.actions button:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(42, 26, 58, 0.15);
}
.actions button:disabled { opacity: 0.45; cursor: not-allowed; }
#submit-btn:not(:disabled) {
  background: linear-gradient(180deg, var(--avocado), var(--plum-deep));
  color: var(--paper);
  border-color: var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}
#submit-btn:not(:disabled):hover { box-shadow: 0 4px 0 var(--ink); }
#submit-btn:not(:disabled):active { box-shadow: 0 1px 0 var(--ink); }

#history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-row {
  padding: 11px 14px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 2px solid var(--border);
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.history-row.skip { color: var(--ink-mute); font-style: italic; }
.history-row.miss { border-left: 6px solid var(--rust); background: linear-gradient(90deg, rgba(184, 69, 106, 0.10), var(--paper) 30%); }
.history-row.hit { border-left: 6px solid var(--avocado); background: linear-gradient(90deg, rgba(138, 108, 196, 0.18), var(--paper) 30%); }
.history-row .badge {
  font-family: "Bagel Fat One", serif;
  font-weight: 400;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--orange);
  background: rgba(201, 142, 224, 0.30);
  padding: 3px 10px;
  border-radius: 999px;
}

#result {
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  box-shadow: 0 6px 0 rgba(42, 26, 58, 0.10), 0 12px 32px rgba(110, 58, 142, 0.15);
}
#result h2 {
  font-family: "Bagel Fat One", serif;
  font-weight: 400;
  margin: 0 0 8px;
  font-size: 2rem;
}
#result.win h2 { color: var(--avocado); }
#result.lose h2 { color: var(--rust); }
#result p {
  font-family: "Caveat Brush", cursive;
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 1.25rem;
}
#result-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}
#result-meta img {
  width: 140px;
  height: 140px;
  border-radius: 12px;
  object-fit: cover;
  border: 3px solid var(--border);
  box-shadow: 0 6px 18px rgba(42, 26, 58, 0.25);
}
#play-again {
  appearance: none;
  border: 2px solid var(--ink);
  background: linear-gradient(180deg, var(--hot), var(--plum));
  color: var(--paper);
  font-family: "Bagel Fat One", serif;
  font-weight: 400;
  padding: 16px 36px;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
  border-radius: 999px;
  cursor: pointer;
  min-width: 220px;
  box-shadow: 0 5px 0 var(--ink), 0 8px 24px rgba(216, 65, 140, .40);
  transition: transform 0.08s, box-shadow 0.15s;
}
#play-again:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 0 var(--ink), 0 8px 24px rgba(216, 65, 140, .45);
}
#play-again:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--ink);
}

footer {
  margin-top: 32px;
  text-align: center;
  color: var(--ink-mute);
  font-size: 0.85rem;
  font-weight: 500;
}
.reset-link {
  background: none;
  border: none;
  color: var(--plum);
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px 8px;
  margin-top: 4px;
}
.reset-link:hover { text-decoration: underline; }

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