

:root {
  --brand: #111111;
  --brand-dark: #000000;
  --accent: #cccccc;
  --brand-ink: #ffffff;

  --bg: #ffffff;
  --surface: #ffffff;
  --line: #e4e6ea;
  --ink: #16181d;
  --ink-soft: #5b6270;
  --ink-faint: #8b929e;
  --ok: #157f3d;
  --warn: #9a5b00;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 20, 28, .06), 0 4px 14px rgba(16, 20, 28, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #161a20;
    --line: #262c35;
    --ink: #eef1f5;
    --ink-soft: #a5adba;
    --ink-faint: #79828f;
    --ok: #57c281;
    --warn: #e0a33e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px; }

.top {
  background: var(--brand);
  color: var(--brand-ink);
  border-bottom: 1px solid rgba(0, 0, 0, .12);
}
.top-in {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding-top: 12px; padding-bottom: 12px;
}
.brand { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-league { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }

@media (max-width: 420px) {
  .brand-league { font-size: 15px; }
  .top-in { gap: 8px; }
  .nav-a { padding: 6px; font-size: 13px; }
}
.brand-pod { font-size: 12px; opacity: .75; }
.brand-pod:empty { display: none; }

.nav { display: flex; align-items: center; gap: 4px; }
.nav-a {
  color: var(--brand-ink); text-decoration: none; opacity: .8;
  font-size: 14px; padding: 6px 8px; border-radius: 8px;
}
.nav-a.is-on, .nav-a:hover { opacity: 1; background: rgba(255, 255, 255, .14); }

.sec { padding: 24px 0; }
.sec-head { margin-bottom: 14px; }
.h1 { font-size: 24px; margin: 0 0 2px; letter-spacing: -.02em; }
.h2 { font-size: 19px; margin: 0 0 2px; letter-spacing: -.01em; }
.sub { margin: 0; color: var(--ink-soft); font-size: 14px; }
.fine { color: var(--ink-faint); font-size: 12px; margin: 8px 0 0; }

.note {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
  color: var(--ink-soft); font-size: 14px; margin-bottom: 12px;
}
.note.is-warn { border-color: var(--warn); color: var(--warn); }

.games { display: grid; gap: 12px; }

.game {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.game.is-own { border-color: var(--brand); border-width: 2px; }
.game.is-locked { opacity: .72; }

.game-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 9px 14px; border-bottom: 1px solid var(--line);
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-faint);
}
.game-tag { font-weight: 700; color: var(--brand); }
.game.is-own .game-tag { color: var(--brand); }

.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 14px 4px; }

.side {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: transparent;
  border-radius: 10px; padding: 10px 12px; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--ink); text-align: left;
  min-height: 48px; width: 100%;
}
.side:hover:not(:disabled) { border-color: var(--ink-faint); }
.side[aria-pressed="true"] {
  border-color: var(--brand); background: var(--brand); color: var(--brand-ink);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.side:disabled { cursor: default; }
.side-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; background: var(--accent); }
.side-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-at { font-size: 11px; color: var(--ink-faint); font-weight: 500; }
.side[aria-pressed="true"] .side-at { color: var(--brand-ink); opacity: .8; }

.bands { padding: 4px 14px 14px; }
.bands-lab { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); margin: 8px 0 6px; }

.band-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
@media (min-width: 560px) { .band-row { grid-template-columns: repeat(6, 1fr); } }

.band {
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 9px; padding: 8px 4px; cursor: pointer; font: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-height: 48px; justify-content: center;
}
.band:hover:not(:disabled) { border-color: var(--ink-faint); }
.band[aria-pressed="true"] { border-color: var(--brand); background: var(--brand); color: var(--brand-ink); }
.band:disabled { cursor: default; }
.band-num { font-weight: 700; font-size: 13px; line-height: 1; }
.band-name { font-size: 9px; text-transform: uppercase; letter-spacing: .03em; opacity: .7; line-height: 1.1; text-align: center; }

.result { padding: 0 14px 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.score { font-weight: 700; }
.chip {
  display: inline-block; border-radius: 999px; padding: 2px 9px;
  font-size: 12px; font-weight: 700; border: 1px solid var(--line); color: var(--ink-soft);
}
.chip.is-5 { background: var(--ok); border-color: var(--ok); color: #fff; }
.chip.is-3 { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.chip.is-0 { color: var(--ink-faint); }

.savebar {
  position: sticky; bottom: 0; margin-top: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 13px;
}
.savecount { font-weight: 700; }
.savestate { color: var(--ink-soft); }
.savestate.is-ok { color: var(--ok); }
.savestate.is-err { color: #c0392b; }

.rules { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.rules > summary { cursor: pointer; padding: 12px 14px; font-weight: 600; font-size: 14px; }
.rules-in { padding: 0 14px 14px; }
.ladder { width: 100%; border-collapse: collapse; font-size: 14px; }
.ladder th { text-align: left; font-weight: 500; color: var(--ink-soft); padding: 5px 0; }
.ladder .pts { text-align: right; font-weight: 700; width: 3em; }
.bandkey { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.bandkey li { display: flex; justify-content: space-between; gap: 10px; color: var(--ink-soft); }
.bandkey b { color: var(--ink); font-variant-numeric: tabular-nums; }

.tablewrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.board { width: 100%; border-collapse: collapse; font-size: 14px; }
.board th, .board td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.board thead th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); font-weight: 600; }
.board tbody tr:last-child td { border-bottom: 0; }
.c-rank { width: 2.5em; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.c-num { text-align: right; font-variant-numeric: tabular-nums; width: 3.2em; }
.board tr.is-you { background: color-mix(in srgb, var(--brand) 9%, transparent); }
.board tr.is-you .c-name { font-weight: 700; }
.host-tag { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--brand-ink); background: var(--brand); border-radius: 4px; padding: 1px 5px; margin-left: 6px; }
@media (max-width: 460px) { .c-hide { display: none; } }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 9px; padding: 8px 14px; min-height: 40px;
}
.btn:hover { border-color: var(--ink-faint); }
.btn-sm { padding: 5px 11px; min-height: 32px; font-size: 13px; background: rgba(255, 255, 255, .16); border-color: transparent; color: var(--brand-ink); }
.btn-sm:hover { background: rgba(255, 255, 255, .26); border-color: transparent; }

.foot { border-top: 1px solid var(--line); margin-top: 32px; padding: 18px 0 40px; }
.foot .fine { margin: 0; }

.skel { color: var(--ink-faint); font-size: 14px; padding: 20px 0; }

.modal[hidden] { display: none; }
.modal-back {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 13, 18, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-panel {
  position: relative; width: 100%; max-width: 380px;
  background: var(--surface); color: var(--ink);
  border-radius: 14px; padding: 24px 22px 22px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}
.modal-h { margin: 0 0 4px; font-size: 20px; letter-spacing: -.01em; }
.modal-sub { margin: 0 0 16px; color: var(--ink-soft); font-size: 14px; line-height: 1.45; }
.modal-form { display: grid; gap: 10px; }
.modal-err {
  margin: 12px 0 0; color: #c0392b; font-size: 13px; line-height: 1.45;
}
.modal-x {
  position: absolute; top: 10px; right: 10px;
  width: 32px; height: 32px; line-height: 1;
  border: 0; background: transparent; color: var(--ink-faint);
  font-size: 22px; cursor: pointer; border-radius: 8px;
}
.modal-x:hover { background: var(--line); color: var(--ink); }

.input {
  font: inherit; width: 100%;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; min-height: 46px;
  background: var(--bg); color: var(--ink);
}
.input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }

.input-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 22px; letter-spacing: .3em; text-align: center;
}

.btn-go {
  background: var(--brand); color: var(--brand-ink); border-color: var(--brand);
  min-height: 46px; font-size: 15px;
}
.btn-go:hover:not(:disabled) { filter: brightness(1.12); border-color: var(--brand); }
.btn-go:disabled { opacity: .65; cursor: default; }

.linkbtn {
  margin-top: 12px; border: 0; background: transparent; padding: 0;
  color: var(--ink-soft); font: inherit; font-size: 13px;
  text-decoration: underline; cursor: pointer;
}
.linkbtn:hover { color: var(--ink); }
