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

:root {
  --bg-0: #05070f;
  --bg-1: #11182b;
  --bg-2: #18243d;
  --panel: #151f37;
  --panel-2: #1b2744;
  --surface: rgba(9, 18, 36, 0.72);
  --surface-strong: rgba(18, 31, 57, 0.9);
  --line: #39547f;
  --line-soft: rgba(123, 167, 255, 0.22);
  --line-strong: rgba(139, 175, 239, 0.5);
  --primary: #ff5f3f;
  --primary-2: #ff9a3f;
  --success: #53d17d;
  --error: #ff7a7a;
  --text: #e8eefc;
  --muted: #aac0eb;
  --spotify: #1db954;
  --focus: #8bc3ff;

  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 16px;

  --space-1: clamp(8px, 0.6vw, 10px);
  --space-2: clamp(12px, 1vw, 16px);
  --space-3: clamp(16px, 1.4vw, 24px);
  --space-4: clamp(20px, 2vw, 32px);

  --tile-h: clamp(124px, 15vh, 144px);
  --gutter: clamp(14px, 2vw, 28px);
  --shadow-panel: 0 18px 42px rgba(2, 6, 20, 0.42);
  --shadow-control: 0 10px 24px rgba(2, 6, 20, 0.28);
  --scroll-thumb: rgba(123, 167, 255, 0.42);
  --scroll-track: rgba(5, 11, 24, 0.32);
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  position: relative;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  line-height: 1.45;
  background:
    linear-gradient(120deg, rgba(255, 95, 63, 0.13), transparent 34%),
    linear-gradient(240deg, rgba(58, 116, 212, 0.16), transparent 42%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 56%, #0b1427);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(139, 175, 239, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139, 175, 239, 0.028) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.55;
}

.app-shell {
  position: relative;
  z-index: 1;
  height: 100dvh;
  padding: clamp(8px, 1.2vh, var(--gutter));
  overflow: hidden;
  display: flex;
  justify-content: center;
}

.container {
  width: min(1320px, 100%);
  margin: 0 auto;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  min-height: 0;
  height: 100%;
  animation: fadeIn 0.32s ease;
}

.screen.active {
  display: flex;
}

#game-screen.active {
  display: block;
  height: 100%;
}

#start-screen,
#end-screen {
  align-items: center;
  justify-content: center;
}

.panel {
  background: linear-gradient(150deg, rgba(28, 42, 72, 0.97), rgba(19, 30, 54, 0.97));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-panel);
}

.header {
  text-align: center;
}

.logo {
  width: 68px;
  height: 68px;
  margin: 0 auto var(--space-2);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2rem;
  background: linear-gradient(140deg, rgba(255, 95, 63, 0.9), rgba(255, 154, 63, 0.9));
  color: #140a05;
  border: 1px solid rgba(255, 214, 167, 0.52);
  box-shadow: 0 0 0 7px rgba(255, 95, 63, 0.08), 0 10px 28px rgba(255, 95, 63, 0.34);
}

h1,
h2,
h3 {
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 3.4vw, 3rem);
  margin-bottom: 8px;
}

.subtitle {
  font-size: clamp(1rem, 1.4vw, 1.18rem);
  color: var(--muted);
}

.spotify-status {
  width: fit-content;
  max-width: 100%;
  margin: 14px auto 0;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid rgba(123, 167, 255, 0.2);
  border-radius: var(--radius-s);
  background: rgba(7, 15, 31, 0.5);
  color: #c8d7f4;
  font-size: 0.88rem;
  line-height: 1.35;
}

.start-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: var(--space-4);
  width: min(1100px, 100%);
}

.intro-panel,
.mode-panel {
  position: relative;
  overflow: hidden;
  padding: clamp(20px, 2.4vw, 34px);
}

.intro-panel > *,
.mode-panel > * {
  position: relative;
  z-index: 1;
}

.rules {
  width: min(430px, 100%);
  margin: var(--space-3) auto;
  list-style: none;
  display: grid;
  gap: 8px;
  counter-reset: game-rule;
  color: var(--muted);
  font-size: clamp(0.9rem, 1.1vw, 1rem);
}

.rules li {
  counter-increment: game-rule;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 5px 9px 5px 6px;
  border-radius: var(--radius-s);
  background: rgba(8, 17, 34, 0.36);
  text-align: left;
}

.rules li::before {
  content: counter(game-rule);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 180, 96, 0.6);
  background: rgba(255, 132, 36, 0.14);
  color: #ffd9ad;
  font-size: 0.76rem;
  font-weight: 800;
}

.start-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.btn-start {
  min-height: 48px;
  padding: 0 24px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  color: #170802;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 24px rgba(255, 95, 63, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-secondary {
  color: var(--text);
  border: 1px solid rgba(78, 139, 225, 0.55);
  background: linear-gradient(135deg, #1d3865, #28558e);
  box-shadow: 0 10px 24px rgba(30, 75, 145, 0.24);
}

.mode-panel {
  display: grid;
  align-items: center;
}

.mode-panel::after {
  content: "";
  position: absolute;
  width: 220px;
  aspect-ratio: 1;
  right: -88px;
  bottom: -96px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 154, 63, 0.5) 0 3%, transparent 4% 18%, rgba(123, 167, 255, 0.18) 19% 20%, transparent 21% 34%, rgba(123, 167, 255, 0.12) 35% 36%, transparent 37%);
  opacity: 0.48;
}

.mode-panel-content {
  width: 100%;
}

.mode-panel h3 {
  margin-bottom: 16px;
  text-align: center;
  color: #c7d7f5;
}

.mode-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.selected-mode-display {
  width: fit-content;
  max-width: 100%;
  margin: 16px auto 0;
  padding: 6px 10px;
  border-radius: var(--radius-s);
  border: 1px solid rgba(255, 180, 96, 0.25);
  background: rgba(255, 132, 36, 0.09);
  text-align: center;
  color: #ffe3b8;
  font-size: 0.88rem;
  font-weight: 700;
}

.mode-btn {
  width: 100%;
  min-height: 44px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: rgba(13, 24, 46, 0.7);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.mode-btn.active {
  border-color: rgba(255, 180, 96, 0.9);
  background: linear-gradient(135deg, rgba(255, 95, 63, 0.35), rgba(255, 154, 63, 0.35));
  box-shadow: inset 0 0 0 1px rgba(255, 217, 173, 0.08), 0 8px 18px rgba(255, 95, 63, 0.12);
}

.test-mode-btn {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 10;
  width: auto;
  min-width: 88px;
  padding-inline: 18px;
  background: rgba(13, 24, 46, 0.9);
  box-shadow: 0 10px 24px rgba(1, 6, 18, 0.3);
}

.game-layout {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: var(--space-3);
  height: 100%;
  min-height: 0;
}

.game-topbar {
  position: relative;
  padding: var(--space-2) var(--space-3);
  display: grid;
  grid-template-columns: auto auto minmax(260px, 440px);
  grid-template-areas: "stats mode progress";
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.game-stats {
  grid-area: stats;
  display: flex;
  gap: clamp(18px, 2vw, 34px);
}

.game-mode-display {
  grid-area: mode;
  justify-self: center;
  border-radius: var(--radius-s);
  border: 1px solid rgba(255, 180, 96, 0.7);
  background: rgba(255, 132, 36, 0.18);
  color: #ffe3b8;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 8px 14px;
  white-space: nowrap;
}

.stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
}

.stat-value {
  font-size: clamp(1.3rem, 2vw, 1.8rem);
  font-weight: 800;
  color: #ffd26a;
}

#streak {
  color: #8ce7ff;
}

.progress-container {
  grid-area: progress;
  justify-self: end;
  width: min(440px, 100%);
}

.progress-bar {
  width: 100%;
  height: 9px;
  background: #0e1830;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(123, 167, 255, 0.3);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width 0.35s ease;
}

.progress-text {
  margin-top: 6px;
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: right;
}

.game-main {
  display: grid;
  grid-template-columns: clamp(270px, 27vw, 340px) minmax(0, 1fr);
  gap: var(--space-3);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.card-section,
.timeline-section {
  min-height: 0;
}

.card-section {
  padding: clamp(12px, 1.5vw, 18px);
  display: grid;
  grid-template-rows: clamp(116px, 15vh, 132px) auto auto auto;
  align-content: start;
  gap: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.current-card-display {
  height: 100%;
  min-height: 0;
}

.unknown-card,
.revealed-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  height: 100%;
  border-radius: var(--radius-m);
  padding: clamp(10px, 1.2vw, 14px);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.unknown-card {
  cursor: grab;
  border: 2px dashed rgba(154, 188, 255, 0.6);
  background: linear-gradient(150deg, rgba(34, 55, 94, 0.98), rgba(22, 38, 69, 0.98));
}

.unknown-card::after,
.revealed-card::after {
  content: "";
  position: absolute;
  width: 88px;
  aspect-ratio: 1;
  right: -32px;
  bottom: -36px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 176, 97, 0.8) 0 4%, #111c34 5% 19%, #40557c 20% 22%, #111c34 23% 36%, #33496f 37% 39%, #111c34 40%);
  opacity: 0.34;
  z-index: -1;
}

.unknown-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 180, 96, 0.9);
  box-shadow: 0 16px 28px rgba(10, 17, 36, 0.55);
}

.unknown-card.dragging {
  opacity: 0.55;
  transform: scale(1.02);
}

.unknown-icon,
.revealed-icon {
  font-size: clamp(1.4rem, 2.2vw, 2rem);
  margin-bottom: 2px;
}

.unknown-card strong,
.revealed-card h3 {
  font-size: clamp(0.94rem, 1vw, 1.08rem);
}

.unknown-card p,
.revealed-card p {
  color: var(--muted);
}

.hint {
  margin-top: -5px;
  color: #ffd9ad !important;
  font-size: 0.8rem !important;
}

.revealed-card {
  border: 2px solid rgba(83, 209, 125, 0.8);
  background: linear-gradient(160deg, rgba(25, 71, 60, 0.9), rgba(22, 50, 69, 0.9));
}

.playback-status {
  text-align: center;
  margin: 0;
}

.playback-status:empty {
  display: none;
}

.playback-controls {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 2px 0;
}

.audio-block {
  display: grid;
  gap: 4px;
  justify-items: center;
}

.play-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid rgba(158, 255, 193, 0.45);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #05220f;
  background: linear-gradient(140deg, #2de16f, #18b759);
  box-shadow: 0 0 0 7px rgba(29, 185, 84, 0.08), 0 12px 26px rgba(29, 185, 84, 0.34);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.play-btn.is-playing {
  box-shadow: 0 0 0 7px rgba(85, 226, 135, 0.18), 0 12px 26px rgba(29, 185, 84, 0.4);
}

.play-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  filter: saturate(0.6);
}

.play-icon {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.play-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.wave-container {
  min-height: 20px;
}

#wave-animation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 20px;
}

.wave-bar {
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(to top, var(--primary), var(--primary-2));
  animation: wave 0.6s ease-in-out infinite;
}

.wave-bar:nth-child(1) { height: 6px; animation-delay: 0s; }
.wave-bar:nth-child(2) { height: 14px; animation-delay: 0.1s; }
.wave-bar:nth-child(3) { height: 10px; animation-delay: 0.2s; }
.wave-bar:nth-child(4) { height: 18px; animation-delay: 0.3s; }
.wave-bar:nth-child(5) { height: 12px; animation-delay: 0.4s; }

#wave-animation:not(.active) .wave-bar {
  animation: none;
  height: 5px !important;
}

.youtube-link {
  align-self: center;
  width: 100%;
  text-decoration: none;
  min-height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-s);
  border: 1px solid rgba(255, 95, 95, 0.58);
  color: #ffd9d9;
  font-size: 0.86rem;
  font-weight: 700;
  text-align: center;
  line-height: 1;
  white-space: nowrap;
  background: rgba(202, 32, 32, 0.14);
  transition: transform 0.2s ease;
}

.youtube-link:hover {
  border-color: rgba(255, 112, 112, 0.9);
  background: rgba(221, 36, 36, 0.24);
  box-shadow: 0 8px 18px rgba(120, 12, 12, 0.2);
}

.youtube-logo {
  width: 18px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.youtube-logo svg {
  width: 100%;
  height: 100%;
  display: block;
}

.guess-section,
.reveal-section {
  border: 1px solid rgba(123, 167, 255, 0.26);
  border-radius: 10px;
  background: rgba(8, 16, 33, 0.44);
  padding: 9px;
}

.guess-toggle-btn {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border-radius: var(--radius-s);
  border: 1px solid rgba(123, 167, 255, 0.4);
  color: var(--text);
  background: rgba(34, 59, 104, 0.5);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}

.guess-toggle-btn::after {
  content: "+";
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(170, 192, 235, 0.36);
  color: #d7e3fa;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
}

.guess-toggle-btn[aria-expanded="true"] {
  border-color: rgba(255, 180, 96, 0.55);
  background: rgba(255, 132, 36, 0.11);
}

.guess-toggle-btn[aria-expanded="true"]::after {
  content: "−";
  border-color: rgba(255, 180, 96, 0.5);
  color: #ffe0b8;
}

.guess-content {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.guess-inputs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.input-group {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.input-group label {
  color: var(--muted);
  font-size: 0.76rem;
}

.input-group input {
  min-height: 40px;
  width: 100%;
  border-radius: var(--radius-s);
  border: 1px solid rgba(123, 167, 255, 0.4);
  background: rgba(7, 14, 27, 0.9);
  color: var(--text);
  padding: 0 10px;
  font-size: 0.86rem;
}

.guess-btn,
.next-round-btn,
.restart-btn {
  min-height: 44px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius-s);
  cursor: pointer;
  color: #1b0902;
  font-size: 0.9rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.guess-btn {
  width: 100%;
}

.reveal-section {
  display: grid;
  gap: 8px;
  align-content: start;
  border-color: rgba(83, 209, 125, 0.3);
  background: rgba(12, 34, 31, 0.34);
}

.reveal-section:has(#next-round-btn[hidden]) {
  display: none;
}

.song-info {
  display: none;
  padding: 3px 4px 6px;
  text-align: center;
}

.song-info h3 {
  color: #ffd26a;
  margin-bottom: 2px;
  font-size: 0.96rem;
}

.song-info p {
  color: var(--muted);
  font-size: 0.84rem;
}

#song-year {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 10px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.8rem;
  background: rgba(255, 159, 71, 0.2);
  border: 1px solid rgba(255, 159, 71, 0.5);
}

.feedback {
  display: none;
  border-radius: var(--radius-s);
  padding: 8px 10px;
  font-size: 0.84rem;
  white-space: normal;
  line-height: 1.35;
  min-height: 38px;
}

.guess-inline-feedback {
  margin-top: 4px;
}

.feedback.correct {
  color: #bdf4ce;
  border: 1px solid rgba(83, 209, 125, 0.55);
  background: rgba(27, 80, 50, 0.42);
}

.feedback.incorrect {
  color: #ffd3d3;
  border: 1px solid rgba(255, 122, 122, 0.65);
  background: rgba(103, 31, 31, 0.4);
}

.next-round-btn {
  width: 100%;
}

.timeline-section {
  padding: clamp(12px, 1.4vw, 18px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

.timeline-header h3 {
  margin-bottom: 4px;
  color: #f1f5ff;
}

.timeline-instruction {
  color: var(--muted);
  font-size: 0.95rem;
}

.timeline-container {
  position: relative;
  border-radius: 10px;
  border: 1px solid rgba(123, 167, 255, 0.25);
  background-color: rgba(7, 13, 28, 0.76);
  background-image:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(var(--tile-h) + 7px),
      rgba(123, 167, 255, 0.055) calc(var(--tile-h) + 7px),
      rgba(123, 167, 255, 0.055) calc(var(--tile-h) + 8px)
    );
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  align-content: flex-start;
  align-items: stretch;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  min-height: 0;
}

.drop-zone,
.timeline-card {
  flex: 0 0 calc((100% - 24px) / 4);
  width: calc((100% - 24px) / 4);
  height: var(--tile-h);
  min-height: var(--tile-h);
  border-radius: 10px;
}

.drop-zone {
  appearance: none;
  font: inherit;
  position: relative;
  overflow: hidden;
  border: 2px dashed rgba(139, 175, 239, 0.62);
  background: rgba(15, 28, 56, 0.58);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(139, 175, 239, 0.05);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.drop-zone::before {
  content: "+";
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(170, 192, 235, 0.48);
  background: rgba(139, 175, 239, 0.1);
  color: #c9d9fa;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1;
}

.drop-zone span {
  pointer-events: none;
  font-size: 0.88rem;
}

.drop-zone.drag-over,
.drop-zone:hover:not(.is-disabled) {
  border-color: rgba(255, 180, 96, 0.95);
  background: rgba(255, 95, 63, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 180, 96, 0.2), 0 8px 20px rgba(0, 0, 0, 0.16);
  transform: translateY(-2px);
}

.drop-zone.drag-over::before,
.drop-zone:hover:not(.is-disabled)::before {
  border-color: rgba(255, 188, 111, 0.8);
  background: rgba(255, 132, 36, 0.18);
  color: #ffe0b8;
}

.drop-zone.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.timeline-card {
  position: relative;
  isolation: isolate;
  border: 1px solid rgba(139, 175, 239, 0.48);
  background: linear-gradient(145deg, #263a63, #172747);
  padding: 13px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: stretch;
  text-align: left;
  gap: 8px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 10px 24px rgba(1, 6, 18, 0.2);
}

.timeline-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(to bottom, var(--primary), var(--primary-2));
  z-index: 1;
}

.timeline-card::after {
  content: "";
  position: absolute;
  width: 86px;
  aspect-ratio: 1;
  right: -25px;
  bottom: -28px;
  border-radius: 50%;
  background:
    radial-gradient(circle, #ffb061 0 5%, #111c34 6% 18%, #40557c 19% 21%, #111c34 22% 34%, #33496f 35% 37%, #111c34 38% 100%);
  opacity: 0.5;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), inset 0 0 16px rgba(0, 0, 0, 0.45);
  z-index: 0;
}

.timeline-card.has-album-cover::after {
  display: none;
}

.timeline-cover-background {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  opacity: 0.5;
  pointer-events: none;
}

.spotify-source-link {
  position: absolute;
  right: 9px;
  bottom: 9px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  background: rgba(10, 17, 31, 0.88);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.spotify-source-icon {
  display: block;
  width: 21px;
  height: 21px;
}

.timeline-info {
  position: relative;
  z-index: 1;
  min-height: 0;
  width: 100%;
  display: grid;
  align-content: center;
  gap: 5px;
  padding-right: 24px;
  overflow: visible;
}

.timeline-title {
  color: #ffffff;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.24;
  display: block;
  max-height: calc(3 * 1.24em + 1px);
  overflow: hidden;
  overflow-wrap: anywhere;
  text-wrap: balance;
  padding-bottom: 1px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.timeline-artist {
  position: relative;
  padding-left: 10px;
  font-size: 0.8rem;
  line-height: 1.25;
  min-height: 1.25em;
  color: #c6d6f6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-artist::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--primary-2);
  transform: translateY(-50%);
}

.timeline-year {
  position: relative;
  z-index: 1;
  align-self: end;
  justify-self: start;
  display: inline-block;
  width: fit-content;
  border-radius: 6px;
  border: 1px solid rgba(255, 188, 111, 0.62);
  background: rgba(255, 132, 36, 0.2);
  color: #ffe2bd;
  padding: 3px 8px;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.1;
}

.end-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: min(620px, 100%);
  padding: clamp(20px, 2.4vw, 34px);
  text-align: center;
}

.end-card::before {
  content: "";
  position: absolute;
  width: 300px;
  aspect-ratio: 1;
  right: -142px;
  bottom: -150px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 176, 97, 0.7) 0 3%, #111c34 4% 18%, #40557c 19% 20%, #111c34 21% 34%, #33496f 35% 36%, #111c34 37%);
  opacity: 0.22;
  z-index: -1;
}

.end-card h2 {
  font-size: clamp(1.7rem, 3vw, 2.25rem);
}

.result-hero {
  width: min(390px, 100%);
  margin: 10px auto 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
}

.final-score {
  font-size: clamp(2.8rem, 8vw, 4.8rem);
  font-weight: 900;
  color: #ffd26a;
  line-height: 1;
  text-align: right;
  text-shadow: 0 8px 24px rgba(255, 157, 55, 0.18);
}

.grade {
  width: 86px;
  height: 86px;
  margin: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2.2rem;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 0 0 7px rgba(123, 167, 255, 0.08), var(--shadow-control);
}

.grade.s { background: linear-gradient(135deg, #ffd700, #ffe97c); color: #2c2200; }
.grade.a { background: linear-gradient(135deg, #53d17d, #93e7ae); color: #0f2619; }
.grade.b { background: linear-gradient(135deg, #5fb3ff, #8dd0ff); color: #082847; }
.grade.c { background: linear-gradient(135deg, #ffac59, #ffc06f); color: #371a00; }
.grade.d { background: linear-gradient(135deg, #ff8686, #ffb0b0); color: #3b0f0f; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  border-radius: var(--radius-s);
  border: 1px solid rgba(123, 167, 255, 0.26);
  background: rgba(10, 19, 39, 0.6);
  padding: 12px 10px;
}

.stat-card .stat-value {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.restart-btn {
  width: min(260px, 100%);
}

button,
a,
input {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

button:hover,
a:hover {
  transform: translateY(-1px);
}

button:active,
a:active {
  transform: translateY(0);
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.card-section,
.timeline-container,
#start-screen,
#end-screen {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

.card-section::-webkit-scrollbar,
.timeline-container::-webkit-scrollbar,
#start-screen::-webkit-scrollbar,
#end-screen::-webkit-scrollbar {
  width: 8px;
}

.card-section::-webkit-scrollbar-track,
.timeline-container::-webkit-scrollbar-track,
#start-screen::-webkit-scrollbar-track,
#end-screen::-webkit-scrollbar-track {
  background: var(--scroll-track);
}

.card-section::-webkit-scrollbar-thumb,
.timeline-container::-webkit-scrollbar-thumb,
#start-screen::-webkit-scrollbar-thumb,
#end-screen::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--scroll-thumb);
  background-clip: padding-box;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes wave {
  0%,
  100% { transform: scaleY(1); }
  50% { transform: scaleY(1.8); }
}

@media (max-width: 1024px) {
  .game-topbar {
    grid-template-columns: auto auto minmax(220px, 1fr);
    gap: 14px;
  }

  .progress-container {
    width: min(340px, 100%);
  }

  .game-main {
    grid-template-columns: minmax(250px, 36%) minmax(0, 1fr);
  }

  .timeline-container {
    --tile-h: clamp(128px, 16vh, 136px);
  }

  .timeline-card {
    padding: 11px;
    gap: 7px;
  }

  .timeline-card::after {
    width: 70px;
    right: -24px;
    bottom: -25px;
  }

  .timeline-info {
    gap: 3px;
    padding-right: 24px;
  }

  .timeline-title {
    font-size: 0.9rem;
  }

  .timeline-artist {
    font-size: 0.74rem;
  }
}

@media (min-width: 701px) and (max-height: 700px) {
  #start-screen,
  #end-screen {
    justify-content: flex-start;
    overflow-y: auto;
    padding-block: 8px;
  }

  .game-layout {
    gap: 10px;
  }

  .game-topbar {
    padding: 8px 14px;
  }

  .intro-panel,
  .mode-panel {
    padding: 20px 24px;
  }

  .logo {
    width: 58px;
    height: 58px;
    font-size: 1.7rem;
  }

  .rules {
    margin-block: 14px;
    gap: 6px;
  }

  .rules li {
    min-height: 30px;
    padding-block: 3px;
  }

  .btn-start {
    min-height: 44px;
  }

  .card-section,
  .timeline-section {
    padding: 10px 12px;
  }

  .card-section {
    grid-template-rows: 104px auto auto auto;
    gap: 8px;
  }

  .play-btn {
    width: 56px;
    height: 56px;
  }

  .play-icon {
    width: 27px;
    height: 27px;
  }

  .timeline-container {
    --tile-h: 120px;
  }

  .timeline-card {
    padding: 10px 12px;
    gap: 5px;
  }

  .timeline-info {
    gap: 3px;
  }

  .timeline-title {
    line-height: 1.22;
  }

  .timeline-year {
    padding: 2px 7px;
  }
}

@media (max-width: 860px) {
  #start-screen,
  #end-screen {
    justify-content: flex-start;
    overflow-y: auto;
    padding-block: 12px;
  }

  .start-layout {
    width: min(620px, 100%);
    margin: auto;
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .mode-panel {
    min-height: 280px;
  }

  .end-card {
    margin: auto;
  }
}

@media (max-width: 700px) {
  .app-shell {
    padding: 8px;
  }

  .container {
    height: 100%;
    min-height: 0;
  }

  .intro-panel,
  .mode-panel,
  .card-section,
  .timeline-section,
  .end-card {
    padding: 12px;
  }

  .logo {
    width: 60px;
    height: 60px;
    font-size: 1.75rem;
  }

  .spotify-status {
    font-size: 0.82rem;
  }

  .start-actions {
    flex-direction: column;
  }

  .btn-start {
    width: 100%;
  }

  .mode-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-panel {
    min-height: 0;
  }

  .game-layout {
    gap: 10px;
  }

  .game-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "stats mode"
      "progress progress";
    gap: 8px 10px;
    padding: 10px 12px;
  }

  .game-stats {
    justify-content: flex-start;
    gap: 22px;
  }

  .game-mode-display {
    justify-self: end;
    padding: 6px 9px;
    font-size: 0.8rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .progress-container {
    justify-self: stretch;
    width: 100%;
  }

  .progress-text {
    margin-top: 4px;
    font-size: 0.82rem;
  }

  .game-main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1.08fr);
    gap: 10px;
  }

  .card-section {
    grid-template-rows: 112px auto auto auto;
    overflow-y: auto;
  }

  .timeline-section {
    overflow: hidden;
  }

  .guess-inputs {
    grid-template-columns: 1fr;
  }

  .timeline-container {
    --tile-h: 116px;
    padding: 8px;
  }

  .drop-zone,
  .timeline-card {
    flex-basis: calc((100% - 16px) / 3);
    width: calc((100% - 16px) / 3);
  }

  .drop-zone {
    gap: 6px;
    padding: 7px;
  }

  .drop-zone::before {
    width: 26px;
    height: 26px;
    font-size: 1.05rem;
  }

  .drop-zone span {
    font-size: 0.72rem;
  }

  .timeline-card {
    border-radius: 8px;
    padding: 8px 7px 8px 10px;
    gap: 4px;
  }

  .timeline-card::before {
    width: 3px;
  }

  .timeline-card::after {
    width: 48px;
    right: -22px;
    bottom: -21px;
    opacity: 0.34;
  }

  .timeline-info {
    gap: 2px;
    padding-right: 20px;
  }

  .spotify-source-link {
    right: 6px;
    bottom: 6px;
    width: 29px;
    height: 29px;
  }

  .timeline-title {
    font-size: 0.74rem;
    line-height: 1.2;
    max-height: calc(3 * 1.2em + 1px);
    overflow: hidden;
  }

  .timeline-artist {
    padding-left: 7px;
    font-size: 0.7rem;
    line-height: 1.25;
  }

  .timeline-artist::before {
    width: 3px;
    height: 3px;
  }

  .timeline-year {
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 0.66rem;
  }

  .result-hero {
    width: min(320px, 100%);
    gap: 16px;
  }

  .grade {
    width: 76px;
    height: 76px;
    font-size: 2rem;
  }
}

@media (max-width: 430px) {
  .start-layout {
    gap: 12px;
  }

  .intro-panel,
  .mode-panel {
    padding: 16px 14px;
  }

  h1 {
    font-size: 2rem;
  }

  .rules {
    margin-block: 16px;
  }

  .game-topbar {
    padding-inline: 10px;
  }

  .game-stats {
    gap: 18px;
  }

  .game-mode-display {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .timeline-header h3 {
    font-size: 1.08rem;
  }

  .timeline-instruction {
    font-size: 0.82rem;
  }

  .stats-grid {
    gap: 6px;
  }

  .stat-card {
    padding-inline: 6px;
  }

  .stat-card .stat-label {
    font-size: 0.68rem;
  }
}

/* =======================
   TELEFOON
   Eén scrollende pagina in plaats van scrollvakken, de tijdlijn als lijst
   en de uitslag als balk onderin beeld. Ook voor liggende telefoons.
======================= */
@media (max-width: 700px), (pointer: coarse) and (max-height: 500px) {
  html {
    height: auto;
    overflow: visible;
  }

  body {
    height: auto;
    overflow-x: clip;
    overflow-y: visible;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  }

  .container,
  .screen,
  #game-screen.active,
  .game-layout,
  .game-main,
  .current-card-display,
  .unknown-card {
    height: auto;
  }

  button,
  a,
  input {
    touch-action: manipulation;
  }

  /* Alleen vervagen: een transform-animatie laat vaste knoppen even verspringen */
  .screen {
    animation-name: screenFadeIn;
  }

  /* Startscherm: startknop blijft in beeld terwijl je een modus kiest */
  #start-screen {
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    overflow: visible;
    padding-block: 4px 96px;
  }

  /* .intro-panel > * maakt een eigen laag; zonder dit valt de vaste knop onder het moduspaneel */
  .intro-panel > .start-actions {
    z-index: 20;
  }

  #start-btn {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 20;
    width: auto;
    max-width: 560px;
    margin-inline: auto;
    box-shadow: 0 12px 32px rgba(1, 6, 18, 0.6);
  }

  .test-mode-btn {
    position: static;
    align-self: center;
    margin-top: 12px;
    box-shadow: none;
  }

  #end-screen.active {
    min-height: calc(100dvh - 16px);
  }

  /* Spelscherm */
  .game-layout {
    gap: 8px;
  }

  .game-topbar {
    position: sticky;
    top: 0;
    z-index: 15;
    padding: 8px 12px;
    gap: 6px 10px;
    box-shadow: 0 8px 20px rgba(1, 6, 18, 0.45);
  }

  .game-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    overflow: visible;
    gap: 8px;
  }

  .card-section {
    grid-template-rows: none;
    overflow: visible;
    scrollbar-gutter: auto;
    gap: 10px;
  }

  .unknown-card {
    padding: 10px 12px;
    gap: 4px;
  }

  .playback-controls {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    justify-items: stretch;
    gap: 14px;
  }

  .youtube-link {
    min-height: 44px;
  }

  .input-group input {
    min-height: 44px;
    font-size: 16px; /* voorkomt automatisch inzoomen op iPhone */
  }

  .timeline-section {
    overflow: visible;
  }

  /* Tijdlijn als lijst, van oud (boven) naar nieuw (onder) */
  .timeline-container {
    flex: none;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 8px;
    overflow: visible;
    scrollbar-gutter: auto;
    background-image: none;
  }

  .drop-zone,
  .timeline-card {
    flex: none;
    width: 100%;
    height: auto;
    min-height: 0;
  }

  .drop-zone {
    flex-direction: row;
    gap: 10px;
    min-height: 46px;
    padding: 6px 12px;
  }

  .drop-zone::before {
    width: 26px;
    height: 26px;
    font-size: 1.1rem;
  }

  .drop-zone span {
    font-size: 0.86rem;
  }

  .drop-zone:hover:not(.is-disabled) {
    transform: none;
  }

  /* Na het plaatsen alleen de kaarten tonen */
  .drop-zone.is-disabled {
    display: none;
  }

  .timeline-card {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "year info";
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 9px 12px 9px 14px;
    border-radius: 10px;
  }

  .timeline-card::after {
    width: 56px;
    right: -18px;
    bottom: -22px;
  }

  .timeline-year {
    grid-area: year;
    align-self: center;
    padding: 4px 8px;
    font-size: 0.85rem;
  }

  .timeline-info {
    grid-area: info;
    gap: 2px;
    padding-right: 36px;
  }

  .timeline-title {
    max-height: none;
    overflow: visible;
    overflow-wrap: break-word;
    font-size: 0.95rem;
    line-height: 1.25;
  }

  .timeline-artist {
    padding-left: 9px;
    font-size: 0.8rem;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .timeline-artist::before {
    top: 0.62em;
  }

  .spotify-source-link {
    top: 50%;
    right: 10px;
    bottom: auto;
    width: 30px;
    height: 30px;
    transform: translateY(-50%);
  }

  /* Uitslag als balk onderin beeld */
  .reveal-section {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 20;
    max-width: 560px;
    margin-inline: auto;
    padding: 12px;
    background: linear-gradient(150deg, rgba(20, 58, 49, 0.98), rgba(17, 37, 58, 0.98));
    box-shadow: 0 -8px 30px rgba(1, 6, 18, 0.6);
    animation: revealSheetIn 0.22s ease;
  }

  .song-info h3 {
    font-size: 1.08rem;
  }

  /* Ruimte onderaan, zodat de uitslagbalk geen kaarten afdekt */
  .game-layout:has(#next-round-btn:not([hidden])) {
    padding-bottom: 210px;
  }
}

/* Liggende telefoon: uitslag in één rij */
@media (pointer: coarse) and (max-height: 500px) and (min-width: 560px) {
  .reveal-section {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto;
    align-items: center;
    max-width: 780px;
  }

  .game-layout:has(#next-round-btn:not([hidden])) {
    padding-bottom: 120px;
  }
}

@keyframes screenFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes revealSheetIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
