:root {
  --ink: #14080c;
  --pit: #1c0b10;
  --gold: #e2b45a;
  --gold-deep: #8d6420;
  --paper: #f3e7cf;
  --oxblood: #6e2430;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--pit);
  color: var(--paper);
  font-family: Didot, "Bodoni MT", "Bodoni 72", "Times New Roman", serif;
}

button, input { font: inherit; }

#lobby {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 1.25rem 3.5rem;
  padding: 3.2rem 4.2rem 2.6rem;
  background:
    radial-gradient(ellipse at 20% 0%, #4a1822 0%, transparent 46%),
    var(--pit);
}

.mast h1 {
  margin: 0;
  font-weight: 500;
  font-size: clamp(4.2rem, 7vw, 7.4rem);
  line-height: 0.86;
  color: var(--gold);
  letter-spacing: -0.03em;
}

.deck {
  margin: 0.8rem 0 0;
  max-width: 16em;
  font-size: 1.45rem;
  line-height: 1.25;
  color: var(--paper);
}

#seats {
  list-style: none;
  margin: 0;
  padding: 0;
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.seat {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 72px;
  border-bottom: 1px solid rgba(226, 180, 90, 0.28);
}

.seat img {
  width: 62px;
  height: auto;
  background: transparent;
}

.seat .who {
  font-size: clamp(1.45rem, 2.4vw, 2.2rem);
  line-height: 1;
  color: var(--paper);
}

.seat .state {
  color: var(--gold);
  font-size: 1.35rem;
}

.seat.empty {
  grid-template-columns: 1fr;
  min-height: 44px;
}

.seat.empty .who {
  color: rgba(243, 231, 207, 0.38);
}

.launch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.2rem;
}

.start {
  appearance: none;
  border: 0;
  background: var(--gold);
  color: var(--ink);
  padding: 0.9rem 1.7rem;
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
}

.start:disabled {
  background: transparent;
  color: rgba(226, 180, 90, 0.5);
  box-shadow: inset 0 0 0 1px rgba(226, 180, 90, 0.4);
  cursor: not-allowed;
}

.start:focus-visible,
button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

#host-error {
  margin: 0;
  color: #ffb4b0;
  font-size: 1.15rem;
}

.ticket {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: center;
  justify-self: end;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#qr {
  width: min(280px, 28vw);
  height: auto;
  background: #f4ecd8;
  padding: 0.7rem;
}

.code {
  margin: 0.55rem 0 0;
  font-size: clamp(3.2rem, 5vw, 4.6rem);
  letter-spacing: 0.14em;
  line-height: 1;
  color: var(--gold);
}

.url {
  margin: 0.35rem 0 0;
  max-width: 16rem;
  text-align: center;
  color: rgba(243, 231, 207, 0.72);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.85rem;
  line-height: 1.3;
  word-break: break-all;
}

#fullscreen {
  position: fixed;
  top: 0.7rem;
  left: 0.85rem;
  z-index: 7;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0.42rem;
  display: grid;
  place-items: center;
  appearance: none;
  border: 0;
  background: rgba(20, 8, 12, 0.72);
  color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(226, 180, 90, 0.75);
  cursor: pointer;
}

#fullscreen svg {
  width: 100%;
  height: 100%;
  display: block;
}

#fullscreen .exit { display: none; }

#fullscreen.is-on .enter { display: none; }
#fullscreen.is-on .exit { display: block; }

#fullscreen:hover {
  color: var(--paper);
  box-shadow: inset 0 0 0 1px var(--paper);
}

#next {
  position: fixed;
  top: 0.7rem;
  left: 3.8rem;
  z-index: 6;
  appearance: none;
  border: 0;
  background: var(--gold);
  color: var(--ink);
  font-family: Didot, "Bodoni MT", "Bodoni 72", "Times New Roman", serif;
  font-size: 1.35rem;
  line-height: 1;
  padding: 0.6rem 0.95rem;
  cursor: pointer;
}

#next:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

#stop {
  position: fixed;
  top: 0.7rem;
  right: 0.85rem;
  z-index: 6;
  appearance: none;
  border: 0;
  background: rgba(20, 8, 12, 0.72);
  color: #fff;
  font-family: Didot, "Bodoni MT", "Bodoni 72", "Times New Roman", serif;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.55rem 0.85rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

#stop:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

#board {
  position: relative;
  height: 100%;
  background: var(--ink);
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
}

#overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.15rem 1.1rem 1rem;
  pointer-events: none;
}

.top { display: flex; flex-direction: column; align-items: center; }

#round {
  margin: 0;
  min-height: 1.2em;
  color: rgba(255, 248, 238, 0.78);
  font-size: 1.2rem;
}

#correct {
  margin: 0.35rem 0 0;
  color: var(--gold);
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(1.1rem, 1.8vw, 1.7rem);
  line-height: 1.1;
  text-align: center;
  text-shadow: 0 2px 0 #000, 0 6px 12px rgba(0, 0, 0, 0.85);
}

#question {
  margin: 0.15rem auto 0;
  max-width: 18em;
  text-align: center;
  color: #fff;
  font-family: "Arial Black", "Arial Bold", Impact, sans-serif;
  font-weight: 900;
  font-size: clamp(1.55rem, 2.8vw, 3.15rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  text-wrap: balance;
  text-shadow:
    0 2px 0 #000,
    0 8px 18px rgba(0, 0, 0, 0.9);
}

#timer {
  margin: 0.25rem 0 0.15rem;
  min-height: 1.15em;
  color: #fff;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(1.35rem, 2vw, 2rem);
  text-shadow: 0 2px 0 #000;
}

.four {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(var(--seats, 4), minmax(0, 1fr));
  gap: 0.4rem;
}

.head-col, .pick {
  text-align: center;
  min-width: 0;
}

.name {
  margin: 0;
  color: #fff;
  font-family: "Arial Black", "Arial Bold", Impact, sans-serif;
  font-weight: 900;
  font-size: clamp(0.95rem, calc(11vw / var(--seats, 4)), 2.7rem);
  line-height: 1.02;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow:
    0 3px 0 #000,
    0 8px 16px rgba(0, 0, 0, 0.88);
}

.score {
  margin: 0.12rem 0 0;
  color: #fff;
  font-size: clamp(1.45rem, 2.3vw, 2.5rem);
  line-height: 1;
  text-shadow: 0 2px 0 #000, 0 6px 12px rgba(0, 0, 0, 0.8);
}

.score.hot { color: var(--gold); }

.status {
  margin: 0.15rem 0 0;
  min-height: 1.1em;
  color: var(--gold);
  font-size: 1.05rem;
  text-shadow: 0 2px 0 #000;
}

.floater {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.3rem;
  margin: 0.15rem 0 0;
  color: #f2d48a;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 1.25rem;
  text-shadow: 0 2px 0 #000;
  animation: float-up 1.35s ease forwards;
}

.floater img {
  width: 1.35rem;
  height: 1.35rem;
}

.pick {
  margin: 0;
  min-height: 1.35em;
  align-self: end;
  color: #fff;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(0.95rem, 1.5vw, 1.55rem);
  line-height: 1.05;
  text-shadow: 0 2px 0 #000, 0 6px 12px #000;
}

.pick.hit { color: var(--gold); }

.pick.wrong { opacity: 0.62; }

.pick.miss {
  font-family: Didot, "Bodoni MT", "Times New Roman", serif;
  opacity: 0.62;
}

#answers {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  width: min(1080px, 94%);
  min-height: 0;
  margin: 0.35rem auto 0;
}

.answer-tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 0.7rem 0.8rem 0.55rem;
  border-radius: 1.15rem;
  background: rgba(16, 6, 8, 0.62);
  box-shadow: inset 0 0 0 2px rgba(255, 248, 238, 0.2);
  transition: box-shadow 0.35s ease, background 0.35s ease, opacity 0.35s ease;
}

.answer-tile.right {
  background: rgba(226, 180, 90, 0.28);
  box-shadow:
    inset 0 0 0 3px var(--gold),
    0 0 28px rgba(226, 180, 90, 0.6);
}

.answer-tile.dim { opacity: 0.42; }

.answer-label {
  margin: 0;
  text-align: center;
  color: #fff;
  font-family: "Arial Black", "Arial Bold", Impact, sans-serif;
  font-weight: 900;
  font-size: clamp(1.2rem, 2.15vw, 2.15rem);
  line-height: 1.05;
  text-wrap: balance;
  text-shadow: 0 2px 0 #000, 0 6px 14px rgba(0, 0, 0, 0.88);
}

.card-stack {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 0;
  padding-top: 0.35rem;
}

.answer-card {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  max-width: calc(100% / var(--count, 1));
  margin: 0 -0.25rem;
  flex: 0 1 auto;
}

.answer-card .face {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.5));
}

.answer-card .coin {
  position: absolute;
  right: 6%;
  bottom: 14%;
  width: 32%;
  height: auto;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.55));
}

.answer-card.bounce {
  animation: card-bounce 0.72s cubic-bezier(0.22, 0.85, 0.28, 1) both;
}

@keyframes card-bounce {
  0% { transform: translateY(-48vh) scale(0.86); opacity: 0; }
  62% { transform: translateY(10px) scale(1.04); opacity: 1; }
  82% { transform: translateY(-5px) scale(0.99); }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

#veil {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 0;
  top: 18%;
  display: grid;
  place-items: center;
  background: linear-gradient(to bottom, rgba(20, 8, 12, 0) 0%, rgba(20, 8, 12, 0.9) 16%);
}

#veil.finale {
  top: 0;
  background: rgba(16, 6, 8, 0.78);
}

.sheet {
  width: min(760px, 88vw);
}

.rank {
  display: grid;
  grid-template-columns: 4.2rem 64px minmax(0, 1fr) auto;
  gap: 0.9rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(226, 180, 90, 0.32);
}

.rank img {
  width: 64px;
  height: auto;
  background: transparent;
}

.place {
  margin: 0;
  color: var(--gold);
  font-size: 1.7rem;
}

.person {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.points {
  margin: 0;
  color: #fff;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 1.7rem;
}

.crown {
  text-align: center;
}

.faces {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.faces img {
  width: min(180px, 22vw);
  height: auto;
  background: transparent;
}

.crown h2 {
  margin: 0.35rem 0 0;
  color: var(--gold);
  font-weight: 500;
  font-size: clamp(3.4rem, 7vw, 6.4rem);
  line-height: 0.9;
}

.crown p {
  margin: 0.4rem 0 0;
  color: #fff;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(1.4rem, 2vw, 2rem);
  text-shadow: 0 2px 0 #000;
}

@keyframes float-up {
  0% { opacity: 0; transform: translateY(8px); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-28px); }
}

@media (prefers-reduced-motion: reduce) {
  .floater { animation: none; opacity: 1; }
  .answer-card.bounce { animation: none; }
  .answer-tile { transition: none; }
}

@media (max-width: 860px) {
  #lobby {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    overflow: auto;
    padding: 1.4rem;
  }

  .ticket {
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
  }

  html, body { overflow: auto; }
}
