:root {
  --bg: #f3ecdf;
  --ink: #1c1917;
  --muted: #57534e;
  --line: #d6cbb8;
  --card: #fffaf3;
  --left: #1d4e89;
  --left-soft: #d7e5f6;
  --right: #c45c12;
  --right-soft: #fde4d0;
  --rope: #6b3f24;
  --ok: #146c43;
  --ok-soft: #e5f6ee;
  --bad: #9a3412;
  --bad-soft: #fff1e6;
  --shadow: 0 10px 30px rgba(60, 40, 20, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "PT Sans", sans-serif;
}

button, input { font: inherit; }

button {
  cursor: pointer;
  border: 3px solid transparent;
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
}

button:focus-visible, input:focus-visible {
  outline: 4px solid #111827;
  outline-offset: 2px;
}

#app { min-height: 100%; }

.setup {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 28px 32px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.05;
}

.hero p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 20px;
}

.langs {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.langs button {
  min-height: 56px;
  padding: 0 18px;
  font-size: 20px;
  font-weight: 700;
  background: var(--card);
}

.langs button.selected { border-color: var(--ink); }

.panel {
  margin-top: 22px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 18px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.topics {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.rounds-box { max-width: 920px; }

.rounds-value {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 700;
}

.rounds-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 56px;
  margin: 0;
  background: transparent;
  border: 0;
}

.rounds-slider:focus-visible { outline-offset: 6px; }

.rounds-slider::-webkit-slider-runnable-track {
  height: 14px;
  border-radius: 999px;
  background: var(--line);
}

.rounds-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 56px;
  height: 56px;
  margin-top: -21px;
  border-radius: 50%;
  border: 4px solid white;
  background: var(--ink);
  cursor: pointer;
}

.rounds-slider::-moz-range-track {
  height: 14px;
  border-radius: 999px;
  background: var(--line);
  border: 0;
}

.rounds-slider::-moz-range-thumb {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid white;
  background: var(--ink);
  cursor: pointer;
}

.tick-row {
  position: relative;
  height: 64px;
}

.tick {
  position: absolute;
  top: 0;
  left: calc(28px + (100% - 56px) * var(--i));
  transform: translateX(-50%);
  min-width: 56px;
  min-height: 56px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  font-weight: 700;
}

.tick::before {
  content: "";
  display: block;
  width: 3px;
  height: 12px;
  margin: 0 auto 4px;
  border-radius: 2px;
  background: var(--line);
}

.tick.on { color: var(--ink); }
.tick.on::before { height: 16px; background: var(--ink); }

.choice {
  min-height: 80px;
  padding: 12px 14px;
  text-align: left;
  box-shadow: var(--shadow);
}

.choice small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 15px;
}

.choice.selected {
  border-color: var(--ink);
  background: #fff;
}

.teams {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 22px;
}

.team {
  background: var(--card);
  border-radius: 22px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.team.left { border-top: 8px solid var(--left); }
.team.right { border-top: 8px solid var(--right); }

.team-name {
  min-height: 64px;
  width: 100%;
  margin-bottom: 12px;
  font-size: 28px;
  font-weight: 700;
  background: transparent;
}

.team.left .team-name { color: var(--left); }
.team.right .team-name { color: var(--right); }

.roster {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.player {
  min-height: 72px;
  font-size: 22px;
  font-weight: 700;
  background: var(--bg);
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 22px;
}

.start, .again, .next {
  min-height: 84px;
  padding: 0 28px;
  background: var(--ink);
  color: white;
  font-size: 28px;
  font-weight: 700;
}

.ghost {
  min-height: 84px;
  padding: 0 18px;
  background: transparent;
  border-color: var(--line);
  font-size: 20px;
}

.stock {
  margin-left: auto;
  color: var(--muted);
  font-size: 18px;
  text-align: right;
}

.match {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 12px 16px 14px;
  gap: 10px;
}

.rope-wrap {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 220px;
  gap: 12px;
  align-items: center;
}

.side-label { min-width: 0; }
.side-label strong {
  display: block;
  font-size: 26px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-label span { color: var(--muted); font-size: 18px; }
.side-label.left strong { color: var(--left); }
.side-label.right strong { color: var(--right); text-align: right; }
.side-label.right span { display: block; text-align: right; }

.rope {
  position: relative;
  height: 74px;
}

.track {
  position: absolute;
  left: 28px;
  right: 28px;
  top: 30px;
  height: 14px;
  border-radius: 999px;
  background:
    repeating-linear-gradient(90deg, #8a5a32 0 10px, #6b3f24 10px 18px);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25);
}

.flag {
  position: absolute;
  top: 8px;
  width: 0;
  height: 0;
  border-top: 16px solid transparent;
  border-bottom: 16px solid transparent;
}

.flag::after {
  content: "";
  position: absolute;
  top: -18px;
  width: 4px;
  height: 58px;
  background: #44403c;
}

.flag.left {
  left: 8px;
  border-left: 22px solid var(--left);
}
.flag.left::after { left: -2px; }

.flag.right {
  right: 8px;
  border-right: 22px solid var(--right);
}
.flag.right::after { right: -2px; }

.knot {
  position: absolute;
  top: -14px;
  width: 42px;
  height: 42px;
  margin-left: -21px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, #fff, #f3e6cf 40%, #d8b98a 72%, #6b3f24 100%);
  border: 4px solid #3f2a1d;
}

.stop {
  min-height: 48px;
  margin-top: 6px;
  padding: 0 16px;
  font-size: 16px;
}

.need {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  color: var(--muted);
  margin-top: -6px;
}

.boards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 0;
}

.board {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
  border-radius: 22px;
  background: var(--card);
}

.board.left { box-shadow: inset 0 0 0 4px var(--left-soft); }
.board.right { box-shadow: inset 0 0 0 4px var(--right-soft); }

.goal {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.qwrap {
  min-height: 0;
  overflow: auto;
}

.qtext {
  margin: 0;
  font-size: clamp(22px, 2.1vw, 32px);
  line-height: 1.25;
}

.chart {
  width: min(100%, 460px);
  height: 150px;
  display: block;
  margin-top: 12px;
}

.chart line, .chart polyline {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart text {
  font-size: 12px;
  fill: var(--muted);
}

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.answer {
  min-height: 80px;
  padding: 10px 12px;
  font-size: 20px;
  text-align: left;
  background: var(--bg);
}

.answer:disabled { cursor: default; }

.answer.picked-ok, .answer.reveal-ok {
  background: var(--ok-soft);
  border-color: var(--ok);
}

.answer.picked-bad {
  background: var(--bad-soft);
  border-color: var(--bad);
}

.explain {
  margin: 0;
  min-height: 48px;
  font-size: 18px;
  line-height: 1.3;
}

.footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}

.queue {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  min-width: 42px;
  min-height: 42px;
  padding: 4px 8px;
  border-radius: 999px;
  background: white;
  border: 2px solid var(--line);
  font-weight: 700;
}

.queue.left .chip.now { background: var(--left); color: white; border-color: var(--left); }
.queue.right .chip.now { background: var(--right); color: white; border-color: var(--right); }
.queue.right { justify-content: flex-end; }

.round-no {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
}

.result {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.result-card {
  width: min(1100px, 100%);
  background: var(--card);
  border-radius: 28px;
  padding: 28px 32px 32px;
  box-shadow: var(--shadow);
}

.result-card h1, .result-card .lead { text-align: center; }

.result-card h1 {
  margin: 0;
  font-size: clamp(36px, 5vw, 64px);
}

.result-card .lead { margin: 8px 0 0; font-size: 24px; color: var(--muted); }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 22px 0;
}

.stat-col {
  border-radius: 18px;
  padding: 14px 16px 16px;
  background: var(--bg);
}

.stat-col.left { box-shadow: inset 0 0 0 4px var(--left-soft); }
.stat-col.right { box-shadow: inset 0 0 0 4px var(--right-soft); }

.stat-col h2 { margin: 0; font-size: 28px; }
.stat-col.left h2 { color: var(--left); }
.stat-col.right h2 { color: var(--right); }

.stat-total { margin: 6px 0 12px; font-size: 22px; }

.stat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.stat-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 20px;
}

.ok-num { color: var(--ok); }
.bad-num { color: var(--bad); }

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
}

.dialog {
  width: min(560px, 100%);
  background: white;
  border-radius: 24px;
  padding: 22px;
}

.dialog h3 { margin: 0 0 12px; font-size: 28px; }

.name-input {
  width: 100%;
  min-height: 80px;
  border-radius: 16px;
  border: 3px solid var(--ink);
  padding: 0 16px;
  font-size: 32px;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.dialog-actions button { flex: 1; min-height: 80px; font-size: 22px; }

@media (max-width: 1100px) {
  .topics { grid-template-columns: 1fr 1fr; }
  .rope-wrap { grid-template-columns: 140px minmax(0, 1fr) 140px; }
  .side-label strong { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .knot { transition: none; }
}
