:root {
  --bg: #070707;
  --panel: #111214;
  --panel-2: #1a1c20;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 229, 0, 0.35);
  --text: #eef0f2;
  --muted: #9aa0a6;
  --yellow: #ffe500;
  --yellow-deep: #f5c518;
  --red: #ff2e2e;
  --head: 'Oswald', 'Arial Narrow', sans-serif;
  --body: 'Barlow Semi Condensed', system-ui, sans-serif;
  --mono: 'Share Tech Mono', ui-monospace, monospace;
  --stripe: repeating-linear-gradient(-45deg, #ffe500 0 14px, #0a0a0a 14px 28px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--body);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 100vh;
}

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

.fx-scan {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0.18;
  mix-blend-mode: overlay;
  background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(0, 0, 0, 0.2) 2px 3px);
}

.top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  background: var(--panel);
}

.stripe { height: 6px; background: var(--stripe); opacity: 0.9; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }

.emblem {
  width: 24px;
  height: 34px;
  flex: none;
  background: linear-gradient(180deg, #fff 0%, var(--yellow) 52%, #c9a300 100%);
  -webkit-mask: url("../icons/Super_Earth.svg") center / contain no-repeat;
  mask: url("../icons/Super_Earth.svg") center / contain no-repeat;
}

.wordmark { display: flex; flex-direction: column; line-height: 1; }
.wordmark b { font-family: var(--head); font-weight: 700; letter-spacing: 0.22em; font-size: 17px; }
.wordmark em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 4px;
}

.round {
  flex: 1;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 229, 0, 0.04);
  font-family: var(--head);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 13px;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}
.chip:hover { color: var(--yellow); }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.layout { display: grid; grid-template-columns: 1fr 280px; min-height: 0; }

.board {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(60% 60% at 50% 45%, rgba(255, 229, 0, 0.04), transparent 70%),
    linear-gradient(rgba(255, 229, 0, 0.035) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(255, 229, 0, 0.035) 1px, transparent 1px) 0 0 / 40px 40px;
}

#map {
  display: block;
  outline: 1px solid var(--line-strong);
  outline-offset: 3px;
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.6);
  cursor: crosshair;
  image-rendering: pixelated;
  touch-action: manipulation;
}

.banner {
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: rgba(7, 7, 7, 0.9);
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--yellow);
  font-family: var(--head);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  pointer-events: none;
  max-width: calc(100% - 32px);
}

.tooltip {
  position: absolute;
  padding: 6px 10px;
  background: rgba(7, 7, 7, 0.94);
  border: 1px solid var(--line);
  pointer-events: none;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12px;
}

.toast {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: #2a0b0b;
  border: 1px solid #7a1f1f;
  border-left: 4px solid var(--red);
  color: #ffd6d6;
  font-family: var(--mono);
  font-size: 13px;
  pointer-events: none;
}

.side {
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}

.side h2 {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--yellow);
  margin: 4px 0 10px;
}
.side h2:not(:first-child) { margin-top: 24px; }

.standings, .history { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }

.standings li, .history li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  background: var(--panel-2);
  border-left: 2px solid transparent;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.standings li.me { border-left-color: var(--yellow); background: rgba(255, 229, 0, 0.07); }
.standings .name, .history .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standings .num, .history .num { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.history li { font-size: 13px; }
.muted { color: var(--muted); background: none !important; }

.tag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  padding: 0 4px;
}
.tag--terminid { color: #ff8a00; }
.tag--automaton { color: #ff4d4d; }
.tag--illuminate { color: #c58cf0; }
.tag--human { color: var(--yellow); }

.howto { margin-top: 24px; color: var(--muted); }
.howto summary {
  cursor: pointer;
  color: var(--text);
  font-family: var(--head);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 13px;
}
.howto ul { padding-left: 18px; margin: 8px 0 0; }
.howto li { margin-bottom: 5px; }

.back {
  display: inline-block;
  margin-top: 22px;
  font-family: var(--head);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}
.back:hover { color: var(--yellow); }

.bar {
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 10px 16px;
  border-top: 2px solid var(--yellow);
  background: var(--panel);
  flex-wrap: wrap;
}

.stat { display: flex; flex-direction: column; min-width: 100px; font-variant-numeric: tabular-nums; }
.stat span:last-child { font-family: var(--head); font-weight: 700; font-size: 20px; color: var(--yellow); line-height: 1.1; }
.label { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.2em; color: var(--muted); }

.ratio { display: flex; align-items: center; gap: 10px; }
.ratio input { width: 170px; accent-color: var(--yellow); }
.ratio output { width: 44px; font-family: var(--head); font-weight: 700; font-size: 18px; }

.hint { color: var(--muted); flex: 1; text-align: right; min-width: 200px; }

dialog {
  border: 1px solid var(--line-strong);
  border-top: 4px solid var(--yellow);
  background: var(--panel);
  color: var(--text);
  padding: 20px;
  width: min(320px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
dialog h3 { margin: 0 0 14px; font-family: var(--head); letter-spacing: 0.1em; text-transform: uppercase; }
dialog label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
dialog input:not([type="color"]) {
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-family: var(--body);
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
}
dialog input[type="color"] { width: 100%; height: 36px; border: 1px solid var(--line); background: var(--bg); padding: 2px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 6px 0 0; padding: 0; }
dialog button {
  padding: 8px 16px;
  border: 0;
  background: linear-gradient(180deg, var(--yellow), var(--yellow-deep));
  color: #111;
  font-family: var(--head);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}
dialog button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto auto; }
  .board { padding: 8px; height: calc((100vw - 16px) * 0.6 + 16px); }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .hint { text-align: left; flex-basis: 100%; }
  .bar { gap: 16px; }
  .top { gap: 10px; flex-wrap: wrap; }
  .round { order: 3; flex-basis: 100%; font-size: 11px; }
}
