/* ═══════════════════════════════════════════════════════════
   THINK FOR YOURSELF — style.css
   Retro / vintage · Desktop-first · Album-reactive theming
   Fonts: Playfair Display · Courier Prime · DM Serif Display
═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;0,900;1,400;1,700&family=Courier+Prime:ital,wght@0,400;0,700;1,400&family=DM+Serif+Display:ital@0;1&display=swap');

/* ─────────────────────────────────────────────────────────
   TOKENS
───────────────────────────────────────────────────────── */
:root {
  --bg:           #0e0c0a;
  --bg-2:         #161310;
  --bg-3:         #1f1b17;
  --surface:      #262118;
  --surface-2:    #2e2820;
  --border:       #3a3128;
  --border-light: #4a4038;

  --text:         #f0e6d3;
  --text-2:       #b8a898;
  --text-3:       #786858;

  --accent:       #c9940a;
  --accent-dim:   rgba(201,148,10,0.25);
  --accent-faint: rgba(201,148,10,0.08);

  --correct:      #4a7c59;
  --correct-dim:  rgba(74,124,89,0.2);
  --wrong:        #8b3a3a;
  --wrong-dim:    rgba(139,58,58,0.2);
  --muted:        #5a5048;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono:    'Courier Prime', 'Courier New', monospace;
  --font-num:     'DM Serif Display', Georgia, serif;

  --radius-sm: 3px;
  --radius:    6px;
  --radius-lg: 12px;

  --ease:        cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out:    cubic-bezier(0, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Screen transition speed */
  --t-screen: 180ms;
}

/* ─────────────────────────────────────────────────────────
   RESET
───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='250' height='250' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
}

button { font-family: var(--font-display); cursor: pointer; border: none; background: none; color: inherit; }
input  { font-family: var(--font-display); border: none; outline: none; background: none; color: inherit; }
ul     { list-style: none; }

/* ─────────────────────────────────────────────────────────
   SCREEN TRANSITIONS — snappy, ~180ms
   Screens stack on top of each other (position: fixed)
   JS adds/removes: .active .hidden .exit-left .exit-right
                    .enter-left .enter-right
───────────────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* will-change removed — causes extra compositing layers on iPad */
}

.screen.hidden {
  display: none;
}

/* Base entering/exiting states */
.screen.enter-right {
  transform: translateX(40px) scale(0.97);
  opacity: 0;
  transition: transform var(--t-screen) var(--ease-out),
              opacity   var(--t-screen) var(--ease-out);
}

.screen.enter-left {
  transform: translateX(-40px) scale(0.97);
  opacity: 0;
  transition: transform var(--t-screen) var(--ease-out),
              opacity   var(--t-screen) var(--ease-out);
}

.screen.exit-left {
  transform: translateX(-40px) scale(0.97);
  opacity: 0;
  transition: transform var(--t-screen) var(--ease-out),
              opacity   var(--t-screen) var(--ease-out);
}

.screen.exit-right {
  transform: translateX(40px) scale(0.97);
  opacity: 0;
  transition: transform var(--t-screen) var(--ease-out),
              opacity   var(--t-screen) var(--ease-out);
}

.screen.active {
  transform: translateX(0) scale(1);
  opacity: 1;
  transition: transform var(--t-screen) var(--ease-out),
              opacity   var(--t-screen) var(--ease-out);
}

/* ═══════════════════════════════════════════════════════════
   MENU SCREEN
═══════════════════════════════════════════════════════════ */
#screen-menu {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(201,148,10,0.07) 0%, transparent 60%),
    radial-gradient(ellipse at 75% 80%, rgba(180,80,40,0.06) 0%, transparent 55%),
    var(--bg);
  gap: 56px;
}

#menu-header { text-align: center; }

#site-title {
  font-family: var(--font-display);
  font-size: clamp(48px, 6vw, 80px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: -1px;
  line-height: 1;
  color: var(--text);
  text-shadow: 3px 3px 0 rgba(0,0,0,0.5), 0 0 60px rgba(201,148,10,0.15);
}

#site-tagline {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-top: 10px;
}

/* Mode grid */
#mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 220px);
  gap: 20px;
  align-items: stretch;
}

.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 24px 20px;
  aspect-ratio: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.25s var(--ease-spring), border-color 0.2s, box-shadow 0.25s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 4px 24px rgba(0,0,0,0.4);
}

.mode-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(255,255,255,0.04) 0%, transparent 70%);
  pointer-events: none;
}

.mode-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px var(--accent-dim);
}

.mode-card:active { transform: translateY(-1px) scale(0.99); }

.mode-card-graphic {
  position: absolute;
  inset: 0 0 70px 0;
  opacity: 0.18;
  background-size: 60%;
  background-repeat: no-repeat;
  background-position: center;
  transition: opacity 0.25s;
}

.mode-card:hover .mode-card-graphic { opacity: 0.28; }

#graphic-endless {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 60' fill='none'%3E%3Cpath d='M10 30 Q25 10 40 30 Q55 50 70 30 Q85 10 90 30' stroke='%23f0e6d3' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E");
}
#graphic-album {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 80' fill='none'%3E%3Ccircle cx='40' cy='40' r='35' stroke='%23f0e6d3' stroke-width='3'/%3E%3Ccircle cx='40' cy='40' r='18' stroke='%23f0e6d3' stroke-width='2'/%3E%3Ccircle cx='40' cy='40' r='4' fill='%23f0e6d3'/%3E%3C/svg%3E");
}
#graphic-sets {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 60' fill='%23f0e6d3'%3E%3Crect x='5' y='8' width='70' height='10' rx='2'/%3E%3Crect x='5' y='25' width='50' height='10' rx='2'/%3E%3Crect x='5' y='42' width='60' height='10' rx='2'/%3E%3C/svg%3E");
}

.mode-card-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  position: relative;
  z-index: 1;
}

.mode-card-desc {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-3);
  text-align: center;
  position: relative;
  z-index: 1;
}

/* ═══════════════════════════════════════════════════════════
   CAROUSEL SCREEN — vinyl crate, one dominant cover
═══════════════════════════════════════════════════════════ */
#screen-carousel {
  justify-content: space-between;
  padding: 0;
  overflow: hidden;
}

/* Blurred BG */
#carousel-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#carousel-bg-image,
#carousel-bg-video {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  filter: blur(32px) brightness(0.25) saturate(0.6);
  transform: scale(1.06);
  transition: opacity 0.5s var(--ease);
}

#carousel-bg-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to bottom,
    rgba(14,12,10,0.55) 0%,
    rgba(14,12,10,0.15) 35%,
    rgba(14,12,10,0.15) 65%,
    rgba(14,12,10,0.9)  100%);
}

#carousel-assets {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

/* Asset layers — bg sits at bottom, fg floats above */
/* Asset wrapper centres both layers */
.asset-wrap {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 75%;
  pointer-events: none;
}

.asset-bg {
  position: absolute;
  bottom: 0;
  right: 4%;
  width: 38%;
  max-width: 420px;
  height: auto;
  display: block;
  object-fit: contain;
  opacity: 0.85;
  filter: grayscale(15%) brightness(0.55);
  animation: asset-bg-in 0.5s ease both;
}

.asset-fg {
  position: absolute;
  bottom: 0;
  right: 4%;
  width: 38%;
  max-width: 420px;
  height: auto;
  display: block;
  object-fit: contain;
  opacity: 0.92;
  animation: asset-fg-in 0.4s ease both;
}

@keyframes asset-fade-in {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Override opacity after animation settles */
.asset-bg  { animation: asset-bg-in  0.5s ease both; }
.asset-fg  { animation: asset-fg-in  0.4s ease both; }

@keyframes asset-bg-in {
  from { opacity: 0;    transform: translateY(24px); }
  to   { opacity: 0.85; transform: translateY(0); }
}

@keyframes asset-fg-in {
  from { opacity: 0;    transform: translateY(32px); }
  to   { opacity: 0.92; transform: translateY(0); }
}

/* Header */
#carousel-header {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 28px 48px 0;
  flex-shrink: 0;
}

#carousel-back-btn {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--text-2);
  width: 38px; height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(14,12,10,0.5);
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  flex-shrink: 0;
}

#carousel-back-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-faint);
}

#carousel-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 4px;
  color: var(--text-3);
  text-transform: uppercase;
}

/* ── Stage: arrows + viewport ── */
#carousel-stage {
  position: relative;
  z-index: 2;
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 0 48px;
  min-height: 0;
}

/* Viewport: clips overflow so only centre + edge peeks show */
#carousel-viewport {
  flex: 1;
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  perspective: 1200px;
}

/* Nav arrows */
#carousel-prev,
#carousel-next {
  font-size: 28px;
  line-height: 1;
  padding-bottom: 2px;
  color: var(--text-2);
  width: 48px; height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(14,12,10,0.65);
  backdrop-filter: blur(8px);
  transition: color 0.12s, border-color 0.12s, transform 0.15s;
  z-index: 3;
}

#carousel-prev:hover,
#carousel-next:hover {
  color: var(--text);
  border-color: var(--accent);
  transform: scale(1.1);
}

/* ── Cards — vinyl sleeve scale ── */
.carousel-card {
  position: absolute;
  width: 380px;
  cursor: pointer;
  /* 3D flip container */
  perspective: 1000px;
  transition: transform 0.4s var(--ease), opacity 0.3s var(--ease), filter 0.3s var(--ease);
}

/* Position offsets — each card sits at an offset from centre */
.carousel-card.active    { transform: translateX(0)     scale(1)    translateZ(0);   opacity: 1;    filter: none;                        z-index: 3; }
.carousel-card.prev      { transform: translateX(-72%)  scale(0.72) translateZ(-80px); opacity: 0.5;  filter: brightness(0.55) saturate(0.4); z-index: 2; }
.carousel-card.next      { transform: translateX(72%)   scale(0.72) translateZ(-80px); opacity: 0.5;  filter: brightness(0.55) saturate(0.4); z-index: 2; }
.carousel-card.far-left  { transform: translateX(-110%) scale(0.55) translateZ(-160px); opacity: 0; pointer-events: none; z-index: 0; }
.carousel-card.far-right { transform: translateX(110%)  scale(0.55) translateZ(-160px); opacity: 0; pointer-events: none; z-index: 0; }

/* Inner — the flipping element */
.card-inner {
  width: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform var(--t-screen) var(--ease-out);
}

/* Flip keyframe — fast Y flip like pulling a record from a crate */
.card-inner.flipping {
  animation: card-flip var(--flip-dur, 320ms) var(--ease-out);
}

@keyframes card-flip {
  0%   { transform: rotateY(0deg); }
  45%  { transform: rotateY(-90deg); }
  55%  { transform: rotateY(-90deg); }
  100% { transform: rotateY(0deg); }
}

.card-front,
.card-back {
  width: 100%;
  backface-visibility: hidden;
}

.card-front {
  position: relative;
}

.card-back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
  background: #0a0806;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Vinyl record back label */
.card-back-label {
  width: 140px; height: 140px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-3);
  padding: 20px;
}

.card-cover {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
}

/* Static poster sits underneath, always visible immediately */
img.card-cover {
  display: block;
}

/* Video layers on top of the poster, fades in once ready */
video.card-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity 0.6s ease;
}

video.card-cover.loaded {
  opacity: 1;
}

/* Active card glow */
.carousel-card.active .card-cover {
  box-shadow:
    0 24px 64px rgba(0,0,0,0.7),
    0 0 0 2px var(--accent),
    0 0 48px var(--accent-dim);
}

/* Info */
#carousel-info {
  position: relative;
  z-index: 2;
  text-align: center;
  flex-shrink: 0;
  padding: 0 48px 8px;
}

#carousel-album-name {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  font-style: italic;
  color: var(--text);
  margin-bottom: 6px;
  text-shadow: 0 2px 20px rgba(0,0,0,0.6);
}

#carousel-album-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-3);
}

#carousel-play-btn {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  margin: 0 auto 36px;
  padding: 14px 64px;
  color: var(--bg);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  border: none;
  background-size: 600% 100%;
  /* background-image set dynamically by JS in updatePlayBtnGradient() */
  background-image: linear-gradient(90deg, var(--accent) 0%, var(--accent) 100%);
  animation: play-btn-shimmer 8s linear infinite;
  box-shadow: 0 4px 24px var(--accent-dim);
  transition: transform 0.15s var(--ease-spring), box-shadow 0.15s;
}

@keyframes play-btn-shimmer {
  0%   { background-position: 0% 0%; }
  100% { background-position: 100% 0%; }
}

#carousel-play-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px var(--accent-dim);
}

#carousel-play-btn:active { transform: translateY(1px); }

/* ═══════════════════════════════════════════════════════════
   GAME SCREEN
═══════════════════════════════════════════════════════════ */
#screen-game {
  justify-content: flex-start;
  padding: 0;
}

/* Blurred album background */
#game-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#game-bg.hidden { display: none; }

#game-bg-image {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  filter: blur(28px) brightness(0.18) saturate(0.5);
  transform: scale(1.05);
}

#game-bg-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(14,12,10,0.6);
}

/* Scorebar */
#scorebar {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(14,12,10,0.75);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

#game-back-btn {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text-3);
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  margin-right: 16px;
  flex-shrink: 0;
  transition: color 0.12s, border-color 0.12s;
}

#game-back-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.score-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.score-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-3);
}

.score-val {
  font-family: var(--font-num);
  font-size: 26px;
  color: var(--text);
  line-height: 1;
}

#display-score { color: var(--accent); }

/* Game body */
#game-body {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

/* Sidebar */
#points-sidebar {
  width: 68px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 0;
  border-right: 1px solid var(--border);
  background: rgba(14,12,10,0.5);
}

#points-meter-wrap {
  position: relative;
  width: 18px; height: 160px;
  background: var(--bg-3);
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--border);
}

#points-meter-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  border-radius: 9px;
  transition: height 0.5s var(--ease-spring), background 0.4s var(--ease);
}

#points-meter-val {
  font-family: var(--font-num);
  font-size: 20px;
  color: var(--text);
  line-height: 1;
}

#points-meter-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-3);
}

#mode-graphic {
  margin-top: auto;
  width: 36px; height: 36px;
  opacity: 0.2;
}

/* Game card */
#game-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 64px;
  position: relative;
  overflow: hidden;
  max-width: 700px;
  margin: 0 auto;
}

#confetti-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  width: 100%; height: 100%;
}

/* Question view */
#question-view {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

/* Play button */
#player-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#play-btn {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text);
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s var(--ease-spring), border-color 0.15s, box-shadow 0.2s, background 0.15s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

#play-btn:hover {
  transform: scale(1.08);
  border-color: var(--accent);
  box-shadow: 0 6px 28px rgba(0,0,0,0.5), 0 0 0 4px var(--accent-faint);
}

#play-btn[data-state="playing"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  animation: play-pulse 1.4s ease-in-out infinite;
}

#play-btn[data-state="loading"] {
  opacity: 0.55;
  cursor: wait;
}

@keyframes play-pulse {
  0%,100% { opacity: 1; }
  50%     { opacity: 0.85; }
}

#player-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#snippet-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-3);
}

#audio-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  min-height: 16px;
}

#audio-status[data-error="true"] { color: var(--wrong); }

/* Action row */
#action-row { display: flex; gap: 12px; }

#add-sec-btn, #skip-btn {
  padding: 8px 24px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  transition: border-color 0.12s, color 0.12s, background 0.12s, transform 0.12s;
}

#add-sec-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-faint);
  transform: translateY(-1px);
}

#skip-btn:hover {
  border-color: var(--wrong);
  color: #c47878;
  background: var(--wrong-dim);
  transform: translateY(-1px);
}

#add-sec-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Guess area */
#guess-area {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#input-wrap { position: relative; }

#guess-input {
  width: 100%;
  padding: 13px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}

#guess-input::placeholder { color: var(--text-3); }

#guess-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-faint);
}

/* Autocomplete */
#autocomplete-list {
  position: absolute;
  top: calc(100% + 5px);
  left: 0; right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  max-height: 220px;
  overflow-y: auto;
  z-index: 50;
  animation: dropdown-in 0.12s var(--ease-out);
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

#autocomplete-list li {
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  transition: background 0.1s, color 0.1s;
}

#autocomplete-list li:last-child { border-bottom: none; }

#autocomplete-list li:hover,
#autocomplete-list li.highlighted {
  background: var(--surface);
  color: var(--text);
}

#autocomplete-list li mark {
  background: none;
  color: var(--accent);
  font-weight: 700;
  font-style: normal;
}

#submit-btn {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: var(--bg);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px var(--accent-dim);
  transition: transform 0.15s var(--ease-spring), box-shadow 0.15s, opacity 0.15s;
}

#submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-dim);
}

#submit-btn:active:not(:disabled) { transform: translateY(1px); }
#submit-btn:disabled { opacity: 0.3; cursor: not-allowed; box-shadow: none; }

/* Result view */
#result-view {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: fadeUp 0.2s var(--ease-out);
}

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

#result-verdict {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 900;
  font-style: italic;
  line-height: 1;
}

#result-verdict[data-outcome="correct"] { color: var(--correct); }
#result-verdict[data-outcome="wrong"]   { color: var(--wrong); }
#result-verdict[data-outcome="skip"]    { color: var(--text-3); }

#result-song-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

#result-song-album {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-3);
}

#result-points-earned {
  font-family: var(--font-num);
  font-size: 36px;
  color: var(--accent);
  margin: 2px 0;
}

/* Mini player */
#result-player {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 380px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 6px;
}

#result-play-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s var(--ease-spring);
}

#result-play-btn:hover { transform: scale(1.1); }

#result-progress-wrap {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

#result-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.1s linear;
}

#result-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  flex-shrink: 0;
  min-width: 32px;
  text-align: right;
}

#next-btn {
  margin-top: 6px;
  padding: 11px 36px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: color 0.12s, border-color 0.12s, transform 0.12s;
}

#next-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  transform: translateY(-1px);
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-8px); }
  40%     { transform: translateX(8px); }
  60%     { transform: translateX(-5px); }
  80%     { transform: translateX(5px); }
}
.shake { animation: shake 0.35s var(--ease); }

/* ═══════════════════════════════════════════════════════════
   FINAL SCREEN
═══════════════════════════════════════════════════════════ */
#screen-final {
  gap: 36px;
  padding: 48px;
  background:
    radial-gradient(ellipse at 50% 0%, var(--accent-faint) 0%, transparent 55%),
    var(--bg);
}

#final-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#final-title {
  font-size: 48px;
  font-weight: 900;
  font-style: italic;
  color: var(--text);
}

#final-score-display {
  font-family: var(--font-num);
  font-size: 80px;
  color: var(--accent);
  line-height: 1;
}

#final-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-3);
}

#history-list {
  width: 100%;
  max-width: 560px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.history-item {
  display: grid;
  grid-template-columns: 28px 1fr 1fr 48px;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  transition: background 0.1s;
}

.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--surface); }

.history-item[data-outcome="correct"] { border-left: 3px solid var(--correct); }
.history-item[data-outcome="wrong"]   { border-left: 3px solid var(--wrong); }
.history-item[data-outcome="skip"]    { border-left: 3px solid var(--muted); }

.history-num   { font-family: var(--font-mono); font-size: 10px; color: var(--text-3); text-align: right; }
.history-title { font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-album { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-pts   { font-family: var(--font-num); font-size: 16px; color: var(--accent); text-align: right; }

#final-actions { display: flex; gap: 12px; }

#play-again-btn {
  padding: 13px 48px;
  background: var(--accent);
  color: var(--bg);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px var(--accent-dim);
  transition: transform 0.15s var(--ease-spring), box-shadow 0.15s;
}

#play-again-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--accent-dim);
}

#back-to-menu-btn {
  padding: 13px 32px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: color 0.12s, border-color 0.12s, transform 0.12s;
}

#back-to-menu-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* ─────────────────────────────────────────────────────────
   UTILITY
───────────────────────────────────────────────────────── */
.hidden { display: none !important; }

::-webkit-scrollbar        { width: 4px; height: 4px; }
::-webkit-scrollbar-track  { background: var(--bg-2); }
::-webkit-scrollbar-thumb  { background: var(--border-light); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ═══════════════════════════════════════════════════════════
   MOBILE — iPhone & iPad
   Breakpoints:
   - max-width: 768px  → phones (iPhone all sizes)
   - 769px–1024px      → iPad portrait
═══════════════════════════════════════════════════════════ */

/* ── iOS viewport height fix ── */
@supports (-webkit-touch-callout: none) {
  html, body { height: -webkit-fill-available; }
  .screen    { min-height: -webkit-fill-available; }
}

/* ────────────────────────────────────────────────────────
   PHONE — up to 768px
─────────────────────────────────────────────────────────*/
@media (max-width: 768px) {

  /* MENU */
  #screen-menu { gap: 32px; padding: 24px 20px; }

  #site-title { font-size: clamp(36px, 10vw, 56px); }

  #site-tagline { font-size: 10px; letter-spacing: 2.5px; }

  #mode-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 420px;
  }

  .mode-card {
    padding: 16px 10px;
    gap: 6px;
  }

  .mode-card-name  { font-size: 14px; }
  .mode-card-desc  { font-size: 9px; letter-spacing: 0.5px; }
  .mode-card-graphic { inset: 0 0 55px 0; background-size: 50%; }

  /* CAROUSEL */
  #carousel-header { padding: 20px 20px 0; }
  #carousel-title  { font-size: 10px; letter-spacing: 3px; }

  #carousel-stage  { padding: 0 12px; gap: 8px; }

  #carousel-prev,
  #carousel-next   { width: 36px; height: 36px; font-size: 20px; }

  .carousel-card   { width: min(72vw, 300px); }

  video.card-cover { height: min(72vw, 300px); }

  /* Tighten side card offsets for narrow screens */
  .carousel-card.prev  { transform: translateX(-68%) scale(0.72) translateZ(-80px); }
  .carousel-card.next  { transform: translateX(68%)  scale(0.72) translateZ(-80px); }

  #carousel-album-name { font-size: 22px; }
  #carousel-album-meta { font-size: 10px; letter-spacing: 2px; }
  #carousel-info       { padding: 0 20px 4px; }

  #carousel-play-btn {
    padding: 13px 48px;
    font-size: 13px;
    margin-bottom: 28px;
  }

  /* Hide assets on small phones — not enough room */
  #carousel-assets { display: none; }

  /* GAME */
  #scorebar {
    padding: 10px 16px;
    gap: 0;
  }

  #game-back-btn { width: 30px; height: 30px; font-size: 14px; margin-right: 10px; }

  .score-val   { font-size: 20px; }
  .score-label { font-size: 8px; letter-spacing: 2px; }

  /* Sidebar becomes a thin horizontal strip at the top of game-body */
  #game-body { flex-direction: column; }

  #points-sidebar {
    width: 100%;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    height: auto;
  }

  /* Meter becomes horizontal */
  #points-meter-wrap {
    width: 120px;
    height: 10px;
    border-radius: 5px;
  }

  #points-meter-fill {
    /* Switch from vertical to horizontal fill */
    position: absolute;
    top: 0; left: 0; bottom: 0;
    right: auto;
    width: var(--meter-pct, 100%);
    height: 100%;
    border-radius: 5px;
    transition: width 0.5s var(--ease-spring), background 0.4s var(--ease);
  }

  #points-meter-val   { font-size: 18px; }
  #points-meter-label { font-size: 8px; }
  #mode-graphic       { display: none; }

  #game-card {
    padding: 24px 20px;
    justify-content: flex-start;
    overflow-y: auto;
  }

  #question-view { gap: 22px; }

  #play-btn { width: 76px; height: 76px; font-size: 24px; }

  #snippet-label { font-size: 10px; letter-spacing: 2px; }

  #add-sec-btn, #skip-btn {
    padding: 10px 18px;
    font-size: 10px;
  }

  #guess-area    { max-width: 100%; }
  #guess-input   { padding: 14px 16px; font-size: 16px; } /* 16px prevents iOS zoom */

  #autocomplete-list li { padding: 12px 16px; font-size: 15px; }

  #submit-btn { padding: 15px; font-size: 13px; }

  /* Result */
  #result-verdict      { font-size: 40px; }
  #result-song-title   { font-size: 18px; }
  #result-points-earned { font-size: 28px; }
  #result-player       { max-width: 100%; }
  #next-btn            { padding: 13px 28px; }

  /* Final */
  #screen-final { gap: 24px; padding: 32px 20px; }
  #final-title  { font-size: 36px; }
  #final-score-display { font-size: 60px; }

  #history-list { max-height: 200px; overflow-y: auto; }

  /* Drop album column on small screens */
  .history-item {
    grid-template-columns: 24px 1fr 44px;
    gap: 8px;
    padding: 9px 12px;
  }
  .history-album { display: none; }

  #final-actions { flex-direction: column; width: 100%; max-width: 320px; }
  #play-again-btn  { padding: 14px; text-align: center; }
  #back-to-menu-btn { padding: 14px; text-align: center; }
}

/* ────────────────────────────────────────────────────────
   IPAD PORTRAIT — 769px to 1024px
─────────────────────────────────────────────────────────*/
@media (min-width: 769px) and (max-width: 1024px) {

  /* MENU */
  #screen-menu { gap: 40px; }
  #site-title  { font-size: clamp(44px, 7vw, 64px); }

  #mode-grid {
    grid-template-columns: repeat(3, 180px);
    gap: 16px;
  }

  /* CAROUSEL */
  .carousel-card  { width: 280px; }
  video.card-cover { height: 280px; }

  #carousel-album-name { font-size: 26px; }

  /* GAME */
  #game-card { padding: 36px 40px; }

  #points-meter-wrap { height: 140px; }

  #guess-area  { max-width: 400px; }
  #guess-input { font-size: 16px; } /* prevent iOS zoom */
}

/* ────────────────────────────────────────────────────────
   TOUCH — disable hover effects on touch devices
   Prevents stuck hover states on iOS
─────────────────────────────────────────────────────────*/
@media (hover: none) {
  .mode-card:hover       { transform: none; box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 4px 24px rgba(0,0,0,0.4); border-color: var(--border); }
  .mode-card:active      { transform: scale(0.97); border-color: var(--accent); }
  #carousel-prev:hover,
  #carousel-next:hover   { transform: none; }
  #carousel-prev:active,
  #carousel-next:active  { transform: scale(0.92); }
  #submit-btn:hover:not(:disabled)    { transform: none; }
  #submit-btn:active:not(:disabled)   { transform: scale(0.98); }
  #carousel-play-btn:hover            { transform: none; }
  #carousel-play-btn:active           { transform: scale(0.97); }
  #play-btn:hover                     { transform: none; }
  #play-btn:active                    { transform: scale(0.94); }
}
