:root {
  --navy: #07111f;
  --navy-2: #0c1a30;
  --navy-3: #132544;
  --navy-4: #1a3260;
  --gold: #e0b44b;
  --gold-2: #f0cd74;
  --gold-dark: #9a6f1c;
  --gold-ink: #1a1406;
  --cream: #f3e6c4;
  --cream-dim: #c9b896;
  --red: #d61f2c;
  --red-dark: #8e121c;
  --line: #2a3f66;
  --white: #f7f1e3;
  --pad: 14px;
  --radius: 4px;
  --font-display: "Bebas Neue", "Arial Narrow", sans-serif;
  --font-ui: "Atkinson Hyperlegible", "Segoe UI", sans-serif;
}

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

html, body {
  background: var(--navy);
  color: var(--cream);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.3;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

button, input {
  font: inherit;
  color: inherit;
  appearance: none;
  border: 0;
  background: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button { cursor: pointer; }

input[type="text"] {
  font-size: 16px;
  background: var(--navy-3);
  border: 1px solid var(--line);
  color: var(--white);
  border-radius: var(--radius);
  padding: 10px 12px;
  width: 100%;
  min-height: 44px;
}

input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.app {
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  height: calc(100dvh - env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top {
  flex-shrink: 0;
  padding: 8px var(--pad) 6px;
  border-bottom: 2px solid var(--gold-dark);
  background: var(--navy-2);
}

.scores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: end;
}

.score { min-width: 0; }
.score.right { text-align: right; }

.score-name {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--cream-dim);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-pts {
  font-family: var(--font-display);
  font-size: 48px;
  line-height: 0.85;
  color: var(--white);
}

.round-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}

.round-meta {
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  font-size: 15px;
  color: var(--cream-dim);
}

.badge {
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  font-size: 14px;
  color: var(--gold-ink);
  background: var(--gold);
  padding: 2px 7px;
  margin-left: 6px;
}

.up {
  font-size: 13px;
  color: var(--cream-dim);
  padding: 6px var(--pad) 0;
  flex-shrink: 0;
}

.main {
  flex: 1;
  min-height: 0;
  padding: 8px var(--pad) 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.question {
  font-size: 22px;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.answers {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.answer {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--navy-3);
  border: 2px solid var(--gold-dark);
  border-radius: var(--radius);
  padding: 0 8px;
  min-height: 0;
  height: 100%;
  max-height: 52px;
  color: var(--cream);
  flex: 1;
}

.answer-num {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--gold);
  line-height: 1;
}

.answer-text {
  font-size: 14px;
  color: var(--cream-dim);
  line-height: 1.15;
  min-width: 0;
}

.answer-pts {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--gold-2);
  line-height: 1;
  opacity: 0.35;
}

.answer.revealed {
  background: var(--gold);
  border-color: var(--gold-2);
}

.answer.revealed .answer-num,
.answer.revealed .answer-text,
.answer.revealed .answer-pts {
  color: var(--gold-ink);
  opacity: 1;
}

.answer.revealed .answer-text {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.03em;
  line-height: 1;
}

.bottom {
  flex-shrink: 0;
  padding: 8px var(--pad) calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--navy);
  border-top: 1px solid var(--navy-4);
}

.x-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: stretch;
}

.btn-x {
  min-height: 52px;
  background: var(--red);
  color: var(--white);
  border: 2px solid #f04a55;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.08em;
  box-shadow: 0 2px 0 rgba(0,0,0,0.35);
}

.btn-x:active { transform: translateY(1px); box-shadow: none; }

.x-marks {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 0 6px;
  min-width: 96px;
  justify-content: center;
}

.x-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 2px solid var(--red-dark);
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1;
  color: transparent;
  background: var(--navy-2);
}

.x-mark.on {
  background: var(--red);
  border-color: var(--red);
  color: var(--white);
}

.win-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-win {
  min-height: 56px;
  padding: 4px 8px;
  background: var(--gold);
  color: var(--gold-ink);
  border: 2px solid var(--gold-2);
  border-radius: var(--radius);
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  line-height: 1.05;
  box-shadow: 0 2px 0 rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.btn-win:active { transform: translateY(1px); box-shadow: none; }

.btn-win .who { font-size: 16px; }
.btn-win .amt { font-size: 26px; }

.links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.links button, .links a {
  font-size: 13px;
  color: var(--cream-dim);
  text-decoration: none;
  padding: 6px 0;
  background: none;
  border: 0;
  box-shadow: none;
  font-family: var(--font-ui);
  letter-spacing: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.82);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.overlay.hidden { display: none; }

.sheet {
  background: var(--navy-2);
  border: 2px solid var(--gold-dark);
  width: min(100%, 360px);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet h2 {
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  font-size: 22px;
  color: var(--gold);
  margin-bottom: 4px;
}

.sheet label {
  display: block;
  font-size: 13px;
  color: var(--cream-dim);
  margin: 6px 0 4px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  width: 100%;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.08em;
  border: 2px solid transparent;
  box-shadow: 0 2px 0 rgba(0,0,0,0.35);
}

.btn-gold { background: var(--gold); color: var(--gold-ink); border-color: var(--gold-2); }
.btn-navy { background: var(--navy-3); color: var(--cream); border-color: var(--line); }
.btn-red { background: var(--red); color: var(--white); border-color: #f04a55; }

.winner {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px var(--pad);
  text-align: center;
}

.winner h1 {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.12em;
  color: var(--gold);
}

.winner-name {
  font-family: var(--font-display);
  font-size: 64px;
  line-height: 0.9;
  color: var(--white);
  margin: 8px 0 18px;
}

.final-scores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.final-scores div { background: var(--navy-3); padding: 12px 8px; }
.final-scores .t {
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  color: var(--cream-dim);
  font-size: 14px;
}
.final-scores .p {
  font-family: var(--font-display);
  font-size: 44px;
  line-height: 1;
  color: var(--gold);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  background: var(--gold);
  color: var(--gold-ink);
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  font-size: 20px;
  padding: 12px 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 28px);
  box-shadow: 0 4px 0 rgba(0,0,0,0.4);
}

.toast button {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.08em;
  color: var(--gold-ink);
  border: 2px solid var(--gold-ink);
  padding: 4px 10px;
  border-radius: var(--radius);
  min-height: 36px;
}

.toast.hidden { display: none; }

@media (max-height: 700px) {
  .score-pts { font-size: 40px; }
  .question { font-size: 19px; margin-bottom: 6px; }
  .btn-x { min-height: 46px; font-size: 22px; }
  .btn-win { min-height: 50px; }
  .btn-win .amt { font-size: 22px; }
}

@media (max-width: 360px) {
  .score-pts { font-size: 36px; }
  .question { font-size: 18px; }
}
