:root {
  --bg: #12101a;
  --panel: #1d1a29;
  --line: #34304a;
  --text: #ece8f5;
  --muted: #9a93b0;
  --gold: #e9b44c;
  --left: #3b8beb;
  --right: #e5484d;
  --good: #46c46d;
}
* { box-sizing: border-box; }
/* Make the hidden attribute win over display rules like .overlay/.narrow { display:flex } */
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 50% -20%, #2b2342, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
}
header { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; border-bottom: 1px solid var(--line); }
h1 { margin: 0; font-size: 26px; letter-spacing: 1px; }
h1 span { color: var(--gold); }
h2 { margin: 0 0 12px; font-size: 20px; }
h3 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
a { color: var(--gold); }
.screen { padding: 20px; max-width: 1480px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.narrow { max-width: 440px; margin: 40px auto; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.gap { gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.status { color: var(--gold); min-height: 1.2em; margin: 0; }
.pill { font-size: 13px; background: var(--line); padding: 2px 10px; border-radius: 99px; vertical-align: middle; }
input { background: #120f1b; border: 1px solid var(--line); color: var(--text); padding: 9px 12px; border-radius: 7px; font-size: 15px; }
button { background: #2b2640; color: var(--text); border: 1px solid var(--line); padding: 9px 16px; border-radius: 7px; cursor: pointer; font-size: 15px; font-weight: 600; }
button:hover:not(:disabled) { border-color: var(--gold); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--gold); color: #1b1404; border-color: var(--gold); }
button.ghost { background: transparent; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; max-height: 58vh; overflow-y: auto; padding: 4px; }
.card { background: #15121f; border: 2px solid var(--line); border-radius: 9px; padding: 6px; cursor: pointer; text-align: center; position: relative; }
.card.selected { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(233,180,76,.25); }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: #241f33; }
.card .name { font-size: 12px; font-weight: 700; margin: 4px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta { font-size: 11px; color: var(--muted); }
.card .stats { font-size: 11px; display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.badge { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.7); font-size: 11px; padding: 1px 6px; border-radius: 4px; }

.game-layout { display: grid; grid-template-columns: 200px 1fr 200px; gap: 16px; align-items: center; }
.banner-row { display: flex; justify-content: center; margin-bottom: 10px; }
.below-board { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 10px; }
/* --side-h is set from the board's drawn height (~82% of it) in client.js.
   Rows share the height evenly and shrink to fit, so there's never a scrollbar. */
.side { display: flex; flex-direction: column; height: var(--side-h, auto); min-height: 0; }
.side .roster { flex: 1; min-height: 0; overflow: hidden; gap: 4px; }
.side .roster-item { flex: 1 1 0; min-height: 0; max-height: 58px; padding: 3px 5px; overflow: hidden; }
.side .roster-item img, .side .roster-item .flag-thumb { height: 100%; max-height: 34px; width: auto; aspect-ratio: 1; flex-shrink: 0; }
.side .roster > p { flex: 0 0 auto; margin: 0; }
.ri-text { min-width: 0; flex: 1; line-height: 1.3; }
.ri-top { display: flex; justify-content: space-between; gap: 6px; }
.ri-top b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-top .copies { flex-shrink: 0; }
.ri-stats { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.center { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.center-row { justify-content: center; }
#board { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; }
.turn-banner { font-weight: 700; padding: 6px 18px; border-radius: 99px; background: var(--line); }
.turn-banner.mine { background: var(--good); color: #062b12; }
.player-tag { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 12px; border-radius: 8px; font-weight: 700; margin-bottom: 8px; }
.player-tag.p0 { background: rgba(59,139,235,.2); border: 1px solid var(--left); }
.player-tag.p1 { background: rgba(229,72,77,.2); border: 1px solid var(--right); }
.player-tag small { color: var(--muted); }
.player-tag.active { box-shadow: 0 0 12px var(--gold); }
.roster { display: flex; flex-direction: column; gap: 6px; }
.roster-item { display: flex; gap: 8px; align-items: center; font-size: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px; }
.roster-item.dead { opacity: .35; text-decoration: line-through; }
.roster-item.pickable { cursor: pointer; }
.roster-item.pickable:hover { border-color: var(--gold); }
.roster-item.picked { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(233,180,76,.25); }
.roster-item.done-placing { opacity: .55; }
.roster-item img { width: 32px; height: 32px; border-radius: 4px; object-fit: cover; background: #241f33; }
.game-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.unit-info { min-height: 120px; display: flex; gap: 14px; }
.unit-info img { width: 96px; height: 96px; border-radius: 8px; object-fit: cover; background: #241f33; }
.unit-info table { font-size: 13px; border-collapse: collapse; }
.unit-info td { padding: 1px 10px 1px 0; }
.log { max-height: 180px; overflow-y: auto; }
.log ol { margin: 0; padding-left: 20px; font-size: 13px; display: flex; flex-direction: column-reverse; gap: 2px; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; }
.overlay .panel { margin: 0; text-align: center; }

@media (max-width: 1250px) {
  .game-layout { grid-template-columns: 1fr; }
  .side { display: none; }
  .game-bottom { grid-template-columns: 1fr; }
}

/* ---------- navigation, menus, collection ---------- */
nav { display: flex; align-items: center; gap: 8px; }
#whoami { color: var(--gold); font-weight: 600; margin-left: 6px; }
select { background: #120f1b; border: 1px solid var(--line); color: var(--text); padding: 9px 12px; border-radius: 7px; font-size: 15px; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.type-card h3 { color: var(--gold); font-size: 18px; text-transform: none; letter-spacing: 0; }
.type-card p { line-height: 1.45; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab { padding: 6px 12px; font-size: 13px; border-color: var(--c); background: transparent; }
.tab.active { background: var(--c); color: #120f1b; }
.card-grid.tall { max-height: none; }
.card .badge.right { left: auto; right: 8px; color: var(--gold); }
.card .score { font-size: 11px; color: var(--gold); margin-top: 3px; font-weight: 600; }
.card[draggable="true"] { cursor: grab; }
#summoner-grid { margin-top: 10px; }

/* ---------- rank slots ---------- */
.rank-slots { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin: 12px 0 16px; }
.slot { position: relative; background: #15121f; border: 2px dashed var(--line); border-radius: 9px; padding: 6px; min-height: 190px; text-align: center; cursor: pointer; font-size: 11px; }
.slot.filled { border-style: solid; }
.slot.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(233,180,76,.25); }
.slot.drop-ok { border-color: var(--good); background: rgba(70,196,109,.12); }
.slot.drop-bad { border-color: var(--right); background: rgba(229,72,77,.1); }
.slot-head { display: flex; flex-direction: column; margin-bottom: 4px; }
.slot-head b { font-size: 13px; }
.slot-head span { color: var(--muted); }
.slot img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: #241f33; }
.slot .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.slot .stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.slot .score { color: var(--gold); font-weight: 600; }
.slot-empty { color: var(--muted); padding-top: 50px; }
.slot-clear { position: absolute; top: 4px; right: 4px; padding: 0 7px; font-size: 14px; line-height: 20px; }
.pool-title { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--text); }

/* ---------- game extras ---------- */
.preview { margin-top: 6px; font-size: 13px; }
.good { color: var(--good); font-weight: 600; }
.bad { color: var(--right); font-weight: 600; }

@media (max-width: 1000px) {
  .rank-slots { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- setup (placement) ---------- */
.setup-panel { width: min(960px, 100%); margin: 0; }
.tray { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 8px; }
.tray-item { display: flex; gap: 8px; align-items: center; font-size: 12px; background: #15121f; border: 2px solid var(--line); border-radius: 8px; padding: 5px; cursor: grab; }
.tray-item img { width: 40px; height: 40px; border-radius: 5px; object-fit: cover; background: #241f33; }
.tray-item.picked { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(233,180,76,.25); }
.tray-item.done { opacity: .4; cursor: default; }
.copies { color: var(--gold); font-weight: 700; }
.hidden-token { width: 96px; height: 96px; border-radius: 8px; background: #3a1d24; border: 3px solid var(--right); display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 700; color: rgba(255,255,255,.75); flex-shrink: 0; }
.hidden-token.flag { border-color: var(--gold); color: #fff; }
.flag-thumb { width: 40px; height: 40px; border-radius: 5px; background: var(--gold); color: #1b1404; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.flag-thumb.small { width: 32px; height: 32px; font-size: 18px; border-radius: 4px; }
.flag-thumb.unknown-thumb { background: #3a1d24; color: rgba(255,255,255,.75); border: 2px solid var(--right); }
.roster-item.unknown { opacity: .8; }
.card.pool .meta:first-of-type { margin-top: 4px; }
.card.pool .score { font-size: 12px; }
.slot .meta { font-size: 11px; color: var(--muted); }
.slot .meta:first-of-type { margin-top: 4px; }
.type-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.instructions { margin-top: 16px; }
.instructions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 8px 28px; }
.instructions h3 { color: var(--gold); font-size: 14px; margin-top: 10px; }
.instructions ul { margin: 0; padding-left: 18px; line-height: 1.5; font-size: 14px; }
.instructions li { margin-bottom: 4px; }
.rank-table { border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.rank-table th, .rank-table td { border: 1px solid var(--line); padding: 3px 7px; text-align: center; }
.rank-table th { color: var(--muted); font-weight: 600; text-align: left; }
.collection-group { margin-bottom: 18px; }
.collection-group h3 { font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--gold); margin: 6px 0 10px; }
.collection-group h3 .muted { font-size: 13px; font-weight: 400; }
.remember { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
.remember input { width: 16px; height: 16px; accent-color: var(--gold); }
.saved-title { margin: 0; }
#saved-teams .divider { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
#saved-team-select { min-width: 180px; }
table.leaderboard { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; }
table.leaderboard th, table.leaderboard td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; }
table.leaderboard th:nth-child(2), table.leaderboard td:nth-child(2) { text-align: left; }
table.leaderboard th:first-child, table.leaderboard td:first-child { text-align: center; width: 48px; }
table.leaderboard th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
table.leaderboard tbody tr:nth-child(-n+3) td:first-child { color: var(--gold); font-weight: 700; }
table.leaderboard tr.me td { background: rgba(233,180,76,.12); font-weight: 600; }
.splinter-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-top: 10px; }
.splinter-btn { display: flex; flex-direction: column; gap: 4px; padding: 22px 10px; border: 2px solid var(--c); background: transparent; }
.splinter-btn b { font-size: 20px; color: var(--c); }
.splinter-btn span { font-size: 12px; color: var(--muted); font-weight: 400; }
.splinter-btn:hover { background: color-mix(in srgb, var(--c) 18%, transparent); border-color: var(--c); }
@media (max-width: 800px) { .splinter-grid { grid-template-columns: repeat(2, 1fr); } }
table.legend { border-collapse: collapse; font-size: 14px; }
table.legend td { padding: 2px 10px 2px 0; vertical-align: top; }
table.legend td.sym { font-weight: 700; color: var(--gold); white-space: nowrap; }
.instructions-wrap { margin-top: 16px; }
.instructions p.intro { margin: 4px 0 8px; line-height: 1.55; font-size: 15px; }
table.guide-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 6px; }
table.guide-table th, table.guide-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }
table.guide-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
table.guide-table td:first-child, table.guide-table td:nth-child(2) { white-space: nowrap; font-weight: 600; }
/* Board labels: numbers 1-16 on top, letters A-L down the left side */
.board-wrap { display: grid; grid-template-columns: 20px minmax(0, 960px); grid-template-rows: 20px auto; width: min(980px, 100%); }
.board-cols { display: grid; grid-template-columns: repeat(16, 1fr); align-items: end; }
.board-rows { display: grid; grid-template-rows: repeat(12, 1fr); }
.board-cols span, .board-rows span { display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.board-cols span { padding-bottom: 3px; }
.board-rows span { padding-right: 4px; }
/* Turn clock above the active player's side bar */
.side-timer { flex: 0 0 auto; margin-bottom: 6px; padding: 6px 10px; border-radius: 8px; text-align: center;
  font-weight: 700; font-size: 16px; background: rgba(229,72,77,.18); color: #ffb3b5; border: 1px solid var(--right); visibility: hidden; }
.side-timer.mine { background: var(--good); color: #062b12; border-color: var(--good); }
.about-text p { line-height: 1.6; font-size: 15px; margin: 0 0 12px; max-width: 900px; }
