:root {
  --bg: #17140f;
  --panel: #221e17;
  --line: #3a3326;
  --text: #f1e8d4;
  --muted: #a3967c;
  --accent: #e3b23c;
  --ok: #7ccf6b;
  --bad: #e2574c;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(ellipse at top, #2a2318, var(--bg) 60%);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font: 700 28px/1 Georgia, "Times New Roman", serif;
  color: var(--accent);
  letter-spacing: .02em;
}

h2 {
  margin: 18px 0 8px;
  font: 600 13px/1 system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

#timer { font: 700 24px/1 ui-monospace, Consolas, monospace; font-variant-numeric: tabular-nums; }

.muted { color: var(--muted); }
.small { font-size: 12px; margin: 0 0 6px; }

.pill { margin-left: auto; padding: 3px 10px; border-radius: 99px; font-size: 12px; background: var(--line); }
.pill[data-s="online"] { background: #22401d; color: var(--ok); }
.pill[data-s="offline"], .pill[data-s="replaced"] { background: #4a1f1b; color: var(--bad); }

button {
  font: inherit;
  color: #1b150b;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
}
button.link { background: none; color: var(--muted); padding: 0; text-decoration: underline; }

main {
  display: grid;
  grid-template-columns: minmax(0, 960px) minmax(360px, 1fr);
  gap: 20px;
  padding: 16px 20px;
  align-items: start;
}

.board { position: relative; }

#field {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 8px;
  box-shadow: 0 0 0 1px var(--line), 0 12px 40px rgba(0, 0, 0, .5);
  touch-action: none;
  cursor: crosshair;
}

#minimap {
  position: absolute;
  top: 10px;
  right: 10px;
  width: clamp(110px, 22%, 210px);
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
  pointer-events: none;
  image-rendering: pixelated;
}

.overlay {
  position: absolute;
  inset: 0 0 auto 0;
  aspect-ratio: 3 / 2;
  display: grid;
  place-items: center;
  background: rgba(15, 12, 8, .72);
  border-radius: 8px;
  backdrop-filter: blur(2px);
}
.overlay[hidden] { display: none; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 24px;
  max-width: 90%;
  text-align: center;
}
.card.wide { width: 720px; max-height: 90%; overflow: auto; }
.card h2 { margin-top: 0; color: var(--accent); font-size: 18px; }

.hint { margin: 10px 0 0; font-size: 12px; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 5px 4px; text-align: center; border-bottom: 1px solid var(--line); }
th { font-size: 16px; font-weight: 400; }
th small, td small { display: block; font-size: 10px; color: var(--muted); }
td b { font-size: 14px; }
td.name { text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
td.name small { display: inline; }
td.nil { color: var(--line); }
td.total { font-weight: 700; font-size: 16px; color: var(--accent); }
tr.me { background: rgba(227, 178, 60, .1); }
tr.off { opacity: .55; }

i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: baseline; }

ul, ol { list-style: none; padding: 0; margin: 0; }
#legend li, #fame li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}
#legend b, #fame b { margin-left: auto; color: var(--accent); }
#legend small, #fame small { color: var(--muted); min-width: 92px; text-align: right; }
.sw { width: 24px; height: 24px; border-radius: 5px; display: grid; place-items: center; font-size: 14px; }

dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  width: min(380px, 92vw);
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin-top: 0; color: var(--accent); font-size: 20px; text-transform: none; letter-spacing: 0; }
dialog input {
  width: 100%;
  margin: 8px 0 14px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

@media (max-width: 1100px) {
  main { grid-template-columns: 1fr; padding: 12px 16px; }
  header { padding: 12px 16px; }
}
