:root {
  color-scheme: dark;
  --bg: #151614;
  --panel: #1d1e1a;
  --raised: #24251f;
  --line: #3c3a2f;
  --text: #eeeadc;
  --muted: #b7b2a1;
  --quiet: #a29b86;
  --gold: #e2b573;
  --teal: #78d3bb;
  --rust: #f39a80;
  --display: Georgia, 'Times New Roman', serif;
  font: 16px/1.45 system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 300px;
  color: var(--text);
  background: radial-gradient(ellipse at 35% -20%, #302a21 0%, transparent 53%), var(--bg);
}
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: var(--display); font-weight: 500; }
.shell { width: min(1360px, calc(100% - 88px)); margin-inline: auto; }
.masthead { border-bottom: 1px solid #373329; background: #191915; }
.masthead-inner { height: 68px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.identity { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.identity h1 { font-size: clamp(1.45rem, 3vw, 1.9rem); white-space: nowrap; letter-spacing: -.035em; }
.identity h1 span { color: var(--gold); }
.quiet, .icon-button, .speed {
  background: #25251f;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
}
.quiet { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px; min-height: 39px; font-size: .875rem; font-weight: 650; }
.quiet:hover, .icon-button:enabled:hover, .speed:hover { background: #343228; border-color: #665742; }
.question-mark { display: inline-grid; place-items: center; width: 17px; height: 17px; color: var(--gold); font-size: .7rem; border: 1px solid #93754f; border-radius: 50%; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 27vw, 380px); gap: 22px; align-items: start; padding-block: 26px 40px; }
.war-room { min-width: 0; }
.field-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 15px; }
.eyebrow { font-size: .75rem; color: var(--gold); font-weight: 700; letter-spacing: .16em; }
.field-heading h2 { margin-top: 4px; font-size: clamp(2.25rem, 4vw, 3.35rem); line-height: 1; letter-spacing: -.045em; }
.rival-label { display: grid; gap: 4px; font-size: .8rem; font-weight: 600; color: var(--muted); }
select {
  width: 100%;
  min-width: 0;
  appearance: none;
  padding: 8px 28px 8px 10px;
  border: 1px solid #4a473a;
  border-radius: 5px;
  background-color: #20211c;
  background-image: linear-gradient(45deg, transparent 51%, #b9a789 51%), linear-gradient(135deg, #b9a789 51%, transparent 51%);
  background-position: calc(100% - 14px) 51%, calc(100% - 10px) 51%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  font-size: .875rem;
  color: var(--text);
  min-height: 36px;
}
select:enabled:hover { border-color: #8e7650; }
select:disabled { opacity: .68; }
.rival-label select { min-width: 152px; }
.battle-card, .command, .journal { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: 0 6px 16px #0002; }
.scoreboard { display: grid; grid-template-columns: minmax(0,1fr) 106px minmax(0,1fr); align-items: stretch; padding: 10px 15px; gap: 10px; background: linear-gradient(#272721, #20211c); }
.team-score { --team: var(--teal); display: flex; align-items: center; gap: 9px; padding: 7px 9px; min-width: 0; background: #1c2520; border: 1px solid #33463d; border-radius: 5px; }
.team-score.rust { --team: var(--rust); background: #2c211d; border-color: #513a33; text-align: right; justify-content: flex-end; }
.team-mark { background: var(--team); width: 11px; height: 16px; flex: none; clip-path: polygon(0 0, 100% 0, 100% 72%, 50% 100%, 0 72%); }
.team-name { color: var(--team); font-size: .875rem; font-weight: 750; line-height: 1.25; }
.team-caption { color: var(--muted); font-size: .75rem; margin-top: 2px; }
.team-count { margin-left: auto; color: var(--team); font-size: 1.45rem; line-height: 1; font-weight: 750; font-variant-numeric: tabular-nums; }
.rust .team-count { margin-left: 0; margin-right: auto; }
.battle-time { display: grid; justify-items: center; align-content: center; }
#clock { font: 600 1.35rem/1.2 ui-monospace, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
#phase { color: var(--gold); font: 700 .67rem/1.3 system-ui, sans-serif; letter-spacing: .08em; margin-top: 2px; text-align: center; }
.arena {
  position: relative;
  isolation: isolate;
  aspect-ratio: 2 / 1;
  width: 100%;
  background: radial-gradient(ellipse at center, transparent 52%, #10130d4a 100%),
    #414c2d url("./the-crossing.webp") center / 100% 100%;
  overflow: hidden;
  border-block: 1px solid #37372b;
}
#field { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: manipulation; }
#field:focus-visible { outline: 2px solid var(--gold); outline-offset: -3px; }
.gate-label {
  position: absolute;
  bottom: 5%;
  padding: 3px 7px;
  color: var(--teal);
  background: #141b16e8;
  border: 1px solid #56766a;
  border-radius: 4px;
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .12em;
  pointer-events: none;
}
.gate-west { left: 4%; }
.gate-east { right: 4%; color: var(--rust); background: #281b17e8; border-color: #856054; }
.battle-result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px;
  text-align: center;
  background: #11130dde;
}
.battle-result h3 { font: 500 clamp(1.55rem, 4vw, 3.2rem)/1.05 var(--display); }
.battle-result p { color: var(--muted); font-size: .875rem; }
.battle-result button { margin-top: 6px; }
.field-toolbar { padding: 11px 14px; display: flex; gap: 12px; align-items: center; min-height: 67px; }
.transport { display: flex; gap: 6px; }
.icon-button, .speed { display: inline-grid; place-items: center; min-width: 35px; height: 36px; padding-inline: 7px; line-height: 1; font-size: .94rem; font-weight: 700; }
#reset { font-size: 1.3rem; font-weight: 400; }
.inspection { flex: 1; font-size: .8125rem; color: var(--muted); }
.inspection strong { font-weight: 650; color: var(--text); }
.deploy {
  flex: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  border: 1px solid #f2c882;
  border-radius: 6px;
  min-height: 42px;
  padding: 8px 15px;
  background: linear-gradient(#efc580,#dca75e);
  box-shadow: inset 0 1px #ffffff48, 0 3px 8px #0005;
  color: #251b0f;
  font-size: .9rem;
  font-weight: 790;
}
.deploy:enabled:hover { background: #f8d395; }
.journal { margin-top: 14px; }
.journal header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid #36352c; }
.journal h3 { font-size: .9rem; font-weight: 720; }
#round-number { color: var(--quiet); font-size: .71rem; font-weight: 750; letter-spacing: .12em; }
#log { list-style: none; padding: 8px 14px 10px; margin: 0; min-height: 41px; max-height: 122px; overflow: auto; font-size: .8125rem; color: var(--muted); }
#log li { display: flex; align-items: baseline; gap: 10px; padding-block: 3px; }
#log time { color: var(--gold); font: .75rem ui-monospace, Menlo, Consolas, monospace; }
.command { padding: 18px; background: linear-gradient(145deg, #26261f, #1b1c18 55%); }
.command-heading { margin-bottom: 15px; }
.command-heading h2 { margin-top: 4px; font-size: 2.15rem; line-height: 1.06; letter-spacing: -.04em; }
.command-heading > p:last-child { color: var(--muted); font-size: .875rem; margin-top: 7px; }
.classes, .army-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; padding: 3px; border: 1px solid #39392e; border-radius: 6px; background: #171813; }
.army-switch { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 10px; }
.classes button, .army-switch button {
  padding: 5px 3px;
  min-height: 37px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  font-size: .8125rem;
  font-weight: 660;
}
.classes button[aria-pressed="true"], .army-switch button[aria-pressed="true"] { background: #3b3222; border-color: #685336; color: #f2cc91; }
.classes button:hover, .army-switch button:hover { color: #f8dbb0; }
.unit-summary { display: flex; align-items: center; gap: 9px; margin: 13px 0 14px; min-height: 57px; }
.class-emblem { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid #66563c; border-radius: 6px; background: #332a1e; color: var(--gold); font-size: 1.3rem; }
.unit-summary h3, .orders-heading label { font-size: .95rem; line-height: 1.25; }
.unit-summary p { color: var(--muted); font-size: .8125rem; }
.orders-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.text-button { border: 0; background: none; color: var(--gold); font-size: .78rem; padding: 5px 0; }
.text-button:enabled:hover { text-decoration: underline; }
.add-rule { padding: 7px; min-height: 36px; width: 100%; border: 1px solid #5e503a; border-radius: 5px; background: #2b271e; color: #edc488; font-weight: 680; font-size: .875rem; }
.add-rule:enabled:hover { background: #3a3021; }
dialog { width: min(500px, calc(100% - 24px)); padding: 24px; color: var(--text); border: 1px solid #6a573e; border-radius: 9px; background: #23231d; box-shadow: 0 20px 70px #000a; }
dialog::backdrop { background: #100e0bd9; }
dialog h2 { font-size: 2.1rem; }
.close-button { position: absolute; right: 15px; top: 15px; font-size: 1.3rem; }
.guide-steps { padding-left: 22px; }
.guide-steps li { padding: 3px 0 5px 3px; }
.guide-steps li::marker { color: var(--gold); }
.guide-extra { color: var(--muted); margin: 0 0 15px; font-size: .875rem; }
@media (max-width: 1150px) {
  .shell { width: calc(100% - 44px); }
  .layout { gap: 15px; }
  .scoreboard { grid-template-columns: minmax(0,1fr) 78px minmax(0,1fr); }
  .team-caption { display: none; }
  .team-name { font-size: .8rem; }
}
@media (min-width: 871px) {
  .arena { max-height: max(280px, 53vh); }
}
@media (max-width: 870px) {
  .layout { grid-template-columns: minmax(0, 1fr); max-width: 720px; }
  .team-caption { display: block; }
}
@media (max-width: 510px) {
  .shell { width: calc(100% - 22px); }
  .layout { padding-top: 23px; }
  .masthead-inner { height: 63px; }
  .identity { gap: 5px; }
  .identity img { width: 31px; height: 36px; }
  .help-button { padding: 6px 7px; font-size: .75rem; gap: 5px; }
  .field-heading { gap: 7px; }
  .field-heading h2 { font-size: 2rem; }
  .rival-label select { min-width: 0; max-width: 131px; font-size: .77rem; }
  .scoreboard { grid-template-columns: minmax(0,1fr) 58px minmax(0,1fr); padding: 7px 5px; gap: 4px; }
  .team-score { gap: 4px; padding: 5px; }
  .team-mark { display: none; }
  .team-caption { display: none; }
  .team-name { font-size: .75rem; }
  .team-count { font-size: 1.12rem; }
  #clock { font-size: 1.03rem; }
  #phase { font-size: .57rem; }
  .field-toolbar { flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 8px; }
  .inspection { order: 3; flex: 0 0 100%; min-height: 21px; }
  .gate-label { font-size: .57rem; padding: 2px 4px; }
  .command { padding: 14px; }
}

.match-selectors { display: flex; flex-wrap: wrap; justify-content: end; gap: 9px; }
.match-selectors select { min-width: 135px; }
.unit-slots { margin-left: auto; display: flex; gap: 4px; }
.unit-slots button {
  min-width: 28px;
  height: 31px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding-inline: 4px;
  background: #20211b;
  color: var(--muted);
  font: 600 .8rem ui-monospace, Menlo, monospace;
}
.unit-slots button[aria-pressed=true] { border-color: #aa8351; color: #f7d1a1; background: #3b3223; }
.unit-slots button:hover { color: #f7d1a1; border-color: #aa8351; }
.code-editor {
  display: grid;
  grid-template-columns: 29px minmax(0, 1fr);
  border: 1px solid #464235;
  border-radius: 6px;
  background: #121410;
  margin-top: 6px;
  overflow: hidden;
}
.code-editor:focus-within { border-color: #aa8351; }
.code-editor textarea, .line-numbers, .lab-candidate {
  font: .84rem/1.57 ui-monospace, Menlo, Monaco, Consolas, monospace;
  font-variant-ligatures: none;
  tab-size: 2;
}
.code-editor textarea {
  height: clamp(205px, 33vh, 345px);
  min-height: 165px;
  width: 100%;
  min-width: 0;
  white-space: pre;
  resize: vertical;
  padding: 9px 10px 11px 8px;
  color: #f1e8d4;
  background: transparent;
  border: 0;
}
.code-editor textarea:focus { outline: 0; }
.code-editor textarea[readonly] { color: var(--muted); }
.line-numbers {
  align-self: stretch;
  min-height: 0;
  height: 0;
  min-height: 100%;
  overflow: hidden;
  white-space: pre;
  padding: 9px 5px 11px 2px;
  border-right: 1px solid #323127;
  text-align: right;
  color: #a59b85;
  user-select: none;
}
.code-status { padding: 7px 1px 5px; min-height: 31px; font-size: .78rem; color: var(--teal); }
.code-status.error { color: var(--rust); }
.editor-tools { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.editor-tools select { min-width: 0; }
.editor-tools .quiet { flex: none; min-height: 36px; padding-block: 5px; }
.lab-button { margin-top: 6px; background: transparent; }
.reference { width: min(700px, calc(100% - 24px)); }
.reference h2 { margin-right: 33px; }
.reference p, .reference dl { margin-top: 9px; }
.reference dl { margin-bottom: 0; }
.reference dt { color: var(--gold); font-weight: 700; }
.reference dd { margin: 2px 0 13px; color: var(--muted); }
.reference code { color: #f0d1a0; overflow-wrap: anywhere; }
.lab-candidate {
  margin: 9px 0 13px;
  background: #121410;
  padding: 11px;
  overflow: auto;
  max-height: 260px;
}
.lab-status { color: var(--teal); margin-bottom: 9px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
@media (max-width: 1150px) {
  .match-selectors select { min-width: 120px; }
}
@media (max-width: 570px) {
  .field-heading { flex-wrap: wrap; }
  .match-selectors { justify-content: start; }
  .code-editor textarea { height: 260px; }
}

.report-panel {
  padding: 9px 14px 11px;
  border-top: 1px solid var(--line);
}
.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.report-actions .quiet { min-height: 32px; padding: 5px 8px; font-size: .8rem; }
.report-actions .text-button { min-height: 32px; padding-inline: 4px; }
.report-status { margin-top: 7px; color: var(--teal); font-size: .8125rem; overflow-wrap: anywhere; }
.report-status.error { color: var(--rust); }

.series-dialog { width: min(1020px, calc(100% - 25px)); max-height: calc(100% - 26px); overflow: auto; }
.series-close { position: sticky; top: 0; height: 0; z-index: 1; }
.series-close .close-button { top: 0; right: 0; }
.series-dialog h2 { padding-right: 43px; }
.series-intro { color: var(--muted); margin: 6px 0 13px; max-width: 62ch; }
.series-setup { display: flex; flex-wrap: wrap; align-items: end; gap: 7px; }
.series-setup label { display: grid; gap: 3px; min-width: 108px; color: var(--muted); font-size: .8rem; }
.series-setup button { min-height: 36px; }
.series-status { min-height: 20px; color: var(--teal); margin: 10px 0 9px; font-size: .875rem; }
.series-results { display: grid; grid-template-columns: minmax(165px, .35fr) minmax(0, 1fr); align-items: start; gap: 16px; }
.series-rounds { display: grid; gap: 5px; padding: 0; margin: 0; list-style: none; }
.series-rounds button {
  text-align: left;
  width: 100%;
  min-height: 45px;
  padding: 7px 9px;
  background: #1a1b16;
  border: 1px solid var(--line);
  border-radius: 5px;
}
.series-rounds button span { display: block; }
.series-rounds button span:first-child { font-size: .69rem; color: var(--gold); font-weight: 750; letter-spacing: .065em; }
.series-rounds button span:last-child { font-size: .875rem; color: var(--text); }
.series-rounds button[aria-pressed=true], .series-rounds button:hover { border-color: #9c8158; background: #393020; }
.series-detail { min-width: 0; }
.series-detail h3 { font-family: var(--display); font-weight: 500; font-size: 1.4rem; }
.series-result-line { color: var(--gold); margin-top: 3px; font-size: .875rem; }
.series-explanation { margin-top: 5px; color: var(--text); font-size: .875rem; }
.series-findings { margin: 5px 0 8px; padding-left: 17px; color: var(--muted); font-size: .8125rem; }
.series-board { width: min(100%, 80vh); margin-top: 7px; aspect-ratio: 2 / 1; border: 1px solid var(--line); border-radius: 5px; overflow: hidden;
  background: #424b2e url("./the-crossing.webp") center / 100% 100%; }
.series-board canvas { display: block; width: 100%; height: 100%; }
.series-timeline { max-width: 80vh; display: flex; align-items: center; gap: 9px; margin-top: 7px; }
.series-timeline input { width: 100%; min-width: 0; accent-color: var(--gold); }
.series-timeline .quiet { flex: none; min-height: 34px; padding-block: 5px; }
.series-timeline output { flex: none; min-width: 42px; color: var(--muted); text-align: right; font-size: .825rem; }
.series-programs { margin-top: 10px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; }
.series-programs summary { cursor: pointer; color: var(--gold); font-size: .875rem; }
.series-programs label { display: block; margin-top: 8px; font-size: .79rem; color: var(--muted); }
.series-programs pre { max-height: 160px; margin: 7px 0 2px; overflow: auto; font: .78rem/1.45 ui-monospace, Menlo, monospace; color: var(--text); }
.series-round-download { margin-top: 8px; }
@media (max-width: 640px) {
  .series-dialog { padding: 16px; }
  .series-results { grid-template-columns: minmax(0,1fr); gap: 10px; }
  .series-rounds { grid-template-columns: repeat(2,minmax(0,1fr)); max-height: 170px; overflow: auto; }
}

.identity .site-wordmark { font: 500 clamp(1.45rem, 3vw, 1.9rem)/1.45 var(--display); white-space: nowrap; letter-spacing: -.035em; }
.identity .site-wordmark span { color: var(--gold); }
.page-nav { display: flex; align-items: center; gap: 6px; }
.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  font-size: .875rem;
  font-weight: 650;
}
.nav-link:hover,.nav-link[aria-current=page] { color: var(--gold); border-color: var(--line); background: #27251d; }
@media (max-width:510px) {
  .nav-link { padding-inline: 5px; font-size: .75rem; min-height: 33px; }
  .page-nav { gap: 2px; }
}
@media (max-width:355px) {
  .identity h1,.identity .site-wordmark { font-size: 1.23rem; }
  .question-mark { display: none; }
}

.arena,.series-board { aspect-ratio: var(--board-aspect, 2 / 1); }
.procedural-controls { display: flex; align-items: center; justify-content: end; gap: 7px; margin: -3px 0 8px; }
.procedural-controls span { margin-right: auto; color: var(--gold); font-size: .85rem; font-weight: 670; }
.procedural-controls label { color: var(--muted); font-size: .8rem; }
.procedural-controls input {
  width: 99px; min-height: 32px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px;
  background: #20211c; color: var(--text); font: inherit; font-size: .8rem;
}
.procedural-controls button { min-height: 32px; padding: 4px 7px; font-size: .8rem; }
.draft-button { margin-top: 8px; min-height: 30px; padding: 4px 8px; color: var(--gold); font-size: .83rem; }
.draft-board-note { color: var(--gold); font-size: .85rem; }
.draft-source {
  width: 100%; min-height: 165px; margin-top: 9px; padding: 8px; resize: vertical;
  background: #121410; color: var(--text); border: 1px solid var(--line); border-radius: 5px;
  font: .85rem/1.55 ui-monospace,Menlo,monospace;
}
@media (max-width: 430px) {
  .procedural-controls { flex-wrap: wrap; }
  .procedural-controls span { width: 100%; }
  #draft-dialog .editor-tools { flex-wrap: wrap; }
}
