/* 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; }
}
.container { max-width: 760px; margin: 2rem auto; padding: 0 1.25rem; }
/* The game page uses the full window width so the board can stretch (760px suits text pages). */
.container-game { max-width: none; }
/* Wide enough for a two-column layout (e.g. the waiting room: offers + post-an-offer form). */
.container-wide { max-width: 1080px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem;
}
h1 { margin: 0 0 0.5rem; font-weight: 500; }
.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; }
.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 */
.msg-head { display: flex; align-items: center; justify-content: space-between; }
.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 td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); }
.messages tr.unread .msg-subj a { font-weight: 700; }
/* the subject is the link to the message — style it like any other link (as the sender name is),
   so it reads as clickable and people stop clicking the name expecting to open the message */
.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); }

/* ---- 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 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; }

/* 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); }
@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; gap: 0.45rem; font-size: 1.15rem; box-sizing: border-box; height: calc(var(--banner-space) - 0.6rem); margin: 0 0 0.6rem; }
/* 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; flex-direction: column; gap: 0.1rem; padding: 0.4rem 0.55rem; border-radius: 8px; }
.player-row.to-move { background: #eaf3ee; }
.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; }
.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; }
.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; } }
