:root {
  --bg0: #0c1210;
  --bg1: #15211c;
  --ink: #f3f0e7;
  --muted: #a8b5ad;
  --accent: #e8ff47;
  --accent-2: #3dd6c6;
  --danger: #ff6b5a;
  --card: rgba(255, 255, 255, 0.05);
  --line: rgba(243, 240, 231, 0.12);
  --font-display: "Bebas Neue", Impact, sans-serif;
  --font-body: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg0);
  line-height: 1.45;
}

.shell { position: relative; min-height: 100vh; min-height: 100dvh; padding: 1.25rem; }
.shell.play,
.shell.host {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding: 0.75rem 1rem 1rem;
}
.shell.play > .panel,
.shell.host > .panel {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
#p-themes,
#panel-themes {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow: hidden;
}
#p-themes h1,
#panel-themes h2 {
  font-size: clamp(1.35rem, 4vw, 1.9rem);
  margin: 0;
  flex-shrink: 0;
}
#p-themes #pick-hint,
#panel-themes #theme-picker-hint {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.host-top,
.play-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  flex-shrink: 0;
}
.play-top .brand.compact { flex-shrink: 0; }
.play-top #play-status { flex-shrink: 0; }
.home-bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(61, 214, 198, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 80%, rgba(232, 255, 71, 0.12), transparent 50%),
    linear-gradient(160deg, #0c1210, #1a2a22 50%, #0c1210);
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(3rem, 10vw, 6rem);
  letter-spacing: 0.04em;
  margin: 0;
  line-height: 0.9;
  color: var(--accent);
}
.brand.compact { font-size: 1.75rem; color: var(--accent); }

h1, h2, h3 { font-family: var(--font-display); letter-spacing: 0.03em; font-weight: 400; margin: 0 0 0.5rem; }
h1 { font-size: clamp(2rem, 6vw, 3.2rem); }
h2 { font-size: clamp(1.6rem, 4vw, 2.2rem); }

.lede { color: var(--muted); max-width: 36rem; }
.muted { color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; color: var(--accent-2); }

.home-hero { max-width: 40rem; padding: 12vh 0 4rem; }
.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

.btn {
  appearance: none; border: 1px solid var(--line);
  background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600;
  padding: 0.85rem 1.25rem; border-radius: 0.35rem;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--accent); color: #10140f; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.buzz {
  width: min(80vw, 18rem); height: min(80vw, 18rem); border-radius: 50%;
  background: var(--accent); color: #10140f; font-family: var(--font-display);
  font-size: 4rem; margin: 2rem auto; display: grid; place-items: center;
  box-shadow: 0 0 0 0 rgba(232, 255, 71, 0.4);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  50% { box-shadow: 0 0 0 18px rgba(232, 255, 71, 0); }
}

.field { display: grid; gap: 0.35rem; margin: 0.75rem 0; font-size: 0.9rem; color: var(--muted); }
.field input, .field select {
  font: inherit; color: var(--ink); background: rgba(0,0,0,0.35);
  border: 1px solid var(--line); border-radius: 0.35rem; padding: 0.75rem 0.9rem;
}

.error { color: var(--danger); margin-top: 1rem; }
.status { color: var(--accent-2); font-weight: 600; }
.highlight {
  font-family: var(--font-display); font-size: 1.8rem; color: var(--accent);
  animation: rise 0.6s ease both;
}

.room-code strong { color: var(--accent); letter-spacing: 0.15em; }

.lobby-grid, .theme-play {
  display: grid; gap: 1.5rem;
}
@media (min-width: 800px) {
  .lobby-grid, .theme-play { grid-template-columns: 1fr 1fr; }
}

.qr {
  width: min(100%, 240px); background: #fff; padding: 0.75rem; border-radius: 0.5rem;
}

.player-list, .live-answers { list-style: none; padding: 0; margin: 0; }
.player-list li, .live-answers li {
  padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 0.5rem;
}
.live-answers .done { color: var(--accent-2); }
.live-answers .wait { color: var(--muted); }

.correct-banner {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--accent);
  margin: 0.5rem 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 0.35rem;
  background: rgba(232, 255, 71, 0.08);
}

.reveal-answers { list-style: none; padding: 0; margin: 0; }
.reveal-answers li {
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: var(--card);
  animation: rise 0.35s ease both;
}
.reveal-answers li.ok { border-color: var(--accent-2); }
.reveal-answers li.ko { border-color: var(--danger); opacity: 0.92; }
.reveal-answers .meta {
  display: flex; justify-content: space-between; gap: 0.5rem; align-items: center;
  font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem;
}
.reveal-answers .btn-toggle-correct {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}
.reveal-answers .pts { font-weight: 700; color: var(--accent); }
.reveal-answers .pts.gain { color: var(--accent-2); }
.reveal-answers .pts.loss { color: var(--danger); }
.reveal-answers .fast { color: var(--accent); font-size: 0.8rem; }

.score-hud {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  position: relative;
  margin-left: auto;
  margin-right: 0.75rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: rgba(232, 255, 71, 0.08);
}
.score-hud-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.score-hud strong {
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1;
  color: var(--accent);
}
.score-delta {
  position: absolute;
  right: 0.5rem;
  top: -0.85rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  opacity: 0;
  pointer-events: none;
}
.score-delta.is-gain { color: var(--accent-2); }
.score-delta.is-loss { color: var(--danger); }
.score-delta.is-pop {
  animation: score-pop 1.2s ease forwards;
}

.scoreboard {
  list-style: none;
  padding: 0;
  margin: 0 0 0.85rem;
  display: grid;
  gap: 0.35rem;
}
.scoreboard li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: var(--card);
  animation: rise 0.35s ease both;
}
.scoreboard li.is-me {
  border-color: var(--accent);
  background: rgba(232, 255, 71, 0.1);
}
.scoreboard .sb-pseudo { font-weight: 600; }
.scoreboard .sb-delta {
  font-family: var(--font-display);
  font-size: 1.15rem;
  min-width: 2.2rem;
  text-align: right;
}
.scoreboard .sb-delta.gain { color: var(--accent-2); animation: delta-flash 0.7s ease; }
.scoreboard .sb-delta.loss { color: var(--danger); animation: delta-flash 0.7s ease; }
.scoreboard .sb-delta.flat { color: var(--muted); }
.scoreboard .sb-total {
  font-weight: 700;
  color: var(--accent);
  min-width: 3.5rem;
  text-align: right;
}

@keyframes score-pop {
  0% { opacity: 0; transform: translateY(8px) scale(0.85); }
  20% { opacity: 1; transform: translateY(0) scale(1.12); }
  70% { opacity: 1; transform: translateY(-10px) scale(1); }
  100% { opacity: 0; transform: translateY(-22px) scale(0.95); }
}
@keyframes delta-flash {
  0% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.theme-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 0.45rem;
}
@media (min-width: 700px) {
  .theme-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
}
.theme-tile {
  position: relative;
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.2), rgba(0,0,0,0.72)),
    var(--tile-image, linear-gradient(145deg, #24352e, #15211c));
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.5rem 0.55rem;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(0.8rem, 2.4vw, 1.15rem);
  letter-spacing: 0.03em;
  transition: transform 0.18s ease, border-color 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
}
.theme-tile-title {
  line-height: 1.1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.theme-tile-badge {
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}
.theme-tile:hover:not(:disabled):not(.is-used) {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.theme-tile:disabled:not(.is-used) {
  opacity: 0.7;
  cursor: default;
  transform: none;
}
.theme-tile.is-used,
.theme-tile.is-used:disabled {
  filter: grayscale(1);
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
  border-color: var(--line);
}
.theme-tile.is-proposed {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232, 255, 71, 0.55), 0 0 18px rgba(232, 255, 71, 0.25);
  opacity: 1;
  filter: none;
}
.theme-tile.is-proposed .theme-tile-badge { color: var(--accent); }
.theme-launch-row {
  flex-shrink: 0;
  margin-top: 0.5rem;
  justify-content: center;
}
#btn-launch-theme:disabled { opacity: 0.45; cursor: not-allowed; }


.carre-grid { display: grid; gap: 0.65rem; }
.carre-grid button { width: 100%; text-align: left; }

.podium { list-style: none; padding: 0; counter-reset: podium; }
.podium li {
  counter-increment: podium;
  padding: 0.9rem 1rem; margin: 0.5rem 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 0.4rem;
  display: flex; justify-content: space-between;
  animation: rise 0.5s ease both;
}
.podium li:nth-child(1) { animation-delay: 0.05s; border-color: var(--accent); }
.podium li:nth-child(2) { animation-delay: 0.15s; }
.podium li:nth-child(3) { animation-delay: 0.25s; }
.podium li::before {
  content: "#" counter(podium);
  font-family: var(--font-display); color: var(--accent-2); margin-right: 0.75rem;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.card-form {
  max-width: 24rem; margin: 15vh auto;
  padding: 1.5rem; border: 1px solid var(--line); border-radius: 0.5rem;
  background: rgba(255,255,255,0.03);
}

.admin-themes { display: grid; gap: 1.25rem; margin-top: 1.5rem; }
.admin-theme {
  padding: 1rem; border: 1px solid var(--line); border-radius: 0.45rem; background: var(--card);
}
.admin-player {
  margin: 1rem 0 1.5rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: rgba(255,255,255,0.03);
}
.admin-track-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.admin-track-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.admin-track-label { flex: 1; min-width: 0; }
.admin-track-row .btn { flex-shrink: 0; padding: 0.45rem 0.85rem; font-size: 0.85rem; }
.inline-form { display: grid; gap: 0.5rem; margin: 0.75rem 0; }
@media (min-width: 700px) {
  .inline-form { grid-template-columns: 1fr auto; align-items: end; }
}

.panel[hidden] { display: none !important; }


/* Classement permanent — écran maître */
.host-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.35rem;
}
.host-top-left { min-width: 0; }
.host-score-recap {
  flex: 0 1 min(22rem, 48vw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  padding: 0.45rem 0.65rem 0.55rem;
  max-height: 7.5rem;
  overflow: auto;
}
.host-score-title {
  margin: 0 0 0.25rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-2);
}
.host-scoreboard {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.2rem;
}
.host-scoreboard li {
  display: grid;
  grid-template-columns: 1.1rem 1fr auto auto;
  align-items: center;
  gap: 0.35rem 0.5rem;
  font-size: 0.86rem;
  line-height: 1.2;
}
.host-scoreboard li.is-offline { opacity: 0.45; }
.host-scoreboard .hs-rank {
  font-family: var(--font-display);
  color: var(--muted);
  font-size: 0.95rem;
}
.host-scoreboard .hs-pseudo {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.host-scoreboard .hs-theme {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}
.host-scoreboard .hs-total {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--accent);
  text-align: right;
  white-space: nowrap;
}
.host-scoreboard .hs-total small {
  font-family: var(--font-body);
  font-size: 0.65rem;
  color: var(--muted);
  margin-left: 0.15rem;
}
@media (max-width: 640px) {
  .host-top { flex-wrap: wrap; }
  .host-score-recap { flex: 1 1 100%; max-height: 6.5rem; }
}
