/* EUI-inspired (Elastic Amsterdam) light theme — vanilla CSS, no build step.
   Tokens approximate @elastic/eui light theme values. */
:root {
  --eui-primary: #0077cc;
  --eui-primary-dark: #005a9e;
  --eui-accent: #ba3d76;
  --eui-success: #00bfb3;
  --eui-warning: #fec514;
  --eui-danger: #bd271e;
  --eui-text: #343741;
  --eui-subdued: #69707d;
  --eui-light-shade: #d3dae6;
  --eui-lightest-shade: #f5f7fa;
  --eui-page-bg: #fafbfd;
  --eui-panel-bg: #ffffff;
  --eui-gold: #f5a700;
  --eui-radius: 6px;
  --eui-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.08);
  --eui-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --eui-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --eui-mono: 'Roboto Mono', 'SF Mono', 'Fira Code', monospace;
}

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

body {
  font-family: var(--eui-font);
  background: var(--eui-page-bg);
  color: var(--eui-text);
  min-height: 100vh;
  overflow: hidden;
}

/* --- Animated background blobs --- */
.blobs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.4;
  will-change: transform;
}
.blob-1 {
  width: 460px; height: 460px;
  background: var(--eui-primary);
  top: -120px; left: -80px;
  animation: blob-move-1 22s ease-in-out infinite;
}
.blob-2 {
  width: 400px; height: 400px;
  background: var(--eui-success);
  bottom: -140px; right: -60px;
  animation: blob-move-2 26s ease-in-out infinite;
}
.blob-3 {
  width: 360px; height: 360px;
  background: var(--eui-accent);
  top: 40%; left: 55%;
  opacity: 0.28;
  animation: blob-move-3 30s ease-in-out infinite;
}
@keyframes blob-move-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(120px, 80px) scale(1.15); }
  66% { transform: translate(60px, 160px) scale(0.9); }
}
@keyframes blob-move-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-100px, -60px) scale(0.9); }
  66% { transform: translate(-160px, 40px) scale(1.2); }
}
@keyframes blob-move-3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-140px, -100px) scale(1.1); }
}
@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
}

.container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 1.75rem 2rem;
  gap: 1.25rem;
}

header {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 96px;
}
/* Quiz page: logo on the left (day board keeps it centered for the back button). */
body.quiz header { justify-content: flex-start; }

.logo { height: 88px; width: auto; display: block; }

/* Keep the progress counter pinned right so the logo stays centered. */
header .progress-counter { position: absolute; right: 0; top: 50%; transform: translateY(-50%); }

/* Back-to-main link, pinned left so the logo stays centered. */
header .back-btn {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  background: var(--eui-panel-bg);
  border: 1px solid var(--eui-light-shade);
  color: var(--eui-text);
  padding: 0.55rem 1.2rem;
  border-radius: var(--eui-radius);
  font-size: 0.95rem; font-weight: 500;
  text-decoration: none;
  box-shadow: var(--eui-shadow);
  transition: background 0.15s, border-color 0.15s;
}
header .back-btn:hover { background: var(--eui-lightest-shade); border-color: var(--eui-primary); }

h1 {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--eui-text);
  letter-spacing: -0.01em;
}

.progress-counter {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--eui-primary);
  background: rgba(0, 119, 204, 0.1);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
}

.stage { flex: 1; overflow: hidden; display: flex; }

/* --- Panels / cards --- */
.panel {
  background: var(--eui-panel-bg);
  border: 1px solid var(--eui-light-shade);
  border-radius: var(--eui-radius);
  padding: 1.5rem;
  overflow-y: auto;
  box-shadow: var(--eui-shadow);
}
.panel h2 {
  font-size: 0.95rem;
  margin-bottom: 1rem;
  color: var(--eui-subdued);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* --- Score rows --- */
.scores { position: relative; }
.score-row {
  display: flex;
  align-items: center;
  padding: 0.7rem 0.9rem;
  border-radius: var(--eui-radius);
  margin-bottom: 0.5rem;
  background: var(--eui-lightest-shade);
  border: 1px solid transparent;
  will-change: transform;
}
.score-row:nth-child(1) { background: rgba(245, 167, 0, 0.12); border-color: rgba(245, 167, 0, 0.35); }
.score-row:nth-child(2) { background: rgba(105, 112, 125, 0.1); border-color: rgba(105, 112, 125, 0.25); }
.score-row:nth-child(3) { background: rgba(186, 61, 118, 0.08); border-color: rgba(186, 61, 118, 0.2); }

.score-row.moved-up { animation: pop-up 1.6s ease-out; z-index: 2; position: relative; }
.score-row.moved-down { animation: pop-down 1.6s ease-out; }
@keyframes pop-up {
  0%   { box-shadow: 0 0 0 0 rgba(0, 191, 179, 0); }
  25%  { box-shadow: 0 0 18px 4px rgba(0, 191, 179, 0.75); }
  100% { box-shadow: 0 0 0 0 rgba(0, 191, 179, 0); }
}
@keyframes pop-down {
  0%   { box-shadow: 0 0 0 0 rgba(189, 39, 30, 0); }
  25%  { box-shadow: 0 0 14px 3px rgba(189, 39, 30, 0.5); }
  100% { box-shadow: 0 0 0 0 rgba(189, 39, 30, 0); }
}

.position { font-size: 1.2rem; font-weight: 700; width: 2.6rem; text-align: center; }
.avatar {
  width: 2.4rem; height: 2.4rem; flex-shrink: 0;
  border-radius: 50%; margin-right: 0.7rem;
  background: #fff; border: 1px solid var(--eui-light-shade);
  object-fit: contain;
}
.player-name { flex: 1; font-size: 1.15rem; font-weight: 600; display: flex; align-items: center; gap: 0.4rem; }
.fire { display: inline-block; animation: fire-flicker 0.9s ease-in-out infinite alternate; }
@keyframes fire-flicker { from { transform: scale(1) rotate(-4deg); } to { transform: scale(1.15) rotate(4deg); } }
.fire.boom { animation: boom-pulse 0.6s ease-in-out infinite alternate; }
@keyframes boom-pulse { from { transform: scale(1); } to { transform: scale(1.35); } }
.fire.zap { animation: zap-flash 0.5s steps(2, jump-none) infinite; }
@keyframes zap-flash { 0% { transform: scale(1.2); filter: drop-shadow(0 0 4px gold); } 100% { transform: scale(1); filter: none; } }

.score-badge {
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0.25rem 0.7rem;
  border-radius: var(--eui-radius);
  background: rgba(0, 119, 204, 0.12);
  color: var(--eui-primary);
}

.empty-state {
  color: var(--eui-subdued);
  font-size: 1.1rem;
  text-align: center;
  padding: 2.5rem;
}

/* --- Admin bar --- */
.admin-bar {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--eui-light-shade);
}
.admin-bar button, .link-btn {
  background: var(--eui-panel-bg);
  border: 1px solid var(--eui-light-shade);
  color: var(--eui-text);
  padding: 0.55rem 1.3rem;
  border-radius: var(--eui-radius);
  font-size: 0.95rem;
  font-weight: 500;
  font-family: var(--eui-font);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s, border-color 0.15s;
}
.admin-bar button:hover, .link-btn:hover {
  background: var(--eui-lightest-shade);
  border-color: var(--eui-primary);
}
#next-btn {
  background: var(--eui-primary);
  color: #fff;
  border-color: var(--eui-primary);
  font-weight: 600;
}
#next-btn:hover { background: var(--eui-primary-dark); border-color: var(--eui-primary-dark); }

/* --- Confetti --- */
.confetti-container {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 2000;
}
.confetti-piece { position: absolute; width: 10px; height: 10px; top: -10px; animation: fall 3s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: 0; } }

/* --- Lobby --- */
.hidden { display: none !important; }
.lobby { flex: 1; display: flex; align-items: center; justify-content: center; }
.lobby-split {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5rem;
}
.lobby-logo { height: 292px; width: auto; display: block; }
.lobby-divider {
  width: 2px;
  align-self: stretch;
  min-height: 300px;
  background: linear-gradient(180deg, rgba(211,218,230,0) 0%, var(--eui-light-shade) 20%, var(--eui-light-shade) 80%, rgba(211,218,230,0) 100%);
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.12);
  border-radius: 2px;
}
.join-cta { text-align: center; }
.qr-code {
  display: inline-block;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--eui-light-shade);
  border-radius: 12px;
  margin: 1.25rem 0;
  box-shadow: var(--eui-shadow-lg);
}
.qr-code img, .qr-code canvas { display: block; }
.join-label { font-size: 1.3rem; color: var(--eui-subdued); font-weight: 500; }
.join-url {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--eui-primary);
  font-family: var(--eui-mono);
}
.player-count { font-size: 1.6rem; color: var(--eui-success); font-weight: 700; margin-top: 0.75rem; }

/* --- Question stage (full width) --- */
.question-stage { flex: 1; display: flex; flex-direction: column; gap: 1rem; overflow: hidden; }
.q-topbar {
  display: flex; align-items: center; gap: 1rem;
}
.q-topbar .q-kind { flex: 1; }
.q-main { flex: 1; display: flex; flex-direction: column; gap: 1rem; overflow: hidden; }
.q-kind {
  font-size: 1rem; letter-spacing: 0.08em; font-weight: 700;
  color: var(--eui-accent); text-transform: uppercase;
}
.q-prompt { font-size: 1.8rem; font-weight: 700; color: var(--eui-text); }
.q-code {
  background: #fbfcfd;
  border: 1px solid var(--eui-light-shade);
  border-radius: var(--eui-radius);
  padding: 1.5rem;
  overflow: auto;
  font-size: 1.6rem;
  line-height: 1.55;
  box-shadow: var(--eui-shadow);
  flex: 1;
}
.q-code code { font-family: var(--eui-mono); background: none; padding: 0; }

.q-options { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.option {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 1.1rem 1.25rem;
  border-radius: var(--eui-radius);
  color: #fff;
  border: 2px solid transparent;
  font-size: 1.35rem; font-weight: 600;
  box-shadow: var(--eui-shadow);
  transition: all 0.3s ease;
}
/* Option colors match the phone answer buttons (A/B/C/D). */
.option.opt-a { background: #bd271e; }
.option.opt-b { background: #0077cc; }
.option.opt-c { background: #f5a700; }
.option.opt-d { background: #00a68b; }
.opt-letter {
  width: 2.4rem; height: 2.4rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--eui-radius); font-weight: 800;
  background: rgba(255, 255, 255, 0.25); color: #fff;
}
.option.correct {
  border-color: #fff;
  box-shadow: 0 0 0 4px var(--eui-success), var(--eui-shadow-lg);
}
.option.dimmed { opacity: 0.4; }

.countdown {
  font-size: 2.6rem; font-weight: 800; text-align: center;
  color: var(--eui-primary);
  background: var(--eui-panel-bg);
  border: 1px solid var(--eui-light-shade);
  border-radius: var(--eui-radius);
  padding: 0.3rem 1.2rem; min-width: 4rem;
  box-shadow: var(--eui-shadow);
}
.countdown.critical { color: var(--eui-danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }
.answered { font-size: 1.1rem; color: var(--eui-subdued); font-weight: 600; }

/* Who still needs to answer */
.q-waiting { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.q-waiting:empty { display: none; }
.q-waiting-label {
  font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--eui-subdued); font-weight: 600; margin-right: 0.25rem;
}
.waiting-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--eui-panel-bg); border: 1px solid var(--eui-light-shade);
  border-radius: 999px; padding: 0.25rem 0.75rem 0.25rem 0.3rem;
  font-size: 1rem; font-weight: 600; color: var(--eui-text);
  box-shadow: var(--eui-shadow);
}
.waiting-chip img {
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: #fff; border: 1px solid var(--eui-light-shade);
}

/* --- Final --- */
.final { flex: 1; display: flex; flex-direction: column; align-items: center; overflow-y: auto; }
.final-title { font-size: 2.2rem; margin-bottom: 1.5rem; color: var(--eui-gold); font-weight: 800; }
.podium { width: 100%; max-width: 700px; }

/* --- Explanation modal --- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(52, 55, 65, 0.45); backdrop-filter: blur(3px);
  animation: modal-fade 0.2s ease;
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: min(780px, 92vw);
  background: var(--eui-panel-bg);
  border: 1px solid var(--eui-light-shade);
  border-top: 4px solid var(--eui-success);
  border-radius: 10px;
  box-shadow: var(--eui-shadow-lg);
  padding: 1.75rem 2rem 2rem;
  animation: modal-pop 0.25s ease;
}
@keyframes modal-pop { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; }
.modal-heading { flex: 1; display: flex; flex-direction: column; gap: 0.4rem; }
.modal-eyebrow {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--eui-subdued); font-weight: 600;
  display: flex; align-items: center; gap: 0.5rem;
}
.modal-timeout {
  background: rgba(254, 197, 20, 0.2); color: #8a6d00;
  padding: 0.1rem 0.5rem; border-radius: 999px;
  font-size: 0.7rem; letter-spacing: 0;
}
.modal-answer { font-size: 1.5rem; font-weight: 700; color: var(--eui-text); display: flex; align-items: center; gap: 0.6rem; }
.modal-letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: var(--eui-radius);
  background: var(--eui-success); color: #fff; font-size: 1.1rem; flex-shrink: 0;
}
.modal-body { font-size: 1.25rem; line-height: 1.6; }
.modal-main { color: var(--eui-text); margin-bottom: 1rem; }
.modal-others-label {
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--eui-subdued); font-weight: 600; margin-bottom: 0.4rem;
}
.modal-others { color: var(--eui-subdued); font-size: 1.1rem; }

/* Session leaderboard inside the reveal modal */
.modal-board {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--eui-light-shade);
  max-height: 40vh;
  overflow-y: auto;
}
.modal-board-title {
  font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--eui-subdued); font-weight: 600; margin-bottom: 0.75rem;
}
.modal-footer { margin-top: 1.5rem; display: flex; justify-content: flex-end; }
.modal-next-btn {
  background: var(--eui-primary); color: #fff;
  border: none; border-radius: var(--eui-radius);
  padding: 0.8rem 1.8rem; font-size: 1.15rem; font-weight: 700;
  cursor: pointer; font-family: var(--eui-font);
  box-shadow: var(--eui-shadow);
  transition: background 0.15s;
}
.modal-next-btn:hover { background: var(--eui-primary-dark); }
.modal-next-btn:active { transform: scale(0.98); }

/* --- Player page --- */
body.play { overflow: auto; background: var(--eui-page-bg); }
.play-wrap { position: relative; z-index: 1; max-width: 500px; margin: 0 auto; padding: 1.5rem; min-height: 100vh; display: flex; flex-direction: column; }
.play-header { text-align: center; margin-bottom: 1rem; }
.play-header .logo { height: 72px; width: auto; margin: 0 auto; }
.join-form { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 6vh; align-items: stretch; }
.avatar-preview {
  width: 120px; height: 120px; margin: 0 auto;
  border-radius: 50%; background: #fff;
  border: 2px solid var(--eui-primary); padding: 6px;
  box-shadow: var(--eui-shadow);
}
.avatar-picker-label {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  font-size: 0.95rem; font-weight: 600; color: var(--eui-subdued);
}
.shuffle-btn {
  background: var(--eui-lightest-shade); border: 1px solid var(--eui-light-shade);
  color: var(--eui-text); padding: 0.3rem 0.7rem; border-radius: var(--eui-radius);
  font-size: 0.85rem; font-weight: 500; cursor: pointer; font-family: var(--eui-font);
}
.shuffle-btn:active { transform: scale(0.96); }
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.6rem; }
.avatar-choice {
  width: 100%; aspect-ratio: 1/1; border-radius: 50%;
  background: #fff; border: 2px solid var(--eui-light-shade); padding: 4px;
  cursor: pointer; transition: transform 0.1s, border-color 0.15s;
}
.avatar-choice:active { transform: scale(0.92); }
.avatar-choice.selected { border-color: var(--eui-primary); box-shadow: 0 0 0 2px rgba(0,119,204,0.3); }
.my-identity { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.avatar-lg {
  width: 88px; height: 88px; border-radius: 50%;
  background: #fff; border: 2px solid var(--eui-light-shade); padding: 5px;
  box-shadow: var(--eui-shadow);
}
.my-name { font-size: 1.3rem; font-weight: 700; color: var(--eui-text); }
.join-form input {
  padding: 1rem; font-size: 1.2rem; border-radius: var(--eui-radius);
  border: 1px solid var(--eui-light-shade); background: #fff; color: var(--eui-text);
  font-family: var(--eui-font);
}
.join-form input:focus { outline: none; border-color: var(--eui-primary); box-shadow: 0 0 0 2px rgba(0,119,204,0.2); }
.join-form button {
  padding: 1rem; font-size: 1.2rem; font-weight: 700; border: none;
  border-radius: var(--eui-radius); cursor: pointer; color: #fff;
  background: var(--eui-primary); font-family: var(--eui-font);
}
.join-form button:hover { background: var(--eui-primary-dark); }
.status-msg { text-align: center; font-size: 1.2rem; margin: 2rem 0; color: var(--eui-subdued); font-weight: 500; }
.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.answer-btn {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  font-size: 3rem; font-weight: 800; border: none; border-radius: 10px;
  cursor: pointer; color: #fff; transition: transform 0.1s, opacity 0.2s;
  box-shadow: var(--eui-shadow);
}
.answer-btn:active { transform: scale(0.95); }
.answer-btn.A { background: #bd271e; }
.answer-btn.B { background: #0077cc; }
.answer-btn.C { background: #f5a700; }
.answer-btn.D { background: #00a68b; }
.answer-btn:disabled { opacity: 0.35; cursor: default; }
.answer-btn.chosen { outline: 4px solid var(--eui-text); opacity: 1; }
.result-banner { text-align: center; font-size: 1.5rem; font-weight: 700; margin-top: 1.5rem; padding: 1rem; border-radius: var(--eui-radius); }
.result-banner.correct { background: rgba(0, 191, 179, 0.15); color: #007b73; }
.result-banner.incorrect { background: rgba(189, 39, 30, 0.12); color: var(--eui-danger); }
.my-score { text-align: center; font-size: 1.15rem; color: var(--eui-primary); margin-top: 1rem; font-weight: 600; }
.my-streak { text-align: center; font-size: 1.3rem; margin-top: 0.5rem; }
