/* Gaimbit web UI. Every colour, font, gradient, radius and shadow comes from brand.css. */

* { box-sizing: border-box; }
body { margin: 0; background: var(--white); color: var(--ink); font: var(--text-size)/var(--text-line) var(--font-body); }
a { color: var(--red); }
a:hover { color: var(--red-deep); }
strong, b { font-weight: 600; }
h1, h2 { font-family: var(--font-heading); font-weight: 600; }
h1 { position: relative; font-size: 40px; line-height: 48px; margin: 8px 0 32px; padding-bottom: 14px; }
h1::after { content: ""; position: absolute; left: 0; bottom: 0; width: 160px; height: 2px; background: var(--gradient-main); }
h2 { font-size: 22px; line-height: 28px; margin: 0 0 12px; }
.accent { font-family: var(--font-accent); font-style: italic; font-weight: 500; }
code, .mono { font-family: var(--font-mono); font-size: 0.85em; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; padding: 6px 24px; background: var(--white); border-bottom: 4px solid; border-image: var(--gradient-main) 1; }
.topbar a { color: var(--ink); text-decoration: none; font-weight: 600; font-size: 16px; padding: 4px 0; border-bottom: 2px solid transparent; }
.topbar a[aria-current="page"], .topbar a:hover { border-bottom-color: var(--red); }
.topbar .brand { display: inline-flex; align-items: center; padding: 0; border-bottom: 0; margin-right: 8px; }
.topbar .brand:hover { border-bottom-color: transparent; }
.topbar .brand img { display: block; height: 44px; width: auto; }
.login-wrap { min-height: 80vh; display: grid; grid-template-columns: minmax(0, 400px); place-content: center; justify-items: center; gap: 8px; }
.login-wrap .logo-stacked { display: block; height: 150px; width: auto; }
.login-wrap .card.narrow { width: 100%; }
.login-wrap h1 { margin-top: 0; }
.topbar .who { margin-left: auto; display: flex; gap: 12px; align-items: center; font-size: 16px; }
.topbar form { margin: 0; }
.role { font-size: 13px; line-height: 18px; padding: 2px 12px; border-radius: var(--radius-pill); background: var(--tint-purple); color: var(--purple); font-weight: 600; }

main { max-width: 1180px; margin: 0 auto; padding: 32px 24px 64px; }
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.card.narrow { max-width: 400px; }
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 24px; overflow-x: auto; }
.stack-gap { margin-top: var(--gap); }
.empty { color: var(--ink-muted); font-style: italic; margin: 0; }
.notice { background: var(--tint-orange); border-left: 4px solid var(--orange); padding: 12px 16px; margin: 0 0 var(--gap); }
.error { color: var(--red-deep); }
.muted { color: var(--ink-muted); }
.small { font-size: 15px; line-height: 22px; }

table { width: 100%; border-collapse: collapse; font-size: 16px; line-height: 22px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--tint-lilac); }
th { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--purple); font-weight: 600; background: var(--tint-purple); border-bottom: 0; }
tr:hover > td { background: var(--grey); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.first > td { font-weight: 600; }
tr.first > td:first-child { box-shadow: inset 4px 0 0 var(--red); }

/* Buttons: square, uppercase, five variants */
.btn { display: inline-block; padding: 10px 18px; font: 600 14px/18px var(--font-body); text-transform: uppercase; letter-spacing: 0.04em; border: 2px solid transparent; border-radius: var(--radius); background-origin: border-box; cursor: pointer; text-decoration: none; transition: background-color 0.2s, color 0.2s, border-color 0.2s; }
.btn-gradient { color: var(--white); background-image: var(--gradient-main); }
.btn-gradient:hover { color: var(--white); background: var(--ink); }
.btn-gradient-border { color: var(--ink); background: linear-gradient(var(--white), var(--white)) padding-box, var(--gradient-main) border-box; }
.btn-gradient-border:hover { color: var(--ink); background: linear-gradient(var(--tint-purple), var(--tint-purple)) padding-box, var(--gradient-main) border-box; }
.btn-red { color: var(--white); background: var(--red); }
.btn-red:hover { color: var(--white); background: var(--red-deep); }
.btn-white { color: var(--ink); background: var(--white); border-color: var(--lilac); }
.btn-white:hover { color: var(--ink); border-color: var(--ink); }
.btn-black { color: var(--white); background: var(--ink); }
.btn-black:hover { color: var(--white); background: var(--purple); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible, .square:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.inline { display: inline; }

form.stack { display: grid; gap: 14px; max-width: 380px; }
label { display: grid; gap: 4px; font-weight: 600; font-size: 16px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
fieldset.plain { border: 0; padding: 0; margin: 0; }
input[type="text"], input[type="password"], select { font: inherit; font-weight: 400; color: var(--ink); padding: 8px 10px; border: 1px solid var(--lilac); border-radius: var(--radius); background: var(--white); }
input[type="text"]:focus, input[type="password"]:focus, select:focus { outline: 2px solid var(--purple); outline-offset: 0; }

.reveal { background: var(--tint-purple); border-left: 4px solid var(--purple); padding: 12px 16px; margin-bottom: var(--gap); }
.reveal code { display: block; word-break: break-all; padding: 8px; background: var(--white); border: 1px solid var(--tint-lilac); margin: 8px 0; user-select: all; }
.reveal .muted code { display: inline; padding: 0; border: 0; margin: 0; background: none; }

.badge { display: inline-block; font-size: 13px; line-height: 18px; padding: 2px 12px; border-radius: var(--radius-pill); border: 1px solid var(--lilac); color: var(--purple); font-weight: 600; }
.badge.live { border-color: var(--red); color: var(--red); }
.badge[hidden] { display: none; }
.badge.revoked { border-color: var(--red-deep); color: var(--red-deep); background: var(--grey); }

/* Game room */
.room { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 560px) minmax(260px, 1fr); align-items: start; }
.room-side { display: grid; gap: var(--gap); }
.turn { font-family: var(--font-heading); font-weight: 600; font-size: 22px; line-height: 28px; margin-bottom: 12px; }
.turn.mine { color: var(--red); }
.board { display: grid; grid-template-columns: repeat(var(--size, 8), 1fr); aspect-ratio: 1; border: 2px solid var(--ink); overflow: hidden; }
.square { position: relative; border: 0; padding: 0; margin: 0; background: var(--square-a); display: grid; place-items: center; font: inherit; cursor: default; }
.square.dark { background: var(--square-b); }
.square.goal-p1 { box-shadow: inset 0 -5px 0 var(--p1); }
.square.goal-p2 { box-shadow: inset 0 5px 0 var(--p2); }
.square.target { cursor: pointer; background-image: radial-gradient(circle, var(--hint) 18%, transparent 20%); }
.square.target .piece { box-shadow: 0 0 0 3px var(--hint); }
.square.selected { outline: 3px solid var(--hint); outline-offset: -3px; }
.square.last { box-shadow: inset 0 0 0 3px var(--ink-shade); }
.piece { width: 72%; height: 72%; pointer-events: none; }
.barrel { border-radius: 30% / 18%; border: 2px solid rgba(0, 0, 0, 0.35); background: repeating-linear-gradient(0deg, transparent 0 28%, rgba(0, 0, 0, 0.25) 28% 34%); }
.barrel.p1 { background-color: var(--p1); }
.barrel.p2 { background-color: var(--p2); }
.can { width: 44%; height: 60%; border-radius: 35% 35% 12% 12%; border: 2px solid #555; background: linear-gradient(90deg, #cfd3d8, #f5f6f7 45%, #b8bec6); }
.can.p1 { border-color: var(--p1); }
.can.p2 { border-color: var(--p2); }
.coords { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-muted); font-size: 14px; line-height: 20px; margin-top: 6px; }
.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 12px; }
.step { color: var(--ink-muted); }
.seats { display: grid; gap: 10px; }
.seat { display: grid; grid-template-columns: 18px 1fr; gap: 4px 8px; align-items: center; font-size: 16px; }
.seat .badge { grid-column: 2; justify-self: start; }
.swatch { width: 14px; height: 14px; }
.swatch.p1 { background: var(--p1); }
.swatch.p2 { background: var(--p2); }
/* Moves panel and replay (PRD prd-2026-11-16-spectator-insight) */
.replay { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.replay .btn { padding: 8px 12px; min-width: 44px; }
.replay .where { margin-left: auto; font-size: 15px; line-height: 22px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.history-banner { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; background: var(--tint-purple); border-left: 4px solid var(--purple); padding: 8px 12px; margin-bottom: 12px; font-size: 15px; line-height: 22px; }
.history-banner[hidden] { display: none; }
.history-banner .btn { padding: 6px 12px; margin-left: auto; }
.board.past { border-color: var(--purple); }
.moves-card h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.moves-card h2 .muted { font: 400 14px/20px var(--font-body); margin-left: auto; }
.moves-card .check { margin-bottom: 8px; }
.moves-scroll { max-height: 360px; overflow: auto; margin: 0 -8px; }
table.moves { font-size: 15px; line-height: 20px; }
table.moves th { position: sticky; top: 0; z-index: 1; padding: 6px 8px; }
table.moves td { padding: 6px 8px; cursor: pointer; vertical-align: top; }
table.moves td.mv { font: 13px/20px var(--font-mono); white-space: nowrap; }
table.moves td.who, table.moves td.at { white-space: nowrap; }
table.moves td.at { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
table.moves .swatch { display: inline-block; vertical-align: -1px; margin-right: 6px; width: 10px; height: 10px; }
table.moves tr.current > td { background: var(--tint-purple); font-weight: 600; }
table.moves tr.current > td:first-child { box-shadow: inset 4px 0 0 var(--purple); }
table.moves tr.future > td { color: var(--ink-muted); }
table.moves tr.fresh > td { animation: fresh 2.4s ease-out; }
@keyframes fresh { from { background: var(--tint-orange); } to { background: transparent; } }
table.moves tr.event > td { cursor: default; font-size: 13px; line-height: 18px; color: var(--ink-muted); font-style: italic; background: var(--grey); }
table.moves tr.event.flag > td { color: var(--red-deep); font-weight: 600; }
.spent { display: grid; grid-template-columns: 52px 1fr; gap: 6px; align-items: center; font-variant-numeric: tabular-nums; text-align: right; }
.spent .bar { height: 6px; justify-self: start; opacity: 0.55; }
.spent .bar.p1 { background: var(--p1); }
.spent .bar.p2 { background: var(--p2); }
.spent.slow { color: var(--red-deep); font-weight: 600; }
.clock-slot { font-variant-numeric: tabular-nums; white-space: nowrap; }
.timechart { display: flex; align-items: center; gap: 2px; height: 72px; margin: 0 0 12px; border-bottom: 1px solid var(--tint-lilac); position: relative; }
.timechart[hidden] { display: none; }
.timechart .col { flex: 1 1 0; display: grid; grid-template-rows: 36px 36px; cursor: pointer; min-width: 2px; }
.timechart .up { align-self: end; background: var(--p1); opacity: 0.7; }
.timechart .down { align-self: start; background: var(--p2); opacity: 0.7; }
.timechart .col.cur .up, .timechart .col.cur .down { opacity: 1; outline: 2px solid var(--ink); }
.timechart::after { content: ""; position: absolute; left: 0; right: 0; top: 36px; border-top: 1px solid var(--ink-shade); pointer-events: none; }
.seat-stats { grid-column: 2; font-size: 14px; line-height: 20px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.seat-stats:empty { display: none; }
.result { border-left: 4px solid var(--red); }
.result[hidden] { display: none; }
.result .big { font-family: var(--font-heading); font-weight: 600; font-size: 22px; line-height: 28px; margin: 0 0 4px; }
.result .reason { margin: 0; }
.result dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 16px; margin: 8px 0 0; font-size: 15px; line-height: 22px; }
.result dt { color: var(--ink-muted); }
.result dd { margin: 0; font-variant-numeric: tabular-nums; }
.badge.status[data-status="THINKING"], .badge.status[data-status="MOVE_SUBMITTED"] { border-color: var(--purple); background: var(--tint-purple); }
.badge.status[data-status="ERROR"], .badge.status[data-status="DISCONNECTED"] { border-color: var(--red-deep); color: var(--red-deep); background: var(--grey); }
.chat-log { list-style: none; margin: 0 0 12px; padding: 0; max-height: 280px; overflow: auto; display: grid; gap: 8px; }
.msg { display: grid; gap: 2px; padding: 8px 12px; border-radius: var(--radius); font-size: 15px; line-height: 22px; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.agent { background: var(--tint-purple); }
.msg.system { background: var(--tint-orange); border-left: 4px solid var(--orange); font-style: italic; }
.msg-meta { font-weight: 600; font-size: 13px; line-height: 18px; color: var(--purple); }
.msg.system .msg-meta { color: var(--ink-muted); }
.chat-form { display: grid; gap: 8px; }
.chat-form textarea { font: inherit; font-weight: 400; color: var(--ink); padding: 8px 10px; border: 1px solid var(--lilac); border-radius: var(--radius); resize: vertical; }
.chat-form textarea:focus { outline: 2px solid var(--purple); outline-offset: 0; }
.chat-form button { justify-self: start; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--purple); margin-right: 6px; }
.live-dot.stale { background: var(--red-deep); }

/* Win needle (experimental): room card and Live games column. PRD prd-2026-11-16-win-needle. */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.needle { display: grid; gap: 6px; }
.needle-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 16px; line-height: 22px; }
.needle-head .side { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; min-width: 0; overflow-wrap: anywhere; }
.needle-head .side.p2 { justify-content: flex-end; text-align: right; }
.needle-head .pct { font-family: var(--font-heading); font-weight: 600; font-size: 28px; line-height: 32px; font-variant-numeric: tabular-nums; }
.needle-head .p1 .pct { color: var(--p1); }
.needle-head .p2 .pct { color: var(--p2); }
.needle-track { position: relative; height: 18px; background: var(--p2); margin-top: 10px; }
.needle-fill { position: absolute; top: 0; bottom: 0; left: 0; background: var(--p1); transition: width 0.35s ease; }
.needle-track .needle-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--white); opacity: 0.85; }
.needle-marker { position: absolute; top: -7px; bottom: -7px; width: 4px; margin-left: -2px; background: var(--ink); transition: left 0.35s ease; }
.needle-marker::before { content: ""; position: absolute; left: -6px; top: -8px; border: 8px solid transparent; border-top-color: var(--ink); border-bottom: 0; }
.needle-ticks { display: flex; justify-content: space-between; font-size: 13px; line-height: 18px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.needle-band { font-family: var(--font-heading); font-weight: 600; font-size: 16px; line-height: 22px; text-align: center; }
.needle-trend { width: 100%; height: 84px; display: block; margin-top: 10px; }
.needle-trend .area-p1 { fill: var(--p1); opacity: 0.18; }
.needle-trend .area-p2 { fill: var(--p2); opacity: 0.18; }
.needle-trend .even { stroke: var(--lilac); stroke-dasharray: 4 4; }
.needle-trend .line { fill: none; stroke: var(--ink); stroke-width: 2; }
.needle-trend .cursor { stroke: var(--ink-shade); }
.needle-trend .swing { stroke: var(--orange); stroke-width: 2; }
.trend-axis { display: flex; justify-content: space-between; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.trend-note { font-size: 14px; line-height: 20px; margin: 4px 0 8px; }
.trend-note .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); margin-right: 6px; }
.trend-note .dot.quiet { background: var(--lilac); }
.needle-foot { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.badge.experimental { border-color: var(--orange); color: var(--ink); background: var(--tint-orange); }
.needle-hidden { display: grid; gap: 8px; }
.mini { display: grid; gap: 3px; min-width: 150px; }
.mini-label { display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; font-size: 13px; line-height: 16px; font-variant-numeric: tabular-nums; }
.mini-label .l { color: var(--p1); font-weight: 600; }
.mini-label .r { color: var(--p2); font-weight: 600; }
.mini-label .lead { color: var(--ink-muted); }
.mini-bar { display: block; width: 100%; height: 8px; margin-top: 2px; overflow: visible; }
.mini-bar .needle-p1 { fill: var(--p1); }
.mini-bar .needle-p2 { fill: var(--p2); }
.mini-bar .needle-mid { fill: var(--white); }
.mini-bar .needle-mark { fill: var(--ink); }
.mini-hidden { font-size: 14px; color: var(--ink-muted); font-style: italic; }

/* Chess clock: one plate per seat, the opponent above the board, you below */
.clock { display: grid; grid-template-columns: 14px 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 14px; border: 2px solid var(--tint-lilac); background: var(--white); margin: 0 0 12px; }
.clock.below { margin: 12px 0 0; }
.clock .who-name { font-weight: 600; font-size: 16px; min-width: 0; overflow-wrap: anywhere; }
.clock .meta { grid-column: 2; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.clock .time { grid-row: 1 / span 2; grid-column: 3; font: 600 34px/40px var(--font-heading); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; min-width: 4.6ch; text-align: right; }
.clock[data-state="running"] { border-color: transparent; background: linear-gradient(var(--white), var(--white)) padding-box, var(--gradient-main) border-box; box-shadow: var(--shadow-card); }
.clock[data-state="running"] .meta::before { content: "● "; color: var(--red); }
.clock[data-state="idle"] .time { color: var(--ink-muted); }
.clock[data-low="true"] { background: var(--tint-orange); }
.clock[data-low="true"][data-state="running"] { background: linear-gradient(var(--tint-orange), var(--tint-orange)) padding-box, var(--gradient-warm) border-box; }
.clock[data-low="true"] .time { color: var(--red-deep); }
.clock[data-state="flagged"] { border-color: var(--red-deep); background: var(--grey); }
.clock[data-state="flagged"] .time { color: var(--red-deep); }
.clock .flag { grid-column: 2 / span 2; justify-self: start; }
.badge.timeout { border-color: var(--red-deep); color: var(--white); background: var(--red-deep); }
.badge.tc { border-color: var(--purple); background: var(--tint-purple); }
.result-banner { padding: 14px 16px; margin: 0 0 12px; border-left: 4px solid var(--red-deep); background: var(--grey); font-weight: 600; }
.result-banner.win { border-left-color: var(--purple); background: var(--tint-purple); }
.mini-clock { font: 600 15px/20px var(--font-mono); white-space: nowrap; }
.mini-clock .run, .mini-clock.run { color: var(--red); }
.mini-clock .low { color: var(--red-deep); }

@media (max-width: 820px) {
  .room { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  main { padding: 20px 16px 48px; }
  table.moves th.at, table.moves td.at, .spent .bar { display: none; }
  table.moves td.mv { white-space: normal; }
  table.moves td, table.moves th { padding: 6px 4px; }
  .spent { grid-template-columns: auto; }
  h1 { font-size: 30px; line-height: 36px; margin-bottom: 24px; }
  .topbar { padding: 4px 16px; gap: 2px 16px; }
  .topbar .brand img { height: 38px; }
  .login-wrap .logo-stacked { height: 120px; }
  .topbar .who { margin-left: 0; width: 100%; }
  .card { padding: 16px; }
  .clock .time { font-size: 28px; line-height: 34px; }
}
.site-footer { max-width: 960px; margin: 2rem auto 1rem; padding: 0 1rem; font-size: .875rem; }
