:root {
  --bg: oklch(0.105 0 0);
  --surface: oklch(0.165 0.006 70);
  --surface-2: oklch(0.215 0.012 70);
  --surface-3: oklch(0.275 0.016 70);
  --ink: oklch(0.955 0.004 80);
  --muted: oklch(0.745 0.014 75);
  --primary: oklch(0.635 0.135 70);
  --primary-strong: oklch(0.58 0.155 70);
  --accent: oklch(0.62 0.155 235);
  --line: oklch(0.32 0.012 70);
  --danger: oklch(0.59 0.18 28);
  --player-red: oklch(0.58 0.18 28);
  --player-blue: oklch(0.61 0.15 238);
  --success: oklch(0.66 0.13 145);
  --warning: oklch(0.72 0.14 85);
  --focus: oklch(0.78 0.14 82);
  --neutral: oklch(0.28 0.01 70);
  --gold: oklch(0.74 0.14 82);
  --color-bg-main: var(--bg);
  --color-bg-panel: var(--surface);
  --color-border-soft: var(--line);
  --color-text-main: var(--ink);
  --color-text-muted: var(--muted);
  --color-player-red: var(--player-red);
  --color-player-blue: var(--player-blue);
  --color-neutral: var(--neutral);
  --color-gold: var(--gold);
  --color-success: var(--success);
  --color-danger: var(--danger);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
}

.ui-icon,
.topic-icon,
.event-svg,
.territory-svg,
.emblem-icon,
.timer-icon,
.victory-icon,
.crown-icon {
  display: inline-block;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.ui-icon {
  width: 15px;
  height: 15px;
  margin-right: 6px;
  vertical-align: -2px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

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

.hidden {
  display: none !important;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px) 14px;
}

.app-header h1,
.setup-copy h2,
.board-topline h2,
.compact-panel h3,
.section-head h3 {
  margin: 0;
  letter-spacing: 0;
  text-wrap: balance;
}

.app-header h1 {
  font-size: 30px;
  line-height: 1.05;
}

.kicker,
.label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.server-pill,
.round-chip,
.settings-panel .section-head span,
.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

main {
  width: min(1780px, 100%);
  margin: 0 auto;
  padding: 6px clamp(10px, 2vw, 28px) 28px;
}

.setup-view {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.2fr);
  gap: 28px;
  align-items: start;
  padding-top: 40px;
}

.setup-copy {
  max-width: 620px;
}

.setup-copy h2 {
  max-width: 11ch;
  font-size: 56px;
  line-height: 0.98;
}

.setup-copy p {
  max-width: 64ch;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.compact-panel,
.side-panel,
.duel-panel {
  padding: 16px;
}

.compact-panel {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--bg);
}

input[readonly] {
  color: var(--muted);
  background: color-mix(in oklch, var(--surface-2) 76%, var(--bg) 24%);
}

input::placeholder {
  color: oklch(0.68 0.01 70);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.answer-btn,
.territory {
  border-radius: 8px;
  border: 0;
  transition: background 180ms var(--ease-out), color 180ms var(--ease-out), border-color 180ms var(--ease-out), transform 180ms var(--ease-out), box-shadow 180ms var(--ease-out), opacity 180ms var(--ease-out);
}

.primary-btn,
.secondary-btn,
.danger-btn,
.ghost-btn {
  min-height: 42px;
  padding: 9px 13px;
  font-weight: 800;
}

.primary-btn {
  color: var(--ink);
  background: var(--primary-strong);
}

.primary-btn:hover:not(:disabled) {
  background: var(--primary);
  transform: translateY(-1px);
}

.secondary-btn {
  color: var(--ink);
  background: var(--surface-3);
  border: 1px solid var(--line);
}

.secondary-btn:hover:not(:disabled),
.ghost-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: color-mix(in oklch, var(--surface-3) 82%, var(--primary) 18%);
}

.ghost-btn {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

.danger-btn {
  color: var(--ink);
  background: color-mix(in oklch, var(--danger) 64%, var(--surface) 36%);
  border: 1px solid color-mix(in oklch, var(--danger) 72%, var(--ink) 28%);
}

.danger-btn:hover:not(:disabled) {
  background: var(--danger);
  transform: translateY(-1px);
}

.primary-btn:active:not(:disabled),
.secondary-btn:active:not(:disabled),
.ghost-btn:active:not(:disabled),
.danger-btn:active:not(:disabled) {
  transform: translateY(0);
}

.is-busy button:not(:disabled) {
  cursor: progress;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(720px, 1fr) minmax(250px, 310px);
  gap: 10px;
  align-items: start;
}

.side-panel,
.duel-panel {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.room-block {
  display: grid;
  gap: 8px;
}

.room-code-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.room-code-row strong {
  font-size: 27px;
  line-height: 1;
  letter-spacing: 0.08em;
}

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

.player-card {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, color-mix(in oklch, var(--player-color, var(--line)) 14%, transparent), transparent 54%),
    var(--surface-2);
  transition: border-color 180ms var(--ease-out), background 180ms var(--ease-out), transform 180ms var(--ease-out), box-shadow 180ms var(--ease-out);
}

.player-card.is-turn {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--primary) 35%, transparent) inset;
}

.player-card.in-duel {
  border-color: color-mix(in oklch, var(--player-color, var(--primary)) 72%, var(--primary) 28%);
  background:
    linear-gradient(90deg, color-mix(in oklch, var(--player-color, var(--line)) 22%, transparent), transparent 58%),
    var(--surface-2);
}

.player-card.is-waiting {
  opacity: 0.62;
}

.player-card.red {
  --player-color: var(--player-red);
}

.player-card.blue {
  --player-color: var(--player-blue);
}

.player-emblem {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid color-mix(in oklch, var(--emblem-color, var(--line)) 72%, var(--ink) 28%);
  border-radius: 8px;
  color: var(--ink);
  background:
    radial-gradient(circle at 35% 22%, oklch(1 0 0 / 0.16), transparent 42%),
    color-mix(in oklch, var(--emblem-color, var(--line)) 62%, var(--surface) 38%);
}

.player-emblem.red {
  --emblem-color: var(--player-red);
}

.player-emblem.blue {
  --emblem-color: var(--player-blue);
}

.player-emblem.neutral {
  --emblem-color: var(--line);
}

.player-emblem.small {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.player-emblem.large {
  width: 54px;
  height: 54px;
  border-radius: 12px;
}

.emblem-icon {
  width: 18px;
  height: 18px;
}

.player-name {
  display: block;
  color: var(--ink);
  font-weight: 800;
}

.player-meta {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.player-score {
  min-width: 48px;
  text-align: right;
  font-size: 22px;
  font-weight: 900;
  transition: color 180ms var(--ease-out), transform 180ms var(--ease-out);
}

.player-side {
  display: grid;
  justify-items: end;
  gap: 3px;
}

.turn-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border: 1px solid color-mix(in oklch, var(--primary) 50%, var(--line) 50%);
  border-radius: 999px;
  color: var(--ink);
  background: color-mix(in oklch, var(--primary) 24%, var(--surface) 76%);
  font-size: 11px;
  font-weight: 900;
}

.score-flash {
  color: var(--gold);
  animation: score-pop 700ms var(--ease-out);
}

.settings-panel {
  display: grid;
  gap: 12px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toggle-row {
  display: flex;
  grid-template-columns: none;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
  transition: transform 160ms var(--ease-out);
}

.toggle-row input:checked {
  transform: scale(1.08);
}

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

.topic-check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  transition: border-color 180ms var(--ease-out), background 180ms var(--ease-out), color 180ms var(--ease-out), transform 180ms var(--ease-out);
}

.topic-check input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--primary);
}

.topic-check span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.topic-icon {
  width: 15px;
  height: 15px;
  color: var(--primary);
}

.topic-check:has(input:checked) {
  border-color: color-mix(in oklch, var(--primary) 70%, var(--line) 30%);
  color: var(--ink);
  background: color-mix(in oklch, var(--primary) 18%, var(--bg) 82%);
}

.topic-check:has(input:not(:disabled)):hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}

.field-hint,
.start-reason {
  margin: -2px 0 0;
  color: color-mix(in oklch, var(--muted) 86%, var(--ink) 14%);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

.start-reason:empty {
  display: none;
}

.range-grid {
  display: grid;
  gap: 9px;
}

.board-panel {
  padding: 10px;
  min-width: 0;
  overflow: visible;
}

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

.board-topline h2 {
  margin-top: 3px;
  font-size: 22px;
  line-height: 1.18;
}

.turn-subtitle {
  max-width: 72ch;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.board-stage {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-height: clamp(620px, calc(100vh - 154px), 840px);
  aspect-ratio: auto;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(140deg, color-mix(in oklch, var(--surface-2) 84%, var(--accent) 16%), var(--bg));
  animation: board-fade 420ms var(--ease-out);
}

.board-stage::before,
.board-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
}

.board-stage::before {
  opacity: 0.2;
  filter: blur(0.35px);
  background:
    radial-gradient(ellipse at 20% 28%, oklch(0.48 0.06 75 / 0.32), transparent 23%),
    radial-gradient(ellipse at 72% 35%, oklch(0.42 0.05 238 / 0.22), transparent 28%),
    radial-gradient(ellipse at 50% 74%, oklch(0.34 0.04 95 / 0.28), transparent 26%),
    linear-gradient(30deg, transparent 0 34%, oklch(0.72 0.08 82 / 0.08) 35%, transparent 38% 100%),
    linear-gradient(150deg, transparent 0 44%, oklch(0.58 0.06 70 / 0.07) 45%, transparent 48% 100%);
}

.board-stage::after {
  opacity: 0.78;
  background:
    radial-gradient(circle at 50% 48%, transparent 0 34%, oklch(0.06 0 0 / 0.34) 78%),
    linear-gradient(180deg, oklch(0.05 0 0 / 0.16), oklch(0.03 0 0 / 0.24));
}

.board-routes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.board-routes line {
  stroke: oklch(0.58 0.035 78 / 0.52);
  stroke-width: 1.55;
  vector-effect: non-scaling-stroke;
  transition: stroke 200ms var(--ease-out), stroke-width 200ms var(--ease-out), opacity 200ms var(--ease-out);
}

.board-routes line.route-active {
  stroke: var(--gold);
  stroke-width: 2.4;
  opacity: 0.95;
  filter: drop-shadow(0 0 5px color-mix(in oklch, var(--gold) 70%, transparent));
}

.territory {
  --owner-color: var(--line);
  --node-half: 53px;
  position: absolute;
  left: clamp(var(--node-half), calc(var(--x) * 1%), calc(100% - var(--node-half)));
  top: clamp(var(--node-half), calc(var(--y) * 1%), calc(100% - var(--node-half)));
  display: grid;
  place-items: center;
  width: 106px;
  min-height: 66px;
  padding: 7px 8px 8px;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 0%, color-mix(in oklch, var(--owner-color) 28%, transparent), transparent 54%),
    var(--surface-2);
  border: 2px solid var(--owner-color);
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 2;
  cursor: not-allowed;
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.04) inset;
}

.territory:not([aria-disabled="true"]) {
  cursor: pointer;
}

.territory[aria-disabled="true"] {
  cursor: not-allowed;
}

.territory:hover:not([aria-disabled="true"]) {
  border-color: var(--primary);
  background: color-mix(in oklch, var(--surface-3) 78%, var(--primary) 22%);
  transform: translate(-50%, -50%) translateY(-3px) scale(1.025);
}

.territory.owner-red {
  --owner-color: var(--player-red);
  background:
    radial-gradient(circle at 50% 0%, color-mix(in oklch, var(--player-red) 36%, transparent), transparent 58%),
    color-mix(in oklch, var(--player-red) 45%, var(--surface) 55%);
}

.territory.owner-blue {
  --owner-color: var(--player-blue);
  background:
    radial-gradient(circle at 50% 0%, color-mix(in oklch, var(--player-blue) 36%, transparent), transparent 58%),
    color-mix(in oklch, var(--player-blue) 45%, var(--surface) 55%);
}

.territory.neutral {
  --owner-color: color-mix(in oklch, var(--neutral) 78%, var(--muted) 22%);
  background:
    radial-gradient(circle at 50% 0%, oklch(0.56 0.025 80 / 0.18), transparent 58%),
    color-mix(in oklch, var(--neutral) 64%, var(--surface) 36%);
}

.territory.attackable {
  border-color: var(--gold);
  cursor: crosshair;
  animation: attackable-pulse 1800ms var(--ease-out) infinite;
}

.territory.attackable::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 1px solid color-mix(in oklch, var(--gold) 72%, transparent);
  border-radius: 10px;
  pointer-events: none;
  opacity: 0.8;
}

.territory.duel-target,
.territory.selected-target {
  border-color: var(--warning);
  z-index: 4;
  animation: selected-pulse 950ms var(--ease-out) infinite;
}

.territory.inactive {
  opacity: 0.52;
  filter: saturate(0.75) brightness(0.86);
}

.territory.capture-flash {
  animation: capture-flash 900ms var(--ease-out);
}

.territory-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 18px;
  margin-bottom: 3px;
  color: color-mix(in oklch, var(--ink) 82%, var(--owner-color) 18%);
}

.territory-svg {
  width: 18px;
  height: 18px;
}

.territory .territory-name {
  display: block;
  max-width: 94px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.15;
  text-shadow: 0 1px 0 oklch(0 0 0 / 0.24);
}

.territory .territory-value {
  display: block;
  margin-top: 3px;
  color: oklch(0.92 0.012 80);
  font-size: 11px;
  font-weight: 800;
}

.territory.base .territory-value::before {
  content: "Крепость · ";
}

.territory-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  display: grid;
  gap: 2px;
  width: max-content;
  min-width: 160px;
  max-width: 220px;
  padding: 9px 10px;
  border: 1px solid color-mix(in oklch, var(--gold) 42%, var(--line) 58%);
  border-radius: 8px;
  color: var(--ink);
  background: color-mix(in oklch, var(--surface) 92%, var(--bg) 8%);
  opacity: 0;
  transform: translate(-50%, 4px);
  pointer-events: none;
  text-align: left;
  font-size: 12px;
  line-height: 1.35;
  transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
  z-index: 8;
}

.territory-tooltip strong {
  font-size: 13px;
}

.territory:hover .territory-tooltip,
.territory:focus-visible .territory-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.duel-panel h3,
.duel-panel h2 {
  margin: 0;
}

.empty-duel {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.empty-duel p {
  margin: 0;
  color: var(--muted);
}

.duel-card {
  display: grid;
  gap: 12px;
}

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

.duel-meta .status-chip {
  gap: 0;
}

.question-text {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 850;
  line-height: 1.32;
  text-wrap: pretty;
}

.answers-grid {
  display: grid;
  gap: 8px;
}

.answer-btn {
  min-height: 52px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  text-align: left;
  font-weight: 750;
}

.answer-btn:disabled {
  cursor: default;
  opacity: 1;
}

.answer-btn span:first-child {
  display: block;
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--surface-3);
  transform: translateY(-1px);
}

.answer-btn.selected {
  border-color: var(--gold);
  background: color-mix(in oklch, var(--gold) 24%, var(--surface-2) 76%);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--gold) 28%, transparent) inset;
}

.answer-btn.correct {
  border-color: var(--success);
  background: color-mix(in oklch, var(--success) 34%, var(--surface) 66%);
}

.answer-btn.wrong {
  border-color: var(--danger);
  background: color-mix(in oklch, var(--danger) 35%, var(--surface) 65%);
}

.answer-markers {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.duel-modal {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
  padding: 18px;
  background: oklch(0.045 0 0 / 0.78);
  backdrop-filter: blur(3px);
  animation: modal-backdrop 180ms var(--ease-out);
}

.duel-modal-card {
  display: grid;
  gap: 14px;
  width: min(820px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 2px solid color-mix(in oklch, var(--gold) 36%, var(--line) 64%);
  border-radius: 8px;
  padding: 18px;
  background:
    radial-gradient(circle at 20% 0%, color-mix(in oklch, var(--gold) 11%, transparent), transparent 36%),
    linear-gradient(140deg, color-mix(in oklch, var(--surface-2) 72%, var(--bg) 28%), var(--surface));
  box-shadow: 0 0 14px oklch(0.72 0.14 82 / 0.16);
  animation: modal-card-in 210ms var(--ease-out);
}

.duel-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.duel-modal-head h2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 0;
  font-size: 24px;
  line-height: 1.15;
}

.duel-subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.modal-timer {
  --timer-progress: 1;
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  min-width: 82px;
  min-height: 82px;
  border: 1px solid color-mix(in oklch, var(--gold) 70%, var(--line) 30%);
  border-radius: 50%;
  color: var(--ink);
  background:
    radial-gradient(circle, var(--surface) 0 54%, transparent 56%),
    conic-gradient(var(--gold) calc(var(--timer-progress) * 1turn), color-mix(in oklch, var(--line) 68%, var(--surface) 32%) 0);
  font-size: 30px;
  font-weight: 950;
  line-height: 1;
}

.modal-timer span {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: color-mix(in oklch, var(--surface) 90%, var(--bg) 10%);
}

.modal-timer.is-low {
  border-color: var(--danger);
  background:
    radial-gradient(circle, var(--surface) 0 54%, transparent 56%),
    conic-gradient(var(--danger) calc(var(--timer-progress) * 1turn), color-mix(in oklch, var(--line) 68%, var(--surface) 32%) 0);
  animation: low-time 780ms var(--ease-out) infinite;
}

.duel-modal .question-text {
  font-size: 23px;
  line-height: 1.34;
}

.question-block {
  padding: 14px;
  border: 1px solid color-mix(in oklch, var(--gold) 22%, var(--line) 78%);
  border-radius: 8px;
  background:
    radial-gradient(circle at 0% 0%, color-mix(in oklch, var(--gold) 8%, transparent), transparent 42%),
    color-mix(in oklch, var(--surface-2) 84%, var(--bg) 16%);
}

.duel-modal .answer-btn {
  min-height: 66px;
  padding: 13px 14px;
  font-size: 16px;
}

.result-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid color-mix(in oklch, var(--gold) 24%, var(--line) 76%);
  border-radius: 8px;
  background:
    radial-gradient(circle at 100% 0%, color-mix(in oklch, var(--gold) 8%, transparent), transparent 36%),
    var(--surface-2);
}

.result-box strong {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
}

.result-box p {
  margin: 0;
  color: var(--muted);
}

.duel-result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.timer-icon {
  width: 23px;
  height: 23px;
}

.timer {
  font-size: 28px;
  font-weight: 950;
}

.log-block {
  display: grid;
  gap: 10px;
}

#gameLog {
  display: grid;
  gap: 8px;
  max-height: 310px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

#gameLog li {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--bg);
  font-size: 13px;
}

.event-item {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 8px;
  align-items: start;
}

.event-item.is-new {
  animation: event-in 220ms var(--ease-out);
}

.event-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface-2);
}

.event-svg {
  width: 14px;
  height: 14px;
}

.event-attack .event-icon,
.event-capture .event-icon {
  color: var(--gold);
  border-color: color-mix(in oklch, var(--gold) 55%, var(--line) 45%);
}

.event-defense .event-icon {
  color: var(--accent);
  border-color: color-mix(in oklch, var(--accent) 50%, var(--line) 50%);
}

.event-correct .event-icon {
  color: var(--success);
  border-color: color-mix(in oklch, var(--success) 50%, var(--line) 50%);
}

.event-wrong .event-icon,
.event-timeout .event-icon {
  color: var(--danger);
  border-color: color-mix(in oklch, var(--danger) 50%, var(--line) 50%);
}

.event-match-start .event-icon,
.event-match-end .event-icon {
  color: var(--primary);
  border-color: color-mix(in oklch, var(--primary) 60%, var(--line) 40%);
}

.match-end-card {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid color-mix(in oklch, var(--victory-color, var(--gold)) 35%, var(--line) 65%);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% -10%, color-mix(in oklch, var(--victory-color, var(--gold)) 20%, transparent), transparent 46%),
    var(--surface-2);
}

.match-end-card.red {
  --victory-color: var(--player-red);
}

.match-end-card.blue {
  --victory-color: var(--player-blue);
}

.match-end-card h2 {
  margin: 0;
  font-size: 24px;
}

.match-end-card p {
  margin: 0;
  color: var(--muted);
}

.victory-mark {
  display: flex;
  align-items: center;
  gap: 9px;
}

.victory-mark > span:last-child {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--gold);
  background: color-mix(in oklch, var(--gold) 15%, var(--surface) 85%);
}

.victory-icon,
.crown-icon {
  width: 22px;
  height: 22px;
}

.final-score-grid,
.match-summary {
  display: grid;
  gap: 8px;
}

.final-score-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in oklch, var(--surface) 72%, var(--bg) 28%);
  font-size: 13px;
}

.final-score-row strong {
  color: var(--ink);
}

.match-summary {
  padding-top: 2px;
}

.match-summary span {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 24px));
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-3);
  transform: translateX(-50%);
  animation: toast-in 180ms var(--ease-out);
}

@keyframes board-fade {
  from {
    opacity: 0.82;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes attackable-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 1px color-mix(in oklch, var(--gold) 24%, transparent) inset;
  }
  50% {
    box-shadow: 0 0 0 1px color-mix(in oklch, var(--gold) 38%, transparent) inset, 0 0 12px oklch(0.74 0.14 82 / 0.2);
  }
}

@keyframes selected-pulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.045);
  }
}

@keyframes capture-flash {
  0% {
    box-shadow: 0 0 0 1px var(--gold) inset, 0 0 0 oklch(0.74 0.14 82 / 0);
  }
  35% {
    box-shadow: 0 0 0 2px var(--gold) inset, 0 0 14px oklch(0.74 0.14 82 / 0.34);
  }
  100% {
    box-shadow: 0 0 0 1px oklch(1 0 0 / 0.04) inset, 0 0 0 oklch(0.74 0.14 82 / 0);
  }
}

@keyframes score-pop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.22);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes modal-backdrop {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modal-card-in {
  from {
    opacity: 0;
    transform: scale(0.975) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes low-time {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.22);
  }
}

@keyframes event-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@media (max-width: 1280px) {
  .game-shell {
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  }

  .duel-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .setup-view,
  .game-shell {
    grid-template-columns: 1fr;
  }

  .setup-copy h2 {
    max-width: 14ch;
    font-size: 38px;
  }

  .board-stage {
    min-height: 500px;
  }

  .duel-modal-card {
    padding: 14px;
  }

  .duel-modal-head {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-timer {
    width: 72px;
    height: 72px;
    min-width: 72px;
    min-height: 72px;
  }

  .duel-modal .question-text {
    font-size: 19px;
  }

  .territory {
    --node-half: 44px;
    width: 88px;
    min-height: 62px;
  }

  .territory .territory-name {
    max-width: 74px;
    font-size: 11px;
  }

  .duel-result-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  main {
    padding-inline: 10px;
  }

  .board-panel {
    padding: 10px;
  }

  .board-topline {
    align-items: flex-start;
    flex-direction: column;
  }

  .board-stage {
    min-height: 440px;
  }

  .territory {
    --node-half: 36px;
    width: 72px;
    min-height: 60px;
    padding: 5px;
  }

  .territory-icon {
    width: 18px;
    height: 15px;
    margin-bottom: 1px;
  }

  .territory-svg {
    width: 15px;
    height: 15px;
  }

  .territory .territory-name {
    max-width: 62px;
    font-size: 10px;
  }

  .territory .territory-value {
    font-size: 10px;
  }

  .territory-tooltip {
    min-width: 145px;
    max-width: 180px;
  }

  .topics-grid,
  .setup-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }

  .territory:hover:not([aria-disabled="true"]) {
    transform: translate(-50%, -50%);
  }

  .duel-modal {
    backdrop-filter: none;
  }
}
