:root {
  --bg: #04070c;
  --panel: #0a0f17;
  --line: #1a2231;
  --text: #d6dee9;
  --muted: #5d6879;
  --gold: #e9b949;
  --blue: #2f8bff;
  --red: #ff3347;
  --font: 'Barlow Condensed', 'Kanit', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 300px at 50% -100px, #2a0c12aa, transparent), var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 0.85em; background: #121a26; padding: 1px 5px; border-radius: 3px; text-transform: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.spacer { flex: 1; }
.panel { background: var(--panel); border: 1px solid var(--line); padding: 12px 14px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lbl { color: var(--muted); letter-spacing: 0.18em; font-size: 13px; }

.btn, .seg button, .tabs button {
  background: #0f1622; border: 1px solid #222c3c; padding: 7px 14px; cursor: pointer;
  letter-spacing: 0.14em; font-size: 14px; text-transform: uppercase; text-decoration: none; color: var(--text);
  white-space: nowrap; display: inline-flex; align-items: center;
}
.btn:hover, .seg button:hover { border-color: #3a475c; }
.btn.gold { border-color: #7c6227; color: var(--gold); }
.btn.gold:hover { border-color: var(--gold); }
.btn.toggle.on { border-color: var(--gold); color: var(--gold); background: #1b1608; }
.btn:disabled { opacity: 0.4; cursor: default; }
.seg { display: inline-flex; }
.seg button + button { border-left: 0; }
.seg button.on { background: #18243a; color: #9ec5ff; border-color: #2c4d80; }
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; letter-spacing: 0.05em; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; }
.brand { letter-spacing: 0.3em; font-weight: 700; color: var(--gold); }
.conn { font-size: 13px; letter-spacing: 0.1em; color: var(--muted); }
.conn::before { content: '●'; margin-right: 6px; color: #f55; }
.conn.ok::before { color: #3ddc84; }
.mode { font-size: 13px; letter-spacing: 0.15em; padding: 3px 10px; }
.mode.blue { background: var(--blue); color: #fff; }
.mode.red { background: var(--red); color: #fff; }

/* board preview */
.boardwrap { position: relative; overflow: hidden; }
#board { transform-origin: 0 0; width: 1920px; }

/* picker */
.pickerhead { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.turn {
  border: 1px solid var(--blue); padding: 6px 14px; min-width: 300px;
  font-size: 22px; letter-spacing: 0.14em; color: #9ec5ff; text-transform: uppercase; white-space: nowrap;
}
.turn small { font-size: 12px; letter-spacing: 0.15em; color: var(--muted); margin-left: 10px; }
.turn.red { border-color: var(--red); color: #ff9aa5; }
.turn.edit { border-color: #fff; color: #fff; }
.turn.done { border-color: var(--gold); color: var(--gold); }
.search { flex: 1; background: #070b12; border: 1px solid #222c3c; padding: 9px 12px; outline: none; }
.search:focus { border-color: #3d5378; }
.roles { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.roles:empty { display: none; }
.roles button { background: #0f1622; border: 1px solid #222c3c; padding: 3px 12px; cursor: pointer; letter-spacing: 0.1em; text-transform: uppercase; }
.roles button.on { border-color: var(--gold); color: var(--gold); }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px;
  max-height: 380px; overflow-y: auto; padding-right: 4px;
}
.hero {
  background: none; border: 0; padding: 0; cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.hero .art { position: relative; inset: auto; width: 100%; aspect-ratio: 1; border: 1px solid #1d2635; }
.hero .art.noimg span { font-size: 24px; }
.hero > span {
  font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #0d131d; padding: 2px 2px;
}
.hero:hover:not(:disabled) .art { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.hero:disabled { cursor: not-allowed; opacity: 0.22; filter: grayscale(1); }
.hero.locked:disabled { opacity: 0.35; }
.hero.locked .art::after { content: 'FEARLESS'; position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; text-align: center; background: #000c; letter-spacing: 0.1em; }
.hero.first .art { box-shadow: 0 0 0 2px #9ec5ff; }
.hint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }
.hint b { color: var(--text); font-weight: 600; }

/* series */
.series .row { gap: 10px; }
.num { width: 64px; background: #070b12; border: 1px solid #222c3c; padding: 6px 8px; }
.history { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.history:empty { display: none; }
.hist { display: flex; align-items: center; gap: 10px; font-size: 14px; letter-spacing: 0.05em; padding: 4px 8px; background: #0d131d; }
.hist .g { color: var(--gold); width: 40px; }
.hist .w { color: #3ddc84; }
.hist .icons { display: flex; gap: 2px; }
.hist .icons .art { position: relative; width: 26px; height: 26px; inset: auto; }
.hist .icons .art.noimg span { font-size: 10px; }
.hist .vs { color: var(--muted); }
.hist .b { color: #9ec5ff; } .hist .r { color: #ff9aa5; }

/* settings */
.tabs { display: flex; gap: 0; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button + button { border-left: 0; }
.tabs button.on { color: var(--gold); border-color: #7c6227; background: #1b1608; }
.tab { display: none; }
.tab.on { display: block; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px 18px; align-items: start; }
.form .wide { grid-column: 1 / -1; }
.form label:not(.chk):not(.btn) { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; letter-spacing: 0.06em; }
.form input:not([type=checkbox]):not([type=color]):not([type=range]), .form select, .form textarea, .teamcol input {
  background: #070b12; border: 1px solid #222c3c; padding: 7px 10px; color: var(--text); outline: none; width: 100%;
}
.form input:focus, .form textarea:focus, .teamcol input:focus { border-color: #3d5378; }
.form input[type=color] { width: 70px; height: 34px; background: none; border: 1px solid #222c3c; padding: 2px; }
.form p { margin: 0 0 8px; line-height: 1.6; }
.mono { font-family: ui-monospace, Menlo, monospace !important; font-size: 13px; }
#laneInputs input { width: 90px !important; }
.btn.file { cursor: pointer; }
.url { padding: 6px 10px; font-size: 14px; }
#lanLinks .row { margin-bottom: 6px; }

.teamgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.teamcol { display: flex; flex-direction: column; gap: 8px; border-top: 3px solid #333; padding-top: 10px; }
.teamcol h3 { margin: 0; letter-spacing: 0.2em; font-size: 16px; color: var(--gold); }
.teamcol label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.teamcol .players { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.teamcol .logoRow { display: flex; gap: 8px; align-items: center; }
.teamcol .logoRow img { width: 40px; height: 40px; object-fit: contain; background: #070b12; border: 1px solid #222c3c; }

/* modal + toast */
.modal { position: fixed; inset: 0; background: #000b; display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal[hidden] { display: none; }
.modal .box { background: var(--panel); border: 1px solid #2a3446; padding: 24px; min-width: 420px; max-width: 90vw; text-align: center; }
.modal h2 { margin: 0 0 6px; letter-spacing: 0.2em; font-weight: 600; }
.modal p { color: var(--muted); margin: 0 0 18px; }
.modal .choices { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.modal .choices .btn { font-size: 18px; padding: 12px 22px; }
.modal .btn.win.blue { border-color: var(--blue); color: #9ec5ff; }
.modal .btn.win.red { border-color: var(--red); color: #ff9aa5; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: #2a0d12; border: 1px solid #ff3347; color: #ffd3d8; padding: 10px 18px; letter-spacing: 0.05em;
}
.toast.ok { background: #0d2a18; border-color: #3ddc84; color: #c9f5da; }

/* captain mode */
body.captain .admin { display: none !important; }

@media (max-width: 900px) {
  .pickerhead { flex-wrap: wrap; }
  .turn { min-width: 0; width: 100%; }
  .teamgrid { grid-template-columns: 1fr; }
  .series .spacer { display: none; }
}

/* roster */
.roster { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.roster h3 { margin: 0; letter-spacing: 0.2em; font-size: 16px; color: var(--gold); }
.rrow { display: grid; grid-template-columns: 44px 1fr 40px auto auto auto auto; gap: 8px; align-items: center; }
.rrow input[type=color] { width: 44px; height: 34px; background: none; border: 1px solid #222c3c; padding: 2px; }
.rrow input[type=text], .rrow input:not([type]) { background: #070b12; border: 1px solid #222c3c; padding: 7px 10px; outline: none; width: 100%; }
.rrow img { width: 36px; height: 36px; object-fit: contain; background: #070b12; border: 1px solid #222c3c; }
.rrow .btn.on { border-color: var(--gold); color: var(--gold); }
.teamcol select { background: #070b12; border: 1px solid #222c3c; padding: 7px 10px; color: var(--text); }
.banner { background: #2a1d08; border: 1px solid #7c6227; color: #f3d48a; padding: 10px 14px; }
.banner[hidden] { display: none; }
body.static .local-only { display: none !important; }
body:not(.static) .static-only { display: none !important; }
@media (max-width: 900px) { .rrow { grid-template-columns: 44px 1fr 40px auto; } }
