:root {
  --paper: #fbf5e9;
  --card: #ffffff;
  --ink: #1c2b33;
  --muted: #5d6b72;
  --line: #e4dac6;
  --brass: #e0a526;
  --brass-deep: #8a5a00;
  --good: #2e7d4f;
  --bad: #b23a22;
  --tile-a: #1f4e5f;
  --tile-b: #b8401f;
  --tile-c: #8a5a00;
  --tile-d: #2e7d4f;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
}

h1, h2, h3, p { margin: 0; }

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

button:disabled { cursor: not-allowed; opacity: .55; }

:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: .3em;
  font-weight: 800;
  letter-spacing: -.02em;
  font-size: 1.4rem;
  color: var(--ink);
  text-decoration: none;
}

.wordmark img { width: 1.05em; height: 1.05em; }

.page { max-width: 860px; margin: 0 auto; padding: 20px 16px 96px; display: grid; gap: 20px; }

.narrow { max-width: 420px; }

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  gap: 14px;
}

.card h2 { font-size: 1.15rem; }

.hint { color: var(--muted); font-size: .92rem; }

.field { display: grid; gap: 5px; font-weight: 600; font-size: .92rem; min-width: 0; }

input[type="text"], input[type="password"], input[type="number"], input:not([type]), select {
  width: 100%;
  background: #fff;
  border: 1px solid #c9bfa9;
  border-radius: 9px;
  padding: 10px 12px;
  font-weight: 400;
  font-size: 1rem;
  min-width: 0;
}

.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }

.row > .grow { flex: 1 1 200px; }

.btn {
  background: #fff;
  border: 1px solid #c9bfa9;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
}

.btn:hover:not(:disabled) { background: #f6efe0; }

.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }

.btn.primary:hover:not(:disabled) { background: #2d4350; }

.btn.big { padding: 15px 28px; font-size: 1.15rem; border-radius: 12px; }

.btn.link { background: none; border: none; padding: 4px 6px; color: var(--muted); font-weight: 500; text-decoration: underline; }

.error { color: var(--bad); font-weight: 600; }

.error:empty { display: none; }

.banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bad);
  color: #fff;
  padding: 6px 12px;
  text-align: center;
  font-weight: 600;
  z-index: 10;
}

.banner[hidden] { display: none; }

/* Quiz editor */

.q-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 10px; background: #fffdf8; }

.q-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 700; }

.q-tools { display: flex; align-items: center; gap: 8px; font-weight: 400; }

.q-tools select { width: auto; padding: 5px 8px; font-size: .9rem; }

.opt-row { display: flex; align-items: center; gap: 8px; }

.opt-row input[type="radio"] { width: 22px; height: 22px; flex: none; accent-color: var(--good); margin: 0; }

.opt-row .btn.link { flex: none; }

.sticky-action {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(251, 245, 233, .96);
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* Live screens */

.stage { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: clamp(14px, 2.4vw, 32px); gap: clamp(12px, 2vw, 24px); }

.stage-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-weight: 600; }

.stage-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: clamp(14px, 2.4vw, 30px); min-height: 0; }

.stage-foot { display: flex; justify-content: flex-end; align-items: center; gap: 14px; flex-wrap: wrap; }

.lobby { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: clamp(16px, 4vw, 56px); align-items: center; }

.join-url { font-size: clamp(1rem, 2vw, 1.5rem); font-weight: 600; overflow-wrap: anywhere; }

.pin { font-size: clamp(3.5rem, 12vw, 9rem); font-weight: 800; letter-spacing: .04em; line-height: 1.05; font-variant-numeric: tabular-nums; }

.qr { width: clamp(150px, 24vw, 300px); background: #fff; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); }

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

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 600; }

button.chip:hover { border-color: var(--bad); color: var(--bad); text-decoration: line-through; }

.chip.away { opacity: .5; }

.question-text { font-size: clamp(1.5rem, 4.2vw, 3.4rem); line-height: 1.15; font-weight: 800; letter-spacing: -.015em; text-align: center; overflow-wrap: anywhere; }

.timer-track { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; }

.timer-bar { height: 100%; background: var(--brass); transform-origin: left; transition: transform .1s linear; }

.status-line { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; font-size: clamp(1.05rem, 2.2vw, 1.7rem); font-variant-numeric: tabular-nums; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(8px, 1.4vw, 16px); }

.tile {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.5vw, 18px);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  padding: clamp(12px, 2vw, 26px);
  text-align: left;
  font-weight: 700;
  font-size: clamp(1.02rem, 2.4vw, 1.9rem);
  line-height: 1.2;
  min-height: clamp(76px, 13vh, 170px);
  overflow-wrap: anywhere;
  position: relative;
  transition: opacity .2s, transform .08s;
}

button.tile:active:not(:disabled) { transform: scale(.98); }

button.tile:disabled { opacity: 1; cursor: default; }

.tile .letter {
  flex: none;
  width: 1.9em;
  height: 1.9em;
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  display: grid;
  place-items: center;
  font-size: .86em;
}

.tile .tile-text { flex: 1; min-width: 0; }

.tile .count { flex: none; font-variant-numeric: tabular-nums; }

.tile-0 { background: var(--tile-a); }
.tile-1 { background: var(--tile-b); }
.tile-2 { background: var(--tile-c); }
.tile-3 { background: var(--tile-d); }

.tile.dim { background: #e7dfcf; color: #47555c; }

.tile.dim .letter { background: rgba(28, 43, 51, .1); }

.tile.right { outline: 5px solid var(--ink); outline-offset: 3px; }

.tile.mine { outline: 4px solid var(--brass); outline-offset: 3px; }

.tile .mark { flex: none; font-size: 1.2em; }

.board { display: grid; gap: 8px; width: min(760px, 100%); margin: 0 auto; }

.board-row {
  display: grid;
  grid-template-columns: 2.6em minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: clamp(10px, 1.5vw, 16px) clamp(12px, 2vw, 22px);
  font-size: clamp(1.05rem, 2.3vw, 1.75rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.board-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.board-row.first { background: var(--ink); border-color: var(--ink); color: #fff; }

.center { text-align: center; }

.title-lg { font-size: clamp(1.8rem, 5vw, 3.6rem); font-weight: 800; letter-spacing: -.02em; text-align: center; line-height: 1.1; }

.podium { display: flex; justify-content: center; align-items: flex-end; gap: clamp(6px, 1.5vw, 18px); }

.step { flex: 1 1 0; max-width: 260px; min-width: 0; display: grid; gap: 8px; text-align: center; }

.step .who { font-weight: 800; font-size: clamp(1rem, 2.6vw, 1.9rem); overflow-wrap: anywhere; line-height: 1.15; }

.step .pts { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }

.step .block {
  border-radius: 12px 12px 0 0;
  background: var(--tile-a);
  color: #fff;
  font-size: clamp(1.6rem, 5vw, 3.6rem);
  font-weight: 800;
  display: grid;
  place-items: center;
}

.step-1 .block { height: clamp(130px, 30vh, 280px); background: var(--brass); color: var(--ink); }
.step-2 .block { height: clamp(95px, 21vh, 200px); }
.step-3 .block { height: clamp(70px, 14vh, 140px); background: var(--tile-b); }

/* Player */

.player-stage { padding: 14px 12px; gap: 12px; }

.player-stage .tiles { flex: 1; grid-auto-rows: 1fr; }

.player-stage .tile { font-size: clamp(1.05rem, 5vw, 1.5rem); }

.player-stage .question-text { font-size: clamp(1.15rem, 5.4vw, 2rem); }

.player-bar { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }

.player-bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.message { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; text-align: center; padding: 16px; }

.message .big { font-size: clamp(2rem, 10vw, 3.4rem); font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }

.message .mid { font-size: 1.25rem; font-weight: 600; }

.message.good .big { color: var(--good); }

.message.bad .big { color: var(--bad); }

.correct-was { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; font-weight: 600; overflow-wrap: anywhere; }

.pin-input { font-size: 1.8rem !important; text-align: center; letter-spacing: .12em; font-weight: 700 !important; font-variant-numeric: tabular-nums; }

.home { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; }

.home-title { font-size: clamp(2.8rem, 15vw, 4.6rem); font-weight: 800; letter-spacing: -.03em; line-height: 1; display: flex; align-items: center; justify-content: center; gap: .15em; }

.home-title img { width: .9em; height: .9em; }

@media (max-width: 640px) {
  .lobby { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .stage-foot { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
