:root {
  --bg: #0b0c16;
  --panel: #14152b;
  --panel-2: #1b1d3a;
  --line: #ffffff;
  --ink: #ffffff;
  --muted: #9aa0b4;
  --accent: #ffd23f;
  --go: #2a9d4f;
  --blue: #2b59c3;
  --bad: #ff6b6b;
  --pixel: 'Press Start 2P', ui-monospace, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background:
    linear-gradient(rgba(11, 12, 22, 0.88), rgba(11, 12, 22, 0.96)),
    repeating-conic-gradient(#1b1d3a 0 25%, #14152b 0 50%) 0 0 / 32px 32px;
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

a { color: inherit; }

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

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px clamp(16px, 4vw, 40px);
  background: #000;
  border-bottom: 3px solid var(--line);
}

.logo {
  text-decoration: none;
  font-family: var(--pixel);
  line-height: 1.3;
  display: flex;
  flex-direction: column;
}

.logo-a { font-size: 11px; color: var(--muted); letter-spacing: 0.15em; }
.logo-b { font-size: clamp(20px, 4vw, 28px); color: var(--accent); text-shadow: 3px 3px 0 #b5470a; }

.account { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.who { font-family: var(--pixel); font-size: 11px; color: var(--accent); }

/* ---------------------------------------------------------------- buttons */

.btn {
  font: 600 15px/1 system-ui, sans-serif;
  color: #fff;
  background: var(--go);
  border: 2px solid #000;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.25), 3px 3px 0 #000;
  padding: 12px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  touch-action: manipulation;
}

.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translate(2px, 2px); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.3), 1px 1px 0 #000; }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn.small { padding: 8px 12px; min-height: 36px; font-size: 14px; }
.btn.ghost { background: var(--panel-2); }
.btn.blue { background: var(--blue); }
.btn:disabled { opacity: 0.6; cursor: default; }

/* ---------------------------------------------------------------- content */

main { max-width: 1100px; margin: 0 auto; padding: 24px clamp(16px, 4vw, 40px) 40px; }

.intro h1 { font-family: var(--pixel); font-size: clamp(18px, 3vw, 24px); margin: 8px 0 12px; }
.intro p { color: var(--muted); max-width: 60ch; margin: 0 0 24px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 24px;
}

.card {
  background: var(--panel);
  border: 3px solid var(--line);
  box-shadow: 0 0 0 3px #000, 6px 6px 0 #000;
  display: flex;
  flex-direction: column;
}

.cover {
  aspect-ratio: 16 / 9;
  background: #000 center / cover no-repeat;
  image-rendering: pixelated;
  border-bottom: 3px solid #000;
  display: block;
}

.card-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card h2 { font-family: var(--pixel); font-size: 15px; margin: 0; color: var(--accent); line-height: 1.4; }
.card p { margin: 0; color: #d6d8e8; font-size: 15px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: auto; }
.stat { background: #0b0c16; border: 2px solid #2b2d42; padding: 8px 10px; min-width: 0; }
.stat .k { display: block; font-size: 12px; color: var(--muted); }
.stat .v { display: block; font-family: var(--pixel); font-size: 11px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.actions { display: flex; gap: 10px; }
.actions .btn:first-child { flex: 1; }

.card.soon { border-style: dashed; border-color: #4a4e69; box-shadow: none; justify-content: center; align-items: center; text-align: center; min-height: 280px; }
.card.soon h2 { color: var(--muted); }
.card.soon p { color: var(--muted); max-width: 26ch; }

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 0 16px 32px; }

/* ---------------------------------------------------------------- dialogs */

dialog {
  width: min(400px, calc(100% - 32px));
  background: var(--panel);
  color: var(--ink);
  border: 3px solid var(--line);
  box-shadow: 0 0 0 3px #000, 6px 6px 0 #000;
  padding: 20px;
}

dialog::backdrop { background: rgba(8, 8, 20, 0.75); }

.tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.tab {
  flex: 1;
  font: 600 14px system-ui, sans-serif;
  padding: 10px;
  background: #0b0c16;
  color: var(--muted);
  border: 2px solid #2b2d42;
  cursor: pointer;
}
.tab[aria-selected='true'] { color: #000; background: var(--accent); border-color: #000; }

dialog label { display: block; margin: 12px 0 4px; font-size: 13px; color: #c9cbe0; }
dialog .row { display: flex; gap: 8px; }
dialog .row.end { justify-content: flex-end; margin-top: 16px; }

dialog input {
  flex: 1;
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  padding: 10px;
  border: 2px solid #4a4e69;
  background: #0b0c16;
  color: #fff;
}
dialog input:focus { outline: none; border-color: var(--accent); }

.note { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.error { margin: 6px 0 0; min-height: 1.3em; font-size: 14px; color: var(--bad); }

.board-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.board-head h2 { font-family: var(--pixel); font-size: 13px; color: var(--accent); margin: 0; line-height: 1.5; }

#board-list { list-style: none; padding: 0; margin: 16px 0 0; counter-reset: rank; }
#board-list li {
  counter-increment: rank;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid #2b2d42;
}
#board-list li::before { content: counter(rank); width: 2ch; color: var(--muted); font-family: var(--pixel); font-size: 11px; }
#board-list li .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#board-list li .score { font-family: var(--pixel); font-size: 11px; }
#board-list li.me { background: rgba(255, 210, 63, 0.15); }
#board-list .empty { color: var(--muted); justify-content: center; }
#board-list .empty::before { content: none; }

@media (prefers-reduced-motion: reduce) {
  .btn:active { transform: none; }
}
