:root {
  --bg: #07080B;
  --surface: rgba(18, 21, 28, 0.72);
  --surface-solid: #12151C;
  --surface-raised: #1A1F29;
  --line: rgba(255, 255, 255, 0.08);
  --text: #F3F1EC;
  --text-muted: #9A9388;
  --accent: #FF4D6A;
  --accent-hot: #FF8A5B;
  --accent-dim: #8A2A3A;
  --good: #3EE8B5;
  --cream: #F0D2A8;
  --font-display: 'Syne', system-ui, sans-serif;
  --font-body: 'Outfit', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(255, 77, 106, 0.16), transparent 55%),
    radial-gradient(900px 500px at 100% 10%, rgba(62, 232, 181, 0.1), transparent 50%),
    var(--bg);
}

button {
  font-family: inherit;
}

.glow {
  position: fixed;
  width: 42vw;
  height: 42vw;
  max-width: 520px;
  max-height: 520px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

.glow-coral {
  top: -12%;
  left: -8%;
  background: #FF4D6A;
}

.glow-mint {
  right: -10%;
  top: 18%;
  background: #3EE8B5;
  opacity: 0.22;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.18;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.page {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 8, 11, 0.55);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.5px;
  background: #16181F;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 8px 24px rgba(255, 77, 106, 0.28);
}

.brand-mark i {
  display: block;
  width: 3px;
  border-radius: 99px;
  background: #FF4D6A;
}

.brand-mark i:nth-child(1) { height: 10px; background: #FF4D6A; }
.brand-mark i:nth-child(2) { height: 18px; background: #FF7A68; }
.brand-mark i:nth-child(3) { height: 26px; background: #E8C4A0; }
.brand-mark i:nth-child(4) { height: 9px;  background: #C8EBD4; }
.brand-mark i:nth-child(5) { height: 26px; background: #7ED9B8; }
.brand-mark i:nth-child(6) { height: 18px; background: #5CE0B8; }
.brand-mark i:nth-child(7) { height: 10px; background: #4CE0B3; }

.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: 0.12em;
  transform: skewX(-8deg);
  background: linear-gradient(105deg, #fff 20%, var(--cream) 50%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topnav {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.nav-link {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 500;
  outline: none;
}

.nav-link:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

.nav-link.active {
  color: #14080c;
  background: linear-gradient(180deg, #FF8A5B, var(--accent));
  font-weight: 600;
}

/* ---------- Layout ---------- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  padding: 20px 16px 16px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.game-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.ad-col-left { display: none; }

@media (min-width: 1100px) {
  .layout {
    max-width: 1280px;
    grid-template-columns: 160px minmax(0, 640px) 160px;
    justify-content: center;
    align-items: start;
    gap: 24px;
    padding-left: 20px;
    padding-right: 20px;
  }
  .ad-col-left { display: block; }
}

@media (min-width: 1360px) {
  .layout {
    max-width: 1440px;
    grid-template-columns: 300px minmax(0, 640px) 300px;
  }
}

/* ---------- Ad slots ---------- */

.ad-band {
  width: 100%;
  padding: 12px 16px 0;
  display: flex;
  justify-content: center;
}

.ad-band-bottom {
  padding: 8px 16px 0;
}

.ad-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 16px;
}

.ad-slot {
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.03);
}

.ad-slot-leaderboard {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
}

.ad-slot-infeed {
  min-height: 250px;
}

.ad-slot-sky {
  min-height: 600px;
}

.ad-slot-box {
  min-height: 250px;
}

@media (max-width: 1099px) {
  .ad-col-right .ad-slot-sky { min-height: 250px; }
  .ad-col-right .ad-slot-box { display: none; }
}

/* ---------- Puzzle card ---------- */

.puzzle-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  backdrop-filter: blur(22px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 30px 80px rgba(0, 0, 0, 0.35);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.puzzle-card.verdict-wrong {
  border-color: rgba(255, 77, 106, 0.85);
  box-shadow:
    0 0 0 1px rgba(255, 77, 106, 0.45),
    0 0 48px rgba(255, 77, 106, 0.22),
    0 30px 80px rgba(0, 0, 0, 0.35);
}

.puzzle-card.verdict-right {
  border-color: rgba(62, 232, 181, 0.9);
  box-shadow:
    0 0 0 1px rgba(62, 232, 181, 0.5),
    0 0 48px rgba(62, 232, 181, 0.2),
    0 30px 80px rgba(0, 0, 0, 0.35);
}

.puzzle-card.flash-wrong { animation: flash-wrong 0.55s ease; }
.puzzle-card.flash-right { animation: flash-right 0.55s ease; }

@keyframes flash-wrong {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@keyframes flash-right {
  0% { transform: scale(1); }
  40% { transform: scale(1.015); }
  100% { transform: scale(1); }
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.puzzle-kicker {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cream);
}

.puzzle-date {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0;
}

.demo-banner {
  margin: 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(240, 210, 168, 0.1);
  color: var(--cream);
  font-size: 0.8rem;
}

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

.how span {
  font-size: 0.72rem;
  color: var(--text-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
}

/* Waveform hero */

.stage {
  position: relative;
  border-radius: 16px;
  padding: 28px 16px 22px;
  overflow: hidden;
  background:
    radial-gradient(80% 120% at 50% 120%, rgba(255, 77, 106, 0.22), transparent 55%),
    linear-gradient(180deg, #0C0E14, #151922);
  border: 1px solid var(--line);
}

.puzzle-card.verdict-wrong .stage {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(255, 77, 106, 0.45);
  background:
    radial-gradient(80% 120% at 50% 120%, rgba(255, 77, 106, 0.38), transparent 55%),
    linear-gradient(180deg, #0C0E14, #151922);
}

.puzzle-card.verdict-right .stage {
  border-color: var(--good);
  box-shadow: inset 0 0 0 2px rgba(62, 232, 181, 0.45);
  background:
    radial-gradient(80% 120% at 50% 120%, rgba(62, 232, 181, 0.32), transparent 55%),
    linear-gradient(180deg, #0C0E14, #151922);
}

.verdict-label {
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.verdict-label.wrong { color: var(--accent); }
.verdict-label.right { color: var(--good); }

.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 18px,
    rgba(255, 255, 255, 0.015) 18px,
    rgba(255, 255, 255, 0.015) 19px
  );
  pointer-events: none;
}

.waveform {
  position: relative;
  height: 108px;
}

#wave-canvas {
  display: block;
  width: 100%;
  height: 108px;
}

.transport {
  display: flex;
  align-items: center;
  gap: 16px;
}

.play-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(180deg, #FF8A5B 0%, var(--accent) 100%);
  color: #1a0d10;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 0 0 6px rgba(255, 77, 106, 0.16),
    0 12px 28px rgba(255, 77, 106, 0.35);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.play-btn svg {
  width: 22px;
  height: 22px;
  margin-left: 3px;
}

.play-btn:hover {
  transform: scale(1.04);
  filter: brightness(1.06);
}

.play-btn:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 3px;
}

.play-btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
  filter: none;
}

.guess-dots {
  display: flex;
  gap: 7px;
  flex: 1;
}

.guess-dots .dot {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
}

.guess-dots .dot.used { background: var(--accent-dim); }
.guess-dots .dot.wrong { background: var(--accent); }
.guess-dots .dot.correct { background: var(--good); }

.clip-length-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.04em;
  margin: 0;
}

/* Guess input */

.guess-form {
  position: relative;
}

.guess-input {
  width: 100%;
  padding: 15px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 1.02rem;
}

.guess-input::placeholder {
  color: #6F6A64;
}

.guess-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.autocomplete {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #1C212C;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  z-index: 10;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
}

.autocomplete button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 0.92rem;
}

.ac-art {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #0C0E14;
}

.ac-art-empty {
  display: block;
  background: var(--surface-raised);
}

.ac-copy {
  min-width: 0;
}

.autocomplete .song-artist {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.autocomplete button:hover,
.autocomplete button:focus {
  background: rgba(255, 77, 106, 0.1);
}

.skip-btn {
  margin-top: 4px;
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Guess history */

.guess-history {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guess-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface-raised);
  font-size: 0.92rem;
}

.guess-art {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.guess-label {
  flex: 1;
  min-width: 0;
}

.guess-row.correct {
  background: rgba(62, 232, 181, 0.1);
  border: 1px solid rgba(62, 232, 181, 0.45);
}

.guess-row.wrong {
  border: 1px solid transparent;
}

/* Reveal */

.reveal {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

.reveal img {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
}

.reveal-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
}

.reveal-artist {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.reveal-effect {
  margin-left: auto;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  padding: 5px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- Archive ---------- */

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.archive-empty {
  color: var(--text-muted);
  line-height: 1.5;
}

.archive-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-size: 0.95rem;
  backdrop-filter: blur(16px);
}

.archive-row .status {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.archive-row .status.solved { color: var(--good); }

/* ---------- Footer ---------- */

.footer {
  padding: 20px 16px 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* ---------- Win modal ---------- */

.win-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(4, 5, 8, 0.72);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.win-modal {
  width: min(420px, 100%);
  background: linear-gradient(180deg, #1A1F29, #12151C);
  border: 1px solid rgba(62, 232, 181, 0.45);
  border-radius: 22px;
  padding: 28px 24px 22px;
  text-align: center;
  box-shadow: 0 0 0 1px rgba(62, 232, 181, 0.15), 0 30px 80px rgba(0, 0, 0, 0.55);
}

.win-kicker {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--good);
}

.win-modal h2 {
  margin: 8px 0 4px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.55rem;
}

.win-sub {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.win-art {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: 14px;
  margin: 0 auto 16px;
  display: block;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.win-art-empty {
  background: linear-gradient(135deg, var(--accent), var(--good));
}

.win-track {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
}

.win-artist {
  color: var(--text-muted);
  margin-top: 4px;
}

.win-effect {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  padding: 5px 10px;
  border-radius: 999px;
}

.win-links {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 18px 0 8px;
}

.win-links a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.78rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
}

.win-links a:hover {
  border-color: var(--good);
  color: var(--good);
}

.win-close {
  margin-top: 8px;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(180deg, #5CE0B8, var(--good));
  color: #06261c;
}

@media (prefers-reduced-motion: reduce) {
  .grain, .glow { display: none; }
  .puzzle-card.flash-wrong,
  .puzzle-card.flash-right { animation: none; }
}
