/* Long Cang — Chinese running-hand brush calligraphy (Latin subset), self-hosted. Used only for the
   NWGO wordmark, for an East-Asian brush accent; the rest of the site is a clean sans-serif. */
@font-face { font-family: "Long Cang"; font-weight: 400; font-display: swap;
  src: url("../fonts/long-cang.woff2") format("woff2"); }

:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #23221e;
  --muted: #6b6a63;
  --line: #e3e1d8;
  --accent: #1d9e75;
  --seal: #b23b2e;              /* hanko-red accent, used sparingly */
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
h1, h2, h3 { font-weight: 600; }

/* ---- header + navigation -----------------------------------------------------------------
   Only the NWGO wordmark uses the brush font (East-Asian accent); the nav is the site sans-serif. */
.site-header {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem 1.3rem;
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid var(--line); box-shadow: inset 0 -3px 0 var(--seal);   /* thin ink-red rule */
  background: var(--card);
}
.brand { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--ink); }
.brand-logo { width: 34px; height: auto; display: block; }
.brand-name { font-family: "Long Cang", "Brush Script MT", cursive;
  font-size: 2.2rem; line-height: 1; color: var(--ink); letter-spacing: 0.04em; }
.nav { display: flex; align-items: center; flex-wrap: wrap; gap: 0.15rem; }
.nav a { padding: 0.35rem 0.7rem; text-decoration: none; color: var(--muted); border-radius: 7px; font-size: 1rem; }
.nav a:hover { color: var(--ink); background: rgba(0, 0, 0, 0.045); }
/* Account dropdown — native <details> (click/tap/keyboard, no JS). Popover on desktop. */
.nav-dropdown { position: relative; }
.nav-dropdown > summary { list-style: none; cursor: pointer; padding: 0.35rem 0.7rem; color: var(--muted);
  border-radius: 7px; font-size: 1rem; }
.nav-dropdown > summary::-webkit-details-marker { display: none; }
.nav-dropdown > summary::after { content: "\25be"; margin-left: 0.25rem; font-size: 0.7em; }
.nav-dropdown > summary:hover, .nav-dropdown[open] > summary { color: var(--ink); background: rgba(0, 0, 0, 0.045); }
.dropdown-menu { position: absolute; top: calc(100% + 4px); left: 0; min-width: 170px; z-index: 50;
  display: flex; flex-direction: column; padding: 0.25rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); }
.dropdown-menu a { padding: 0.45rem 0.6rem; }
.site-footer {
  padding: 0.9rem 1.25rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem;
}

/* CSS-only hamburger: hidden on wide screens; below the breakpoint the nav collapses under a toggle. */
.nav-toggle, .nav-hamburger { display: none; }
.nav-hamburger { flex-direction: column; justify-content: center; gap: 4px; margin-left: auto;
  width: 42px; height: 34px; padding: 7px 9px; cursor: pointer; border: 1px solid var(--line); border-radius: 7px; }
.nav-hamburger span { display: block; height: 2px; background: var(--ink); border-radius: 2px; }
@media (max-width: 900px) {
  .nav-hamburger { display: inline-flex; }
  .nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 0.1rem; margin-top: 0.4rem; }
  .nav a { padding: 0.6rem 0.5rem; border-radius: 8px; }
  .nav-toggle:checked ~ .nav { display: flex; }
  /* in the hamburger the dropdown expands inline (indented) rather than as a floating popover */
  .nav-dropdown > summary { padding: 0.6rem 0.5rem; }
  .dropdown-menu { position: static; box-shadow: none; border: none; padding: 0 0 0 1rem; min-width: 0; }
}
/* Cap the content measure so sections don't stretch far wider than they need on large screens.
   Wide layouts opt out: the game board fills the window, and the two-column pages get a roomier cap. */
.container { max-width: 760px; margin: 2rem auto; padding: 0 1.25rem; }
.container-game { max-width: none; }    /* game page: full width for the board */
.container-wide { max-width: 1080px; }  /* two-column layouts (waiting room) need more room */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.375rem 1.5rem;                /* tight top/bottom (~25%), unchanged sides */
  margin: 0 0 1.6rem;                      /* breathing room between stacked sections */
  /* barely-there on the top/left, more prominent on the bottom/right */
  box-shadow:
    -1px -1px 2px rgba(0, 0, 0, 0.03),
    2px 2px 4px rgba(0, 0, 0, 0.07),
    4px 7px 15px rgba(0, 0, 0, 0.13);
}
/* Let the card's padding define the top/bottom edges symmetrically — collapse the first/last
   child's outer margins (e.g. .game-list / .ticket-replies top margin) so the top isn't taller. */
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
/* A card that ends in a form (its submit button is the last thing) would otherwise jam the button
   against the tight bottom padding — give it space mirroring the first field's top margin. */
.card > form:last-child { margin-bottom: 0.9rem; }
/* Same for a card ending in an interactive list (Multiple Handles, Choose a handle) — give the list
   bottom breathing room to match the sides instead of jamming the last row against the padding. */
.card > .handle-list:last-child,
.card > .handle-choices:last-child { margin-bottom: 1.125rem; }
h1 { margin: 0 0 0.5rem; font-weight: 500; }

/* A section label sits ABOVE its card, on the page background — not inside the box. */
/* One uniform size for every section title on every page (incl. the h1 page-top titles). */
.section-title { margin: 0 0 0.5rem; padding-left: 0.15rem; font-weight: 500; font-size: 1.2rem; }
/* A section label that carries an inline action (e.g. Bio · Edit) — sits above its card too. */
.section-head { display: flex; align-items: baseline; justify-content: space-between;
  margin: 0 0 0.5rem; padding-left: 0.15rem; }
.section-head > h2 { margin: 0; font-size: 1.2rem; font-weight: 500; }
/* In the grid layouts (waiting room, game side panel) a .section wraps title+card so grid
   placement stays intact; the grid gap owns the spacing, so the card drops its own margin. */
.section > .card, .waitingroom-layout .card, .side-col > .card { margin-bottom: 0; }
.muted { color: var(--muted); }
button {
  margin-top: 1rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
}
.health { margin-top: 0.75rem; color: var(--muted); }
code { background: #f0efe9; padding: 0.05rem 0.3rem; border-radius: 4px; }

form label { display: block; margin: 0.9rem 0 0.2rem; font-size: 0.9rem; color: var(--muted); }
form input {
  display: block; width: 100%; max-width: 22rem; margin-top: 0.2rem;
  padding: 0.5rem 0.6rem; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem;
}
form textarea {
  display: block; width: 100%; max-width: 32rem; margin-top: 0.2rem;
  padding: 0.5rem 0.6rem; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; resize: vertical;
}
.bio-text { white-space: pre-wrap; margin: 0; }
.error { color: #a32d2d; }
.ok { color: var(--accent); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1rem; margin: 1rem 0 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* ---- Profile photo (avatar) ---- */
/* The avatar lives INSIDE the top card, laid out beside the facts (not to the left of it). */
.profile-card { display: flex; align-items: flex-start; gap: 2rem; flex-wrap: wrap; }
.profile-card .avatar-wrap { margin-top: 0.75rem; }   /* breathing room above the photo + gap to its right */
.profile-head-body { flex: 1 1 16rem; min-width: 0; }
.avatar-wrap { position: relative; flex: none; }
.avatar-lg { width: 96px; height: 96px; margin-top: 0.35rem; }   /* aligns with the handle heading */
.avatar-sm { width: 32px; height: 32px; flex: none; }            /* game panel / lists */
.avatar-sm .avatar-initials { font-size: 0.8rem; }
.game-info-card .avatar-sm { width: 48px; height: 48px; }        /* ~50% larger on the game page */
.game-info-card .avatar-sm .avatar-initials { font-size: 1.2rem; }
/* the colour dot sits at the avatar's 1:30 (upper-right), tucked behind it (avatar overlaps its inner edge) */
.avatar-stone { position: relative; flex: none; margin-right: 0.25rem; }
.avatar-stone .avatar-wrap { z-index: 1; }                       /* avatar on top of the stone */
.avatar-stone .stone { position: absolute; top: -6px; right: -6px;
  z-index: 0; width: 18px; height: 18px; }
/* Clicking the circle goes to the player's profile (added by the avatar macro's `link`). Fills the
   wrap so the whole circle is the hit target; the absolute .avatar-photo still anchors to .avatar-wrap. */
.avatar-link { display: block; width: 100%; height: 100%; border-radius: 50%;
  text-decoration: none; color: inherit; }
.avatar-link:hover .avatar { filter: brightness(0.95); }
.avatar { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--line); background: var(--card); }
/* Overlays the initials; stays transparent while loading / on a 404 so the initials never flash
   (no white fill, and the border coincides with the initials circle beneath) — poll re-renders
   recreate this img, and an opaque fill would flicker the initials on every refresh. */
.avatar-photo { position: absolute; inset: 0; background: transparent; }
.avatar-initials { display: flex; align-items: center; justify-content: center; text-transform: uppercase;
  font-weight: 600; color: var(--accent); background: #e7f4ee; letter-spacing: 0.02em; }
.avatar-lg .avatar-initials { font-size: 2.1rem; }
.avatar-edit { position: absolute; right: -2px; bottom: -2px; width: 30px; height: 30px; margin: 0;
  padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%;
  border: 2px solid var(--card); background: var(--accent); color: #fff; font-size: 0.95rem;
  line-height: 1; cursor: pointer; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.avatar-edit:hover { filter: brightness(0.96); }

/* editor modal */
.avatar-editor { text-align: center; }
.avatar-editor h3 { margin: 0 0 0.75rem; }
.avatar-stage { position: relative; width: 240px; height: 240px; margin: 0 auto; }
.avatar-stage .avatar-initials { font-size: 5rem; }
/* the [hidden] attribute must win over the display rules below (canvas/initials/controls toggle) */
.avatar-canvas[hidden], .avatar-initials[hidden], .avatar-controls[hidden] { display: none; }
.avatar-canvas { display: block; width: 240px; height: 240px; border-radius: 50%;
  border: 1px solid var(--line); touch-action: none; cursor: grab; }
.avatar-canvas:active { cursor: grabbing; }
.avatar-upload { margin: 0.8rem 0 0.4rem; }
.avatar-upload a { margin-right: 0.75rem; }
.avatar-controls { display: flex; align-items: center; justify-content: center; gap: 1rem;
  flex-wrap: wrap; margin: 0.3rem 0; }
.avatar-zoom { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-size: 0.9rem;
  color: var(--muted); }
.avatar-zoom input { width: 9rem; }
.avatar-controls button { margin: 0; padding: 0.35rem 0.8rem; font-size: 0.9rem; }
.avatar-remove-row { margin: 0.4rem 0 0; }
.avatar-remove { color: #a32d2d; text-decoration: none; font-size: 0.9rem; }
.avatar-remove:hover { text-decoration: underline; }
.avatar-remove.is-disabled { color: var(--muted); opacity: 0.5; pointer-events: none; }
.inline-form { margin-top: 0.75rem; }
button.primary { border-color: var(--accent); background: var(--accent); }
button.small { margin-top: 0; padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.game-list .inline-form { margin: 0; }
.game-list .inline-form button { margin-top: 0; }
/* messages */
/* Messages toolbar: Inbox/Sent tabs (+ the unread filter) on the left, New-message aligned right. */
.msg-toolbar { display: flex; align-items: center; gap: 0.5rem 1rem; flex-wrap: wrap; }
.msg-toolbar .tabs { margin: 0; }
.msg-toolbar > .button-link { margin-left: auto; }   /* keep New message at the right edge */
.msg-filter { font-size: 0.9rem; color: var(--muted); text-decoration: none; white-space: nowrap; }
.msg-filter:hover { color: var(--ink); text-decoration: underline; }
.tabs a { margin-right: 1rem; text-decoration: none; color: var(--muted); }
.tabs a.active { color: var(--ink); font-weight: 500; }
.messages { width: 100%; border-collapse: collapse; }
.messages th { text-align: left; padding: 0.45rem 0.6rem; color: var(--muted); font-weight: 500;
  font-size: 0.85rem; border-bottom: 1px solid var(--line); }
.messages td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); }
.messages tr.unread .msg-subj a { font-weight: 700; }
/* the whole row opens the message (clickable-rows.js); the subject stays a real link for keyboard
   and screen-reader users, while the sender/recipient name is plain text (no stray profile link) */
.messages tbody tr[data-href] { cursor: pointer; }
.messages tbody tr[data-href]:hover { background: rgba(0, 0, 0, 0.035); }
.messages .msg-date { text-align: right; white-space: nowrap; font-size: 0.85rem; }
.msg-meta { margin-top: -0.4rem; }
.msg-body { white-space: pre-wrap; margin: 1rem 0; }
.unread-card { border-left: 3px solid var(--accent); }
.unread-card a { text-decoration: none; color: var(--ink); }
.ticket-replies { list-style: none; padding: 0; margin: 0.75rem 0 0; }
.ticket-replies li { padding: 0.3rem 0; }
.ticket-replies a { text-decoration: none; color: var(--ink); font-weight: 500; }
.ticket-replies a:hover { text-decoration: underline; }

/* ---- support tickets ---- */
.tickets { width: 100%; border-collapse: collapse; }
.tickets th, .tickets td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); }
.tickets th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
.tickets td a { font-weight: 500; }
.ticket-status { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.8rem; white-space: nowrap; }
.ticket-open { background: #fbe9c8; color: #8a5a00; }        /* awaiting support */
.ticket-answered { background: #d6efe2; color: #1d6e4f; }    /* support replied, awaiting the user */
.ticket-closed { background: #ececec; color: #666; }
.ticket-thread { display: flex; flex-direction: column; gap: 0.75rem; margin: 1rem 0; }
.ticket-msg { border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.8rem; background: var(--card); }
.ticket-msg.from-admin { border-color: var(--accent); background: #f3fbf7; }
.ticket-msg-head { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; margin-bottom: 0.3rem; }
.ticket-msg-body { margin: 0; white-space: pre-wrap; }
.ticket-admin-actions { display: flex; align-items: center; gap: 0.6rem; margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--line); }

/* ---- FAQ / help ---- */
.faq-list { list-style: none; padding: 0; margin: 0.5rem 0 1.5rem; display: grid; gap: 0.7rem; }
.faq-list li { display: flex; flex-direction: column; gap: 0.1rem; }
.faq-list li a { font-weight: 500; }
.faq-article .faq-body { line-height: 1.7; max-width: 44rem; }
.faq-body h3 { margin: 1.3rem 0 0.4rem; font-size: 1.1rem; }
.faq-body ul, .faq-body ol { padding-left: 1.3rem; }
.faq-body li { margin: 0.25rem 0; }
.faq-foot { margin-top: 1.5rem; padding-top: 0.75rem; border-top: 1px solid var(--line); }
/* global alert modal (real-time challenge pop-ups) */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex;
  align-items: center; justify-content: center; z-index: 1000; padding: 1rem; }
.modal-card { background: var(--bg, #fff); border-radius: 12px; padding: 1.25rem 1.5rem;
  max-width: 26rem; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,0.3); }
.modal-body h3 { margin: 0 0 0.5rem; }
.modal-warn { color: #a32d2d; font-size: 0.9rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }
.modal-actions button { margin-top: 0; }
.leaderboard { width: 100%; border-collapse: collapse; }
.leaderboard th, .leaderboard td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); }
.leaderboard th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
.leaderboard td { font-variant-numeric: tabular-nums; }
.rating-chart { width: 100%; height: auto; max-width: 560px; display: block; }
.rating-chart .rc-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.rating-chart .rc-current { fill: var(--accent); font-weight: 600; }
.link-button {
  background: none; border: none; padding: 0; margin: 0;
  color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 0.9rem;
}

/* games */
.row-between { display: flex; align-items: center; justify-content: space-between; }
.button-link {
  display: inline-block; white-space: nowrap;
  text-decoration: none; background: var(--accent); color: #fff;
  padding: 0.4rem 0.8rem; border-radius: 8px; font-size: 0.9rem;
}
.button-link:hover { filter: brightness(0.96); }
.game-list { list-style: none; padding: 0; margin: 1rem 0 0; }
.game-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 0.5rem; }
.game-list li:last-child { border-bottom: none; }   /* no dangling rule at the foot of the list */

/* Row-divided data tables draw a border under every cell; drop it on the last row so no listing
   ends in a dangling horizontal rule (same intent as .game-list above). Centralised here. */
.messages tr:last-child td,
.tickets tr:last-child td,
.leaderboard tr:last-child td,
.offers tr:last-child td,
.games-table tr:last-child td { border-bottom: none; }
.game-list a { font-weight: 500; }
.game-list a { text-decoration: none; color: var(--ink); }
/* each row is a single clickable link — "Open ● opponent" then muted size/type; no button chrome */
.game-open { display: flex; align-items: center; gap: 0.45rem; width: 100%;
  padding: 0.15rem 0.35rem; margin: 0 -0.35rem; border-radius: 6px; }
.game-open:hover { background: rgba(0, 0, 0, 0.04); }
.game-open-cta { color: var(--accent); font-weight: 600; }        /* the "Open" call-to-action */
.game-open:hover .game-open-cta { text-decoration: underline; }
.result-mark { font-weight: 700; }                                /* finished-game win/loss mark */
.result-win { color: var(--accent); }
.result-loss { color: #a32d2d; }
.badge { background: var(--accent); color: #fff; border-radius: 999px; padding: 0.05rem 0.6rem; font-size: 0.8rem; }

.game { display: grid; gap: 1.25rem; }
/* Keep the whole board group (banner + board + controls) inside the viewport so the controls are
   never clipped — the previous fixed height reserve underestimated tall control rows (undo
   prompt, scoring, resign…). #game-body is a height-bounded flex column: the banner and controls
   take their natural height, and the square board absorbs the rest. On a tall window the board
   fills the column width; on a short one it shrinks to the leftover height. The board-wrap owns a
   1:1 aspect-ratio (independent of the SVG) so it can shrink without collapsing. */
#game-body {
  display: flex; flex-direction: column; align-items: center;
  max-height: calc(100vh - 7.5rem);         /* .site-header (~3.4) + .container margins (2 top + 2 bottom) */
  margin: 0 auto;
}
.turn-banner, .controls { flex: 0 0 auto; width: 100%; }   /* natural height; never shrink off-screen */
.board-wrap {
  flex: 0 1 auto; min-height: 0;
  aspect-ratio: 1 / 1; width: 100%; max-width: 100%;
  display: flex; align-items: center; justify-content: center;
}
.goban { width: 100%; height: 100%; display: block; }
.goban .coord { fill: #6b5335; font-size: 11px; pointer-events: none; user-select: none; }
.goban .pt { cursor: pointer; }
.goban .stone { cursor: pointer; }
.goban #ghost { pointer-events: none; }
/* Touch move-placement magnifier (board-touch.js). Circular, floats above the finger, never
   intercepts touches so the drag keeps reaching the board underneath. */
.board-loupe { position: fixed; z-index: 1000; border-radius: 50%; overflow: hidden;
  pointer-events: none; border: 3px solid #fff; background: #d8b483;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.4); }
.board-loupe svg { position: absolute; }
@media (hover: hover) { .board-loupe { display: none; } }   /* belt-and-suspenders: desktop never shows it */

/* Game screen: board left, info + chat right */
.disconnected-banner {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem;
  background: #fbeaea; color: #a32d2d; border: 1px solid #f0c0c0;
  border-radius: 8px; padding: 0.5rem 0.75rem; font-weight: 500;
}
.reconnect {
  background: none; border: none; cursor: pointer; font-size: 1.25rem; line-height: 1;
  color: #a32d2d; padding: 0; margin-left: auto;
}
.reconnect.spinning { animation: nwgo-spin 0.8s linear infinite; }
@keyframes nwgo-spin { to { transform: rotate(360deg); } }


.game-layout { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.5rem; align-items: start; --banner-space: 2.5rem; }
.board-col { min-width: 0; }
/* Offset the panel down by the turn banner's height so its top lines up with the board's top. */
.side-col { display: grid; gap: 1rem; margin-top: var(--banner-space); }
.game-info-card { padding: 1rem 1.1rem; }
/* Collapsed: side panel hidden, board takes the full width. */
.game-layout.collapsed { grid-template-columns: 1fr; }
.game-layout.collapsed .side-col { display: none; }
.panel-toggle {
  position: absolute; top: -0.15rem; right: 0; z-index: 5; margin: 0;
  padding: 0.1rem 0.5rem; font-size: 1.1rem; line-height: 1.3; color: var(--muted);
  background: transparent; border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
}
.panel-toggle:hover { color: var(--ink); border-color: var(--muted); }
/* Wide (two-column) layout: keep the board and side panel together on the left with any leftover
   width to the right, instead of a greedy 1fr board column pushing the panel to the far edge. The
   board is a real square sized by the smaller of the leftover height/width (both definite, so the
   board column and the whole grid shrink to fit the board and left-align). */
@media (min-width: 761px) {
  .game-layout:not(.collapsed) { grid-template-columns: auto 320px; width: fit-content; max-width: 100%; }
  .game-layout:not(.collapsed) #game-body { width: fit-content; max-width: 100%; }
  .game-layout:not(.collapsed) .board-wrap { width: auto; max-width: 100%;
    height: min(calc(100vh - 11rem), calc(100vw - 24rem)); }
}
@media (max-width: 760px) {
  .game-layout, .game-layout.collapsed { grid-template-columns: 1fr; }
  .game-layout.collapsed .side-col { display: grid; }
  .side-col { margin-top: 0; }              /* stacked below the board — no banner offset needed */
  .panel-toggle { display: none; }
}

/* Game info: turn banner + player list */
.stone {
  display: inline-block; width: 0.95em; height: 0.95em; border-radius: 50%;
  vertical-align: middle; flex: none;
  /* soft cast shadow (light from above), matching the board stones */
  box-shadow: 0.05em 0.11em 0.16em rgba(0, 0, 0, 0.4);
}
/* radial gradients mimic slate / clamshell shading with a top-left highlight */
.stone-black { background: radial-gradient(circle at 36% 30%, #71716f, #37373a 42%, #0a0a0b 100%); }
.stone-white { background: radial-gradient(circle at 36% 28%, #ffffff, #f2ecdc 55%, #d6c9ad 100%); }
/* Fixed footprint (height + margin = --banner-space) so the panel offset stays exactly aligned. */
.turn-banner { display: flex; align-items: center; justify-content: center; gap: 0.45rem; font-size: 1.15rem; box-sizing: border-box; height: calc(var(--banner-space) - 0.6rem); margin: 0 0 0.6rem; }   /* centered above the board (matches the centred board/controls) rather than floating to its left when wide */
/* Controls row: the game-action buttons and the next-game link share one box so they are the same
   size and sit on the same baseline. (Base buttons render in the UA form font with a 1rem top
   margin; the link inherited the body's 1.6 line-height — both broke the alignment in this row.) */
.controls button, .controls .next-game {
  margin: 0; padding: 0.45rem 0.9rem; font: inherit; font-size: 0.9rem; line-height: 1.25;
  border: 1px solid var(--accent); border-radius: 8px;
}
.controls .next-game { margin-left: 0.75rem;   /* a little extra gap from the buttons on its left */
  display: inline-flex; align-items: center; background: var(--accent); color: #fff;
  text-decoration: none; white-space: nowrap; }
.controls .next-game:hover { filter: brightness(0.96); }
/* the fallback when no game awaits you reads as a quieter, secondary action */
.controls .next-game.next-game-done { background: transparent; color: var(--muted); border-color: var(--line); }
.controls .next-game.next-game-done:hover { filter: none; border-color: var(--muted); color: var(--ink); }
.players { margin: 0.75rem 0; display: grid; gap: 0.3rem; }
.player-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.55rem; border-radius: 8px; }
.player-row.to-move { background: #eaf3ee; }
.pr-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }   /* avatar · name/captures */
.pr-line { display: flex; align-items: center; gap: 0.5rem; }   /* user info · clock (right) */
.pr-captures { font-size: 0.82rem; display: flex; justify-content: space-between;
  align-items: baseline; gap: 0.5rem; }                         /* captures left, score right */
.pr-score { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.settings-card { max-width: 30rem; }
.settings-card .facts { margin-top: 0.75rem; }
.settings-players { display: grid; gap: 0.45rem; margin-top: 0.5rem; }
.settings-player { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.player-row .p-handle { font-weight: 500; }
.player-row .badge {
  margin-left: auto; font-size: 0.72rem; background: var(--accent); color: #fff;
  padding: 0.08rem 0.45rem; border-radius: 10px;
}
.player-row .clock {
  margin-left: auto; display: inline-flex; align-items: flex-end; gap: 0.2rem;
  font-size: 0.85rem; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap;
}
.player-row:not(.to-move) .clock { color: var(--muted); }   /* the paused clock is dimmer */
.player-row .clock-out { color: #b23; font-weight: 600; }
.time-control {
  border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.8rem 0.8rem;
  margin: 0.5rem 0;
}
.time-control legend { font-size: 0.85rem; color: var(--muted); padding: 0 0.35rem; }
.time-control small { display: block; margin-top: 0.15rem; }
.tc-field { display: flex; gap: 0.4rem; }
.tc-field input { flex: 1 1 auto; min-width: 0; }
.tc-field select { flex: 0 0 7rem; }
.game-meta { font-size: 0.85rem; }

/* Waiting room */
.offers { width: 100%; border-collapse: collapse; margin-bottom: 0.5rem; }
.offers th, .offers td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); }
.offers th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
.offers form { display: inline; }
/* Waiting room: open offers on the left, the post-an-offer form on the right (stacks when narrow). */
.waitingroom-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; }
.waitingroom-layout .card { margin: 0; }
#offers { overflow-x: auto; }        /* the offers table scrolls rather than clipping when space is tight */
@media (max-width: 760px) { .waitingroom-layout { grid-template-columns: 1fr; } }
/* active-games browse */
.filter-form { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: end; margin: 1rem 0 1.25rem; }
.filter-form label { margin: 0; font-size: 0.85rem; color: var(--muted); }
.filter-form input, .filter-form select { display: block; width: auto; max-width: 12rem;
  margin-top: 0.2rem; padding: 0.4rem 0.5rem; border: 1px solid var(--line); border-radius: 8px; font-size: 0.95rem; }
.filter-form button { margin-top: 0; }
/* Active-games filters: shown inline on wide screens; collapse behind a "Filters" toggle when the
   window is narrow (CSS-only checkbox hack, like the nav hamburger) rather than wrapping. */
.filters .filter-form { margin-top: 0; }        /* it sits at the top of the games card */
.filters-toggle { display: none; }
.filters-hamburger { display: none; align-items: center; gap: 0.5rem; cursor: pointer;
  width: max-content; margin: 0 0 0.5rem; padding: 0.45rem 0.75rem;
  border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-size: 0.95rem; }
.filters-bars { display: inline-flex; flex-direction: column; gap: 3px; width: 16px; }
.filters-bars span { display: block; height: 2px; background: var(--ink); border-radius: 2px; }
@media (max-width: 760px) {
  .filters-hamburger { display: inline-flex; }
  .filters .filter-form { display: none; }
  .filters-toggle:checked ~ .filter-form { display: flex; }
}
.table-scroll { overflow-x: auto; }
.games-table { width: 100%; border-collapse: collapse; }
.games-table th, .games-table td { text-align: left; padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
.games-table th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
.games-table th a { color: var(--muted); text-decoration: none; white-space: nowrap; }   /* sortable header */
.games-table th a:hover { color: var(--ink); text-decoration: underline; }
.games-table th a.sorted { color: var(--ink); }
.online-yes { color: var(--accent); font-size: 0.9rem; white-space: nowrap; }   /* users directory presence badge */
.filter-check { flex-direction: row; align-items: center; gap: 0.4rem; }        /* checkbox inline with its label */
.filter-check input { display: inline-block; width: auto; margin: 0; }

/* ---- games: List / Grid view switch + board grid ---- */
.view-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.5rem; margin: 0 0 1.1rem; }
.view-toggle a { text-decoration: none; color: var(--muted); padding: 0.25rem 0.55rem; border-radius: 6px; }
.view-toggle a:hover { color: var(--ink); }
.view-toggle a.active { color: var(--ink); background: rgba(0, 0, 0, 0.06); font-weight: 500; }

.games-grid { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 1rem;
  margin-bottom: 1.125rem; }   /* space below the boards so it isn't tight to the card's bottom edge */
.game-cell { position: relative; }
/* Both players above the board: avatar + colour stone (at 1:30, behind the avatar) + rank, side by side. */
.gc-players { display: flex; justify-content: center; align-items: center; flex-wrap: wrap;
  gap: 0.35rem 0.9rem; margin-bottom: 0.45rem; }
.gc-player { display: inline-flex; align-items: center; gap: 0.3rem; min-width: 0; }
.gc-rank { font-size: 0.8rem; }
.game-cell-board { display: block; text-decoration: none; cursor: pointer; }
.game-cell-board .goban { width: 100%; height: auto; display: block; border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); }
/* Game info: hidden in the cell; games-grid.js clones its markup into a modal on a board click (so it
   works on touch devices too). The .gci-* styling below applies once it's in the modal body. */
.game-cell-info { display: none; }
.gci-players { font-weight: 500; margin-bottom: 0.5rem; }
.gci-facts { display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 0.8rem; margin: 0;
  font-size: 0.88rem; }
.gci-facts dt { color: var(--muted); }
.gci-facts dd { margin: 0; }
@media (max-width: 600px) { .games-grid { grid-template-columns: 1fr; } }   /* one board per row on phones */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; margin-top: 1.25rem; }
.pager-info { color: var(--muted); font-size: 0.9rem; }
.pager-jump { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; }
.pager-jump label { display: flex; align-items: center; gap: 0.4rem; margin: 0; font-size: 0.85rem; color: var(--muted); }
.pager-jump input { width: 4rem; margin: 0; padding: 0.35rem 0.5rem; border: 1px solid var(--line); border-radius: 8px; }
.pager-jump button { margin: 0; }
.game-info { margin-top: 0.75rem; }
.turn { font-weight: 500; }
/* Centre the action buttons under the (centred) board — the board can be narrower than the column
   when the window is height-limited, so left-aligned buttons would detach from it. */
.controls { display: flex; gap: 0.5rem; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: 0.75rem; }
.controls form { margin: 0; }
.controls .muted { flex-basis: 100%; text-align: center; }   /* status text on its own row; buttons wrap below it */
/* replay / move navigator */
.move-nav { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin-top: 0.6rem; }
.move-nav .nav-btn { margin-top: 0; padding: 0.35rem 0.7rem; }
.move-nav .nav-btn[disabled] { opacity: 0.4; cursor: default; }
.move-nav .current { margin-left: auto; }
.move-slider { flex: 1 1 6rem; min-width: 5rem; margin-top: 0; accent-color: var(--accent); cursor: pointer; }
.controls button.danger { border-color: #a32d2d; background: #a32d2d; }
/* Disabled while reviewing an earlier move — greyed and non-interactive, layout unchanged. */
.controls button:disabled { opacity: 0.4; cursor: not-allowed; }
/* chat and game-info are siblings in .side-col — no width cap on chat, so when the side panel
   stacks below the board (narrow window) it matches the game-info card's width. */
.chat-list { list-style: none; padding: 0; margin: 0 0 0.75rem; max-height: 240px; overflow-y: auto; }
.chat-list li { padding: 0.2rem 0; }
.chat-author { font-weight: 500; color: var(--accent); }
#chat form { display: flex; gap: 0.5rem; }
#chat input { flex: 1; }

/* ---- landing (logged out): the ukiyo-e print + call to action ---- */
.landing { display: flex; gap: 2.5rem; align-items: center; flex-wrap: wrap; }
.landing-print { width: 240px; max-width: 46vw; height: auto; border: 6px solid var(--card);
  box-shadow: 0 10px 34px rgba(0,0,0,0.16); border-radius: 2px; }
.landing-copy { flex: 1 1 300px; }
.landing-copy h1 { font-size: 2.6rem; margin: 0 0 0.5rem; }
.landing-copy .lead { font-size: 1.2rem; margin: 0 0 1.4rem; }
.claim-note { margin: 0.9rem 0 0; font-size: 0.95rem; }   /* legacy-account claim prompt */
.btn-primary { display: inline-block; padding: 0.55rem 1.1rem; background: var(--accent); color: #fff;
  border-radius: 8px; text-decoration: none; margin-right: 0.6rem; }
.btn-primary:hover { filter: brightness(0.96); }
@media (max-width: 620px) { .landing-print { max-width: 62vw; } .landing-copy h1 { font-size: 2.1rem; } }

/* ---- admin: site metrics (CloudWatch-rendered graphs) ---- */
.metric-ranges a { margin-left: 0.6rem; text-decoration: none; color: var(--muted); font-size: 0.95rem; }
.metric-ranges a:first-child { margin-left: 0; }
.metric-ranges a:hover { color: var(--ink); }
.metric-ranges a.active { color: var(--ink); font-weight: 500; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem; margin-top: 1rem; }
.metric-graph { border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem; background: var(--card); }
.metric-graph img { display: block; width: 100%; height: auto; border-radius: 4px; }

/* ---- handle picker (a login owning several handles) ---- */
.handle-choices { list-style: none; margin: 1.2rem 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 0.6rem; max-width: 30rem; }
.handle-choices button { width: 100%; display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; padding: 0.7rem 1rem; text-align: left; background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 1rem; }
.handle-choices button:hover { border-color: var(--accent); }
.handle-choices button.current { border-color: var(--accent); }
.handle-choice-name { font-weight: 600; }
.handle-list { list-style: none; margin: 1.2rem 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 0.6rem; max-width: 36rem; }
.handle-row { display: flex; align-items: center; gap: 0.9rem;
  padding: 0.7rem 1rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.handle-row .handle-choice-name { flex: 1 1 auto; }
.badge-default { margin-left: 0.4rem; font-size: 0.72rem; font-weight: 600; color: var(--accent);
  vertical-align: middle; }
.inline-form { margin: 0; }
.inline-form button { background: none; border: none; padding: 0; cursor: pointer;
  color: var(--muted); font-size: 0.9rem; text-decoration: underline; }
.inline-form button:hover { color: var(--ink); }

/* Settings: an inline checkbox row (the text fields above it stack label-over-input) */
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; margin: 0.9rem 0 0.2rem;
  font-size: 0.95rem; color: var(--ink); }
.checkbox-label input { width: auto; margin: 0; }

/* Confirm-move (opt-in): a placed stone waits for Submit/Cancel, which replace the game controls. */
.confirm-move-bar { display: none; gap: 0.5rem; align-items: center; justify-content: center;
  flex-wrap: wrap; margin-top: 0.75rem; }
.confirm-move-bar button { margin: 0; }
.confirm-move-bar button.danger { border-color: #a32d2d; background: #a32d2d; color: #fff; }
#game-body.move-pending .controls,
#game-body.move-pending .move-nav { display: none; }
#game-body.move-pending .confirm-move-bar { display: flex; }

/* Delete-handle affordances (Multiple Handles) */
.handle-delete { color: #a32d2d; font-size: 0.9rem; text-decoration: underline; white-space: nowrap; }
.handle-delete:hover { color: #7d1f1f; }
.warning-box { border: 1px solid #f0c0c0; background: #fbeaea; color: #6a2020;
  border-radius: 8px; padding: 0.75rem 1rem; margin: 1rem 0; }
.warning-box ul { margin: 0.5rem 0 0.5rem 1.1rem; padding: 0; }
.warning-box li { margin: 0.3rem 0; }
.warning-box .muted { color: #7a5a5a; }
.confirm-delete-form { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.confirm-delete-form button.danger { border: 1px solid #a32d2d; background: #a32d2d; color: #fff; }

/* Rescind a sent invite from the dashboard "Waiting on opponent" list (challenger cancels) */
.game-list li.has-action .game-open { width: auto; flex: 1 1 auto; }
.game-row-cancel { margin: 0; flex: 0 0 auto; }
.game-row-cancel button { margin: 0; background: none; color: #a32d2d; border: 1px solid #e0b8b8; }
.game-row-cancel button:hover { background: #fbeaea; color: #7d1f1f; }

/* In-page undo notices (game.js) — a dismissible banner between the turn line and the board,
   replacing the old modal-over-the-board for undo messages. */
.game-notices:empty { display: none; }
.game-notice { position: relative; margin: 0 0 0.6rem; padding: 0.7rem 2.2rem 0.7rem 0.9rem;
  background: var(--card); border: 1px solid var(--accent); border-left: 4px solid var(--accent);
  border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); }
.game-notice-body { line-height: 1.4; }
.game-notice-close { position: absolute; top: 0.25rem; right: 0.35rem; margin: 0; padding: 0 0.3rem;
  background: none; border: none; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.game-notice-close:hover { color: var(--ink); }
.game-notice-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
.game-notice-actions button { margin: 0; padding: 0.4rem 0.85rem; font-size: 0.9rem; }
.game-notice-actions button.danger { border-color: #a32d2d; background: #a32d2d; color: #fff; }
/* While an undo request is waiting on your answer, the board is frozen (game.js blocks the click) —
   show it, and flash the prompt if they try to play anyway. */
#game.undo-locked svg.goban, #game.undo-locked .pt { cursor: not-allowed; }
.game-notice.notice-pulse { animation: nwgo-notice-pulse 0.6s ease; }
@keyframes nwgo-notice-pulse {
  0%, 100% { outline: 0 solid transparent; outline-offset: 2px; }
  30%      { outline: 3px solid var(--accent); outline-offset: 2px; }
}

/* Admin · User Management — login cards + handle rows */
.um-card { border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.9rem; margin: 0.75rem 0; }
.um-handles { list-style: none; padding: 0; margin: 0.25rem 0 0; }
.um-handle { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0;
  border-top: 1px solid var(--line); }
.um-handle:first-child { border-top: none; }
.um-name { font-weight: 600; }
.um-badge { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0.05rem 0.4rem; }
.um-badge-off { color: #a32d2d; border-color: #a32d2d; }
.um-inline { display: inline; margin: 0; }
.um-inline button { margin: 0; padding: 0.25rem 0.7rem; font-size: 0.85rem; }
.um-handle .um-inline { margin-left: auto; }   /* push Disassociate to the right edge */
.um-confirm { border: 1px solid #a32d2d; border-radius: 8px; padding: 0.75rem 0.9rem; margin: 0.75rem 0; }
.um-confirm .um-inline, .um-confirm .button-link { margin-right: 0.5rem; }
