:root {
  --bg-start: #ffe9f0;
  --bg-end: #e9f4ff;
  --primary: #ff4b6e;
  --primary-dark: #d93b5b;
  --accent: #ffd166;
  --ink: #2b2d42;
  --muted: #6b6f8a;
  --card-bg: rgba(255, 255, 255, 0.92);
  --good: #2ecc71;
  --bad: #e74c3c;
  --shadow: 0 20px 60px rgba(43, 45, 66, 0.18);
}

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

html, body {
  height: 100%;
  font-family: 'Heebo', 'Rubik', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 800px at 10% 0%, #fff2c2 0%, transparent 60%),
    radial-gradient(1000px 700px at 100% 100%, #c2e4ff 0%, transparent 60%),
    linear-gradient(135deg, var(--bg-start), var(--bg-end));
  overflow-x: hidden;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
  z-index: 2;
}

/* ===== Floating pics layer ===== */
.floating-pics {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.floating-pics img {
  position: absolute;
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 18px;
  box-shadow: 0 12px 30px rgba(43, 45, 66, 0.25);
  border: 4px solid #fff;
  opacity: 0;
  animation: floatIn 1.2s ease-out forwards, gentleFloat 8s ease-in-out infinite;
}

@keyframes floatIn {
  0% { opacity: 0; transform: scale(0.4) rotate(var(--rot, 0deg)); }
  100% { opacity: 0.85; transform: scale(1) rotate(var(--rot, 0deg)); }
}

@keyframes gentleFloat {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -14px; }
}

/* Dim the floaters once we're past the lobby */
body.in-game .floating-pics img { opacity: 0.12; animation-play-state: paused; }

/* ===== Screens ===== */
.screen { display: none; width: 100%; max-width: 720px; }
.screen.active { display: block; }

.card {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 36px 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.card-wide { max-width: 720px; margin: 0 auto; }

.title {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 900;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--primary), #ff8e3c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.2;
}

.subtitle {
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: 24px;
}

.label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  margin-top: 8px;
  text-align: right;
}

input[type="text"] {
  width: 100%;
  font-family: inherit;
  font-size: 1.15rem;
  padding: 14px 18px;
  border: 2px solid #e6e6f0;
  border-radius: 14px;
  background: #fff;
  text-align: right;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input[type="text"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255, 75, 110, 0.15);
}

.btn {
  display: inline-block;
  font-family: inherit;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 14px 28px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .2s;
  margin-top: 18px;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 10px 24px rgba(255, 75, 110, 0.35);
}
.btn-primary:hover { box-shadow: 0 14px 28px rgba(255, 75, 110, 0.45); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.error {
  color: var(--bad);
  margin-top: 12px;
  font-weight: 600;
}

.muted { color: var(--muted); font-size: 0.95rem; margin-top: 12px; }

/* ===== Lobby ===== */
.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 24px 0;
}
.player-chip {
  background: linear-gradient(135deg, #fff, #fff5f7);
  border: 2px solid #ffd9e2;
  border-radius: 14px;
  padding: 12px 10px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  animation: popIn .4s ease-out;
}
.player-chip.is-host::after { content: "👑"; }
.player-chip.is-me { background: linear-gradient(135deg, #fff2c2, #ffd9e2); border-color: var(--accent); }

@keyframes popIn {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}

.host-controls { margin-top: 16px; }
.host-note { color: var(--ink); font-weight: 600; margin-bottom: 8px; }

/* ===== Question ===== */
.question-card { text-align: right; }

.question-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; margin-bottom: 20px;
}
.progress {
  background: rgba(255, 75, 110, 0.12);
  color: var(--primary-dark);
  padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 0.95rem;
}

.timer-wrap {
  display: flex; align-items: center; gap: 10px; flex: 1; max-width: 360px;
}
.timer-bar {
  flex: 1; height: 12px; background: #ffe1e8; border-radius: 999px; overflow: hidden;
}
.timer-bar > div {
  height: 100%; width: 100%; background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .1s linear;
}
.timer-num {
  font-weight: 900; font-size: 1.4rem; color: var(--primary-dark); min-width: 36px; text-align: center;
}

.question-image-wrap {
  margin: 0 auto 20px;
  text-align: center;
}
.question-image-wrap img {
  display: inline-block;
  max-width: min(380px, 100%);
  max-height: 45vh;
  width: auto;
  height: auto;
  border-radius: 18px;
  border: 4px solid #fff;
  box-shadow: 0 10px 30px rgba(43, 45, 66, 0.2);
}

.question-text {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-weight: 800;
  margin-bottom: 20px;
  line-height: 1.4;
}

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 520px) { .answers { grid-template-columns: 1fr; } }

.answer-btn {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 16px 14px;
  background: #fff;
  border: 2px solid #e6e6f0;
  border-radius: 14px;
  cursor: pointer;
  text-align: right;
  transition: transform .1s, border-color .15s, background .15s;
}
.answer-btn:hover:not(:disabled) { border-color: var(--primary); background: #fff5f7; }
.answer-btn:active { transform: translateY(1px); }
.answer-btn.selected { border-color: var(--primary); background: #ffeaf0; }
.answer-btn.correct { border-color: var(--good); background: #e6fff0; color: #0a7a3a; }
.answer-btn.wrong { border-color: var(--bad); background: #ffe9e6; color: #8a1a1a; }
.answer-btn:disabled { cursor: default; }

/* ===== Reveal ===== */
.reveal-title { font-size: 1.5rem; margin-bottom: 8px; }
.reveal-answer {
  font-size: 1.6rem; font-weight: 900; color: var(--good); margin-bottom: 20px;
}

.reveal-photo-wrap {
  margin: 0 auto 20px;
  text-align: center;
  animation: revealIn .4s ease-out;
}

.reveal-photos {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 4px 8px 8px;
  scrollbar-width: thin;
}
.reveal-photos.single { justify-content: center; }
.reveal-photos.few { justify-content: center; flex-wrap: wrap; }
.reveal-photos img {
  scroll-snap-align: center;
  flex: 0 0 auto;
  max-width: min(420px, 88vw);
  max-height: 44vh;
  width: auto;
  height: auto;
  object-fit: cover;
  border-radius: 16px;
  border: 4px solid #fff;
  box-shadow: 0 10px 26px rgba(43, 45, 66, 0.22);
}
.reveal-photos.single img { max-width: min(460px, 92vw); max-height: 50vh; }

@media (max-width: 600px) {
  .reveal-photos img {
    max-width: 72vw;
    max-height: 30vh;
  }
  .reveal-photos.single img {
    max-width: min(260px, 80vw);
    max-height: 30vh;
  }
  .question-image-wrap img {
    max-width: min(260px, 100%);
    max-height: 30vh;
  }
}
.reveal-caption {
  margin-top: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.5;
}

.troll-answer {
  margin: 18px auto 12px;
  max-width: 460px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #fff2c2, #ffd9e2);
  border: 2px dashed #d93b5b;
  border-radius: 14px;
  font-weight: 700;
  animation: trollIn .6s cubic-bezier(0.34, 1.56, 0.64, 1) .3s both;
  transform-origin: center;
}
.troll-label {
  display: block;
  font-size: 0.9rem;
  color: #8a1a8a;
  margin-bottom: 4px;
}
.troll-text {
  font-size: 1.2rem;
  color: var(--ink);
  font-style: italic;
}
@keyframes trollIn {
  0%   { opacity: 0; transform: scale(0.3) rotate(-8deg); }
  60%  { transform: scale(1.05) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes revealIn {
  from { opacity: 0; transform: scale(0.85) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.mini-leaderboard, .final-leaderboard {
  display: flex; flex-direction: column; gap: 8px;
  max-width: 460px; margin: 16px auto;
}
.lb-row {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; padding: 12px 16px; border-radius: 12px;
  border: 2px solid #f0f0f8;
  font-weight: 700;
}
.lb-row .rank { color: var(--muted); margin-left: 10px; }
.lb-row.me { border-color: var(--accent); background: #fff8e3; }
.lb-row.first { background: linear-gradient(135deg, #fff2c2, #ffe082); border-color: #f9b13a; }
.lb-row.second { background: #f0f0f5; }
.lb-row.third { background: #ffe6d6; }

/* ===== Floating pic helpers — JS sets --x, --y, --rot, --size ===== */
.floating-pics img.pic {
  width: var(--size, 160px);
  height: var(--size, 160px);
  left: var(--x, 50%);
  top: var(--y, 50%);
  --rot-final: var(--rot, 0deg);
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
}
