/* Dame — checkers for two on one phone, or against the phone (js/dame.js). Theme-aware like
   the other tool pages: tokens on :root, redefined under body.dark-theme. */
:root {
    --dm-accent: #9a3412;
    --dm-accent-soft: #ffedd5;
    --dm-page-bg: #fbf7f2;
    --dm-card-bg: #ffffff;
    --dm-card-border: #e7e0d6;
    --dm-muted: #6b7280;
    --dm-shadow: 0 10px 30px rgba(90, 50, 20, .10);
    --dm-sq-light: #f1dfc0;
    --dm-sq-dark: #a86f45;
    --dm-frame: #5b3a22;
    --dm-move: rgba(250, 204, 21, .95);
    --dm-dest: rgba(22, 163, 74, .85);
    --dm-last: rgba(250, 204, 21, .32);
}

body.dark-theme {
    --dm-accent: #fb923c;
    --dm-accent-soft: #3b2417;
    --dm-page-bg: #111827;
    --dm-card-bg: #1f2937;
    --dm-card-border: #374151;
    --dm-muted: #9ca3af;
    --dm-shadow: 0 10px 30px rgba(0, 0, 0, .4);
    --dm-sq-light: #c9b08c;
    --dm-sq-dark: #7a4f31;
    --dm-frame: #2b1b10;
    --dm-dest: rgba(74, 222, 128, .9);
}

/* clip, not hidden: the site-wide `body { overflow-x: hidden }` makes <body> a scroll
   container that never scrolls, which silently kills any position: sticky inside. */
.dm-body, body.dm-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--dm-page-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: clip;
}
.dm-main { padding-top: 100px; padding-bottom: 40px; }
.dm-game .container, .dm-hero .container { max-width: 600px; }

/* ---- hero ---- */
.dm-hero { text-align: center; padding: 4px 0 10px; }
.dm-hero h1 { font-weight: 800; font-size: clamp(1.6rem, 5vw, 2.3rem); margin: 0 0 6px; display: inline-flex; align-items: center; gap: 12px; }
.dm-hero-icon { width: 46px; height: 46px; border-radius: 14px; display: inline-grid; place-items: center; font-size: 22px; color: #fff; background: linear-gradient(135deg, #c2410c, #5b3a22); box-shadow: var(--dm-shadow); }
.dm-lead { max-width: 560px; margin: 0 auto; color: var(--dm-muted); font-size: 1rem; line-height: 1.55; }

/* ---- mode picker ---- */
.dm-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; margin: 10px 0 12px; border-radius: 16px; background: var(--dm-card-bg); border: 1px solid var(--dm-card-border); }
.dm-mode { min-height: 52px; padding: 6px 8px; border: 0; border-radius: 12px; background: transparent; color: inherit; font-weight: 700; font-size: .95rem; line-height: 1.2; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; touch-action: manipulation; text-align: left; }
.dm-mode small { display: block; font-weight: 500; font-size: .76rem; color: var(--dm-muted); }
.dm-mode[aria-checked="true"] { background: var(--dm-accent); color: #fff; }
.dm-mode[aria-checked="true"] small { color: rgba(255, 255, 255, .85); }
.dm-mode:focus-visible { outline: 2px solid var(--dm-accent); outline-offset: 2px; }

/* ---- turn ---- */
.dm-turn { display: flex; align-items: center; justify-content: center; gap: 12px; font-weight: 800; font-size: clamp(1.5rem, 6.5vw, 2.1rem); line-height: 1.15; text-align: center; margin: 4px 0 2px; }
.dm-turn-dot { width: .9em; height: .9em; border-radius: 50%; flex: none; box-shadow: 0 2px 4px rgba(0, 0, 0, .35); }
.dm-turn-dot.is-w, .dm-mini-w { background: radial-gradient(circle at 35% 30%, #ffffff, #efe4cf 55%, #c9b591); }
.dm-turn-dot.is-b, .dm-mini-b { background: radial-gradient(circle at 35% 30%, #6b6b6b, #262626 55%, #0b0b0b); }
.dm-turn.is-thinking #dm-turn-text::after { content: ""; display: inline-block; width: .9em; text-align: left; animation: dm-dots 1.2s steps(4) infinite; }
@keyframes dm-dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.dm-hint { min-height: 1.5em; margin: 0 0 8px; text-align: center; color: var(--dm-muted); font-size: .95rem; font-weight: 600; }
.dm-hint.is-alert { color: var(--dm-accent); }

/* ---- board ---- */
.dm-board-wrap { position: relative; width: 100%; max-width: 560px; margin: 0 auto; }
.dm-board { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); aspect-ratio: 1 / 1; width: 100%; border: 6px solid var(--dm-frame); border-radius: 10px; overflow: hidden; box-shadow: var(--dm-shadow); background: var(--dm-sq-dark); user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.dm-sq { position: relative; min-width: 0; min-height: 0; }
.dm-sq.is-light { background: var(--dm-sq-light); }
.dm-cell { display: block; width: 100%; height: 100%; padding: 0; margin: 0; border: 0; border-radius: 0; background: var(--dm-sq-dark); color: inherit; cursor: default; touch-action: manipulation; font: inherit; }
.dm-cell:focus { outline: none; }
.dm-cell:focus-visible { outline: 3px solid #38bdf8; outline-offset: -3px; z-index: 2; }
.dm-cell.is-last { background-image: linear-gradient(var(--dm-last), var(--dm-last)); }
.dm-cell.is-movable, .dm-cell.is-dest { cursor: pointer; }

/* legal destination: a dot; on a capture move a ring */
.dm-cell.is-dest::after { content: ""; position: absolute; left: 50%; top: 50%; width: 32%; height: 32%; transform: translate(-50%, -50%); border-radius: 50%; background: var(--dm-dest); box-shadow: 0 0 0 3px rgba(255, 255, 255, .35); pointer-events: none; }
.dm-cell.is-dest.is-jump::after { width: 46%; height: 46%; background: transparent; border: 4px solid var(--dm-dest); box-shadow: none; }

/* pieces */
.dm-piece { position: absolute; left: 9%; top: 9%; width: 82%; height: 82%; border-radius: 50%; display: grid; place-items: center; touch-action: none; transition: box-shadow .12s; will-change: transform; }
.dm-piece.is-w { background: radial-gradient(circle at 35% 30%, #ffffff 0%, #f4ead8 45%, #d6c3a0 80%, #b9a17a 100%); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12), inset 0 0 0 3px rgba(255, 255, 255, .45), 0 3px 5px rgba(0, 0, 0, .45); color: #9a3412; }
.dm-piece.is-b { background: radial-gradient(circle at 35% 30%, #7a7a7a 0%, #333333 40%, #161616 75%, #050505 100%); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .4), inset 0 0 0 3px rgba(255, 255, 255, .10), 0 3px 5px rgba(0, 0, 0, .55); color: #fbbf24; }
.dm-piece::before { content: ""; position: absolute; inset: 18%; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .10); }
.dm-piece.is-b::before { border-color: rgba(255, 255, 255, .10); }
.dm-crown { position: relative; font-size: clamp(16px, 5.4vw, 34px); line-height: 1; text-shadow: 0 1px 1px rgba(0, 0, 0, .35); font-family: "Segoe UI Symbol", "DejaVu Sans", "Noto Sans Symbols 2", sans-serif; }
.dm-cell.is-movable .dm-piece { box-shadow: 0 0 0 3px var(--dm-move), 0 3px 6px rgba(0, 0, 0, .5); }
.dm-cell.is-selected .dm-piece { box-shadow: 0 0 0 4px #38bdf8, 0 0 14px 2px rgba(56, 189, 248, .7); }
.dm-piece.is-ghost { opacity: .32; filter: grayscale(.6); }
.dm-piece.is-landed { animation: dm-land .22s ease-out; }
@keyframes dm-land { from { transform: scale(1.18); } to { transform: scale(1); } }
.dm-board.is-dragging .dm-piece { pointer-events: none; }
.dm-board.is-dragging .dm-sq.is-drag-src { z-index: 5; }
.dm-board.is-dragging .is-drag-src .dm-piece { transition: none; }
.dm-board.is-locked .dm-cell { cursor: default; }

/* ---- game over ---- */
.dm-over { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .35); border-radius: 10px; z-index: 10; animation: dm-fade .25s ease-out; }
.dm-over[hidden] { display: none; }
@keyframes dm-fade { from { opacity: 0; } to { opacity: 1; } }
.dm-over-card { width: min(320px, 100%); padding: 20px 18px 18px; border-radius: 18px; background: var(--dm-card-bg); color: var(--text-color); text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .45); }
.dm-over-icon { width: 54px; height: 54px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; color: #fff; background: linear-gradient(135deg, #f59e0b, #c2410c); }
.dm-over-card h2 { font-size: 1.45rem; font-weight: 800; margin: 0 0 4px; }
.dm-over-card p { margin: 0 0 14px; color: var(--dm-muted); }
.dm-over-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* ---- buttons ---- */
.dm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px auto 10px; max-width: 560px; }
.dm-btn { min-height: 48px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--dm-card-border); background: var(--dm-card-bg); color: inherit; font-weight: 700; font-size: .98rem; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; touch-action: manipulation; box-shadow: 0 2px 6px rgba(0, 0, 0, .05); }
.dm-btn:hover:not(:disabled) { border-color: var(--dm-accent); }
.dm-btn:disabled { opacity: .45; cursor: not-allowed; }
.dm-btn:focus-visible { outline: 2px solid var(--dm-accent); outline-offset: 2px; }
.dm-btn-primary { background: var(--dm-accent); border-color: var(--dm-accent); color: #fff; }
body.dark-theme .dm-btn-primary { color: #1f130b; }
.dm-link { border: 0; background: none; padding: 4px 6px; color: var(--dm-muted); font-size: .85rem; text-decoration: underline; cursor: pointer; }

/* ---- flip switch ---- */
.dm-switch { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0 auto 14px; font-weight: 600; cursor: pointer; user-select: none; }
.dm-switch[hidden] { display: none; }
.dm-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dm-switch-track { position: relative; width: 46px; height: 26px; flex: none; border-radius: 999px; background: var(--dm-card-border); transition: background .15s; }
.dm-switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
.dm-switch input:checked + .dm-switch-track { background: var(--dm-accent); }
.dm-switch input:checked + .dm-switch-track::after { transform: translateX(20px); }
.dm-switch input:focus-visible + .dm-switch-track { outline: 2px solid var(--dm-accent); outline-offset: 2px; }

/* ---- score ---- */
.dm-score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; max-width: 560px; margin: 0 auto; padding: 12px; border-radius: 16px; background: var(--dm-card-bg); border: 1px solid var(--dm-card-border); box-shadow: var(--dm-shadow); }
.dm-score-side { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "dot name" "num num" "left left"; align-items: center; justify-items: center; column-gap: 6px; text-align: center; }
.dm-mini { grid-area: dot; width: 16px; height: 16px; border-radius: 50%; box-shadow: 0 1px 2px rgba(0, 0, 0, .4); justify-self: end; }
.dm-score-name { grid-area: name; font-weight: 700; justify-self: start; }
.dm-score-num { grid-area: num; font-size: 2rem; font-weight: 800; line-height: 1.1; }
.dm-score-left { grid-area: left; color: var(--dm-muted); font-size: .82rem; }
.dm-score-mid { color: var(--dm-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.dm-reset-wrap { text-align: center; margin: 4px 0 12px; }

/* ---- help ---- */
.dm-help { max-width: 560px; margin: 0 auto; padding: 12px 14px; border-radius: 14px; background: var(--dm-card-bg); border: 1px solid var(--dm-card-border); }
.dm-help summary { font-weight: 700; cursor: pointer; }
.dm-help ul { margin: 10px 0 8px; padding-left: 20px; line-height: 1.55; }
.dm-help p { margin: 0; color: var(--dm-muted); font-size: .93rem; }
.dm-powered { text-align: center; color: var(--dm-muted); font-size: .85rem; margin: 22px 0 0; }
.dm-powered a { color: var(--dm-accent); }

@media (max-width: 420px) {
    .dm-main { padding-top: 92px; }
    .dm-mode { font-size: .88rem; gap: 6px; padding: 6px; }
    .dm-btn { font-size: .9rem; padding: 8px 10px; }
    .dm-board { border-width: 4px; }
}

/* ---- the 3D park table (shared with Șah): the players at a stone table, the checkers by hand ---- */
.dm-board-wrap.is-3d { max-width: 980px; }
.dm-board-wrap.is-3d > .dm-board { display: none; }
.dm-board3d { position: relative; width: 100%; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; background: #bcd8ec; box-shadow: var(--dm-shadow); }
.dm-board3d[hidden] { display: none; }
@media (max-width: 575.98px) { .dm-board3d { aspect-ratio: 1 / 1; } }
.dm-view-btns { position: absolute; top: 6px; left: 6px; z-index: 6; display: flex; gap: 6px; }
.dm-view-btns[hidden] { display: none; }
.dm-view-btn { width: 38px; height: 38px; border: 0; border-radius: 8px; display: grid; place-items: center; background: rgba(0, 0, 0, .55); color: #fff; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.dm-view-btn.on { background: #1abc9c; color: #0d1f1a; }
.board-voice-btn { position: absolute; top: 6px; right: 6px; z-index: 5; width: 40px; height: 40px; border: 0; border-radius: 8px; display: grid; place-items: center;
    background: rgba(0, 0, 0, 0.55); color: #fff; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.board-voice-btn:active { transform: scale(0.92); }
.people-say { position: absolute; z-index: 4; transform: translateY(-50%); max-width: min(70%, 320px); padding: 0.35rem 0.75rem; border-radius: 14px;
    background: rgba(255, 255, 255, 0.95); color: #222; font-weight: 700; font-size: 0.95rem; line-height: 1.25; text-align: center; pointer-events: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25); }
.people-say[hidden] { display: none; }
.people-say::after { content: ''; position: absolute; right: 100%; top: 50%; transform: translateY(-50%); border: 7px solid transparent; border-right-color: rgba(255, 255, 255, 0.95); }
.people-say.flip::after { right: auto; left: 100%; border-right-color: transparent; border-left-color: rgba(255, 255, 255, 0.95); }
.people-say.me { top: auto; bottom: 62px; transform: translateX(-50%); background: rgba(20, 30, 20, 0.82); color: #fff; }
.people-say.me::after { display: none; }

/* full screen: the table fills the screen (a CSS fallback where the browser has no element full screen, as on iPhone) */
.dm-board-wrap.is-fs { position: fixed; inset: 0; z-index: 2000; max-width: none; width: 100vw; height: 100vh; height: 100dvh; margin: 0; background: #0d1117; }
.dm-board-wrap:fullscreen { max-width: none; width: 100vw; height: 100vh; background: #0d1117; }
.dm-board-wrap.is-fs > .dm-board3d, .dm-board-wrap:fullscreen > .dm-board3d { width: 100%; height: 100%; aspect-ratio: auto; border-radius: 0; }
.dm-board-wrap.is-fs > .dm-board, .dm-board-wrap:fullscreen > .dm-board { width: min(100vw, 100vh); margin: auto; }
body.dm-fs-lock { overflow: hidden; }
