/* Cuvinte pe tablă — the Romanian tile word game (js/cuvinte-pe-tabla.js).
   Theme-aware like the other game pages: tokens on :root, redefined under body.dark-theme. */
:root {
    --ct-accent: #9a3412;
    --ct-accent-2: #c2410c;
    --ct-accent-soft: #fdeee2;
    --ct-on-accent: #ffffff;
    --ct-page-bg: #f7f3ec;
    --ct-card-bg: #ffffff;
    --ct-card-border: #e5dccd;
    --ct-muted: #6b5e4f;
    --ct-shadow: 0 10px 30px rgba(70, 40, 10, .10);
    --ct-frame: #3f4a5a;
    --ct-frame-2: #2c3542;
    --ct-cell: #ece6d9;
    --ct-cell-text: #8a7f6c;
    --ct-tw: #ea7a1c;
    --ct-tw-text: #ffffff;
    --ct-dw: #a78bfa;
    --ct-dw-text: #ffffff;
    --ct-tl: #0f8a7e;
    --ct-tl-text: #ffffff;
    --ct-dl: #a5ecdc;
    --ct-dl-text: #0b4f47;
    --ct-tile: #fbe6b0;
    --ct-tile-2: #efd08a;
    --ct-tile-edge: #c9a45a;
    --ct-tile-text: #3a2810;
    --ct-blank-text: #0f766e;
    --ct-pend: #2563eb;
    --ct-last: #f59e0b;
    --ct-ok: #15803d;
    --ct-ko: #dc2626;
    --ct-gold: #f59e0b;
    --ct-p0: #2563eb;
    --ct-p1: #db2777;
    --ct-p2: #7c3aed;
    --ct-p3: #0d9488;
    --ct-c: 24px;           /* one board cell, set by the script */
}

body.dark-theme {
    --ct-accent: #fb923c;
    --ct-accent-2: #fdba74;
    --ct-accent-soft: #3a2212;
    --ct-on-accent: #2a1305;
    --ct-page-bg: #14110e;
    --ct-card-bg: #1f1b17;
    --ct-card-border: #3a3129;
    --ct-muted: #b3a593;
    --ct-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    --ct-frame: #0d1117;
    --ct-frame-2: #06080b;
    --ct-cell: #2a303a;
    --ct-cell-text: #8892a2;
    --ct-tw: #c2620f;
    --ct-dw: #7c5cd6;
    --ct-tl: #0e8a7d;
    --ct-dl: #22413c;
    --ct-dl-text: #8be9d6;
    --ct-pend: #60a5fa;
    --ct-ok: #4ade80;
    --ct-ko: #f87171;
    --ct-gold: #fbbf24;
    --ct-blank-text: #0f766e;
}

/* 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. */
.ct-body, body.ct-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--ct-page-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: clip;
}
.ct-main { padding-top: 22px; padding-bottom: 40px; }   /* body#page-top already pads 72px for the fixed nav */
.ct-wrap { max-width: 1060px; }

/* ---- hero ---- */
.ct-hero { text-align: center; padding: 4px 0 8px; }
.ct-hero h1 { font-weight: 800; font-size: clamp(1.6rem, 5vw, 2.2rem); margin-bottom: 4px; display: inline-flex; align-items: center; gap: 10px; }
.ct-hero-tiles { display: inline-flex; gap: 3px; }
.ct-hero-tiles span { width: 1.25em; height: 1.25em; display: grid; place-items: center; border-radius: 6px; font-size: .78em; background: linear-gradient(160deg, var(--ct-tile), var(--ct-tile-2)); color: var(--ct-tile-text); box-shadow: inset 0 -3px 0 var(--ct-tile-edge), 0 2px 5px rgba(0, 0, 0, .2); }
.ct-hero-tiles span + span { transform: rotate(6deg); }
.ct-lead { margin: 0 auto; max-width: 600px; color: var(--ct-muted); font-size: .98rem; line-height: 1.45; }
body.ct-playing .ct-lead { display: none; }
body.ct-playing .ct-hero { padding: 0 0 6px; }
body.ct-playing .ct-hero h1 { font-size: 1.3rem; margin: 0; }

/* ---- setup ---- */
.ct-setup { max-width: 560px; margin: 6px auto 0; padding: 14px; border-radius: 18px; background: var(--ct-card-bg); border: 1px solid var(--ct-card-border); box-shadow: var(--ct-shadow); }
.ct-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; margin-bottom: 12px; border-radius: 16px; background: var(--ct-page-bg); border: 1px solid var(--ct-card-border); }
.ct-mode { min-height: 50px; padding: 6px 8px; border: 0; border-radius: 12px; background: transparent; color: inherit; font-weight: 700; font-size: .9rem; line-height: 1.15; cursor: pointer; touch-action: manipulation; display: flex; align-items: center; justify-content: center; gap: 7px; text-align: center; }
.ct-mode small { display: block; font-weight: 600; opacity: .8; }
.ct-mode[aria-checked="true"] { background: var(--ct-accent); color: var(--ct-on-accent); }
.ct-field { margin: 0 0 12px; }
.ct-field[hidden] { display: none; }
.ct-label { display: block; font-weight: 800; margin: 0 0 6px; }
.ct-note { display: block; color: var(--ct-muted); margin-top: 5px; font-size: .84rem; line-height: 1.35; min-height: 1.35em; }
.ct-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ct-chip { min-width: 52px; min-height: 46px; padding: 6px 14px; border-radius: 12px; border: 2px solid var(--ct-card-border); background: var(--ct-card-bg); color: inherit; font-weight: 800; font-size: 1rem; cursor: pointer; touch-action: manipulation; flex: 1 1 0; }
.ct-chip[aria-checked="true"] { border-color: var(--ct-accent); background: var(--ct-accent-soft); color: var(--ct-accent); }
.ct-names { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.ct-name { display: flex; align-items: center; gap: 6px; min-width: 0; margin: 0; padding: 0 8px; min-height: 44px; border-radius: 12px; border: 1px solid var(--ct-card-border); background: var(--ct-page-bg); }
.ct-name[hidden] { display: none; }
.ct-name input { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; color: inherit; font-weight: 700; font-size: 16px; padding: 8px 0; outline: none; }
.ct-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block; }
.ct-dot.c0 { background: var(--ct-p0); } .ct-dot.c1 { background: var(--ct-p1); } .ct-dot.c2 { background: var(--ct-p2); } .ct-dot.c3 { background: var(--ct-p3); }
.ct-dict { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin: 2px 0 12px; font-size: .86rem; color: var(--ct-muted); min-height: 24px; }
.ct-dict-bar { flex: 1 1 120px; height: 6px; border-radius: 4px; background: var(--ct-card-border); overflow: hidden; }
.ct-dict-bar span { display: block; height: 100%; width: 0; background: var(--ct-accent); transition: width .2s; }
.ct-dict.is-ready .ct-dict-bar { display: none; }
.ct-dict.is-ready .ct-dict-txt { color: var(--ct-ok); font-weight: 700; }
.ct-dict.is-error .ct-dict-txt { color: var(--ct-ko); font-weight: 700; }
.ct-start, .ct-resume { width: 100%; }
.ct-resume { margin-top: 8px; }
.ct-chip:focus-visible, .ct-mode:focus-visible, .ct-btn:focus-visible, .ct-tool:focus-visible, .ct-rtile:focus-visible, .ct-letter:focus-visible { outline: 3px solid var(--ct-gold); outline-offset: 2px; }

/* ---- buttons ---- */
.ct-btn { min-height: 48px; padding: 8px 14px; border: 1px solid var(--ct-card-border); border-radius: 14px; background: var(--ct-card-bg); color: inherit; font-weight: 700; font-size: .95rem; cursor: pointer; touch-action: manipulation; display: inline-flex; align-items: center; justify-content: center; gap: 8px; -webkit-tap-highlight-color: transparent; }
.ct-btn:hover:not(:disabled) { border-color: var(--ct-accent); }
.ct-btn:disabled { opacity: .42; cursor: not-allowed; }
.ct-btn-primary { background: var(--ct-accent); border-color: var(--ct-accent); color: var(--ct-on-accent); }
.ct-btn-sm { min-height: 36px; padding: 4px 10px; font-size: .85rem; border-radius: 10px; }
.ct-wide { width: 100%; }

/* ---- layout ---- */
.ct-play { margin: 0 auto; }
.ct-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; max-width: 560px; margin: 0 auto; }

/* ---- scores ---- */
.ct-scores { display: flex; gap: 6px; }
.ct-pl { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 5px 8px; min-height: 44px; border-radius: 12px; background: var(--ct-card-bg); border: 2px solid var(--ct-card-border); }
.ct-pl.is-turn { border-color: var(--pc, var(--ct-accent)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc, var(--ct-accent)) 22%, transparent); }
.ct-pl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: .86rem; line-height: 1.15; }
.ct-pl-name small { display: block; color: var(--ct-muted); font-weight: 600; font-size: .72rem; }
.ct-pl-score { font-weight: 900; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.ct-pl .ct-dot { background: var(--pc); }
.ct-pl-think { display: none; color: var(--ct-muted); font-size: .8rem; }
.ct-pl.is-thinking .ct-pl-think { display: inline-block; animation: ct-spin 1s linear infinite; }
@keyframes ct-spin { to { transform: rotate(360deg); } }

/* ---- board ---- */
.ct-board-col { min-width: 0; }
.ct-board-wrap { position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; background: linear-gradient(160deg, var(--ct-frame), var(--ct-frame-2)); padding: 4px; overflow: hidden; box-shadow: var(--ct-shadow); touch-action: manipulation; }
.ct-board-wrap.is-zoom { overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; }
.ct-board { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); grid-template-rows: repeat(15, minmax(0, 1fr)); gap: 2px; width: 100%; height: 100%; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ct-board-wrap.is-zoom .ct-board { width: calc(15 * 42px + 14 * 2px); height: calc(15 * 42px + 14 * 2px); }
.ct-cell { position: relative; min-width: 0; min-height: 0; border-radius: 3px; background: var(--ct-cell); color: var(--ct-cell-text); display: grid; place-items: center; font-weight: 800; font-size: calc(var(--ct-c) * .34); line-height: 1; letter-spacing: -.02em; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ct-cell.is-tw { background: var(--ct-tw); color: var(--ct-tw-text); }
.ct-cell.is-dw { background: var(--ct-dw); color: var(--ct-dw-text); }
.ct-cell.is-tl { background: var(--ct-tl); color: var(--ct-tl-text); }
.ct-cell.is-dl { background: var(--ct-dl); color: var(--ct-dl-text); }
.ct-cell.is-star { font-size: calc(var(--ct-c) * .62); }
.ct-cell.is-target { box-shadow: inset 0 0 0 2px var(--ct-pend); background-image: linear-gradient(rgba(37, 99, 235, .25), rgba(37, 99, 235, .25)); }
.ct-cell.is-cursor { box-shadow: inset 0 0 0 2px var(--ct-accent); }
.ct-cell.is-cursor::after { content: attr(data-arrow); position: absolute; right: 1px; bottom: 0; font-size: calc(var(--ct-c) * .42); color: var(--ct-accent); font-weight: 900; }
body.dark-theme .ct-cell.is-cursor::after { color: var(--ct-accent-2); }

/* ---- tiles ---- */
.ct-tile { position: absolute; inset: 0; border-radius: 4px; background: linear-gradient(160deg, var(--ct-tile) 0%, var(--ct-tile-2) 100%); box-shadow: inset 0 -2px 0 var(--ct-tile-edge), 0 1px 2px rgba(0, 0, 0, .35); color: var(--ct-tile-text); display: grid; place-items: center; font-weight: 800; font-size: calc(var(--ct-c) * .6); letter-spacing: 0; z-index: 1; }
.ct-tile b { font-weight: 800; transform: translate(-6%, -3%); }
.ct-tile small { position: absolute; right: 7%; bottom: 3%; font-size: calc(var(--ct-c) * .27); font-weight: 800; line-height: 1; opacity: .85; }
.ct-tile.is-blank b { color: var(--ct-blank-text); font-style: italic; }
.ct-tile.is-last { box-shadow: inset 0 -2px 0 var(--ct-tile-edge), 0 0 0 2px var(--ct-last); }
.ct-tile.is-pend { box-shadow: inset 0 -2px 0 var(--ct-tile-edge), 0 0 0 2px var(--ct-pend); cursor: grab; touch-action: none; z-index: 2; }
.ct-tile.is-bad { box-shadow: inset 0 -2px 0 var(--ct-tile-edge), 0 0 0 2px var(--ct-ko); }
.ct-tile.is-new { animation: ct-pop .32s cubic-bezier(.2, .9, .3, 1.4) both; }
.ct-tile.is-dragging { opacity: .25; }
@keyframes ct-pop { from { transform: scale(.2); opacity: 0; } }
.ct-badge { position: absolute; right: -40%; top: -42%; z-index: 4; min-width: calc(var(--ct-c) * .9); padding: 2px 4px; border-radius: 999px; background: var(--ct-ok); color: #fff; font-size: max(10px, calc(var(--ct-c) * .4)); font-weight: 900; line-height: 1.1; text-align: center; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); pointer-events: none; white-space: nowrap; }
.ct-badge.is-bad { background: var(--ct-ko); }
.ct-badge.is-left { right: auto; left: -40%; }
.ct-badge.is-down { top: auto; bottom: -42%; }

/* ---- status + rack ---- */
.ct-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ct-status { margin: 0; min-height: 2.6em; padding: 0 4px; font-weight: 700; text-align: center; color: var(--ct-muted); line-height: 1.3; display: flex; align-items: center; justify-content: center; }
.ct-status.is-ok { color: var(--ct-ok); }
.ct-status.is-bad { color: var(--ct-ko); }
.ct-status.is-you { color: var(--ct-accent); }
.ct-rack { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; padding: 7px; border-radius: 16px; background: linear-gradient(180deg, #7a4a22, #5a3415); box-shadow: inset 0 2px 6px rgba(0, 0, 0, .35); min-height: 62px; touch-action: none; }
body.dark-theme .ct-rack { background: linear-gradient(180deg, #4a2c12, #2e1a08); }
.ct-rack.is-hidden .ct-rtile { visibility: hidden; }
.ct-rack.is-target { box-shadow: inset 0 2px 6px rgba(0, 0, 0, .35), 0 0 0 3px var(--ct-pend); }
.ct-rslot { aspect-ratio: 1; min-width: 0; }
.ct-rtile { position: relative; width: 100%; aspect-ratio: 1; max-height: 58px; padding: 0; border: 0; border-radius: 8px; background: linear-gradient(160deg, var(--ct-tile) 0%, var(--ct-tile-2) 100%); box-shadow: inset 0 -3px 0 var(--ct-tile-edge), 0 2px 4px rgba(0, 0, 0, .35); color: var(--ct-tile-text); font-weight: 800; font-size: clamp(1.25rem, 6.4vw, 1.75rem); line-height: 1; cursor: grab; touch-action: none; -webkit-tap-highlight-color: transparent; transition: transform .14s ease-out, box-shadow .14s; display: grid; place-items: center; }
.ct-rtile b { font-weight: 800; transform: translate(-5%, -3%); }
.ct-rtile small { position: absolute; right: 8%; bottom: 6%; font-size: .45em; font-weight: 800; opacity: .85; }
.ct-rtile.is-blank b { color: var(--ct-blank-text); }
.ct-rtile.is-sel { transform: translateY(-6px); box-shadow: inset 0 -3px 0 var(--ct-tile-edge), 0 0 0 3px var(--ct-pend), 0 6px 10px rgba(0, 0, 0, .35); }
.ct-rtile.is-dragging { opacity: .25; }
.ct-ghost { position: fixed; left: 0; top: 0; z-index: 3000; width: 50px; height: 50px; border-radius: 8px; pointer-events: none; background: linear-gradient(160deg, var(--ct-tile) 0%, var(--ct-tile-2) 100%); box-shadow: inset 0 -3px 0 var(--ct-tile-edge), 0 10px 24px rgba(0, 0, 0, .45); color: var(--ct-tile-text); font-weight: 800; font-size: 1.6rem; display: grid; place-items: center; transform: translate(-50%, -50%) scale(1.06); will-change: left, top; }
.ct-ghost[hidden] { display: none; }
.ct-ghost small { position: absolute; right: 8%; bottom: 6%; font-size: .45em; }

.ct-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.5fr); gap: 6px; }
.ct-icon-btn { flex-direction: column; gap: 2px; padding: 5px 2px; font-size: .74rem; min-height: 54px; border-radius: 12px; }
.ct-icon-btn svg, .ct-icon-btn i { font-size: 1.05rem; }
.ct-play-btn { font-size: .95rem; }
.ct-play-btn svg { font-size: 1.25rem; }
.ct-tools { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.ct-tool { min-height: 46px; padding: 4px 2px; border-radius: 12px; border: 1px solid var(--ct-card-border); background: transparent; color: var(--ct-muted); font-weight: 700; font-size: .72rem; cursor: pointer; touch-action: manipulation; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; -webkit-tap-highlight-color: transparent; }
.ct-tool:hover:not(:disabled) { color: var(--text-color); border-color: var(--ct-accent); }
.ct-tool:disabled { opacity: .4; cursor: not-allowed; }
.ct-tool[aria-pressed="true"]#ct-zoom { color: var(--ct-accent); border-color: var(--ct-accent); }
.ct-tool svg { font-size: 1rem; }
.ct-tool-txt { white-space: nowrap; }

/* ---- move log ---- */
.ct-log-box { border-radius: 14px; background: var(--ct-card-bg); border: 1px solid var(--ct-card-border); padding: 8px 12px; }
.ct-log-box summary { cursor: pointer; font-weight: 800; font-size: .92rem; }
.ct-log-hint { font-weight: 600; color: var(--ct-muted); font-size: .78rem; }
.ct-log { margin: 6px 0 0; padding: 0 0 0 26px; max-height: 260px; overflow: auto; font-size: .88rem; line-height: 1.45; }
.ct-log li { padding: 3px 0; border-bottom: 1px solid var(--ct-card-border); }
.ct-log li:last-child { border-bottom: 0; }
.ct-log li::marker { color: var(--ct-muted); font-size: .8em; }
.ct-log .ct-who { font-weight: 800; }
.ct-log a { color: var(--ct-accent); font-weight: 800; text-decoration: none; letter-spacing: .02em; }
.ct-log a:hover { text-decoration: underline; }
.ct-log .ct-pts { float: right; font-weight: 900; font-variant-numeric: tabular-nums; }
.ct-log .ct-bingo { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 8px; font-size: .72rem; font-weight: 900; background: var(--ct-gold); color: #241400; }
.ct-log .ct-muted { color: var(--ct-muted); }
.ct-log-empty { list-style: none; color: var(--ct-muted); margin-left: -26px; }

/* ---- below ---- */
.ct-record { text-align: center; color: var(--ct-muted); font-size: .88rem; margin: 12px 0 0; min-height: 1.3em; }
.ct-record b { color: var(--text-color); }
.ct-record button { border: 0; background: none; color: var(--ct-muted); text-decoration: underline; font-size: .82rem; padding: 0 4px; cursor: pointer; }
.ct-help { max-width: 760px; margin: 14px auto 0; padding: 12px 16px; border-radius: 14px; background: var(--ct-card-bg); border: 1px solid var(--ct-card-border); }
.ct-help summary { cursor: pointer; font-weight: 700; }
.ct-help ol { margin: 10px 0 0; padding-left: 20px; color: var(--ct-muted); line-height: 1.55; }
.ct-help li { margin-bottom: 4px; }
.ct-help strong { color: var(--text-color); }
.ct-help p { color: var(--ct-muted); margin: 10px 0 0; line-height: 1.55; font-size: .93rem; }
.ct-help a, .ct-credit a, .ct-powered a { color: var(--ct-accent); }
.ct-k { display: inline-block; padding: 0 5px; border-radius: 4px; font-weight: 900; font-size: .8rem; line-height: 1.5; }
.ct-k-tw { background: var(--ct-tw); color: var(--ct-tw-text); }
.ct-k-dw { background: var(--ct-dw); color: var(--ct-dw-text); }
.ct-k-tl { background: var(--ct-tl); color: var(--ct-tl-text); }
.ct-k-dl { background: var(--ct-dl); color: var(--ct-dl-text); }
.ct-credit { max-width: 760px; margin: 12px auto 0; color: var(--ct-muted); font-size: .8rem; line-height: 1.5; text-align: center; }
.ct-powered { text-align: center; color: var(--ct-muted); font-size: .85rem; margin: 22px 0 0; }

/* ---- dialogs ---- */
.ct-overlay { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .55); animation: ct-fade .2s ease-out; }
.ct-overlay[hidden] { display: none; }
#ct-cover { background: rgba(20, 14, 8, .94); }
@keyframes ct-fade { from { opacity: 0; } }
.ct-dialog { width: 100%; max-width: 420px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; padding: 20px 16px 16px; border-radius: 22px; background: var(--ct-card-bg); color: var(--text-color); text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); animation: ct-rise .25s ease-out; }
@keyframes ct-rise { from { transform: translateY(16px) scale(.97); opacity: 0; } }
.ct-dialog h2 { font-weight: 800; font-size: 1.35rem; margin: 2px 0 4px; }
.ct-dialog-icon { font-size: 32px; color: var(--ct-accent); }
.ct-gold { color: var(--ct-gold); }
.ct-dialog-sub { color: var(--ct-muted); margin: 0 0 12px; }
.ct-dialog-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 14px; }
.ct-cover-card { max-width: 340px; }
.ct-cover-last { font-size: .9rem; color: var(--ct-muted); margin: -4px 0 14px; min-height: 1em; }
.ct-cover-last b { color: var(--text-color); }
.ct-letters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.ct-letter { aspect-ratio: 1; min-height: 44px; border: 0; border-radius: 8px; background: linear-gradient(160deg, var(--ct-tile) 0%, var(--ct-tile-2) 100%); box-shadow: inset 0 -3px 0 var(--ct-tile-edge); color: var(--ct-blank-text); font-weight: 800; font-size: 1.3rem; cursor: pointer; touch-action: manipulation; }
.ct-xch-rack { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.ct-xch-rack .ct-rtile { cursor: pointer; }
.ct-xch-rack .ct-rtile[aria-pressed="true"] { transform: translateY(-6px); box-shadow: inset 0 -3px 0 var(--ct-tile-edge), 0 0 0 3px var(--ct-ko); opacity: .75; }
.ct-left-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-bottom: 14px; }
.ct-left-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 0; border-radius: 10px; background: var(--ct-page-bg); border: 1px solid var(--ct-card-border); font-weight: 800; }
.ct-left-item b { font-size: 1.1rem; }
.ct-left-item span { font-size: .78rem; color: var(--ct-muted); }
.ct-left-item.is-zero { opacity: .35; }
.ct-final { text-align: left; margin: 6px auto 0; padding-left: 26px; max-width: 300px; font-weight: 700; line-height: 1.8; }
.ct-final .is-you { color: var(--ct-accent); }
.ct-final small { color: var(--ct-muted); font-weight: 600; }
.ct-over-best { color: var(--ct-muted); font-size: .9rem; margin: 10px 0 0; }

/* shake on a refused move */
.ct-shake { animation: ct-shake .36s ease-in-out; }
@keyframes ct-shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

/* ---- phones ---- */
@media (max-width: 575.98px) {
    .ct-wrap { padding-left: 8px; padding-right: 8px; }
    .ct-board-wrap { padding: 3px; border-radius: 10px; }
    .ct-board { gap: 1px; }
    .ct-pl { padding: 4px 6px; gap: 5px; }
}
@media (max-width: 380px) {
    .ct-icon-btn { font-size: .68rem; }
    .ct-tool { font-size: .66rem; }
    .ct-pl-name { font-size: .78rem; }
    .ct-pl-score { font-size: 1.02rem; }
}

/* ---- desktop: board left, everything else right ---- */
@media (min-width: 900px) {
    .ct-layout { --ct-bw: max(420px, min(680px, calc(100vh - 112px), calc(100vw - 440px))); max-width: none; grid-template-columns: var(--ct-bw) minmax(300px, 380px); grid-template-areas: "board scores" "board side"; grid-template-rows: auto 1fr; gap: 10px 18px; justify-content: center; align-items: start; }
    .ct-scores { grid-area: scores; flex-wrap: wrap; }
    .ct-pl { flex: 1 1 140px; }
    .ct-board-col { grid-area: board; }
    .ct-side { grid-area: side; }
    .ct-board-wrap { width: var(--ct-bw); padding: 6px; }
    .ct-log { max-height: calc(100vh - 560px); min-height: 120px; }
    body.ct-playing .ct-main { padding-top: 12px; }
    body.ct-playing .ct-hero { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .ct-tile, .ct-rtile, .ct-dialog, .ct-overlay, .ct-shake { transition: none !important; animation: none !important; }
}
