:root {
  color-scheme: dark;
  --bg: #101617;
  --panel: #172022;
  --panel-2: #1f2a2d;
  --text: #f7fbf8;
  --muted: #aab7b4;
  --line: #2c393b;
  --green: #1fbf75;
  --cyan: #00a7c7;
  --gold: #f2b84b;
  --red: #f16d5f;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 28rem),
    radial-gradient(circle at 18% 8%, rgba(31, 191, 117, 0.15), transparent 24rem),
    #101617;
}

html,
body {
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: var(--radius);
  color: #07100d;
  background: var(--green);
  min-height: 44px;
  padding: 0 18px;
  font-weight: 800;
  cursor: pointer;
}

button.secondary {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

button.gold {
  background: var(--gold);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #0d1213;
  padding: 0 12px;
}

.shell {
  min-height: 100dvh;
  padding: clamp(10px, 2vw, 24px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.logo {
  width: min(260px, 50vw);
  height: auto;
}

.compact-logo {
  width: min(230px, 32vw);
}

.room-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 130px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  color: var(--gold);
  font-size: clamp(26px, 4vw, 44px);
  font-weight: 900;
  letter-spacing: 0;
}

.grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.4fr);
  gap: 14px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 32, 34, 0.88);
  padding: 14px;
}

.panel h1,
.panel h2,
.panel h3,
.question h1 {
  margin: 0;
  letter-spacing: 0;
}

.panel h1 {
  font-size: clamp(30px, 4.2vw, 54px);
  line-height: 1.02;
}

.panel h2 {
  font-size: 19px;
}

.muted {
  color: var(--muted);
}

.qr {
  width: min(250px, 100%);
  aspect-ratio: 1;
  background: #fff;
  border-radius: var(--radius);
  padding: 12px;
  margin: 10px auto;
}

.qr img {
  width: 100%;
  height: 100%;
  display: block;
}

.join-url {
  color: var(--muted);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.settings label,
.join-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.players {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.player-row,
.score-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  padding: 9px 11px;
}

.score-row:first-child {
  border-color: rgba(242, 184, 75, 0.65);
  background: rgba(242, 184, 75, 0.1);
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 99px;
  margin-right: 8px;
  background: var(--green);
}

.status-dot.off {
  background: var(--red);
}

.question {
  display: grid;
  gap: 10px;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(255, 255, 255, 0.04);
}

.question h1 {
  font-size: clamp(26px, 4.4vw, 58px);
  line-height: 1.02;
}

.translation {
  color: #cdd7d4;
  font-size: clamp(16px, 2vw, 24px);
  line-height: 1.18;
  margin: 6px 0;
}

.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.option {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.045);
  padding: 12px;
  min-height: 86px;
}

.option.correct {
  border-color: rgba(31, 191, 117, 0.9);
  background: rgba(31, 191, 117, 0.18);
}

.option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  margin-bottom: 7px;
  color: #07100d;
  background: var(--gold);
  font-weight: 900;
}

.option-main {
  font-size: clamp(18px, 2.4vw, 30px);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.option-sub {
  margin-top: 5px;
  color: var(--muted);
  font-size: clamp(13px, 1.6vw, 18px);
  overflow-wrap: anywhere;
}

.answer-grid {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.answer-grid button {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 60px;
  text-align: left;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.answer-grid button.selected {
  border-color: var(--gold);
  background: rgba(242, 184, 75, 0.14);
}

.mobile {
  max-width: 620px;
  margin: 0 auto;
  padding: 10px;
}

.join-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.big-state {
  min-height: 62vh;
  display: grid;
  place-items: center;
  text-align: center;
}

.tv-shell,
.mobile {
  overflow: hidden;
}

.compact-topbar {
  margin-bottom: 8px;
}

.tv-lobby,
.tv-game {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(260px, 0.32fr);
  gap: 14px;
  height: calc(100dvh - 140px);
  min-height: 0;
  overflow: hidden;
}

.tv-lobby {
  align-items: center;
}

.tv-lobby h1,
.final-screen h1 {
  margin: 0;
  font-size: clamp(48px, 8vw, 104px);
  line-height: 0.95;
  letter-spacing: 0;
}

.tv-qr {
  width: min(34vh, 290px);
  margin-left: 0;
}

.compact-question {
  min-height: 0;
  align-content: start;
  overflow: hidden;
}

.compact-question .question-meta {
  font-size: clamp(10px, 1.1vw, 13px);
}

.compact-question h1 {
  font-size: clamp(24px, 3.5vw, 46px);
}

.compact-question .translation {
  font-size: clamp(14px, 1.7vw, 20px);
}

.compact-question .option {
  min-height: 70px;
  padding: 9px;
}

.compact-question .option-letter {
  width: 28px;
  height: 28px;
  margin-bottom: 5px;
}

.compact-question .option-main {
  font-size: clamp(16px, 2vw, 24px);
}

.compact-question .option-sub {
  font-size: clamp(12px, 1.35vw, 16px);
}

.side-score {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 32, 34, 0.88);
  padding: 12px;
  min-height: 0;
}

.side-score h2 {
  margin: 12px 0 0;
}

.compact-list {
  max-height: calc(100dvh - 230px);
  overflow: hidden;
}

.round-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  padding: 10px;
}

.round-status > div:not(.timer-bar) {
  display: grid;
  gap: 2px;
}

.countdown {
  color: var(--gold);
  font-size: clamp(26px, 4vw, 46px);
  font-weight: 900;
  line-height: 1;
}

.timer-bar {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.timer-bar span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.final-screen {
  height: calc(100dvh - 120px);
  display: grid;
  grid-template-columns: 0.65fr 1fr;
  gap: 22px;
  align-items: center;
}

.final-list .score-row {
  min-height: 54px;
  font-size: clamp(18px, 2.4vw, 30px);
}

.intermission {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(8, 12, 12, 0.86);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.intermission.show {
  opacity: 1;
}

.intermission img {
  width: min(620px, 82vw);
  filter: drop-shadow(0 24px 50px rgba(0, 0, 0, 0.45));
  animation: pop 820ms ease both;
}

@keyframes pop {
  0% {
    transform: scale(0.86);
  }
  55% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 860px) {
  html,
  body {
    overflow: hidden;
  }

  .shell {
    padding: 10px;
  }

  .topbar {
    align-items: flex-start;
    margin-bottom: 8px;
  }

  .grid,
  .options,
  .settings,
  .tv-lobby,
  .tv-game,
  .final-screen {
    grid-template-columns: 1fr;
  }

  .panel h1 {
    font-size: 28px;
  }

  .question h1 {
    font-size: clamp(20px, 6.2vw, 32px);
  }

  .translation {
    font-size: clamp(13px, 3.6vw, 18px);
  }

  .panel {
    padding: 10px;
  }

  .mobile .logo {
    width: min(210px, 58vw);
  }

  .mobile .question-meta {
    gap: 5px;
    font-size: 10px;
  }

  .mobile .pill {
    padding: 4px 7px;
  }

  .mobile .options {
    gap: 7px;
  }

  .mobile .option {
    min-height: 62px;
    padding: 8px;
  }

  .mobile .option-letter {
    width: 28px;
    height: 28px;
    margin-bottom: 4px;
  }

  .mobile .option-main {
    font-size: 17px;
  }

  .mobile .option-sub {
    font-size: 12px;
  }

  .answer-grid button {
    min-height: 50px;
    grid-template-columns: 34px 1fr;
    padding: 6px 10px;
  }

  .round-status {
    padding: 8px;
  }

  .countdown {
    font-size: 28px;
  }
}
