:root {
  --bg: #0b1220;
  --panel: #121b2e;
  --panel-2: #18233a;
  --line: #24314d;
  --text: #e9edf5;
  --muted: #8d99b3;
  --gold: #d4af37;
  --gold-soft: rgba(212, 175, 55, 0.14);
  --good: #4ade80;
  --bad: #f87171;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
/* The hidden attribute must win over component display rules (e.g. .btn). */
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--text); font-family: 'Montserrat', system-ui, sans-serif; line-height: 1.5; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 900; font-size: 22px; letter-spacing: 0.04em; text-decoration: none; }
.brand span { color: var(--gold); }
.account { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.account img { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--gold); }
.btn { background: var(--gold); color: #111; border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 800; text-decoration: none; display: inline-block; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 6px 12px; }

.wrap { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.hero h1 { font-size: clamp(32px, 6vw, 52px); font-weight: 900; font-style: italic; line-height: 1.05; }
.hero p { color: var(--muted); max-width: 620px; margin-top: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }

.round-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.round-head h2 { font-size: 20px; font-weight: 800; }
.pill { font-size: 13px; font-weight: 800; letter-spacing: 0.08em; padding: 4px 10px; border-radius: 999px; background: var(--gold-soft); color: var(--gold); }
.pill.locked { background: rgba(141, 153, 179, 0.15); color: var(--muted); }
.agents { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.agent { position: relative; background: var(--panel-2); border: 2px solid var(--line); border-radius: 14px; padding: 12px 8px; color: var(--text); display: grid; justify-items: center; gap: 6px; overflow: hidden; transition: border-color 0.15s, transform 0.15s; }
.agent:not(:disabled):hover { border-color: var(--gold); transform: translateY(-2px); }
.agent:disabled { cursor: default; }
.agent img { width: 64px; height: 64px; border-radius: 10px; }
.agent .name { font-weight: 800; font-size: 14px; }
.agent .pct { font-size: 13px; color: var(--muted); font-weight: 700; }
.agent .bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--gold); transition: width 0.4s; }
.agent.mine { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.agent.bottom { border-color: var(--good); }
.agent.bottom .name::after { content: ' (bottom)'; color: var(--good); }
.round-note { margin-top: 14px; color: var(--muted); font-size: 14px; }
.round-note.error { color: var(--bad); }
.empty { color: var(--muted); }

.winners { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.winner { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; gap: 12px; align-items: center; }
.winner.first { border-color: var(--gold); }
.winner img { width: 44px; height: 44px; border-radius: 50%; }
.winner small { color: var(--muted); display: block; font-size: 12px; letter-spacing: 0.06em; }

.tabs { display: flex; gap: 8px; overflow-x: auto; }
.tab { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 8px 16px; font-weight: 700; white-space: nowrap; }
.tab.active { background: var(--gold); border-color: var(--gold); color: #111; }

.board-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.board-head h2 { font-size: 20px; font-weight: 800; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { background: transparent; border: 0; color: var(--muted); padding: 6px 12px; font-weight: 700; font-size: 13px; }
.seg button.active { background: var(--panel-2); color: var(--gold); }
.board { list-style: none; display: grid; gap: 6px; }
.row { display: grid; grid-template-columns: 40px 36px 1fr auto; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); }
.row .rank { font-weight: 900; color: var(--muted); text-align: center; }
.row:nth-child(-n+3) .rank { color: var(--gold); }
.row img, .row .noimg { width: 36px; height: 36px; border-radius: 50%; background: var(--line); }
.row .who { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .score { font-weight: 800; }
.row .score small { color: var(--muted); font-weight: 600; margin-left: 6px; }
.me { margin-bottom: 10px; }
.me .row { border: 1px solid var(--gold); }

@media (max-width: 640px) {
  .agents { grid-template-columns: repeat(3, 1fr); }
  .agent img { width: 52px; height: 52px; }
}
