/* Game surface. SVG coordinates, point mapping and pointer targets remain unchanged. */
.game-mode {
    --game-gold: #cbb17f;
    --game-cream: #eee8db;
    --game-muted: #9b9e92;
    --game-line: #63543d;
    display: block;
    background: radial-gradient(ellipse at 50% 40%, #242923 0, #141a16 62%, #101511 100%);
}
.game-mode .sidebar, .game-mode .topbar, .game-mode .site-footer { display: none; }
.game-mode .main-column { min-height: 100dvh; }
.game-mode main { max-width: none; padding: 10px 16px; }
.game-page {
    height: calc(100dvh - 20px);
    min-height: 0;
    display: grid;
    grid-template-rows: 52px minmax(0, 1fr) 20px;
    gap: 6px;
}

/* Two quiet player plaques; the clock always belongs to the active player. */
.match-header {
    width: 100%; max-width: 1480px; margin: 0 auto;
    display: grid; grid-template-columns: 1fr auto 1fr;
    align-items: center; gap: 20px;
}
.match-player {
    display: flex; align-items: center; gap: 12px;
    width: fit-content; max-width: 100%; min-width: 0; height: 49px;
    padding: 5px 12px; border: 1px solid #3d4439; border-radius: 9px;
    background: linear-gradient(145deg, #272e26c9, #192019aa);
    color: var(--game-cream);
}
.match-player.self { justify-self: end; }
.match-player.active-player {
    border-color: #ad9060; background: linear-gradient(145deg, #393b2c, #252b20);
    box-shadow: inset 0 1px #ddc79816, 0 2px 12px #0002;
}
.player-label { display: flex; flex-direction: column; min-width: 0; }
.player-label strong { font-size: 13px; line-height: 1.5; font-weight: 550; max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-label > span { display: flex; align-items: center; color: var(--game-muted); font-size: 9px; line-height: 1.6; white-space: nowrap; }
.player-label-separator { margin: 0 6px; color: #6c7567; }
.connection-dot { width: 4px; height: 4px; background: #74786b; border-radius: 50%; margin-right: 5px; }
.connection-dot.connected { background: #a3b18f; }
.active-player .player-label > span { color: #c6b58f; }
.piece-dot { width: 26px; height: 26px; display: inline-block; border-radius: 50%; flex-shrink: 0; }
.white-dot { border: 1px solid #e7dcc3; background: radial-gradient(circle at 33% 25%, #fff7e5, #b9aa8a); box-shadow: inset 0 0 0 3px #e1d7bf, inset 0 -3px 3px #847150, 0 2px 3px #0006; }
.black-dot { border: 1px solid #6c7565; background: radial-gradient(circle at 33% 25%, #61665a, #1c241d); box-shadow: inset 0 0 0 3px #3f493c, inset 0 -3px 3px #10150f, 0 2px 3px #0006; }
.player-borne { display: flex; align-items: center; gap: 3px; margin-left: 7px; color: #c1beae; font-variant-numeric: tabular-nums; white-space: nowrap; }
.player-borne svg { width: 15px; height: 18px; fill: none; stroke: #9f9173; stroke-width: 2; stroke-linecap: round; margin-right: 3px; }
.player-borne b { font-size: 12px; font-weight: 550; }
.player-borne small { font-size: 8px; color: #8a907f; }
.match-player time { min-width: 58px; text-align: center; padding: 5px 8px; margin-left: 3px; border-left: 1px solid #776443; color: #ebd9b3; font-size: 18px; letter-spacing: .6px; font-variant-numeric: tabular-nums; }
.match-player time.timer-low { color: #e9a789; background: #a65d3820; border-radius: 3px; border-color: #b47150; }
.match-status { display: flex; flex-direction: column; align-items: center; gap: 2px; color: #c8c9ba; font-size: 11px; white-space: nowrap; }
.match-status small { color: #6e7968; font-size: 7px; letter-spacing: 2.5px; }
.my-turn-dot:before { content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #d4ba85; margin-right: 7px; }

/* Desktop retains the original 1200:760 proportions. Mobile stretches only the surface;
   BoardSurfaceObserver corrects the Y scale of circles and labels, so pieces stay round. */
.game-stage { position: relative; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; }
.board-shell {
    --piece-y-correction: 1;
    position: relative; isolation: isolate;
    width: 100%; max-width: min(1480px, calc((100dvh - 106px) * 1.578947));
    aspect-ratio: 1200 / 760;
}
.backgammon-board { display: block; width: 100%; height: 100%; user-select: none; touch-action: manipulation; filter: drop-shadow(0 12px 16px #0006); }
.wood-frame { fill: url(#board-wood); stroke: #8e7251; stroke-width: 1.7; }
.frame-grain { fill: url(#wood-grain); pointer-events: none; }
.frame-inlay { fill: none; stroke: #b79b6c; stroke-width: .8; opacity: .4; pointer-events: none; }
.board-felt { fill: url(#board-field); stroke: #aa9269; stroke-width: 1.5; }
.center-divider { fill: url(#board-bar); stroke: #8f7552; stroke-width: 1.3; }
.point-triangle { stroke-width: 1; }
.light-point { fill: #c6b08b; stroke: #ddc49c; }
.dark-point { fill: #4d5a50; stroke: #71816d; }
.point-number { font-size: 17px; font-weight: 450; text-anchor: middle; fill: #c9b99c; pointer-events: none; }
.board-checker { stroke-width: 1.7; filter: drop-shadow(0 3px 1.5px #0009); }
.white-piece { fill: url(#checker-white); stroke: #f4e9ce; }
.black-piece { fill: url(#checker-black); stroke: #798171; }
.checker-inset { fill: none; stroke-width: 1.4; pointer-events: none; }
.white-inset { stroke: #ad9874; }
.black-inset { stroke: #7c8473; opacity: .75; }
.checker-count { font-size: 19px; font-weight: 650; text-anchor: middle; pointer-events: none; }
.white-count { fill: #42372a; }
.black-count { fill: #e9e6d8; }
.board-checker, .checker-inset, .source-ring, .target-ring, .target-dot, .target-halo,
.checker-count, .point-number, .borne-count {
    transform-box: fill-box; transform-origin: center;
    transform: scaleY(var(--piece-y-correction));
}
.board-point[aria-disabled=false] { cursor: pointer; }
.board-point:focus { outline: none; }
.source-ring { fill: none; stroke: #c3ab76; stroke-width: 1.6; opacity: .65; pointer-events: none; }
.source-ring.selection-ring { opacity: 1; stroke: #f0d7a2; stroke-width: 3; filter: drop-shadow(0 0 6px #e1ba6a85); }
.board-point:focus-visible .source-ring, .board-point:focus-visible .target-ring { stroke: #ffe7b4; stroke-width: 3; }
.target-halo { fill: #d9bb7c; opacity: .12; pointer-events: none; }
.target-ring { fill: #202b24ed; stroke: #e2c58f; stroke-width: 2.1; pointer-events: none; filter: drop-shadow(0 2px 3px #0007); }
.target-dot { fill: #f0d7a5; pointer-events: none; }
.borne-off-zone > rect:first-child { fill: #111c16; stroke: #806c4c; stroke-width: 1.3; }
.borne-off-zone.available-exit { cursor: pointer; }
.available-exit > rect:first-child { stroke: #e7c98c; stroke-width: 2.6; fill: #a88b4929; }
.borne-white { fill: #e7dac0; stroke: #aa9775; stroke-width: .8; }
.borne-black { fill: #354032; stroke: #69735d; stroke-width: .8; }
.borne-count { font-size: 16px; text-anchor: middle; fill: #c2b497; pointer-events: none; }
.borne-label { font-size: 12px; fill: #b39f7e; text-anchor: middle; letter-spacing: 2px; }

/* Floating dice and a small, independent three-button rail. No large control panel. */
.board-center {
    position: absolute; left: 47.2%; top: 50%; transform: translate(-50%, -50%);
    display: flex; flex-direction: row; align-items: center; justify-content: center;
    gap: 24px; max-width: 92%; z-index: 2; pointer-events: none;
}
.board-center > * { pointer-events: auto; }
.dice-defs { position: absolute; width: 0; height: 0; pointer-events: none; }
.dice-values { position: relative; display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 56px; }
.die { display: inline-block; width: 55px; height: 55px; filter: drop-shadow(0 5px 3px #0009); }
.die svg { width: 100%; height: 100%; }
.die-edge { fill: url(#dice-edge-fill); stroke: #78654a; stroke-width: .8; }
.die-face { fill: url(#dice-face-fill); stroke: #faf0dc; stroke-width: 1; }
.die-glint { fill: none; stroke: #fffdf6; stroke-width: 1.2; opacity: .8; }
.die circle { fill: #343c2e; }
.die.used { opacity: .28; filter: none; }
.double-label { position: absolute; bottom: -12px; left: 0; right: 0; text-align: center; font-size: 7px; letter-spacing: 1.6px; color: #c7b38b; white-space: nowrap; }
.roll-dice-button { display: flex; align-items: center; justify-content: center; gap: 11px; min-height: 58px; padding: 4px 14px 4px 5px; background: linear-gradient(145deg, #38423690, #1d2b1daa); border: 1px solid #8e805d; border-radius: 11px; box-shadow: inset 0 1px #d3ba8420, 0 4px 10px #0005; }
.roll-dice-button:not(:disabled):hover { border-color: #e0c08a; background: #41503ad4; }
.roll-label { font-size: 11px; color: #e8d6b1; letter-spacing: .4px; }
.empty-dice { display: inline-block; width: 72px; height: 52px; filter: drop-shadow(0 3px 3px #0008); }
.empty-dice svg { display: block; width: 100%; height: 100%; }
.empty-dice rect { fill: url(#dice-face-fill); stroke: #e9d5b0; stroke-width: 1; }
.empty-dice circle { fill: #3b4335; }
.roll-dice-button:disabled { opacity: .35; }
.game-controls { display: flex; gap: 6px; align-items: center; padding: 5px; background: #152017cc; border: 1px solid #756141; border-radius: 28px; box-shadow: inset 0 1px #d9c08c12, 0 4px 14px #0006; }
.game-action, .game-menu summary { display: grid; place-items: center; width: 46px; height: 46px; min-width: 46px; min-height: 46px; padding: 0; border-radius: 50%; border: 1px solid #777052; color: #e4d4ae; background: linear-gradient(145deg, #3d4938, #273224); cursor: pointer; }
.game-action > span { font-size: 25px; line-height: 1; font-weight: 450; }
.confirm-action { color: #2c3222; border-color: #d7c08b; background: linear-gradient(145deg, #e4d3a8, #b6a06b); }
.game-action:hover:not(:disabled), .game-menu summary:hover { border-color: #e6c998; box-shadow: inset 0 1px #fff2, 0 0 0 2px #c8ac7320; }
.game-action:disabled { opacity: .28; }
.game-menu { position: relative; }
.game-menu summary { list-style: none; font-size: 24px; line-height: 1; }
.game-menu summary::-webkit-details-marker { display: none; }
.game-menu-items { position: absolute; right: -5px; top: 57px; width: 252px; max-height: min(310px, 45dvh); overflow-y: auto; background: #222b21f7; border: 1px solid #8b7751; border-radius: 11px; padding: 7px; box-shadow: 0 14px 35px #0009; z-index: 10; }
.game-menu-items button { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 44px; gap: 8px; text-align: left; font-size: 12px; padding: 11px 10px; background: transparent; border: 0; border-radius: 6px; }
.game-menu-items button:hover:not(:disabled) { background: #a48c4930; }
.game-menu-items small { font-size: 9px; color: #9d9d86; }
.die-choice { position: absolute; top: calc(100% + 12px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 7px; border: 1px solid #9a8057; border-radius: 8px; background: #273324f5; box-shadow: 0 6px 20px #0007; white-space: nowrap; font-size: 10px; }
.die-choice > span { padding: 0 5px; color: #d3c29b; }
.die-choice button { min-width: 44px; min-height: 44px; background: #decca0; color: #343725; border: 0; border-radius: 6px; font-weight: 650; }
.board-caption { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; max-width: 1480px; margin: 0 auto; font-size: 9px; color: #8e9888; }
.caption-divider { margin: 0 9px; color: #665e49; }

/* Translucent states keep the physical position visible. */
.board-overlay { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; border-radius: 18px; background: #0c130c66; backdrop-filter: blur(.8px); }
.board-overlay-card { text-align: center; padding: 28px 32px; max-width: min(420px, 88%); border: 1px solid #9b8156; border-radius: 15px; background: linear-gradient(145deg, #30382be8, #1c281de8); box-shadow: inset 0 1px #e9d6a418, 0 18px 50px #0007; }
.overlay-symbol { font-size: 30px; color: #d6bd86; line-height: 1; }
.board-overlay h2 { font-size: 22px; font-weight: 500; letter-spacing: 2px; text-transform: uppercase; margin: 16px 0 12px; color: #f0e4c7; }
.board-overlay p { font-size: 11px; line-height: 1.8; color: #b7c1aa; max-width: 310px; margin: 0 auto 16px; }
.board-overlay small { display: block; color: #b5b48c; font-size: 9px; margin-top: 12px; }
.game-page .button.primary { color: #303523; border-color: #d3ba82; background: linear-gradient(145deg, #e6d6af, #b7a06d); }
.game-page .button.secondary { color: #decba3; border-color: #948058; background: #35412c; }
.board-overlay .button { min-height: 44px; padding: 10px 24px; font-size: 12px; }
.game-error { position: fixed; bottom: 15px; left: 50%; transform: translateX(-50%); max-width: 90%; z-index: 30; border: 1px solid #b28d6b; border-radius: 9px; background: #443229f5; color: #efdbc4; padding: 12px 18px; font-size: 12px; box-shadow: 0 4px 25px #0005; }
.result-backdrop { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: #0c130d9c; backdrop-filter: blur(1.5px); border-radius: 18px; }
.result-dialog { display: flex; flex-direction: column; align-items: center; min-width: min(420px, 90%); max-width: 92%; max-height: 96%; overflow-y: auto; padding: 30px 44px; text-align: center; background: radial-gradient(ellipse at 50% 0, #414633, #212b20 75%); border: 1px solid #9b8155; border-radius: 18px; box-shadow: inset 0 1px #e1c78f20, 0 20px 70px #0008; }
.result-mark { display: grid; place-items: center; width: 57px; height: 57px; border: 1px solid #ad9564; border-radius: 50%; margin-bottom: 20px; color: #e6cc91; font-size: 33px; background: #b6964310; box-shadow: 0 0 0 6px #b89d5710; }
.result-dialog .eyebrow { color: #b4a17b; font-size: 8px; letter-spacing: 2px; margin-bottom: 13px; }
.result-dialog h1 { font-size: 35px; letter-spacing: 4px; color: #eeddb7; margin-bottom: 8px; }
.result-loss h1 { color: #d6c5b3; }.result-draw h1 { color: #dedfcc; }
.result-dialog .result-type { font-size: 13px; color: #b5bfa7; margin: 0; }
.result-points { display: flex; align-items: baseline; gap: 7px; color: #eeddb7; font-size: 58px; font-weight: 400; line-height: 1.25; margin: 12px 0; font-variant-numeric: tabular-nums; }
.result-points small { font-size: 13px; color: #b3a987; }
.result-players { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; width: 100%; padding: 16px 0; border-block: 1px solid #90805b50; margin: 0 0 15px; }
.result-players > span { display: flex; align-items: center; gap: 7px; font-size: 12px; color: #d6dac8; }
.result-players .piece-dot { width: 19px; height: 19px; }
.result-versus { color: #8e8c72 !important; }
.result-dialog .result-winner { font-size: 11px; color: #b0bba3; margin: 0 0 10px; }
.result-dialog .button { min-height: 46px; margin-top: 8px; font-size: 12px; }
.portrait-cover { display: none; }

@media (max-width: 1100px) {
    .game-mode main { padding: 7px 8px; }
    .game-page { height: calc(100dvh - 14px); grid-template-rows: 47px minmax(0, 1fr) 17px; gap: 4px; }
    .board-shell { max-width: calc((100dvh - 90px) * 1.578947); }
    .match-header { gap: 8px; }
    .match-player { gap: 8px; padding: 4px 8px; height: 43px; }
    .player-label strong { font-size: 12px; max-width: 135px; }
    .player-label > span { font-size: 8px; }.piece-dot { width: 23px; height: 23px; }
    .player-borne { margin-left: 1px; }.match-player time { min-width: 51px; font-size: 16px; padding: 4px 5px; }
    .match-status { font-size: 10px; }.match-status small { font-size: 6px; letter-spacing: 1.5px; }
    .die { width: 47px; height: 47px; }.dice-values { min-height: 49px; gap: 7px; }
    .board-center { gap: 17px; }.game-action, .game-menu summary { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
    .board-caption { font-size: 8px; }
}
@media (max-width: 1100px) and (orientation: landscape) and (max-height: 600px) {
    .game-mode main { padding: max(2px, env(safe-area-inset-top)) max(3px, env(safe-area-inset-right)) max(2px, env(safe-area-inset-bottom)) max(3px, env(safe-area-inset-left)); }
    .game-page { height: calc(100dvh - max(2px, env(safe-area-inset-top)) - max(2px, env(safe-area-inset-bottom))); grid-template-rows: 36px minmax(0, 1fr); gap: 2px; }
    .match-header { gap: 8px; }
    .match-player { height: 34px; padding: 2px 7px; gap: 7px; border-radius: 7px; }
    .player-label strong { font-size: 11px; max-width: 132px; line-height: 1.3; }
    .player-label > span { font-size: 7px; line-height: 1.4; }.player-label-separator { margin: 0 4px; }
    .piece-dot { width: 21px; height: 21px; }.player-borne svg { width: 12px; height: 14px; margin-right: 0; }
    .player-borne b { font-size: 11px; }.player-borne small { font-size: 7px; }
    .match-player time { font-size: 16px; min-width: 48px; padding: 3px 4px; }
    .match-status { font-size: 9px; gap: 0; }.match-status small { display: none; }
    .board-shell { width: 100%; max-width: none; height: 100%; aspect-ratio: auto; }
    .board-caption { display: none; }
    .backgammon-board { filter: drop-shadow(0 3px 5px #0006); }
    .board-center { gap: 13px; max-width: 94%; }
    .game-controls { padding: 3px; gap: 4px; border-radius: 26px; }
    .game-action, .game-menu summary { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
    .game-action > span { font-size: 24px; }.game-menu summary { font-size: 23px; }
    .dice-values { min-height: 43px; gap: 6px; }.die { width: 42px; height: 42px; }
    .double-label { bottom: -9px; font-size: 6px; letter-spacing: 1px; }
    .roll-dice-button { min-height: 49px; padding: 1px 9px 1px 2px; gap: 6px; border-radius: 9px; }
    .empty-dice { width: 64px; height: 47px; }.roll-label { font-size: 10px; }
    .game-menu-items { top: 51px; max-height: calc(50dvh - 50px); width: 235px; padding: 5px; }
    .game-menu-items button { padding: 9px 10px; font-size: 11px; }
    .die-choice { top: calc(100% + 8px); }
    .board-overlay-card { padding: 15px 25px; }.overlay-symbol { font-size: 25px; }
    .board-overlay h2 { font-size: 18px; letter-spacing: 1.7px; margin: 9px 0; }
    .board-overlay p { font-size: 10px; margin-bottom: 12px; }
    .board-overlay .button { min-height: 44px; font-size: 11px; }
    .result-dialog { padding: 14px 28px; min-width: min(370px, 90%); display: grid; grid-template-columns: 1fr auto; column-gap: 24px; align-items: center; justify-items: center; }
    .result-mark { grid-column: 2; grid-row: 1 / 4; width: 48px; height: 48px; margin: 0; font-size: 27px; }
    .result-dialog .eyebrow { grid-column: 1; margin: 0 0 4px; font-size: 6px; }
    .result-dialog h1 { grid-column: 1; margin: 0; font-size: 26px; letter-spacing: 2px; }
    .result-dialog .result-type { grid-column: 1; font-size: 10px; }
    .result-points { grid-column: 2; grid-row: 4; font-size: 35px; margin: 0; }
    .result-points small { font-size: 9px; }.result-players { grid-column: 1; grid-row: 4; gap: 8px; padding: 10px 0; margin: 9px 0; }
    .result-players > span { font-size: 10px; }.result-players .piece-dot { width: 16px; height: 16px; }
    .result-dialog .result-winner { grid-column: 1 / -1; font-size: 9px; margin: 0; }
    .result-dialog .button { grid-column: 1 / -1; min-height: 44px; margin-top: 9px; }
    .game-error { bottom: 7px; font-size: 11px; padding: 10px 14px; }
}
@media (max-width: 700px) and (orientation: landscape) {
    .player-borne svg { display: none; }.player-label strong { max-width: 100px; }
    .match-player { gap: 6px; }.match-status { font-size: 8px; }.match-player time { font-size: 14px; min-width: 42px; }
    .match-player .piece-dot { width: 18px; height: 18px; }.player-label-separator { margin: 0 3px; }
    .board-center { gap: 10px; }.die { width: 37px; height: 37px; }.dice-values { gap: 4px; }
    .roll-label { display: none; }.roll-dice-button { padding: 0 3px; }
}
@media (max-width: 900px) and (orientation: portrait) {
    .portrait-cover { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; background: #172018f5; backdrop-filter: blur(8px); }
    .portrait-cover > span { font-size: 68px; color: #d9bd86; line-height: 1; }
    .portrait-cover h2 { font-size: 23px; line-height: 1.5; margin: 22px 0 15px; color: #eee4cf; }
    .portrait-cover p { font-size: 12px; color: #a9b29d; }
}
/* End-of-game actions keep the board visible and fit short landscape screens. */
.endgame-modal { z-index: 100; }
.endgame-modal .join-modal { max-height: 92dvh; overflow: auto; }
.resign-options { display: grid; gap: .55rem; margin: 1rem 0; }
.resign-options .button { justify-content: space-between; }
.dialog-actions, .result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; }
.button.danger { background: #8f443b; color: #fff5e7; }
.result-dialog { max-height: 94dvh; overflow: auto; }
.result-metrics { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin: .8rem 0 1rem; color: #aca99c; font-size: .8rem; }
.result-metrics b { display: block; color: #eee4d1; margin-top: .25rem; }
.result-reason { color: #aaa69a; font-size: .8rem; }
.rematch-notice { color: #d8bd82; font-size: .9rem; }
.rematch-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; margin-bottom: 1rem; }
@media (max-height: 500px) and (orientation: landscape) {
 .result-dialog { padding: .8rem 1.3rem; width: min(620px, 95vw); }
 .result-dialog .result-mark { display: none; }
 .result-dialog h1 { font-size: 1.6rem; margin: .2rem; }
 .result-dialog .result-points { font-size: 1.8rem; margin: .2rem; }
 .result-metrics { margin: .4rem; }
 .result-dialog p { margin: .3rem 0; }
}
