/* ===========================================================
   PLACEHOLDER STYLING — swap colors/fonts and drop in art here.
   Look for "ART SLOT" comments in host.html / player.html for
   exactly where background/character images can be inserted.
   =========================================================== */

:root {
  --bg: #1b1330;
  --panel: #2a1f4d;
  --accent: #ff5da2;
  --accent2: #5de4ff;
  --text: #ffffff;
  --muted: #b9aee0;
  --good: #58e07c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
}

h1 { font-size: 2.4rem; margin-bottom: 0.2em; letter-spacing: 1px; }
h2 { font-size: 1.6rem; color: var(--accent2); }
p.subtitle { color: var(--muted); margin-top: -0.5em; }

.panel {
  background: var(--panel);
  border-radius: 16px;
  padding: 30px 40px;
  max-width: 700px;
  width: 100%;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

.room-code {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: 6px;
  color: var(--accent);
  margin: 20px 0;
}

.player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 20px 0;
}

.player-chip {
  background: var(--accent2);
  color: #10142b;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 14px 28px;
  font-size: 1.1rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  margin: 8px;
  transition: transform 0.1s ease;
}
button:hover { transform: scale(1.04); }
button:disabled { background: #555; cursor: not-allowed; transform: none; }

input[type="text"] {
  padding: 12px 16px;
  font-size: 1.1rem;
  border-radius: 8px;
  border: none;
  width: 80%;
  max-width: 400px;
  margin: 10px 0;
}

.prompt-text {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  margin: 20px 0;
}

.record-btn {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  font-size: 1rem;
  background: #e0405c;
}
.record-btn.recording {
  background: var(--good);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(88,224,124,0.6); }
  70% { box-shadow: 0 0 0 20px rgba(88,224,124,0); }
  100% { box-shadow: 0 0 0 0 rgba(88,224,124,0); }
}

.clip-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 10px 16px;
  margin: 8px 0;
}
.clip-row.winner { background: rgba(88,224,124,0.2); border: 2px solid var(--good); }

.vote-btn {
  width: 100%;
  text-align: left;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  margin: 6px 0;
}
.vote-btn.selected { background: var(--accent); }

.leaderboard-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 20px;
  font-size: 1.3rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.leaderboard-row:first-child { color: gold; font-weight: 800; font-size: 1.6rem; }

.status-text { color: var(--muted); margin-top: 10px; }

/* ART SLOT: background layer for host screen — swap for a full illustration */
.host-bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  opacity: 0.25;
}

/* ---- Spotlight reveal stage (host screen) ---- */
#spotlightStage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  margin: 20px 0;
}
.spotlight-card {
  padding: 40px 60px;
  border-radius: 20px;
  background: rgba(255,255,255,0.04);
  transition: all 0.4s ease;
  opacity: 0.5;
}
/* ART SLOT: the .lit state is the "spotlight on this player" look —
   swap the glow/background for a character portrait frame if you want. */
.spotlight-card.lit {
  opacity: 1;
  background: radial-gradient(circle at center, rgba(255,93,162,0.35), rgba(42,31,77,0.9));
  box-shadow: 0 0 60px 10px rgba(255,93,162,0.5);
  transform: scale(1.08);
}
.spotlight-name {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--text);
}
.spotlight-sub {
  color: var(--muted);
  margin-top: 8px;
  font-size: 1.1rem;
}

/* ================= Avatar drawing UI ================= */
#screen-avatar { position: relative; overflow: hidden; }

/* the two panels sit side by side and slide with easing */
.draw-slider {
  display: flex;
  width: 200%;
  transition: transform 0.7s cubic-bezier(0.65, 0, 0.35, 1); /* ease-in-out swipe */
}
.draw-slider.to-mouth { transform: translateX(-50%); }
.draw-panel { width: 50%; flex-shrink: 0; padding: 0 6px; }

.canvas-wrap {
  position: relative;
  width: 300px; max-width: 82vw;
  margin: 12px auto;
  aspect-ratio: 1 / 1;
}
.canvas-wrap canvas {
  width: 100%; height: 100%;
  background: #fff;
  border-radius: 12px;
  touch-action: none; /* stops the page scrolling while drawing */
  cursor: crosshair;
}
/* faint circle so players know the avatar crop */
.canvas-circle-guide {
  position: absolute; inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(93,228,255,0.5) inset;
  pointer-events: none;
}

.tool-row, .palette-row {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 8px 0;
}
.tool-btn, .size-btn {
  background: rgba(255,255,255,0.1); color: var(--text);
  padding: 8px 12px; font-size: 1.1rem; margin: 0; border-radius: 8px;
}
.tool-btn.active, .size-btn.active { background: var(--accent); }
.size-btn { display: flex; align-items: center; justify-content: center; min-width: 40px; }
.size-dot { background: currentColor; border-radius: 50%; display: inline-block; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; padding: 0; margin: 0;
  border: 2px solid rgba(255,255,255,0.3);
}
.swatch.active { border-color: var(--accent2); transform: scale(1.15); }

#confettiCanvas {
  position: fixed; inset: 0; pointer-events: none; display: none; z-index: 50;
}

/* ================= Avatars on the host ================= */
.avatar-mini {
  width: 40px; height: 40px; border-radius: 50%; overflow: hidden;
  flex-shrink: 0; background: var(--panel);
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: middle; border: 2px solid rgba(255,255,255,0.2);
}
.avatar-mini img { width: 100%; height: 100%; object-fit: cover; }
.avatar-mini.big { width: 70px; height: 70px; }
.avatar-fallback { font-weight: 800; color: var(--text); background: var(--accent); }
.lb-name { display: inline-flex; align-items: center; gap: 10px; }

.avatar-grid {
  display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin: 20px 0;
}
.avatar-cell { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.avatar-cell span { color: var(--muted); font-size: 0.9rem; }

/* spotlight avatar: two stacked frames, swap on .talking */
.spotlight-avatar {
  position: relative;
  width: 160px; height: 160px;
  margin: 0 auto 16px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid rgba(255,255,255,0.25);
  box-shadow: 0 0 40px rgba(255,93,162,0.4);
}
.spotlight-avatar img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
}
.spotlight-avatar .av-open { opacity: 0; }
.spotlight-avatar.talking .av-closed { opacity: 0; }
.spotlight-avatar.talking .av-open { opacity: 1; }

/* ================= Logo + volume ================= */
.main-logo { width: 100%; max-width: 440px; height: auto; margin: 0 auto 8px; display: block; }
.main-logo.small { max-width: 260px; }
.volume-corner {
  position: fixed; top: 14px; right: 16px; z-index: 60;
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.3); padding: 8px 12px; border-radius: 20px;
}
.volume-slider { width: 120px; accent-color: var(--accent); }

/* ================= Game selection ================= */
.game-select { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin: 20px 0; }
.game-card {
  background: var(--panel); color: var(--text);
  width: 260px; padding: 24px 20px; border-radius: 16px; margin: 0;
  border: 2px solid rgba(255,255,255,0.1); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  white-space: normal; font-weight: 400;
}
.game-card:hover { border-color: var(--accent); transform: translateY(-4px); }
.game-emoji { font-size: 3rem; }
.game-title { font-size: 1.5rem; font-weight: 800; color: var(--accent2); }
.game-desc { font-size: 0.95rem; color: var(--muted); line-height: 1.4; }

/* ================= Sound Game ================= */
.judge-badge {
  display: inline-block; background: var(--accent); color: #fff;
  padding: 8px 18px; border-radius: 20px; font-weight: 700; margin: 10px 0;
}
/* picked slots row (player) */
.picked-row { display: flex; gap: 8px; justify-content: center; margin: 14px 0; }
.pick-slot {
  flex: 1; max-width: 130px; min-height: 46px; border-radius: 10px;
  background: rgba(255,255,255,0.06); border: 2px dashed rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px; font-size: 0.85rem; text-align: center;
}
.pick-slot.filled { border-style: solid; border-color: var(--good); background: rgba(88,224,124,0.15); }
.pick-num {
  background: var(--accent2); color: #10142b; font-weight: 800;
  width: 20px; height: 20px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-size: 0.8rem; flex-shrink: 0;
}
.pick-empty { color: var(--muted); }

/* sound grid (player) */
.sound-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.sound-cell {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.06); border-radius: 10px; padding: 6px 8px;
  border: 2px solid transparent;
}
.sound-cell.picked { border-color: var(--good); background: rgba(88,224,124,0.12); }
.sound-preview {
  margin: 0; padding: 0; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent2); color: #10142b; font-size: 0.9rem; flex-shrink: 0;
}
.sound-name { flex: 1; font-size: 0.82rem; text-align: left; line-height: 1.2; }
.sound-add {
  margin: 0; padding: 0; width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); font-size: 1.2rem; flex-shrink: 0;
}
.sound-cell.picked .sound-add { background: var(--good); }

/* performance stage (host reveal) */
.perform-stage {
  min-height: 220px; margin: 20px 0; padding: 30px;
  border-radius: 20px; background: rgba(255,255,255,0.04);
  transition: all 0.3s ease; opacity: 0.6;
}
.perform-stage.lit {
  opacity: 1;
  background: radial-gradient(circle at center, rgba(93,228,255,0.25), rgba(42,31,77,0.9));
  box-shadow: 0 0 50px rgba(93,228,255,0.4);
}
.perform-name { font-size: 2.6rem; font-weight: 800; margin-bottom: 20px; }
.perform-sounds { display: flex; flex-direction: column; gap: 10px; max-width: 420px; margin: 0 auto; }
.perform-chip {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.08); border-radius: 12px; padding: 12px 18px;
  font-size: 1.2rem; transition: all 0.15s ease; opacity: 0.55;
}
.perform-chip.playing {
  opacity: 1; background: var(--accent); transform: scale(1.05);
  box-shadow: 0 0 24px rgba(255,93,162,0.6);
}
.pchip-num {
  background: var(--accent2); color: #10142b; font-weight: 800;
  width: 26px; height: 26px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}

/* ================= Simple background (reverted) ================= */
body { background: var(--bg); }

/* ================= Country Pride ================= */
.country-name {
  font-size: 3rem; font-weight: 800; color: var(--accent2);
  margin: 16px 0; text-shadow: 0 0 24px rgba(93,228,255,0.5);
}
/* GIF picker (player) */
.gif-picker { display: flex; gap: 8px; margin: 12px 0; }
.gif-picker input {
  flex: 1; padding: 12px 16px; font-size: 1rem; border-radius: 8px; border: none; margin: 0; width: auto; max-width: none;
}
.gif-picker button { margin: 0; padding: 12px 18px; }
.gif-results {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; max-height: 46vh; overflow-y: auto;
}
.gif-thumb {
  width: 100%; border-radius: 10px; cursor: pointer; border: 3px solid transparent; background: rgba(255,255,255,0.05);
  aspect-ratio: 1 / 1; object-fit: cover;
}
.gif-thumb:hover { border-color: var(--accent); }
.cp-chosen-gif { max-width: 220px; width: 80%; border-radius: 12px; margin: 10px auto; display: block; border: 3px solid var(--good); }

/* reveal stage (host) */
.cp-stage {
  min-height: 300px; margin: 16px 0; padding: 20px; border-radius: 20px;
  background: rgba(255,255,255,0.04); transition: all 0.3s ease; opacity: 0.6;
}
.cp-stage.lit {
  opacity: 1;
  background: radial-gradient(circle at center, rgba(123,47,247,0.3), rgba(23,16,43,0.9));
  box-shadow: 0 0 50px rgba(123,47,247,0.5);
}
.cp-perform-name { font-size: 2.4rem; font-weight: 800; margin-bottom: 14px; }
.cp-reveal-gif { max-width: 460px; width: 70%; max-height: 46vh; border-radius: 14px; object-fit: contain; }
.cp-winner-gif { max-width: 300px; width: 60%; border-radius: 14px; margin: 14px auto; display: block; }

/* vote grid (host) — scales to any number of players */
.cp-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin: 16px 0; max-height: 55vh; overflow-y: auto;
}
.cp-cell { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.cp-cell img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 12px; }
.cp-cell span { color: var(--muted); font-size: 0.9rem; }

/* vote buttons (player) */
.cp-vote-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: rgba(255,255,255,0.08); color: var(--text); margin: 6px 0; padding: 8px;
}
.cp-vote-btn img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }

/* ================= Randomizer reel ================= */
.randomizer {
  font-size: 3.4rem; font-weight: 900; color: var(--accent);
  margin: 20px auto; padding: 20px 30px; min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.05); border-radius: 16px; max-width: 560px;
  text-shadow: 0 0 20px rgba(255,93,162,0.4);
}
.randomizer.reel-spin { opacity: 0.85; }
.randomizer.reel-landed {
  color: var(--accent2); transform: scale(1.12);
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
  text-shadow: 0 0 34px rgba(93,228,255,0.7);
}

/* ================= Playful UI polish ================= */
/* smoother eased screen entrances */
.panel [id^="screen-"] { animation: screenIn 0.34s cubic-bezier(0.22,1,0.36,1); }
@keyframes screenIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* tactile buttons */
button {
  box-shadow: 0 4px 0 rgba(0,0,0,0.25), 0 6px 14px rgba(0,0,0,0.3);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.12s ease;
}
button:active { transform: translateY(3px) scale(0.99); box-shadow: 0 1px 0 rgba(0,0,0,0.25); }

/* big red record button */
.record-btn {
  background: radial-gradient(circle at 38% 34%, #ff6b6b, #d61f3a 62%, #a30f26);
  border: 4px solid rgba(255,255,255,0.18);
  box-shadow: 0 8px 0 #7d0a1c, 0 12px 22px rgba(0,0,0,0.45), inset 0 2px 8px rgba(255,255,255,0.35);
  font-weight: 800; letter-spacing: 0.5px;
}
.record-btn:active { transform: translateY(6px) scale(0.98); box-shadow: 0 2px 0 #7d0a1c, 0 4px 10px rgba(0,0,0,0.4); }
.record-btn.recording {
  background: radial-gradient(circle at 38% 34%, #7bffa0, #24c257 62%, #14933f);
  box-shadow: 0 8px 0 #0c6b2c, 0 0 0 rgba(88,224,124,0.6), 0 12px 22px rgba(0,0,0,0.45);
  animation: recPulse 1s infinite;
}
@keyframes recPulse { 0%{box-shadow:0 8px 0 #0c6b2c,0 0 0 0 rgba(88,224,124,0.55),0 12px 22px rgba(0,0,0,0.45)} 70%{box-shadow:0 8px 0 #0c6b2c,0 0 0 22px rgba(88,224,124,0),0 12px 22px rgba(0,0,0,0.45)} 100%{box-shadow:0 8px 0 #0c6b2c,0 0 0 0 rgba(88,224,124,0),0 12px 22px rgba(0,0,0,0.45)} }

/* circular countdown timer */
.timer-ring { position: relative; width: 108px; height: 108px; margin: 10px auto; }
.timer-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.timer-ring .ring-bg { fill: none; stroke: rgba(255,255,255,0.12); stroke-width: 9; }
.timer-ring .ring-fg { fill: none; stroke: var(--accent2); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke 0.3s; }
.timer-ring.urgent .ring-fg { stroke: #ff5b5b; }
.timer-ring .ring-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; font-weight: 800; color: var(--text);
}
.timer-ring.urgent .ring-num { color: #ff8080; animation: tick 1s infinite; }
@keyframes tick { 0%,100%{transform:scale(1)} 50%{transform:scale(1.14)} }

/* game-start counter */
.big-count {
  font-size: 6rem; font-weight: 900; color: var(--accent);
  animation: popCount 1s ease-in-out; text-shadow: 0 0 40px rgba(255,93,162,0.5);
}
@keyframes popCount { 0%{transform:scale(0.3);opacity:0} 30%{transform:scale(1.15);opacity:1} 70%{transform:scale(1)} 100%{transform:scale(0.85);opacity:0} }

/* ================= Cartist ================= */
.car-name-card {
  background: rgba(255,255,255,0.06); border-radius: 16px; padding: 18px 26px;
  margin: 14px auto; max-width: 480px; line-height: 1.3;
}
.car-year { font-size: 1.3rem; color: var(--muted); font-weight: 700; }
.car-brand { font-size: 1.8rem; color: var(--accent2); font-weight: 800; }
.car-model { font-size: 2.4rem; color: var(--text); font-weight: 900; }

/* reveal stage: reference + one drawing side by side, both boxed */
.car-reveal-stage {
  display: flex; justify-content: center; align-items: center; gap: 24px;
  min-height: 46vh; margin: 16px 0; position: relative;
}
.car-ref-box, .car-draw-box {
  width: 38vw; max-width: 460px; aspect-ratio: 4 / 3; position: relative;
  border-radius: 16px; overflow: hidden; background: rgba(0,0,0,0.3);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45); border: 3px solid rgba(255,255,255,0.12);
  transition: transform 0.6s cubic-bezier(0.22,1,0.36,1);
}
.car-ref-box img, .car-draw-box img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.car-box-label {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 6px;
  background: rgba(23,16,43,0.82); color: var(--text); font-weight: 700; font-size: 1rem;
}
.car-ref-box.to-left { transform: translateX(-8px); }
.car-draw-box { opacity: 0; transform: translateX(60vw); }
.car-draw-box.slide-in { animation: carSlideIn 0.6s cubic-bezier(0.22,1,0.36,1) forwards; }
@keyframes carSlideIn { from { opacity: 0; transform: translateX(60vw); } to { opacity: 1; transform: translateX(0); } }

.car-ref-inline { margin: 10px auto; }
.car-ref-inline img { max-height: 22vh; border-radius: 12px; background:#fff; }
.car-ref-inline span { display: block; color: var(--muted); margin-top: 6px; }

/* ================= Cartist drawing (fixed layout) ================= */
.car-draw-area {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; max-width: 520px; margin: 10px auto;
}
.car-draw-area canvas {
  width: min(88vw, 480px); height: min(88vw, 480px);
  background: #fff; border-radius: 14px; touch-action: none; cursor: crosshair;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); display: block;
}
.car-draw-area .tool-row,
.car-draw-area .palette-row {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin: 10px 0 0; width: 100%; max-width: min(88vw, 480px);
}
.car-draw-area .swatch { width: 32px; height: 32px; }

/* ================= Bigger Cartist reveal ================= */
.car-reveal-stage { gap: 2.5vw; min-height: 66vh; }
.car-ref-box, .car-draw-box { width: 42vw; max-width: 780px; aspect-ratio: 4 / 3; }
.car-box-label { font-size: 1.3rem; padding: 10px; }
/* bigger vote grid cells + reference */
#screen-car-vote .cp-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
#screen-car-vote .cp-cell img { border: 2px solid rgba(255,255,255,0.15); }
.car-ref-inline img { max-height: 30vh; }

/* ================= Player "Join New Game" button ================= */
.leave-btn {
  position: fixed; top: 10px; left: 10px; z-index: 100;
  background: rgba(255,255,255,0.12); color: var(--text);
  padding: 8px 14px; font-size: 0.85rem; border-radius: 20px; margin: 0;
  box-shadow: 0 2px 0 rgba(0,0,0,0.3);
}
.leave-btn:active { transform: translateY(2px); }

/* rolling state for player's country reveal */
.country-name.rolling { animation: rollPulse 0.5s ease-in-out infinite; }
@keyframes rollPulse { 0%,100% { transform: scale(1); opacity: 0.8; } 50% { transform: scale(1.15) rotate(8deg); opacity: 1; } }

/* Cartist reveal needs the full screen — widen the host panel for it */
.panel.wide { max-width: 96vw; }
.panel.wide .car-ref-box, .panel.wide .car-draw-box { width: 44vw; max-width: 860px; }
