:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: #202322; background: #fff; font-synthesis: none;
  --ink: #202322; --muted: #858982; --line: #e2e4dd;
  --accent: #ff571f; --panel: #f4f4ef; --header-height: 64px; --rail-width: 64px;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; color: inherit; border: 0; background: none; }
button:disabled { cursor: default; opacity: .45; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #ff986c; outline-offset: 3px; }
input { min-width: 0; }
h1, h2, h3, p { margin: 0; }
strong { font-weight: 600; }
svg { flex-shrink: 0; }
.icon { display: inline-block; width: 20px; height: 20px; vertical-align: middle; }
::selection { background: #ffdbc8; }
.muted { color: var(--muted); }
.positive { color: #387548; }
.negative { color: #b85c42; }
.small-note { font-size: 11px; line-height: 1.8; color: var(--muted); }
.app-content { margin-left: var(--rail-width); min-height: 100dvh; display: flex; flex-direction: column; }
.site-rail { position: fixed; inset: 0 auto 0 0; z-index: 8; width: var(--rail-width); border-right: 1px solid var(--line); display: flex; align-items: center; flex-direction: column; background: #fff; }
.brand-mark { display: grid; grid-template-columns: repeat(2,7px); grid-template-rows: repeat(2,7px); gap: 2px; }
.brand-mark i { background: var(--ink); border-radius: 50%; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(3) { background: #b5b9b2; }
.rail-mark { padding: 25px 22px; }
.site-rail nav { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.site-rail nav button { position: relative; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; color: #92978d; }
.site-rail nav button.active { background: var(--ink); color: #fff; }
.site-rail nav .icon { width: 17px; height: 17px; }
.site-rail nav button>span { display: none; }
#friend-badge { position: absolute; top: -3px; right: -4px; min-width: 13px; padding: 2px 3px; font-size: 8px; background: var(--accent); color: #fff; font-weight: 500; }
#friend-badge:empty { display: none; }
.rail-help { margin-top: auto; color: #94998e; }
.rail-format { writing-mode: vertical-rl; font: 9px monospace; letter-spacing: 2px; color: #9b9e96; padding: 22px 0; }
.site-header { height: var(--header-height); flex: 0 0 var(--header-height); border-bottom: 1px solid var(--line); }
.header-inner { height: 100%; display: flex; align-items: center; gap: 28px; padding: 0 32px; }
.brand { font: 900 29px/1 "Arial Black", Helvetica, sans-serif; letter-spacing: -1.8px; }
.brand-dot, .heading-dot { color: var(--accent); }
.header-location { font: 8px monospace; letter-spacing: 1px; color: #94998d; }
#header-account { margin-left: auto; }
.account-button { display: flex; align-items: center; gap: 10px; font-size: 11px; }
.account-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.account-button>.icon { height: 12px; width: 12px; color: #8f9587; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; background: var(--panel); font-size: 11px; color: #656d5f; flex-shrink: 0; }
.avatar.large { width: 60px; height: 60px; font-size: 23px; margin-bottom: 20px; }
.avatar .icon { width: 17px; height: 17px; }
.rating-pill { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rating-pill small { font-size: 10px; font-weight: 400; color: var(--muted); margin-left: 3px; }
.mobile-menu { display: none !important; }
#main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 40px; flex: 1; }
.page-notices:empty { display: none; }
.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; height: 42px; flex: 0 0 42px; border-top: 1px solid var(--line); margin: 0 32px; color: #919789; font: 8px monospace; }
.site-footer button { display: inline-flex; align-items: center; gap: 8px; font: inherit; }
.site-footer .icon { width: 12px; height: 12px; }
/* The board's width and height are measured after the surrounding rows lay out. */
body[data-view=lobby] .app-content, body[data-view=match] .app-content { height: 100dvh; }
body[data-view=lobby] #main, body[data-view=match] #main { display: flex; flex-direction: column; min-height: 0; }
body[data-view=match] { height: 100dvh; overflow: hidden; }
body[data-view=match] .site-footer { display: none; }
body[data-view=match] #main { padding-top: 18px; padding-bottom: max(18px,env(safe-area-inset-bottom)); }
.play-layout { display: flex; justify-content: center; gap: 48px; flex: 1; min-height: 0; width: 100%; }
.board-section { height: 100%; width: var(--fit-section-width,min(100%,620px)); flex: 0 1 auto; min-height: 0; min-width: 0; display: grid; place-items: center; --board-side: 0; --board-side-width: 200px; --board-side-gap: 24px; }
.board-stack { width: var(--board-edge, min(100%,520px)); max-width: 100%; display: flex; flex-direction: column; }
.board-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; border-bottom: 2px solid var(--ink); padding: 0 0 12px; }
.board-heading h1 { font: 900 29px/1 "Arial Black", Helvetica, sans-serif; letter-spacing: -1.3px; }
.board-format { font: 7px monospace; white-space: nowrap; color: #8a9081; }
.player-row { display: flex; align-items: center; gap: 10px; height: 56px; padding: 10px 0; flex-shrink: 0; }
.player-details { min-width: 0; display: flex; flex-direction: column; gap: 5px; margin-right: auto; }
.player-details strong { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-details>span { font-size: 9px; color: var(--muted); }
.you-label { font-size: 8px; font-weight: 400; color: #a3a99b; margin-left: 7px; }
.side-label { display: flex; align-items: center; gap: 5px; color: #9da393; font-size: 8px; margin-left: auto; white-space: nowrap; }
.side-piece { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: #333830; }
.side-piece.w { background: #fff; border: 1px solid #a7b09b; }
.clock { padding: 8px 10px; display: flex; align-items: center; justify-content: center; gap: 7px; min-width: 83px; background: var(--panel); flex-shrink: 0; }
.clock>.icon { width: 13px; height: 13px; color: #9da293; }
.timer { font-size: 23px; letter-spacing: -.8px; line-height: 1; font-weight: 650; font-variant-numeric: tabular-nums; }
.clock.running { background: var(--ink); color: #fff; }
.clock.running>.icon { color: #b8c1b0; }
.clock.low { background: var(--accent); color: #fff; }
.clock.low>.icon { color: #ffd5c2; }
.board-slot { width: 100%; height: var(--board-edge,520px); flex-shrink: 0; }
.board-frame { width: 100%; height: 100%; position: relative; }
.board { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(8,minmax(0,1fr)); grid-template-rows: repeat(8,minmax(0,1fr)); user-select: none; overflow: hidden; }
.square { position: relative; padding: 0; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; opacity: 1 !important; }
.square.light { background: #f0f0eb; }
.square.dark { background: #b5b9b2; }
.square.last-move.dark { background: #c7c2ad; }
.square.selected.dark { background: #dfc7b1; }
.square.selectable:hover { background: #cad0c2; }
.square:focus-visible { outline: 3px solid var(--accent); outline-offset: -4px; z-index: 1; }
.rank-label, .file-label { position: absolute; font-size: clamp(6px,calc(var(--board-edge,500px) / 67),9px); color: #72796b; font-weight: 500; pointer-events: none; }
.rank-label { top: 3px; left: 4px; }
.file-label { bottom: 3px; right: 4px; }
.checker { display: flex; align-items: center; justify-content: center; width: 72%; height: 72%; border-radius: 50%; pointer-events: none; }
.checker.b { background: #242724; color: #e4e6df; }
.checker.w { background: #fffefa; color: #606c51; border: 1px solid #dfe3d7; }
.checker-ring { height: 68%; width: 68%; border: 1px solid #747d69; border-radius: 50%; opacity: .35; }
.w .checker-ring { border-color: #a6b09a; opacity: .5; }
.checker.king>.icon { height: 45%; width: 45%; }
.checker.captured { opacity: .28; }
.square.selected .checker { outline: 3px solid var(--accent); outline-offset: 2px; }
.destination-dot { width: 19%; height: 19%; border-radius: 50%; background: var(--accent); opacity: .85; }
.board-bottom { flex-shrink: 0; }
.board-caption, .board-status { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 34px; padding: 7px 0; font-size: 10px; color: var(--muted); }
.board-caption .text-button { font-size: 9px; }
.board-status>span { line-height: 1.5; min-width: 0; }
.board-status>.text-button { font-size: 9px; flex-shrink: 0; }
.board-status .replay-actions { flex-shrink: 0; }
.match-tools { display: flex; align-items: stretch; gap: 8px; padding-top: 5px; flex-shrink: 0; }
.match-tools>.button { min-height: 36px; font-size: 10px; padding: 8px 11px; flex: 1; }
.match-tools>.button .icon { height: 14px; width: 14px; }
.match-tools>.moves-toggle { display: none; }
.match-tools>.resign-button { flex: 0; color: var(--muted); }
.replay-actions { display: flex; align-items: center; gap: 3px; }
.replay-actions .icon-button { width: 25px; height: 25px; }
.replay-actions .text-button { font-size: 9px; margin-left: 5px; }
.play-sidebar { width: 254px; flex: 0 0 254px; min-width: 0; min-height: 0; }
.lobby-sidebar { padding-top: 12px; display: flex; flex-direction: column; }
.personal-rating { flex-shrink: 0; }
.section-label { display: block; font-size: 8px; font-family: monospace; letter-spacing: 1.4px; color: #989e8f; font-weight: 400; }
.personal-rating>strong { display: block; font-size: 78px; letter-spacing: -5px; font-weight: 650; line-height: 1.1; margin-top: 11px; font-variant-numeric: tabular-nums; }
.personal-rating strong>span { font-size: 12px; font-weight: 400; color: var(--muted); letter-spacing: 0; margin-left: 8px; }
.start-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 24px; flex-shrink: 0; }
.button { min-height: 40px; padding: 10px 15px; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; gap: 9px; font-size: 12px; font-weight: 500; line-height: 1.4; border-radius: 0; }
.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.button.primary:hover:not(:disabled) { background: #ec4b17; }
.button.secondary, .button.ghost { background: #fff; }
.button.secondary { border-color: var(--ink); }
.button.ghost:hover:not(:disabled), .button.secondary:hover:not(:disabled) { background: var(--panel); }
.button.large { min-height: 44px; font-size: 11px; }
.button.small { min-height: 31px; padding: 6px 10px; font-size: 10px; }
.button .icon { width: 16px; height: 16px; }
.start-actions .primary { justify-content: space-between; font-weight: 600; }
.action-caption { font-size: 8px; text-align: center; line-height: 1.7; color: #969d8e; margin-top: 3px; }
.text-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 11px; padding: 4px 0; white-space: nowrap; }
.text-button:hover { text-decoration: underline; text-underline-offset: 4px; }
.text-button .icon { width: 13px; height: 13px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; flex-shrink: 0; }
.icon-button .icon { width: 17px; height: 17px; }
.icon-button:hover:not(:disabled) { background: var(--panel); }
.mono-rule, .match-note { border-top: 1px solid var(--line); padding-top: 20px; display: flex; gap: 22px; margin-top: 25px; flex-shrink: 0; }
.mono-rule>b, .match-note>b { color: var(--accent); font: 9px monospace; }
.mono-rule>p, .match-note>p { font-size: 19px; line-height: 1.3; letter-spacing: -.5px; font-weight: 500; }
.history-section { margin-top: 25px; border-top: 1px solid var(--line); padding-top: 20px; min-height: 0; overflow-y: auto; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 13px; }
.section-heading>h2 { font-size: 10px; font-weight: 500; }
.section-heading>span { font-size: 9px; color: var(--muted); }
.empty-history { display: flex; align-items: center; gap: 11px; padding: 8px 0; }
.empty-board { background: var(--panel); color: #a5ae99; padding: 9px; }
.empty-board .icon { width: 13px; height: 13px; }
.empty-history p { color: #9da594; font-size: 9px; line-height: 1.7; }
.history-row { display: flex; gap: 10px; align-items: center; text-align: left; padding: 10px 0; border-bottom: 1px solid var(--line); width: 100%; }
.history-row>span:nth-child(2) { min-width: 0; }
.history-row strong { display: block; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.history-row small { display: block; color: var(--muted); font-size: 8px; margin-top: 5px; }
.result-dot { display: inline-flex; align-items: center; justify-content: center; width: 25px; height: 25px; flex-shrink: 0; font-size: 15px; background: var(--panel); color: #7f8d71; }
.result-dot.win { color: #367146; background: #edf2e9; }
.result-dot.loss { color: #b5765e; background: #f6eee6; }
.history-delta { margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums; }
.history-delta .icon { width: 12px; height: 12px; transform: rotate(-90deg); }
.guest-note { position: relative; display: block; background: var(--panel); text-align: left; padding: 11px 28px 11px 11px; font-size: 10px; margin-top: 20px; width: 100%; }
.guest-note>span { display: block; font-size: 8px; color: var(--muted); margin-top: 4px; }
.guest-note>.icon { position: absolute; right: 9px; top: 16px; width: 13px; height: 13px; }
.match-sidebar { display: flex; flex-direction: column; padding-top: 9px; }
.match-summary { border-bottom: 2px solid var(--ink); padding-bottom: 22px; flex-shrink: 0; }
.match-summary>.section-label { color: var(--accent); }
.match-summary>h2 { font-size: 32px; font-weight: 600; letter-spacing: -1.3px; line-height: 1.1; margin-top: 17px; }
.match-summary>p { font-size: 10px; color: var(--muted); margin-top: 13px; line-height: 1.7; }
.game-info { padding: 19px 0; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.game-info>span { display: flex; align-items: center; gap: 8px; font-size: 10px; color: #7f8975; }
.game-info .icon { width: 14px; height: 14px; }
.moves-panel { display: flex; flex-direction: column; min-height: 0; flex: 1; padding-top: 22px; }
.moves-panel>.section-label { display: flex; justify-content: space-between; padding-bottom: 14px; flex-shrink: 0; }
.move-list { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; font-variant-numeric: tabular-nums; }
.move-pair { display: grid; grid-template-columns: 24px 1fr 1fr; gap: 5px; align-items: center; padding: 3px 0; font-size: 10px; }
.move-pair>span:first-child { font-size: 9px; color: #a8af9f; }
.move-pair button { padding: 5px 6px; text-align: left; font-size: 10px; }
.move-pair button:disabled { opacity: .85; }
.move-pair button:hover:not(:disabled), .move-pair .current { background: #ffdfcd; }
.empty-moves { font-size: 10px; line-height: 1.8; color: #a3ac99; padding: 6px 0; }
.match-note { margin-top: 20px; padding-top: 19px; padding-bottom: 9px; }
.match-note>p { font-size: 17px; }
/* Ready and result dialogs are viewport based even when the board is tiny. */
.board-overlay { position: fixed; inset: var(--header-height) 0 0 var(--rail-width); display: flex; align-items: center; justify-content: center; padding: 18px; background: #20272245; backdrop-filter: blur(2px); z-index: 12; }
.result-card { width: 300px; max-width: 100%; max-height: calc(100dvh - var(--header-height) - 36px); display: flex; flex-direction: column; align-items: center; text-align: center; padding: 28px; gap: 13px; background: #fff; border: 1px solid var(--ink); overflow-y: auto; }
.result-icon { height: 42px; width: 42px; display: flex; align-items: center; justify-content: center; background: var(--panel); color: #849276; }
.result-icon.win { background: #fff0e5; color: var(--accent); }
.result-icon .icon { width: 23px; height: 23px; }
.eyebrow { font-size: 8px; letter-spacing: 1px; color: #9ba38f; }
.result-card h2 { font-size: 31px; font-weight: 600; letter-spacing: -1px; }
.result-card p { font-size: 11px; color: var(--muted); line-height: 1.8; }
.result-card>.button { width: 100%; margin-top: 2px; font-size: 11px; }
.result-card>.text-button { font-size: 10px; }
.overlay-note { font-size: 9px; color: var(--muted); }
.result-rating { font-size: 17px; font-weight: 500; }
.result-rating.muted { font-size: 11px; font-weight: 400; }
.draw-banner { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 8px 0; font-size: 10px; }
.draw-banner>span { flex: 1 1 120px; line-height: 1.5; }
.draw-banner>.button { font-size: 9px; padding: 5px 8px; }
.search-card { display: flex; align-items: center; flex-direction: column; gap: 14px; background: var(--panel); padding: 22px 17px; border: 1px solid var(--line); margin-top: 22px; text-align: center; }
.search-card>strong { font-size: 14px; }
.search-card>p { color: var(--muted); font-size: 10px; line-height: 1.8; }
.search-card>#queue-time { font: 24px monospace; }
.search-card>.button { width: 100%; }
.search-spinner { width: 24px; height: 24px; border: 2px solid #d9ded0; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.connection-banner, .challenge-banner { display: flex; align-items: center; gap: 12px; padding: 11px 15px; border: 1px solid #ead8c8; background: #fff6ed; font-size: 11px; margin-bottom: 14px; }
.connection-banner { color: #a57452; justify-content: space-between; }
.connection-banner button { font-size: 10px; text-decoration: underline; }
.challenge-icon { background: #f7e5d7; color: #ba8059; padding: 8px; }
.challenge-icon>.icon { width: 16px; height: 16px; }
.challenge-banner>div { display: flex; flex-direction: column; gap: 5px; margin-right: auto; }
.challenge-banner strong { font-size: 11px; }
.challenge-banner>div>span { font-size: 9px; color: #b19980; }
/* Secondary pages follow the same monochrome system. */
.inner-page { max-width: 1060px; margin: 10px auto 25px; }
.page-title { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 32px; }
.page-title .eyebrow { font: 8px monospace; letter-spacing: 1.4px; }
.page-title h1 { font-size: 48px; letter-spacing: -2px; font-weight: 650; margin-top: 15px; }
.page-title p { font-size: 12px; color: var(--muted); line-height: 1.8; margin-top: 11px; }
.page-count { display: flex; align-items: center; gap: 10px; font-size: 40px; font-weight: 400; color: #8c9980; }
.page-count small { font-size: 11px; color: var(--muted); }
.friends-layout, .rating-layout { display: grid; grid-template-columns: minmax(0,1fr) 280px; gap: 24px; align-items: start; }
.panel { border: 1px solid var(--line); padding: 23px; margin-bottom: 20px; background: #fff; }
.panel h2 { font-size: 13px; font-weight: 550; }
.panel>h2 { margin-bottom: 18px; }
.panel .section-heading>h2 { font-size: 13px; }
.count { background: #fff0e5; color: var(--accent); font-size: 9px; padding: 3px 5px; margin-left: 5px; }
.friend-row { display: flex; align-items: center; gap: 11px; padding: 16px 0; border-top: 1px solid var(--line); }
.friend-info { display: flex; flex-direction: column; gap: 7px; min-width: 0; margin-right: auto; }
.friend-info strong { font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.friend-info>span { display: flex; align-items: center; gap: 5px; font-size: 9px; color: var(--muted); }
.status-dot { width: 5px; height: 5px; background: #c7cfbc; border-radius: 50%; }
.status-dot.online { background: #8caa75; }
.subtle { color: #a4af97; }
.empty-state { padding: 37px 12px; display: flex; align-items: center; text-align: center; flex-direction: column; gap: 15px; }
.large-symbol { width: 58px; height: 58px; display: flex; align-items: center; justify-content: center; background: var(--panel); color: #a2ac96; }
.large-symbol>.icon { width: 25px; height: 25px; }
.empty-state h3 { font-size: 16px; font-weight: 500; }
.empty-state p { font-size: 11px; line-height: 1.8; color: var(--muted); }
.empty-state>.button { margin-top: 6px; }
.panel-symbol { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; background: var(--panel); color: #9ba98c; margin-bottom: 16px; }
.panel-symbol>.icon { height: 17px; width: 17px; }
.add-friend-panel>p { color: var(--muted); font-size: 10px; line-height: 1.9; }
form label { display: block; font-size: 11px; margin: 18px 0 8px; color: #869278; }
input { width: 100%; padding: 11px 12px; border: 1px solid #d9dfcf; border-radius: 0; font-size: 12px; color: var(--ink); background: #fff; line-height: 1.5; }
input::placeholder { color: #a7af9b; font-size: 11px; }
.input-with-button { position: relative; display: flex; align-items: center; }
.input-with-button>input { padding-right: 40px; }
.input-with-button>.icon-button { position: absolute; right: 4px; color: #a1ae93; }
.search-result { display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); padding: 13px 0; }
.search-result>span { display: flex; flex-direction: column; gap: 5px; }
.search-result strong { font-size: 11px; }
.search-result small { font-size: 9px; color: var(--muted); }
.search-results>p { font-size: 10px; padding: 15px 0; }
.your-nickname { display: flex; align-items: start; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); margin-top: 23px; padding-top: 21px; font-size: 9px; color: var(--muted); }
.your-nickname strong { color: var(--ink); font-size: 13px; }
.your-nickname .text-button { font-size: 10px; }
.centered-page { padding: 50px 0; display: flex; align-items: center; text-align: center; flex-direction: column; }
.centered-page>.eyebrow { font-size: 8px; margin-top: 28px; }
.centered-page h1 { font-size: 46px; letter-spacing: -2px; font-weight: 550; margin-top: 20px; }
.centered-page p { color: var(--muted); font-size: 13px; line-height: 1.9; margin: 22px 0 27px; }
.centered-page>.small-note { margin-top: 16px; }
.elo-explainer { font-size: 10px; color: #9ba68d; text-align: right; line-height: 1.8; }
.leaderboard { padding: 0 22px; }
.leaderboard-head, .leaderboard-row { display: grid; grid-template-columns: 55px minmax(0,1fr) 65px 55px; gap: 9px; align-items: center; }
.leaderboard-head { padding: 20px 0; font-size: 8px; letter-spacing: 1px; color: #a4ae98; }
.leaderboard-head>:nth-child(3), .leaderboard-head>:nth-child(4), .leaderboard-row>:nth-child(3), .leaderboard-row>:nth-child(4) { text-align: right; }
.leaderboard-row { font-size: 11px; padding: 16px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.place { font-size: 15px; color: #a3ae95; }
.leader-player { display: flex; align-items: center; gap: 9px; min-width: 0; }
.leader-player strong { overflow: hidden; text-overflow: ellipsis; }
.leader-player .avatar { width: 28px; height: 28px; font-size: 10px; }
.leader-player>small { font-size: 8px; color: #a7b297; }
.is-you { background: #fbf5ee; }
.rating-explanation>p { font-size: 11px; color: var(--muted); line-height: 1.9; }
.elo-example { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 18px 0; padding: 16px 0; }
.elo-example>span { font-size: 9px; color: #9ca78f; }
.elo-example>div { display: flex; justify-content: space-between; margin-top: 17px; }
.elo-example strong { font-size: 24px; font-weight: 400; color: #6d8659; }
.elo-example strong:last-child { color: #b48d76; }
.elo-example small { display: block; font-size: 8px; font-weight: 400; color: var(--muted); margin-top: 7px; }
.rating-explanation>p.small-note { font-size: 9px; }
.your-stats>div { display: flex; justify-content: space-between; margin-top: 23px; }
.your-stats>div>span { font-size: 9px; color: #9ca98e; display: flex; flex-direction: column; gap: 9px; }
.your-stats strong { font-size: 27px; font-weight: 400; color: #718661; }
/* Dialogs and mobile secondary panels */
.modal-open { overflow: hidden; }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; background: #20272166; backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { position: relative; background: #fff; width: 100%; max-width: 400px; max-height: calc(100dvh - 40px); padding: 34px; overflow-y: auto; text-align: center; border: 1px solid var(--ink); }
.modal-close { position: absolute; right: 9px; top: 9px; color: #9daa90; }
.modal-symbol { display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; background: var(--panel); color: #9cac8b; margin: 0 auto 21px; }
.modal h2 { font-size: 27px; font-weight: 550; line-height: 1.15; letter-spacing: -1px; }
.modal>p { font-size: 11px; line-height: 1.8; color: var(--muted); margin: 15px 0 22px; }
.modal>.button { width: 100%; margin-top: 10px; }
.modal>.small-note { display: block; font-size: 9px; margin-top: 18px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--panel); padding: 4px; margin-top: 22px; }
.auth-tabs button { font-size: 11px; padding: 9px; color: #a2ad94; }
.auth-tabs button.active { background: #fff; color: var(--ink); }
.modal form { text-align: left; }
.modal form>.button { width: 100%; }
.form-error { min-height: 20px; color: #b87558; font-size: 10px; line-height: 1.8; margin: 11px 0 7px; }
.account-rating { font-size: 37px; letter-spacing: -1.5px; font-weight: 450; padding: 0 0 12px; }
.account-rating small { font-size: 13px; color: var(--muted); }
.rules-modal { max-width: 460px; }
.rules-list { text-align: left; margin: 0; padding-left: 24px; font-size: 11px; color: #a1ad93; }
.rules-list li { padding-left: 6px; margin: 17px 0; }
.rules-list strong { display: block; color: var(--ink); font-size: 11px; margin-bottom: 6px; }
.rules-list span { display: block; color: var(--muted); font-size: 10px; line-height: 1.9; }
.mobile-menu-links { display: flex; flex-direction: column; gap: 6px; margin-top: 26px; }
.mobile-menu-links button { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); font-size: 12px; text-align: left; }
.mobile-menu-links .icon { width: 17px; height: 17px; }
.moves-modal { max-width: 420px; }
.moves-modal .move-list { max-height: min(55dvh,460px); }
.moves-modal .moves-panel { padding-top: 0; text-align: left; }
#toast { position: fixed; bottom: 20px; left: 50%; z-index: 40; background: var(--ink); color: #fff; max-width: calc(100vw - 32px); width: max-content; padding: 13px 19px; font-size: 11px; line-height: 1.6; opacity: 0; pointer-events: none; transform: translate(-50%,12px); transition: opacity .2s, transform .2s; }
#toast.visible { opacity: 1; transform: translate(-50%,0); }
#toast.error { background: #a46f50; }
.loading-screen { min-height: 100dvh; display: flex; align-items: center; justify-content: center; gap: 14px; font-size: 12px; color: var(--muted); }
@media (max-height: 700px) {
  :root { --header-height: 54px; }
  body[data-view=match] #main { padding-top: 10px; padding-bottom: max(10px,env(safe-area-inset-bottom)); }
  .board-heading { min-height: 32px; padding-bottom: 8px; }
  .board-heading h1 { font-size: 23px; }
  .player-row { height: 44px; padding: 5px 0; }
  .clock { padding: 6px 9px; }
  .timer { font-size: 21px; }
  .board-status, .board-caption { min-height: 30px; padding: 5px 0; font-size: 9px; }
  .match-tools { padding-top: 3px; }
  .match-tools>.button { min-height: 32px; padding: 6px 9px; font-size: 9px; }
  .match-summary { padding-bottom: 15px; }
  .match-summary>h2 { font-size: 27px; margin-top: 12px; }
  .game-info { padding: 14px 0; gap: 9px; }
  .moves-panel { padding-top: 16px; }
  .match-note { display: none; }
  .lobby-sidebar .personal-rating>strong { font-size: 58px; }
  .lobby-sidebar .start-actions { margin-top: 16px; }
  .lobby-sidebar .mono-rule { margin-top: 18px; padding-top: 16px; }
  .lobby-sidebar .mono-rule>p { font-size: 16px; }
  .lobby-sidebar .history-section { margin-top: 17px; padding-top: 16px; }
}
@media (max-width: 1050px) {
  #main { padding-left: 24px; padding-right: 24px; }
  .play-layout { gap: 30px; }
  .play-sidebar { width: 220px; flex-basis: 220px; }
  .header-inner { padding: 0 24px; }
  .brand { font-size: 27px; }
  .header-location { font-size: 7px; }
  .side-label { display: none; }
  .personal-rating>strong { font-size: 68px; }
  .match-summary>h2 { font-size: 28px; }
  .friends-layout, .rating-layout { grid-template-columns: minmax(0,1fr) 245px; gap: 18px; }
  .panel { padding: 19px; }
}
@media (max-width: 760px) {
  :root { --header-height: 56px; --rail-width: 0px; }
  .header-inner { padding: 0 16px; gap: 15px; }
  .brand { font-size: 25px; letter-spacing: -1.5px; }
  .header-location, .account-name, .account-button>.icon { display: none; }
  .account-button { gap: 8px; }
  .account-button>.avatar { width: 28px; height: 28px; font-size: 10px; }
  .rating-pill { font-size: 12px; }
  .rating-pill small { font-size: 9px; }
  .site-rail { position: absolute; top: var(--header-height); left: 0; right: 0; bottom: auto; width: auto; height: 44px; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-mark, .rail-help, .rail-format { display: none !important; }
  .site-rail nav { flex-direction: row; gap: 18px; margin: 0; height: 100%; }
  .site-rail nav button { width: auto; height: 100%; gap: 7px; padding: 0 12px; }
  .site-rail nav button.active { color: var(--ink); background: none; border-bottom: 2px solid var(--accent); }
  .site-rail nav button>span { display: inline; font-size: 10px; }
  .site-rail nav .icon { width: 14px; height: 14px; }
  #friend-badge { position: static; font-size: 7px; }
  #main { margin-top: 44px; padding: 22px 16px; }
  body[data-view=lobby] .app-content { height: auto; }
  body[data-view=lobby] .play-layout { display: flex; flex-direction: column-reverse; gap: 25px; }
  body[data-view=lobby] .board-section { display: block; width: 100%; height: 500px; flex: auto; }
  .lobby-sidebar { width: 100%; flex: auto; padding-top: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
  .personal-rating>strong { font-size: 54px; letter-spacing: -3px; margin-top: 8px; }
  .personal-rating .section-label { font-size: 7px; letter-spacing: 1px; }
  .personal-rating strong>span { font-size: 10px; margin-left: 5px; }
  .lobby-sidebar .start-actions { margin-top: 0; gap: 6px; justify-content: center; }
  .start-actions>.button { min-height: 35px; padding: 9px; font-size: 9px; }
  .start-actions .icon { width: 13px; height: 13px; }
  .action-caption { grid-column: 1/-1; font-size: 7px; }
  .mono-rule { display: none; }
  .guest-note, .history-section, .search-card { grid-column: 1/-1; margin-top: 0; }
  .history-section { max-height: 170px; padding-top: 14px; margin-top: 3px; }
  .history-section:has(.empty-history) { display: none; }
  .guest-note { font-size: 10px; }
  .history-row strong { max-width: 240px; }
  .site-footer { margin: 0 16px; font-size: 7px; }
  .site-footer>span:nth-child(2) { display: none; }
  body[data-view=match] .site-rail { display: none; }
  body[data-view=match] .mobile-menu { display: inline-flex !important; }
  body[data-view=match] #main { margin-top: 0; padding: 10px 16px max(10px,env(safe-area-inset-bottom)); }
  body[data-view=match] .play-layout { display: block; height: 100%; }
  body[data-view=match] .match-sidebar { display: none; }
  body[data-view=match] .board-section { height: 100%; width: 100%; }
  body[data-view=match] .board-heading { min-height: 34px; padding-bottom: 9px; }
  body[data-view=match] .board-heading h1 { font-size: 25px; }
  .board-format { font-size: 7px; }
  .player-row { height: 48px; padding: 7px 0; gap: 8px; }
  .player-row .avatar { width: 28px; height: 28px; font-size: 10px; }
  .player-details strong { font-size: 10px; }
  .player-details>span { font-size: 8px; }
  .clock { min-width: 78px; padding: 7px 9px; gap: 6px; }
  .timer { font-size: 22px; }
  .board-caption, .board-status { min-height: 32px; font-size: 9px; }
  .board-caption .text-button { font-size: 8px; }
  .match-tools>.moves-toggle { display: inline-flex; }
  .match-tools>.button { min-height: 36px; padding: 8px 9px; font-size: 9px; }
  .match-tools>.resign-button { flex: 1; }
  .match-tools .icon { height: 13px; width: 13px; }
  .connection-banner { font-size: 9px; padding: 9px 10px; margin-bottom: 9px; gap: 8px; }
  .connection-banner button { font-size: 9px; flex-shrink: 0; }
  .challenge-banner { flex-wrap: wrap; padding: 11px 10px; gap: 8px; }
  .challenge-banner strong { font-size: 10px; }
  .challenge-banner>div>span { font-size: 8px; }
  .challenge-icon { padding: 6px; }
  .challenge-icon>.icon { width: 14px; height: 14px; }
  .inner-page { margin-top: 3px; }
  .page-title { margin-bottom: 24px; }
  .page-title h1 { font-size: 39px; margin-top: 12px; letter-spacing: -1.5px; }
  .page-title p { font-size: 11px; }
  .page-title .eyebrow { font-size: 7px; }
  .page-count { flex-direction: column; gap: 4px; font-size: 30px; }
  .page-count small { font-size: 9px; }
  .friends-layout, .rating-layout { grid-template-columns: 1fr; gap: 0; }
  .friends-layout>.add-friend-panel { order: -1; }
  .panel { padding: 18px; }
  .friend-row { gap: 9px; }
  .friend-row .button { font-size: 9px; padding: 7px 8px; }
  .friend-row>.subtle { display: none; }
  .friend-row .button .icon { width: 12px; height: 12px; }
  .centered-page { padding: 28px 0; }
  .centered-page h1 { font-size: 34px; letter-spacing: -1.5px; }
  .centered-page p { font-size: 11px; }
  .centered-page>.eyebrow { font-size: 7px; }
  .elo-explainer { font-size: 8px; max-width: 100px; }
  .leaderboard { padding: 0 12px; }
  .leaderboard-head, .leaderboard-row { grid-template-columns: 34px minmax(0,1fr) 43px 45px; gap: 5px; }
  .leaderboard-head { font-size: 6px; letter-spacing: .7px; }
  .leaderboard-row { font-size: 10px; }
  .leader-player { gap: 6px; }
  .leader-player>.avatar { width: 24px; height: 24px; font-size: 8px; }
  .elo-example>div { justify-content: flex-start; gap: 48px; }
  .modal-backdrop { padding: 16px; }
  .modal { padding: 29px 23px; max-height: calc(100dvh - 32px); }
  .modal h2 { font-size: 24px; }
  .modal p { font-size: 10px; }
  .modal form label { font-size: 10px; }
  #toast { font-size: 10px; padding: 12px 16px; }
}
/* Short wide windows move all chrome to the right of the board. */
@media (max-height: 540px) and (min-aspect-ratio: 6/5) {
  body[data-view=match] { --header-height: 44px; }
  body[data-view=match] .header-inner { padding-left: 18px; padding-right: 18px; }
  body[data-view=match] .brand { font-size: 23px; }
  body[data-view=match] #main { padding: 8px 18px; }
  body[data-view=match] .play-layout { display: block; height: 100%; }
  body[data-view=match] .match-sidebar { display: none; }
  body[data-view=match] .board-section { height: 100%; width: 100%; --board-side: 1; --board-side-width: 200px; --board-side-gap: 24px; }
  body[data-view=match] .board-stack { display: grid; width: calc(var(--board-edge,250px) + 224px); height: var(--board-edge,250px); grid-template-columns: var(--board-edge,250px) 200px; grid-template-rows: auto auto auto minmax(0,1fr) auto; gap: 0 24px; grid-template-areas: "board heading" "board opponent" "board self" "board status" "board tools"; }
  body[data-view=match] .board-slot { grid-area: board; }
  body[data-view=match] .board-heading { grid-area: heading; min-height: 28px; padding-bottom: 8px; }
  body[data-view=match] .board-heading h1 { font-size: 19px; }
  body[data-view=match] .board-format { display: none; }
  body[data-view=match] .opponent-row { grid-area: opponent; }
  body[data-view=match] .self-row { grid-area: self; }
  body[data-view=match] .player-row { height: 42px; padding: 5px 0; gap: 7px; }
  body[data-view=match] .player-row>.avatar { width: 24px; height: 24px; font-size: 9px; }
  body[data-view=match] .player-details>strong { font-size: 9px; }
  body[data-view=match] .player-details>span { font-size: 7px; }
  body[data-view=match] .clock { min-width: 65px; padding: 7px; }
  body[data-view=match] .clock>.icon { display: none; }
  body[data-view=match] .timer { font-size: 20px; }
  body[data-view=match] .side-label { display: none; }
  body[data-view=match] .board-bottom { grid-area: status; min-height: 0; display: flex; flex-direction: column; justify-content: center; }
  body[data-view=match] .board-status { flex-wrap: wrap; font-size: 9px; min-height: 0; gap: 6px; }
  body[data-view=match] .replay-actions { gap: 0; }
  body[data-view=match] .replay-actions .text-button { font-size: 8px; margin-left: 3px; }
  body[data-view=match] .match-tools { grid-area: tools; flex-wrap: wrap; gap: 5px; padding: 0; }
  body[data-view=match] .match-tools>.button { min-height: 31px; padding: 6px 7px; font-size: 8px; flex: 1 1 60px; }
  body[data-view=match] .match-tools>.button .icon { width: 11px; height: 11px; }
  body[data-view=match] .match-tools>.moves-toggle { display: inline-flex; }
  body[data-view=match] .draw-banner { padding: 0; font-size: 9px; }
  body[data-view=match] .draw-banner>span { flex-basis: 100%; }
  body[data-view=match] .draw-banner>.button { min-height: 27px; font-size: 8px; padding: 4px 7px; }
  .result-card { width: 290px; padding: 17px 23px; gap: 9px; }
  .result-card .result-icon { display: none; }
  .result-card h2 { font-size: 26px; }
  .result-card p { font-size: 10px; }
  .result-card>.button { min-height: 33px; padding: 7px 12px; font-size: 10px; }
  .result-card>.text-button { font-size: 9px; }
}
@media (max-height: 390px) and (min-aspect-ratio: 6/5) {
  body[data-view=match] .board-section { --board-side-width: 190px; --board-side-gap: 18px; }
  body[data-view=match] .board-stack { width: calc(var(--board-edge,220px) + 208px); grid-template-columns: var(--board-edge,220px) 190px; column-gap: 18px; }
  body[data-view=match] .player-row { height: 36px; }
  body[data-view=match] .board-heading { min-height: 25px; padding-bottom: 5px; }
  body[data-view=match] .board-heading h1 { font-size: 17px; }
  body[data-view=match] .timer { font-size: 18px; }
  body[data-view=match] .clock { padding: 5px 7px; }
  body[data-view=match] .board-status { font-size: 8px; }
  body[data-view=match] .match-tools>.button { font-size: 8px; padding: 6px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; transition: none !important; scroll-behavior: auto !important; } }

/* Mini App viewport is owned by Telegram, including system and client chrome. */
body[data-platform=telegram] { --rail-width: 0px; }
body[data-platform=telegram] .site-rail { display: none; }
body[data-platform=telegram] .mobile-menu { display: inline-flex !important; }
body[data-platform=telegram] .app-shell { height: var(--telegram-height,100dvh); padding: var(--telegram-top,0px) var(--telegram-right,0px) var(--telegram-bottom,0px) var(--telegram-left,0px); }
body[data-platform=telegram][data-view] .app-content { height: 100%; min-height: 0; }
body[data-platform=telegram][data-view=match] { height: var(--telegram-height,100dvh); }
body[data-platform=telegram] .board-overlay, body[data-platform=telegram] .modal-backdrop { top: var(--telegram-top,0px); bottom: calc(100dvh - var(--telegram-height,100dvh) + var(--telegram-bottom,0px)); left: var(--telegram-left,0px); right: var(--telegram-right,0px); }
body[data-platform=telegram] .board-overlay { top: calc(var(--telegram-top,0px) + var(--header-height)); }
body[data-platform=telegram] .result-card { max-height: calc(var(--telegram-height,100dvh) - var(--telegram-top,0px) - var(--telegram-bottom,0px) - var(--header-height) - 36px); }
body[data-platform=telegram] .modal { max-height: calc(var(--telegram-height,100dvh) - var(--telegram-top,0px) - var(--telegram-bottom,0px) - 40px); }
.telegram-entry-message { min-height: 100dvh; max-width: 520px; margin: auto; padding: 30px; display: flex; flex-direction: column; justify-content: center; gap: 20px; }
.telegram-entry-message h1 { font-size: 34px; letter-spacing: -1px; }
.telegram-entry-message p { line-height: 1.7; color: var(--muted); }
body[data-platform=telegram] .telegram-entry-message { min-height: var(--telegram-height,100dvh); }
.telegram-waiting { display: flex; flex-direction: column; gap: 16px; padding: 24px; border: 1px solid var(--ink); }
.telegram-waiting h2 { font-size: 32px; letter-spacing: -1px; }
.telegram-waiting p { line-height: 1.6; font-size: 13px; }
#telegram-wait-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
body[data-telegram-waiting=true] .board-section, body[data-telegram-waiting=true] .personal-rating, body[data-telegram-waiting=true] .mono-rule, body[data-telegram-waiting=true] .history-section { display: none; }
body[data-telegram-waiting=true] .play-layout { display: flex; align-items: center; justify-content: center; }
body[data-telegram-waiting=true] .lobby-sidebar { flex: 0 1 420px; width: 100%; max-width: 420px; }
