/* Minimalist flat dark theme. No gradients, no shadows, no rounded corners. */

:root {
  --bg: #0d0d0d;
  --panel: #141414;
  --line: #2a2a2a;
  --text: #e4e4e4;
  --dim: #8a8a8a;
  --accent: #6fcf8b;
  --warn: #e0b341;
  --bad: #e06c6c;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.wrap {
  max-width: 1150px;
  margin: 0 auto;
  padding: 0 20px 64px;
}

/* ---------------------------------------------------------------- header */

header {
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  padding-top: 14px;
  padding-bottom: 14px;
}

.brand {
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.08em;
}

nav {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

nav a {
  color: var(--dim);
}

nav a.on,
nav a:hover {
  color: var(--text);
}

header form {
  margin-left: auto;
}

.who {
  color: var(--dim);
}

.who.on,
.who:hover {
  color: var(--text);
}

/* ----------------------------------------------------------------- text */

h1,
h2,
h3 {
  font-weight: 700;
  line-height: 1.3;
  margin: 28px 0 12px;
}

h1 {
  font-size: 19px;
  letter-spacing: 0.04em;
}

h2 {
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--dim);
  text-transform: uppercase;
}

h3 {
  font-size: 14px;
}

p {
  margin: 0 0 12px;
}

.dim {
  color: var(--dim);
}

ul {
  margin: 0 0 12px;
  padding-left: 18px;
}

li {
  margin-bottom: 4px;
}

.note {
  color: var(--dim);
  font-size: 13px;
}

code,
pre {
  font-family: var(--mono);
}

pre {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 12px;
  overflow-x: auto;
  margin: 0 0 16px;
}

/* --------------------------------------------------------------- panels */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 16px;
  margin-bottom: 16px;
}

.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: baseline;
}

.bar .stat b {
  font-size: 18px;
}

/* ---------------------------------------------------------------- forms */

label {
  display: block;
  color: var(--dim);
  margin-bottom: 4px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  padding: 8px 10px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.field {
  margin-bottom: 14px;
}

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

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

.row input[type="text"] {
  flex: 1 1 260px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--dim);
}

.check input {
  width: auto;
}

button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  padding: 8px 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button.primary {
  border-color: var(--accent);
  color: var(--accent);
}

button.danger {
  border-color: var(--bad);
  color: var(--bad);
}

button.danger:hover {
  border-color: var(--bad);
  color: var(--bad);
  background: rgba(224, 108, 108, 0.1);
}

button:disabled,
button:disabled:hover {
  border-color: var(--line);
  color: var(--dim);
  background: transparent;
  cursor: not-allowed;
}

button.link {
  border: none;
  padding: 0;
  color: var(--dim);
  text-decoration: underline;
}

button.link:hover {
  color: var(--text);
}

/* --------------------------------------------------------------- tables */

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--dim);
  font-weight: 400;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.06em;
}

tr:last-child td {
  border-bottom: none;
}

td.num,
th.num {
  text-align: right;
}

/* ---------------------------------------------------------------- flags */

.flash {
  border: 1px solid var(--line);
  border-left-width: 3px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.flash.ok {
  border-left-color: var(--accent);
}

.flash.error {
  border-left-color: var(--bad);
}

/* ---------------------------------------------------------------- chips */

.tag {
  display: inline-block;
  border: 1px solid var(--line);
  color: var(--dim);
  padding: 0 6px;
  margin-right: 4px;
  font-size: 12px;
}

.state {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.state.running {
  color: var(--accent);
}

.state.stopped,
.state.missing {
  color: var(--dim);
}

.state.partial {
  color: var(--warn);
}

/* An absence of information, not a warning — keep it quiet. */
.state.unknown {
  color: var(--dim);
  opacity: 0.7;
}

.own {
  color: var(--accent);
}

.notown {
  color: var(--dim);
}

.diff {
  color: var(--dim);
  font-size: 12px;
}

/* ------------------------------------------------------------ the goal */

.goal > summary {
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.04em;
  list-style-position: outside;
}

.goal > summary::marker {
  color: var(--dim);
}

.goal[open] > summary {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.goal .steps {
  padding-left: 20px;
}

.goal .steps li {
  margin-bottom: 8px;
}

.goal .steps li::marker {
  color: var(--dim);
}

.goal > *:last-child {
  margin-bottom: 0;
}

/* ---------------------------------------------------------- box cards */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 14px;
  color: var(--text);
}

.card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

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

.card .name {
  font-weight: 700;
}

.card .ip {
  color: var(--dim);
  font-size: 13px;
}

.card .theme {
  color: var(--dim);
  font-size: 13px;
}

.card .tags {
  margin-top: auto;
}

.card .foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

/* Solved state has to survive a glance across 15 cards: a thick left edge for
   shape, a badge for words, and [x] markers in the footer for greyscale. */
.card.done {
  border-left: 4px solid var(--accent);
  padding-left: 11px;
}

.card.part {
  border-left: 4px solid var(--warn);
  padding-left: 11px;
}

.card .flags {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* nowrap, not `pre`: `pre` would also preserve the template's indentation. */
.card .mark {
  white-space: nowrap;
}

.card .pts {
  white-space: nowrap;
}

.badge {
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1px 6px;
  white-space: nowrap;
}

.badge.part {
  border-color: var(--warn);
  color: var(--warn);
}

/* Flat ten-segment difficulty meter. */
.dbar {
  display: flex;
  gap: 2px;
  align-items: center;
}

.dbar i {
  width: 5px;
  height: 10px;
  background: var(--line);
}

.dbar i.on {
  background: var(--dim);
}

.empty {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 16px;
  color: var(--dim);
}

/* ---------------------------------------------------------------- chart */

.chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart .grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart .axis {
  fill: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
}

.chart .line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* 2px surface ring so overlapping solve markers stay countable. */
.chart .dot {
  stroke: var(--panel);
  stroke-width: 2;
}

.chart .dot:hover {
  stroke: var(--text);
}

.chart .endlabel {
  fill: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.legend .key {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend .key i {
  width: 10px;
  height: 2px;
}

/* ----------------------------------------------------- flag capture --- */
/* The one moment worth celebrating. Stays in the flat monospace idiom: no
   gradients, no shadows — motion and a single accent hue do the work. */

.capture {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 13, 13, 0.9);
  overflow: hidden;
  cursor: pointer;
  animation: capture-fade 4s ease forwards;
}

@keyframes capture-fade {
  0% { opacity: 0; }
  6% { opacity: 1; }
  85% { opacity: 1; visibility: visible; }
  100% { opacity: 0; visibility: hidden; }
}

.capture-card {
  position: relative;
  border: 1px solid var(--accent);
  background: var(--panel);
  padding: 28px 44px;
  text-align: center;
  animation: capture-pop 420ms cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

@keyframes capture-pop {
  0% { transform: scale(0.86); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Typed out one character at a time, with a caret that stops blinking when
   the text finishes. */
.capture-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--accent);
  overflow: hidden;
  white-space: nowrap;
  width: var(--ch, 14ch);
  margin: 0 auto 14px;
  border-right: 2px solid var(--accent);
  animation:
    capture-type 700ms steps(14) 300ms both,
    capture-caret 700ms step-end 5;
}

@keyframes capture-type {
  from { width: 0; }
  to { width: var(--ch, 14ch); }
}

@keyframes capture-caret {
  50% { border-right-color: transparent; }
}

.capture-box {
  color: var(--text);
  margin-bottom: 10px;
  animation: capture-rise 400ms ease 700ms both;
}

.capture-points {
  font-size: 40px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
  animation: capture-rise 400ms ease 820ms both, capture-beat 900ms ease 1.2s 2;
}

@keyframes capture-beat {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.08); }
}

.capture-owned {
  margin-top: 10px;
  color: var(--warn);
  font-size: 13px;
  letter-spacing: 0.06em;
  animation: capture-rise 400ms ease 960ms both;
}

.capture-hint {
  margin-top: 18px;
  color: var(--dim);
  font-size: 12px;
  animation: capture-rise 400ms ease 1.4s both;
}

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

/* Monospace glyphs falling past the card — flat characters, not confetti. */
.capture-rain {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.capture-rain span {
  position: absolute;
  top: -8%;
  left: var(--x);
  color: var(--accent);
  font-size: 13px;
  opacity: 0;
  animation: capture-drop 2.6s linear both;
  animation-delay: calc(var(--i) * 70ms);
}

.capture-rain span:nth-child(even) {
  color: var(--dim);
  font-size: 11px;
  animation-duration: 3.2s;
}

@keyframes capture-drop {
  0% { transform: translateY(0); opacity: 0; }
  12% { opacity: 0.85; }
  80% { opacity: 0.5; }
  100% { transform: translateY(105vh); opacity: 0; }
}

/* Motion off: keep the announcement, drop the movement. */
@media (prefers-reduced-motion: reduce) {
  .capture,
  .capture-card,
  .capture-title,
  .capture-box,
  .capture-points,
  .capture-owned,
  .capture-hint {
    animation: none;
  }

  .capture-title {
    width: auto;
    border-right: none;
  }

  .capture-rain {
    display: none;
  }
}

/* -------------------------------------------------------- solve matrix */

/* Fifteen boxes will not fit on a phone: scroll the grid, not the page. */
.matrix {
  overflow-x: auto;
  border: 1px solid var(--line);
}

.matrix table {
  border-collapse: collapse;
  width: auto;
  min-width: 100%;
}

.matrix th,
.matrix td {
  padding: 6px 8px;
  white-space: nowrap;
}

.matrix th.col {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: left;
  padding: 8px 4px;
  font-size: 11px;
}

/* Keep the player name in view while scanning across the boxes. */
.matrix .sticky {
  position: sticky;
  left: 0;
  background: var(--panel);
  z-index: 1;
  border-right: 1px solid var(--line);
}

.matrix .cell {
  text-align: center;
  letter-spacing: 1px;
}

.matrix .cell.full {
  background: rgba(111, 207, 139, 0.12);
}

.matrix tr.totals td {
  border-top: 1px solid var(--line);
  border-bottom: none;
  font-size: 12px;
}

/* ------------------------------------------------------------- api docs */

.prose > *:first-child {
  margin-top: 0;
}

.prose > *:last-child {
  margin-bottom: 0;
}

.prose table {
  margin-bottom: 12px;
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.op {
  scroll-margin-top: 16px;
}

.opline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.oppath {
  font-size: 15px;
  word-break: break-all;
}

.opsummary {
  color: var(--dim);
  margin-bottom: 10px;
}

.method {
  border: 1px solid var(--line);
  padding: 1px 8px;
  font-size: 12px;
  letter-spacing: 0.06em;
  min-width: 62px;
  text-align: center;
}

.method.get {
  border-color: #3987e5;
  color: #3987e5;
}

.method.post {
  border-color: var(--accent);
  color: var(--accent);
}

.method.patch,
.method.put {
  border-color: var(--warn);
  color: var(--warn);
}

.method.delete {
  border-color: var(--bad);
  color: var(--bad);
}

.req {
  color: var(--warn);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-left: 4px;
}

.rc2 {
  color: var(--accent);
}

.rc4,
.rc5 {
  color: var(--bad);
}

/* Swagger UI ships its own light stylesheet; give it a plain white card so its
   own controls keep working instead of half-inheriting the dark theme. */
.swagger-host {
  background: #ffffff;
  border: 1px solid var(--line);
  color-scheme: light;
}

footer {
  border-top: 1px solid var(--line);
  margin-top: 40px;
  padding-top: 14px;
  color: var(--dim);
  font-size: 12px;
}
