/* ============================================================
   THE RUNNING ORDER — matte black & mustard
   Flat colors only. No gradients. Calm, record-sleeve feel.
   ============================================================ */

:root {
  --bg: #161513;          /* warm near-black */
  --surface: #201e1a;     /* panels */
  --surface2: #2a2721;    /* inputs, nested surfaces */
  --line: #3a362c;        /* borders */
  --line-soft: #2e2b23;

  --yellow: #d9b44a;      /* muted mustard */
  --yellow-dim: #a8863a;
  --cream: #f6f1e3;       /* card faces */

  --text: #ece7da;
  --muted: #99927f;
  --good: #7fb069;
  --bad: #c4564a;

  --radius: 16px;
  --font: "Baloo 2", "Segoe UI", system-ui, sans-serif;
  --display: "Lilita One", "Baloo 2", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
/* faint dot texture, single color, very low key */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(rgba(217, 180, 74, .05) 1.5px, transparent 1.5px);
  background-size: 42px 42px;
}
#app { position: relative; z-index: 1; }

.hidden { display: none !important; }

.screen { max-width: 1160px; margin: 0 auto; padding: 28px 20px 60px; }

h1, h2, h3, h4, .btn.big, .turn-indicator {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: .5px;
}

/* ============ Buttons — flat, quietly tactile ============ */
.btn {
  font-family: var(--font);
  font-weight: 700;
  font-size: 1rem;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 12px 24px;
  cursor: pointer;
  color: var(--text);
  background: var(--surface2);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .4);
  transition: transform .08s ease, box-shadow .08s ease, filter .12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 rgba(0, 0, 0, .4); filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 rgba(0, 0, 0, .4); }

.btn.primary {
  background: var(--yellow);
  color: #191712;
  border-color: #191712;
  box-shadow: 0 3px 0 var(--yellow-dim);
}
.btn.primary:hover { box-shadow: 0 4px 0 var(--yellow-dim); }
.btn.primary:active { box-shadow: 0 0 0 var(--yellow-dim); }

.btn.ghost { background: transparent; }
.btn.big {
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 15px 40px;
}
.btn.small { padding: 8px 16px; font-size: .85rem; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; filter: none; }

/* ============ Logo / lobby header ============ */
.logo { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 8px 0 24px; }
.logo-img {
  width: min(340px, 68vw); height: auto;
  filter: drop-shadow(0 10px 26px rgba(0, 0, 0, .6));
}
.subtitle {
  margin: 2px 0 0;
  font-family: var(--display);
  color: var(--yellow);
  letter-spacing: 6px;
  text-transform: uppercase;
  font-size: .9rem;
}

/* ============ Panels ============ */
.panel {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .4);
  max-width: 640px;
  margin: 0 auto;
}
.panel h2 { margin: 0 0 16px; font-size: 1.45rem; color: var(--yellow); }

/* ---- player rows ---- */
.player-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.player-row input[type=text] {
  flex: 1; min-width: 0; padding: 11px 16px; border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--surface2); color: var(--text);
  font-family: var(--font); font-weight: 600; font-size: 1rem;
  transition: border-color .15s ease;
}
.player-row input[type=text]:focus { outline: none; border-color: var(--yellow); }
.player-row input[type=text]::placeholder { color: var(--muted); font-weight: 500; }

.color-picker { display: flex; gap: 7px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, .5);
  cursor: pointer; flex: 0 0 auto;
  transition: transform .12s ease, box-shadow .12s ease;
}
.swatch:hover { transform: scale(1.12); }
.swatch.selected {
  border-color: var(--bg);
  box-shadow: 0 0 0 2px var(--yellow);
  transform: scale(1.1);
}
.remove-x { background: none; border: none; color: var(--muted); font-size: 1.4rem; cursor: pointer; line-height: 1; }
.remove-x:hover { color: var(--bad); }

.target-row { display: flex; align-items: center; justify-content: space-between; margin: 20px 0; flex-wrap: wrap; gap: 12px; font-weight: 600; }
.target-row input {
  width: 74px; padding: 9px; border-radius: 10px; border: 2px solid var(--line);
  background: var(--surface2); color: var(--yellow);
  font-family: var(--font); font-weight: 700; font-size: 1.05rem; text-align: center; margin-left: 10px;
}
.deck-badge {
  color: #191712;
  background: var(--yellow);
  border: 2px solid #191712;
  border-radius: 999px; padding: 5px 16px;
  font-weight: 700;
}
.deck-badge b { color: #191712; }
#addPlayer { margin: 4px 0 6px; }

#startBtn { display: block; width: 100%; margin-top: 18px; }

/* ---- Spotify box ---- */
.spotify-box {
  background: var(--surface2); border-radius: 12px; padding: 14px 18px; margin: 18px 0;
  border: 2px solid var(--line-soft);
}
.sp-row { display: flex; align-items: center; gap: 10px; }
.sp-logo { color: #1ed760; font-weight: 700; }
.sp-status { color: var(--muted); font-size: .9rem; }
.sp-status.ok { color: var(--good); }
.sp-status.warn { color: var(--yellow); }
.sp-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.sp-actions select { padding: 8px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); color: var(--text); font-family: var(--font); }
.sp-hint { color: var(--muted); font-size: .82rem; font-weight: 400; margin: 10px 0 0; }

/* ============ Game topbar ============ */
.topbar {
  display: flex; align-items: center; gap: 18px;
  margin-bottom: 22px; flex-wrap: wrap;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 8px 20px 8px 10px;
}
.topbar-logo { width: 52px; height: 52px; flex: 0 0 auto; }
.turn-indicator { font-size: 1.25rem; display: flex; align-items: center; gap: 12px; }
.meta { color: var(--muted); font-size: .88rem; font-weight: 600; margin-left: auto; }
.meta span { color: var(--yellow); }

/* animated equalizer bars — mono, in yellows */
.eq { display: inline-flex; align-items: flex-end; gap: 3px; height: 20px; }
.eq i { width: 4px; border-radius: 2px; animation: eq-bounce 1.1s ease-in-out infinite; }
.eq i:nth-child(1) { background: var(--yellow);     height: 60%; animation-delay: 0s; }
.eq i:nth-child(2) { background: var(--cream);      height: 100%; animation-delay: .15s; }
.eq i:nth-child(3) { background: var(--yellow-dim); height: 75%; animation-delay: .3s; }
.eq i:nth-child(4) { background: var(--yellow);     height: 90%; animation-delay: .45s; }
@keyframes eq-bounce { 0%, 100% { transform: scaleY(.4); } 50% { transform: scaleY(1); } }

/* ============ Table layout ============ */
.table { display: grid; gap: 26px; }

/* ---- turntable / draw zone ---- */
.turntable { display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 6px; }
.record {
  width: 150px; height: 150px; border-radius: 50%;
  background: #0e0d0b;
  display: grid; place-items: center;
  border: 2px solid #000;
  box-shadow:
    inset 0 0 0 12px #14120f,
    inset 0 0 0 24px #0e0d0b,
    inset 0 0 0 36px #14120f,
    inset 0 0 0 48px #0e0d0b,
    0 8px 24px rgba(0, 0, 0, .6);
  position: relative;
}
/* flat mustard center label */
.record::after {
  content: "";
  position: absolute; width: 56px; height: 56px; border-radius: 50%;
  background: var(--yellow);
  border: 2px solid #0e0d0b;
}
.vinyl-hole { width: 10px; height: 10px; border-radius: 50%; background: #0e0d0b; position: relative; z-index: 1; }
.record.spinning { animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#drawBtn { font-size: 1.6rem; padding: 18px 56px; letter-spacing: 4px; }

/* ---- mystery card ---- */
.now-playing { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.now-playing .mystery-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface2);
  border: 2px solid var(--yellow);
  padding: 15px 24px; border-radius: 14px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .4);
}
.mystery-card .note {
  font-family: var(--display);
  font-size: 2.3rem; color: var(--yellow);
  animation: note-wiggle 2s ease-in-out infinite;
}
@keyframes note-wiggle { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.mystery-text { line-height: 1.25; font-weight: 700; font-size: 1rem; }
.mystery-text small { color: var(--muted); font-weight: 500; font-size: .8rem; }
.playback-controls { display: flex; gap: 10px; margin-top: 14px; justify-content: center; flex-wrap: wrap; }

/* ============ Active timeline zone ============ */
.active-zone {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .35);
}
.active-zone h3 { margin: 0 0 16px; font-size: 1.2rem; color: var(--yellow); }

.timeline { display: flex; align-items: stretch; flex-wrap: wrap; gap: 5px; min-height: 100px; }

/* gaps — clear tap targets when placing */
.gap {
  width: 28px; align-self: stretch; min-height: 90px; border-radius: 10px;
  border: 2px dashed transparent;
  display: grid; place-items: center;
  color: var(--muted); font-weight: 700;
  transition: width .15s ease, background .15s ease;
}
.timeline.placing .gap {
  width: 42px;
  border-color: var(--yellow-dim);
  background: rgba(217, 180, 74, .07);
  cursor: pointer;
  color: var(--yellow);
}
.timeline.placing .gap:hover { background: rgba(217, 180, 74, .2); border-color: var(--yellow); }
.timeline.placing .gap.selected {
  background: var(--yellow);
  color: #191712; border-style: solid; border-color: #191712;
  box-shadow: 0 3px 0 var(--yellow-dim);
}

/* cards — cream faces, black edges, colored top strip */
.card {
  --pc: var(--yellow);
  width: 122px; min-height: 90px; border-radius: 12px; padding: 10px 12px 8px;
  background: var(--cream);
  border: 2px solid #191712;
  border-top: 7px solid var(--pc);
  color: #191712;
  display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .45), 0 10px 18px rgba(0, 0, 0, .3);
  animation: card-in .25s ease backwards;
}
@keyframes card-in { from { transform: translateY(12px) scale(.9); opacity: 0; } }
.card .c-year {
  font-family: var(--display);
  font-size: 1.65rem; color: #191712;
}
.card .c-song { font-size: .7rem; color: #6f6753; font-weight: 600; line-height: 1.2; }

/* placement controls */
.place-controls { margin-top: 18px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.year-guess { color: var(--muted); font-size: .9rem; font-weight: 600; }
.year-guess input {
  margin-left: 10px; width: 110px; padding: 9px; border-radius: 10px;
  border: 2px solid var(--line); background: var(--surface2); color: var(--yellow);
  font-family: var(--font); font-weight: 700; font-size: 1rem; text-align: center;
}
.year-guess input:focus { outline: none; border-color: var(--yellow); }
.hint { color: var(--yellow); font-weight: 600; margin: 0; }
#confirmBtn { margin-left: auto; }

/* ============ Other players ============ */
.others h4 {
  margin: 0 0 14px;
  font-size: 1rem; color: var(--muted);
  letter-spacing: 2px; text-transform: uppercase;
}
.other-player {
  margin-bottom: 12px; padding: 12px 16px;
  background: var(--surface);
  border: 2px solid var(--line-soft);
  border-radius: 14px;
}
.other-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-weight: 700; }
.other-head .dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, .5);
}
.other-head .score { margin-left: auto; color: var(--muted); font-weight: 600; font-size: .85rem; }
.mini-timeline { display: flex; gap: 5px; flex-wrap: wrap; }
.mini-card {
  width: 46px; height: 46px; border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 700; font-size: .8rem;
  border: 2px solid rgba(0, 0, 0, .45);
}
.mini-empty { color: var(--muted); font-size: .85rem; font-style: italic; font-weight: 400; }
.active-glow { border-color: var(--yellow) !important; }

/* ============ Overlays ============ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(10, 9, 7, .84);
  display: grid; place-items: center; z-index: 50;
  backdrop-filter: blur(3px);
}

/* ---- reveal card ---- */
.reveal-card {
  background: var(--cream);
  color: #191712;
  border: 3px solid #191712;
  border-radius: 20px;
  padding: 36px 50px 32px;
  text-align: center; min-width: 340px; max-width: 92vw;
  box-shadow: 0 10px 0 rgba(0, 0, 0, .45), 0 34px 80px rgba(0, 0, 0, .5);
  animation: flip .5s cubic-bezier(.2, 1.3, .4, 1);
  position: relative;
}
@keyframes flip {
  from { transform: rotateY(90deg) scale(.85); opacity: 0; }
  to { transform: rotateY(0) scale(1); opacity: 1; }
}
.reveal-sparkles {
  position: absolute; top: -16px; right: -10px;
  font-size: 2rem; color: var(--yellow);
}
.reveal-result {
  font-family: var(--display);
  font-size: 1.35rem; margin-bottom: 14px;
  padding: 7px 20px; border-radius: 999px; display: inline-block;
  color: var(--cream);
}
.reveal-result.ok { background: var(--good); }
.reveal-result.no { background: var(--bad); }
.reveal-song { font-size: 1.45rem; font-weight: 700; }
.reveal-show { color: #6f6753; margin: 4px 0 10px; font-weight: 600; }
.reveal-year {
  font-family: var(--display);
  font-size: 4rem; line-height: 1.15;
  color: #191712;
}
.reveal-bonus { color: #4d7a3f; font-weight: 700; min-height: 26px; margin: 2px 0 18px; }

/* ---- end screen ---- */
.end-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 20px; padding: 36px 52px;
  text-align: center;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .55);
  position: relative; z-index: 2;
}
.end-card h2 { font-size: 2.1rem; margin: 0 0 6px; color: var(--yellow); }
.podium { display: flex; flex-direction: column; gap: 10px; margin: 24px 0; }
.podium-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface2); padding: 12px 18px; border-radius: 12px;
  border: 2px solid transparent;
}
.podium-row .rank {
  font-family: var(--display);
  font-size: 1.25rem; width: 34px; height: 34px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--line); color: var(--muted);
  flex: 0 0 auto;
}
.podium-row:nth-child(1) .rank { background: var(--yellow); color: #191712; }
.podium-row:nth-child(2) .rank { background: #b9b3a4; color: #191712; }
.podium-row:nth-child(3) .rank { background: #a1793f; color: var(--cream); }
.podium-row .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .5); }
.podium-row .p-name { font-weight: 700; }
.podium-row .p-score { margin-left: auto; color: var(--yellow); font-weight: 700; }
.podium-row.win { border-color: var(--yellow); }

/* ---- confetti (spawned by client.js on the end screen) ---- */
.confetti-piece {
  position: fixed; top: -24px; z-index: 1;
  width: 10px; height: 15px; border-radius: 2px;
  animation: confetti-fall linear forwards;
  pointer-events: none;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0) scaleX(1); opacity: 1; }
  25% { transform: translateY(28vh) rotate(200deg) scaleX(.4); }
  50% { transform: translateY(55vh) rotate(390deg) scaleX(1); }
  75% { transform: translateY(82vh) rotate(580deg) scaleX(.4); }
  100% { transform: translateY(112vh) rotate(760deg) scaleX(1); opacity: .9; }
}

/* ============ Small screens ============ */
@media (max-width: 640px) {
  .btn.big { font-size: 1.15rem; padding: 13px 28px; }
  #drawBtn { font-size: 1.35rem; padding: 15px 40px; }
  .topbar { border-radius: 18px; }
  .meta { margin-left: 0; }
  .reveal-card { padding: 28px 26px 26px; }
  .reveal-year { font-size: 3rem; }
  .card { width: 104px; }
}

/* --- Drag-and-drop card placement --- */
#nowPlaying .mystery-card { cursor: grab; user-select: none; }
#nowPlaying .mystery-card:active { cursor: grabbing; }
.timeline .gap-slot { opacity: .4; font-size: 1.3rem; pointer-events: none; }
.timeline.dragging .gap { min-width: 44px; border: 2px dashed rgba(255,255,255,.45); background: rgba(255,255,255,.06); border-radius: 12px; transition: all .12s ease; }
.timeline.dragging .gap.dragover { border-color: #ffd24a; background: rgba(255,210,74,.28); transform: scale(1.06); }
.timeline .gap.selected { border: none; background: transparent; }
.gap .pending-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 96px; min-height: 88px; border-radius: 12px; font-size: 1.7rem; font-weight: 800;
  color: #1a1526; background: var(--pc, #ffd24a); border: 3px solid rgba(255,255,255,.25);
  box-shadow: 0 8px 20px rgba(0,0,0,.45); animation: pop .18s ease;
}
.gap .pending-card span { font-size: .58rem; font-weight: 700; letter-spacing: .5px; opacity: .8; text-transform: uppercase; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* --- Webcam avatars --- */
.avatar { border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.25); flex: 0 0 auto; vertical-align: middle; }
.lobby-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background-size: cover; background-position: center; color: rgba(0,0,0,.55);
  border: 2px solid rgba(0,0,0,.5); font-size: 1rem;
  transition: transform .12s ease, box-shadow .12s ease;
}
.lobby-avatar:hover { transform: scale(1.06); box-shadow: 0 0 0 2px var(--yellow); }

/* --- Camera modal --- */
.camera-box { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 22px 24px; text-align: center; box-shadow: 0 22px 60px rgba(0,0,0,.6); }
.camera-box h3 { margin: 0 0 14px; color: var(--yellow); }
.cam-frame { width: 280px; height: 280px; border-radius: 14px; overflow: hidden; background: #000; margin: 0 auto; border: 2px solid var(--line); }
#camVideo { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.camera-actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }
