:root {
  --bg: #0c1a24;
  --panel: #10202c;
  --line: #2e5a74;
  --ink: #eef6f8;
  --muted: #9ab8c4;
  --gold: #ffd84a;
  --green: #5ad06a;
  --red: #ff5a4a;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  font-family: "VT323", "Courier New", monospace;
  font-size: 18px;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 12px),
    radial-gradient(ellipse at 50% 20%, #17384c, var(--bg) 70%);
  background-color: var(--bg);
}

.stage {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 3px #000, 0 0 0 6px #24485c, 0 20px 60px rgba(0, 0, 0, 0.7);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- HUD ---------- */

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 8px 10px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(6, 14, 20, 0.88), rgba(6, 14, 20, 0));
}

.hud .row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 10px;
}

.hud button { pointer-events: auto; }

h1 {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  font-weight: 400;
  font-size: clamp(9px, 2vmin, 13px);
  color: var(--gold);
  text-shadow: 2px 2px 0 #5a3a00;
}

.links { display: flex; gap: 6px; }

.stats {
  margin-top: 4px;
  font-size: clamp(16px, 3vmin, 22px);
  color: var(--muted);
}

.stats b { color: var(--ink); font-weight: 400; }

.home {
  position: absolute;
  left: 10px;
  bottom: 6px;
  font-size: 18px;
  color: var(--muted);
  text-decoration: none;
  text-shadow: 1px 1px 0 #000, 0 0 6px #000;
}

.home:hover { color: var(--ink); text-decoration: underline; }

button {
  font-family: "VT323", "Courier New", monospace;
  font-size: 17px;
  line-height: 1;
  color: var(--ink);
  background: rgba(8, 18, 26, 0.85);
  border: 2px solid var(--line);
  border-radius: 0;
  padding: 4px 7px;
  cursor: pointer;
  box-shadow: 2px 2px 0 #000;
}

button:hover { border-color: #4a8aaa; }

button:disabled { opacity: 0.4; cursor: default; }

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

/* ---------- Overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(4, 10, 14, 0.55);
}

.card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 16px 16px 18px;
  background: var(--panel);
  border: 3px solid var(--line);
  box-shadow: 5px 5px 0 #000;
  text-align: center;
}

.card h2 {
  margin: 0 0 10px;
  font-family: "Press Start 2P", monospace;
  font-weight: 400;
  font-size: clamp(12px, 3.4vmin, 17px);
  line-height: 1.5;
  color: var(--gold);
  text-shadow: 3px 3px 0 #5a3a00;
}

.card h3 {
  margin: 14px 0 6px;
  font-family: "Press Start 2P", monospace;
  font-weight: 400;
  font-size: 10px;
  color: var(--muted);
}

.card p { margin: 0 0 10px; font-size: 20px; }

.card ul {
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  text-align: left;
  font-size: 18px;
  color: var(--muted);
}

.card li { margin: 5px 0; }

.card li b { color: var(--ink); font-weight: 400; }

.card .small { font-size: 18px; color: var(--muted); }

.faceoff {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 4px 0 10px;
}

.faceoff figure { margin: 0; }

.faceoff figcaption {
  margin-top: 4px;
  font-size: 18px;
  color: var(--muted);
}

.portrait {
  display: block;
  width: 72px;
  height: 96px;
  margin: 0 auto;
  image-rendering: pixelated;
  background: #0a1620;
  border: 2px solid var(--line);
}

.vs {
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  color: var(--red);
}

.board {
  width: 100%;
  border-collapse: collapse;
  font-size: 19px;
}

.board td {
  padding: 3px 6px;
  border-bottom: 1px solid #1e3a4c;
  text-align: left;
}

.board td:last-child { text-align: right; }

.board tr.you td { color: var(--gold); }

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border: 1px solid #000;
  vertical-align: middle;
}

button.primary {
  margin-top: 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  padding: 12px 16px;
  color: #2a1a00;
  background: var(--gold);
  border-color: #fff2a8;
  box-shadow: 3px 3px 0 #000;
}

button.primary:hover { background: #ffe47a; }

button.primary:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
