/* ChessWatch Live — Second-portal branding (second/portal/static/portal.css tokens) */
:root {
  --bg: #f4f3ef; --panel: #faf9f6; --surface: #ffffff; --ink: #23221e; --body: #5d594f;
  --muted: #8b8578; --faint: #a49e91; --line: #e6e3dc; --line-soft: #f2f0ea; --btn-line: #ddd8cd;
  --acc: #2e6b4f; --acc-deep: #24513c; --acc-soft: #e9efe9; --warn: #8a6118; --warn-soft: #f6ecda;
  --loss: #b2432a; --sq-l: #ebecd0; --sq-d: #6f9e56; --rim: #4d6636;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Instrument Sans', 'Avenir Next', 'Segoe UI', system-ui, sans-serif; }
a { color: var(--acc); text-decoration: none; }
a:hover { color: var(--acc-deep); }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 4px; }
button { font-family: inherit; cursor: pointer; }
.mono, .clock { font-family: 'Spline Sans Mono', ui-monospace, Consolas, monospace; font-variant-numeric: tabular-nums; }

/* ---------- shell: sidebar + main (portal layout) ---------- */
.shell { display: flex; min-height: 100%; }
.side { width: 212px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px; padding: 18px 12px 16px; background: var(--panel); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; color: var(--ink); }
.logo:hover { color: var(--ink); }
.lg1 { display: block; font-size: 14px; font-weight: 600; }
.lg2 { display: block; font-size: 10px; font-weight: 700; letter-spacing: 0.22em; color: var(--acc); }
.nitem { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 13.5px; font-weight: 500; color: var(--body); }
.nitem:hover { background: #f1efe9; color: var(--body); }
.nitem.active, .nitem.active:hover { background: var(--acc-soft); color: var(--acc-deep); font-weight: 600; }
.nitem .tag { margin-left: auto; font-size: 10px; font-weight: 600; letter-spacing: 0.06em; border-radius: 5px; padding: 1px 6px; color: var(--muted); border: 1px solid var(--btn-line); white-space: nowrap; }
.nitem .tag.ok { color: var(--acc-deep); border-color: #c9d8cd; }
.nitem .tag.warn { color: var(--warn); border-color: #e8d4ad; }
.lab { font-size: 11px; font-weight: 700; letter-spacing: 0.09em; color: var(--muted); text-transform: uppercase; }
.side .lab { padding: 16px 10px 6px; }
.side .foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { height: 58px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 28px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.crumb { font-size: 14px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb .dim { color: var(--muted); font-weight: 500; }
.ptop { display: none; }
.mtitle { display: none; }

/* ---------- shared bits ---------- */
.chips { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.chip.ok { background: var(--acc-soft); color: var(--acc-deep); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.mut { background: #efede8; color: #79746a; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 9px; font-size: 13px; font-weight: 600; border: 1px solid var(--btn-line); background: var(--surface); color: #4a463e; white-space: nowrap; }
.btn:hover { background: #f7f6f2; color: #4a463e; }
.foot { font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.empty { padding: 40px 28px; font-size: 14px; color: var(--body); }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); border: 2px solid var(--rim); border-radius: 8px; overflow: hidden; user-select: none; container-type: inline-size; }
.sq { position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; line-height: 1; }
.sq.l { background: var(--sq-l); } .sq.d { background: var(--sq-d); }
.sq.last::before { content: ""; position: absolute; inset: 0; background: rgba(246,224,94,0.55); }
.sq.check::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(214,40,28,0.95) 0%, rgba(214,40,28,0.55) 38%, rgba(214,40,28,0) 72%); }
.pc { position: relative; font-family: 'Noto Sans Symbols 2', 'Segoe UI Symbol', 'DejaVu Sans', serif; font-size: 10cqw; }
.pc.w { color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000, 1px 1px 1px #000; }
.pc.b { color: #1a1712; text-shadow: 0 0 2px rgba(255,255,255,0.55); }
.cc { position: absolute; font-size: max(8px, 1.8cqw); font-weight: 600; color: rgba(0,0,0,0.45); z-index: 1; }
.sq.d .cc { color: rgba(255,255,255,0.8); }
.cc.r { left: 3px; top: 2px; } .cc.f { right: 3px; bottom: 1px; }

/* ---------- players ---------- */
.player { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--muted); flex-shrink: 0; }
.swatch.b { background: var(--ink); } .swatch.w { background: #fff; }
.pname { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clock { font-size: 22px; font-weight: 600; padding: 4px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); color: var(--body); }
.clock.run { background: var(--acc); border-color: var(--acc); color: #fff; }
.clock:empty { display: none; }
.pts { font-size: 15px; font-weight: 700; padding: 2px 10px; border-radius: 8px; color: #fff; }
.pts.win { background: var(--acc); } .pts.loss { background: var(--loss); } .pts.draw { background: var(--warn); }
.pts:empty { display: none; }

/* ---------- game page ---------- */
.game { flex: 1; padding: 22px 28px 28px; display: flex; gap: 18px; align-items: flex-start; }
.gamecard { width: min(626px, 58vh + 34px); min-width: 360px; flex-shrink: 0; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.strip { display: none; }
.rightcol { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.moves { display: flex; flex-direction: column; overflow: hidden; }
.moves-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.moves-head b { font-size: 13px; font-weight: 600; text-align: right; }
.mlist { max-height: 52vh; overflow-y: auto; padding: 6px 0; }
.mrow { display: grid; grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1fr); gap: 10px; padding: 2px 16px; align-items: center; font-size: 14px; }
.mrow .n { font-family: 'Spline Sans Mono', monospace; font-size: 12px; color: var(--faint); }
.mv { text-align: left; border: none; background: none; padding: 3px 6px; border-radius: 6px; font-size: 14px; font-weight: 500; color: var(--ink); }
.mv:hover { background: #f4f3ef; }
.mv.cur { background: var(--acc-soft); color: var(--acc-deep); font-weight: 600; }
.mv small { font-family: 'Spline Sans Mono', monospace; font-size: 11px; color: var(--faint); font-weight: 400; margin-left: 4px; }
.mnone { padding: 10px 16px; font-size: 13px; color: var(--muted); }
.nav { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line-soft); }
.nav button { width: 44px; height: 36px; border: 1px solid var(--btn-line); border-radius: 8px; background: var(--surface); color: #4a463e; font-size: 14px; }
.nav button:hover { background: #f7f6f2; }
.nav span { font-size: 12px; color: var(--muted); min-width: 130px; text-align: center; }
.info { display: flex; align-items: center; gap: 16px; padding: 14px 16px; }
.info > div { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.info .t { font-size: 13px; font-weight: 600; }
.info .s { font-size: 12.5px; color: var(--body); }

/* sound toggle (game page) */
.snd { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 7px; background: var(--surface); border: 1px solid var(--btn-line); color: var(--acc-deep); }
.snd:hover { background: #f7f6f2; }
.snd .x { display: none; }
.snd.off { color: var(--muted); }
.snd.off .w { display: none; }
.snd.off .x { display: inline; }
.snd.locked { color: var(--warn); border-color: #e8d4ad; background: var(--warn-soft); }
.ptop .snd { margin-left: auto; min-height: 36px; }

/* ---------- all-boards page ---------- */
.boards { flex: 1; padding: 22px 28px 28px; display: flex; flex-direction: column; gap: 16px; }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fchip { font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 8px; background: var(--surface); border: 1px solid var(--btn-line); color: #79746a; }
.fchip:hover { background: #f7f6f2; }
.fchip.on, .fchip.on:hover { background: var(--acc-soft); color: var(--acc-deep); border-color: var(--acc-soft); }
.filters .hint { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.mini { padding: 12px; display: flex; flex-direction: column; gap: 6px; color: var(--ink); }
.mini:hover { border-color: #cdc7ba; color: var(--ink); }
.mini-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mini-head b { font-size: 14px; }
.mini .player { min-height: 24px; gap: 8px; }
.mini .swatch { width: 10px; height: 10px; border-radius: 2px; }
.mini .pname { font-size: 13px; font-weight: 500; }
.mini .clock { font-size: 13px; padding: 1px 7px; border-radius: 6px; font-weight: 500; border: none; background: none; }
.mini .clock.run { background: var(--acc); }
.mini .pts { font-size: 12px; padding: 1px 7px; border-radius: 6px; }

/* ---------- tournaments page ---------- */
.elist { display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.ev { display: flex; align-items: center; gap: 16px; padding: 16px 18px; color: var(--ink); }
.ev:hover { border-color: #cdc7ba; color: var(--ink); }
.ev-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ev-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-sub { font-size: 12.5px; color: var(--muted); }
.ev .chips { flex-shrink: 0; justify-content: flex-end; }
.ev-go { color: var(--faint); flex-shrink: 0; }
.elab { padding: 14px 2px 2px; }

/* ---------- phone ---------- */
@media (max-width: 900px) {
  .side, .top { display: none; }
  .ptop { display: flex; height: 56px; align-items: center; gap: 10px; padding: 0 16px 0 4px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
  .ptop .back { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--body); }
  .ptop .nob { width: 12px; }
  .ptop .lg1, .ptop .lg2 { display: inline; }
  .mtitle { display: flex; flex-direction: column; gap: 10px; padding: 16px 16px 0; }
  .mtitle h1 { margin: 0; font-size: 20px; font-weight: 700; }
  .mtitle .sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
  .game { flex-direction: column; align-items: stretch; padding: 14px 16px 24px; gap: 14px; }
  .gamecard { width: 100%; min-width: 0; padding: 12px; gap: 8px; }
  .gamecard .player { min-height: 34px; gap: 8px; }
  .gamecard .swatch { width: 12px; height: 12px; }
  .gamecard .pname { font-size: 15px; }
  .gamecard .clock { font-size: 17px; padding: 3px 10px; border-radius: 7px; }
  .strip { display: block; padding-top: 4px; }
  .strip b { display: block; font-size: 13px; font-weight: 600; }
  .strip div { font-size: 14px; color: var(--body); margin-top: 2px; }
  .strip .cur { color: var(--acc-deep); font-weight: 600; }
  .mlist { max-height: none; }
  .nav { justify-content: space-between; gap: 6px; }
  .nav button { width: 56px; height: 44px; }
  .nav span { min-width: 0; }
  .info { flex-direction: column; align-items: stretch; }
  .boards { padding: 14px 16px 24px; }
  .filters .hint { display: none; }
  .ev { padding: 14px; gap: 10px; }
  .ev .chips { flex-direction: column; align-items: flex-end; }
}
@media (prefers-reduced-motion: no-preference) {
  .sq.last::before { transition: opacity .2s; }
}
