/* Canastă — 2 or 4 players, against the phone or friends on one phone (js/canasta.js).
   Theme-aware like the other game pages: tokens on :root, redefined under body.dark-theme. */
:root {
    --cn-accent: #166534;
    --cn-accent-2: #15803d;
    --cn-accent-soft: #e3f4e8;
    --cn-page-bg: #f3f6f2;
    --cn-card-bg: #ffffff;
    --cn-card-border: #d8e3da;
    --cn-muted: #56645a;
    --cn-shadow: 0 10px 30px rgba(20, 60, 30, .10);
    --cn-felt: #1d6b45;
    --cn-felt-2: #0e3d26;
    --cn-wood: #6b3a1f;
    --cn-wood-2: #4a250f;
    --cn-felt-text: #effaf3;
    --cn-face: #ffffff;
    --cn-face-2: #f3f1ea;
    --cn-face-border: #cfc8b8;
    --cn-black: #1b1f27;
    --cn-red: #c4202a;
    --cn-back: #1e3a8a;
    --cn-back-2: #2563eb;
    --cn-us: #2dd4bf;
    --cn-them: #fb7185;
    --cn-ok: #15803d;
    --cn-ko: #dc2626;
    --cn-gold: #f59e0b;
    --cn-turn: #fde047;
    --cn-gw: 46px;   /* a group in your hand */
    --cn-mw: 40px;   /* one of your side's melds */
    --cn-ow: 32px;   /* one of the other side's melds */
}

body.dark-theme {
    --cn-accent: #4ade80;
    --cn-accent-2: #22c55e;
    --cn-accent-soft: #12301d;
    --cn-page-bg: #0f1411;
    --cn-card-bg: #18201b;
    --cn-card-border: #2c3a30;
    --cn-muted: #a3b5a8;
    --cn-shadow: 0 10px 30px rgba(0, 0, 0, .4);
    --cn-felt: #155234;
    --cn-felt-2: #08261a;
    --cn-wood: #43230f;
    --cn-wood-2: #2c1608;
    --cn-face: #f4f1e8;
    --cn-face-2: #e4dfd2;
    --cn-face-border: #a59d8a;
    --cn-ok: #4ade80;
    --cn-ko: #f87171;
    --cn-gold: #fbbf24;
}

/* 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. */
.cn-body, body.cn-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--cn-page-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: clip;
}
.cn-main { padding-top: 92px; padding-bottom: 40px; }
.cn-game .container, .cn-hero .container { max-width: 820px; }
.cn-game .container { padding-left: 12px; padding-right: 12px; }

/* ---- hero ---- */
.cn-hero { text-align: center; padding: 4px 0 8px; }
.cn-hero h1 { font-weight: 800; font-size: clamp(1.6rem, 5vw, 2.2rem); margin-bottom: 4px; }
.cn-hero-icon { color: var(--cn-accent); }
.cn-lead { margin: 0 auto; max-width: 580px; color: var(--cn-muted); font-size: .98rem; line-height: 1.45; }
body.cn-playing .cn-lead { display: none; }
body.cn-playing .cn-hero { padding: 0 0 6px; }
body.cn-playing .cn-hero h1 { font-size: 1.35rem; margin: 0; }

/* ---- setup ---- */
.cn-setup { max-width: 560px; margin: 6px auto 0; padding: 14px; border-radius: 18px; background: var(--cn-card-bg); border: 1px solid var(--cn-card-border); box-shadow: var(--cn-shadow); }
.cn-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; margin-bottom: 12px; border-radius: 16px; background: var(--cn-page-bg); border: 1px solid var(--cn-card-border); }
.cn-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; }
.cn-mode small { display: block; font-weight: 600; opacity: .8; }
.cn-mode[aria-checked="true"] { background: var(--cn-accent); color: #fff; }
body.dark-theme .cn-mode[aria-checked="true"] { color: #062b14; }
.cn-field { margin: 0 0 12px; }
.cn-field[hidden] { display: none; }
.cn-label { display: block; font-weight: 800; margin: 0 0 6px; }
.cn-note { display: block; color: var(--cn-muted); margin-top: 5px; font-size: .84rem; line-height: 1.35; }
.cn-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cn-chip { min-width: 52px; min-height: 46px; padding: 6px 12px; border-radius: 12px; border: 2px solid var(--cn-card-border); background: var(--cn-card-bg); color: inherit; font-weight: 800; font-size: 1rem; line-height: 1.1; cursor: pointer; touch-action: manipulation; flex: 1 1 0; }
.cn-chip small { display: block; font-size: .72rem; font-weight: 700; opacity: .75; }
.cn-chip[aria-checked="true"] { border-color: var(--cn-accent); background: var(--cn-accent-soft); color: var(--cn-accent); }
.cn-chip:focus-visible, .cn-mode:focus-visible, .cn-btn:focus-visible, .cn-grp:focus-visible, .cn-meld:focus-visible, .cn-x:focus-visible, .cn-stock:focus-visible, .cn-pile:focus-visible { outline: 3px solid var(--cn-gold); outline-offset: 2px; }
.cn-start, .cn-resume { width: 100%; margin-top: 4px; }
.cn-resume { margin-top: 8px; }

/* ---- buttons ---- */
.cn-btn { min-height: 48px; padding: 8px 12px; border: 1px solid var(--cn-card-border); border-radius: 14px; background: var(--cn-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; line-height: 1.15; }
.cn-btn:hover:not(:disabled) { border-color: var(--cn-accent); }
.cn-btn:disabled { opacity: .45; cursor: not-allowed; }
.cn-btn-primary { background: var(--cn-accent); border-color: var(--cn-accent); color: #fff; }
body.dark-theme .cn-btn-primary { color: #062b14; }
.cn-wide { width: 100%; }

/* ---- status bar ---- */
.cn-play { max-width: 820px; margin: 0 auto; }
.cn-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; margin: 0 0 8px; min-height: 44px; border-radius: 14px; background: var(--cn-card-bg); border: 1px solid var(--cn-card-border); font-size: .9rem; font-weight: 700; }
.cn-bar-hand { font-weight: 800; white-space: nowrap; }
.cn-score { flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; gap: 6px; white-space: nowrap; }
.cn-score .cn-tm { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; background: var(--cn-page-bg); }
.cn-score .cn-tm i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.cn-score .cn-tm.is-us i { background: var(--cn-us); }
.cn-score .cn-tm.is-them i { background: var(--cn-them); }
.cn-score b { font-weight: 900; }
.cn-bar-target { color: var(--cn-muted); white-space: nowrap; font-size: .8rem; }

/* ---- the table (felt) ---- */
.cn-table { position: relative; padding: 6px 6px 8px; border-radius: 24px; background: radial-gradient(ellipse at 50% 45%, var(--cn-felt) 0%, var(--cn-felt-2) 100%); border: 6px solid var(--cn-wood); box-shadow: inset 0 0 0 2px var(--cn-wood-2), inset 0 8px 30px rgba(0, 0, 0, .35), var(--cn-shadow); color: var(--cn-felt-text); }
.cn-seats { display: flex; justify-content: space-around; gap: 4px; min-height: 50px; }
.cn-seat { position: relative; flex: 1 1 0; min-width: 0; max-width: 150px; display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 14px; transition: background .2s, box-shadow .2s; }
.cn-seat.is-turn { background: rgba(253, 224, 71, .16); box-shadow: 0 0 0 2px var(--cn-turn); }
.cn-av { position: relative; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .95rem; color: #fff; background: var(--av, #475569); box-shadow: 0 0 0 2px var(--ring, transparent), 0 2px 6px rgba(0, 0, 0, .35); flex: none; }
.cn-seat-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.cn-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; font-size: .82rem; }
.cn-cnt { font-size: .74rem; opacity: .9; white-space: nowrap; }
@media (max-width: 520px) { .cn-mate { display: none; } }
.cn-dealer { position: absolute; right: -5px; bottom: -4px; width: 16px; height: 16px; border-radius: 50%; background: #fff; color: #111; font-size: .6rem; font-weight: 900; display: grid; place-items: center; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }

.cn-side { margin-top: 6px; padding: 5px 6px 6px; border-radius: 14px; background: rgba(0, 0, 0, .14); border: 1px solid rgba(255, 255, 255, .08); }
.cn-side.is-us { background: rgba(0, 0, 0, .2); }
.cn-side.is-target { box-shadow: 0 0 0 2px var(--cn-gold); }
.cn-side-head { display: flex; align-items: center; gap: 6px; min-height: 20px; font-size: .78rem; font-weight: 800; }
.cn-side-name { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.cn-side-name::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--cn-them); }
.is-us .cn-side-name::before { background: var(--cn-us); }
.cn-side-info { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; font-weight: 700; }
.cn-side-info .is-short { color: #fde68a; }
.cn-side-info .is-met { color: #86efac; }
.cn-red3s { display: inline-flex; gap: 2px; }
.cn-red3 { min-width: 18px; height: 20px; padding: 0 3px; border-radius: 4px; background: var(--cn-face); color: var(--cn-red); font: 700 .7rem/20px Georgia, serif; text-align: center; box-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.cn-melds { display: flex; flex-wrap: wrap; gap: 4px; min-height: calc(var(--cn-ow) * 1.38); margin-top: 4px; align-items: flex-end; }
.is-us .cn-melds { min-height: calc(var(--cn-mw) * 1.38); }
.cn-melds-empty { font-size: .78rem; opacity: .65; align-self: center; padding-left: 2px; }

/* a meld: one card with its count */
.cn-meld { --w: var(--cn-ow); position: relative; width: var(--w); height: calc(var(--w) * 1.38); padding: 0; border-radius: calc(var(--w) * .14); border: 1px solid var(--cn-face-border); background: linear-gradient(160deg, var(--cn-face) 0%, var(--cn-face-2) 100%); color: var(--cn-black); font-family: Georgia, "Times New Roman", serif; box-shadow: 1px 1px 0 var(--cn-face-border), 2px 2px 0 rgba(0, 0, 0, .25), 0 3px 6px rgba(0, 0, 0, .3); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; cursor: default; touch-action: manipulation; }
.is-us .cn-meld { --w: var(--cn-mw); cursor: pointer; }
.cn-m-rank { font-weight: 800; font-size: calc(var(--w) * .42); }
.cn-m-n { font: 800 calc(var(--w) * .3) system-ui, sans-serif; margin-top: 2px; color: #374151; }
.cn-m-w { position: absolute; bottom: -6px; right: -6px; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); min-width: 13px; height: 13px; padding: 0 2px; border-radius: 7px; background: #7c3aed; color: #fff; font: 800 9px/13px system-ui, sans-serif; text-align: center; }
.cn-meld.is-canasta { border: 2px solid var(--cn-gold); box-shadow: 2px 2px 0 var(--cn-gold), 3px 3px 0 rgba(0, 0, 0, .3), 0 4px 10px rgba(0, 0, 0, .35); }
.cn-meld.is-clean { background: linear-gradient(160deg, #fee2e2, #fecaca); color: var(--cn-red); }
.cn-meld.is-dirty { background: linear-gradient(160deg, #374151, #111827); color: #f9fafb; }
.cn-meld.is-dirty .cn-m-n { color: #e5e7eb; }
.cn-meld.is-target { outline: 3px solid var(--cn-gold); outline-offset: 1px; animation: cn-glow 1s ease-in-out infinite alternate; }
.cn-meld.is-new { animation: cn-pop .35s ease-out; }
@keyframes cn-glow { to { outline-color: rgba(245, 158, 11, .35); } }
@keyframes cn-pop { from { transform: scale(.6); opacity: .2; } }

/* ---- centre: stock and pile ---- */
.cn-center { position: relative; display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 92px; margin: 6px 0 0; }
.cn-stock, .cn-pile { position: relative; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; touch-action: manipulation; border-radius: 10px; -webkit-tap-highlight-color: transparent; }
.cn-stock .cn-card, .cn-pile .cn-card { --w: 50px; }
.cn-stock:disabled, .cn-pile:disabled { cursor: default; }
.cn-pc { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); min-width: 26px; padding: 1px 6px; border-radius: 999px; background: rgba(0, 0, 0, .65); color: #fff; font: 800 .72rem/1.3 system-ui, sans-serif; white-space: nowrap; }
.cn-pile-cards { position: relative; display: block; width: 50px; height: 70px; }
.cn-pile-cards .cn-card { position: absolute; left: 0; top: 0; }
.cn-pile-cards .cn-card.is-under { transform: rotate(90deg) translate(6px, 0); filter: brightness(.9); }
.cn-pile-cards .cn-slot { position: absolute; inset: 0; border-radius: 7px; border: 2px dashed rgba(255, 255, 255, .35); }
.cn-frozen { position: absolute; top: -6px; right: -8px; width: 22px; height: 22px; border-radius: 50%; background: #e0f2fe; color: #0369a1; display: grid; place-items: center; font-size: .72rem; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.cn-frozen[hidden] { display: none; }
.cn-stock.is-can .cn-card, .cn-pile.is-can .cn-pile-cards { box-shadow: 0 0 0 3px var(--cn-turn), 0 0 16px rgba(253, 224, 71, .55); border-radius: 7px; }
.cn-pile.is-drop .cn-pile-cards, .cn-pile.is-discard .cn-pile-cards { box-shadow: 0 0 0 3px var(--cn-gold), 0 0 18px rgba(245, 158, 11, .6); border-radius: 7px; }
.cn-cinfo { display: flex; flex-direction: column; gap: 3px; font-size: .74rem; font-weight: 700; line-height: 1.2; max-width: 130px; }
.cn-cinfo span { white-space: nowrap; }
.cn-cinfo .is-frozen { color: #bae6fd; }
.cn-toast { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5; margin: 0; width: max-content; max-width: calc(100% - 16px); padding: 8px 14px; border-radius: 14px; background: rgba(6, 26, 15, .9); color: #fff; font-weight: 800; font-size: .92rem; text-align: center; line-height: 1.3; box-shadow: 0 6px 20px rgba(0, 0, 0, .35); opacity: 0; transition: opacity .25s; pointer-events: none; }
.cn-toast.is-on { opacity: 1; }
.cn-toast.is-err { background: rgba(127, 29, 29, .94); }

/* ---- cards (pure CSS) ---- */
.cn-card { --w: var(--cn-gw); position: relative; display: block; width: var(--w); height: calc(var(--w) * 1.4); border-radius: calc(var(--w) * .13); background: linear-gradient(160deg, var(--cn-face) 0%, var(--cn-face-2) 100%); border: 1px solid var(--cn-face-border); box-shadow: 0 2px 6px rgba(0, 0, 0, .28); color: var(--cn-black); font-family: Georgia, "Times New Roman", serif; user-select: none; -webkit-user-select: none; overflow: hidden; }
.cn-card.is-red { color: var(--cn-red); }
.cn-c-tl { position: absolute; top: calc(var(--w) * .05); left: calc(var(--w) * .08); font-weight: 700; font-size: calc(var(--w) * .3); line-height: 1; }
.cn-c-mid { position: absolute; left: 50%; top: 56%; transform: translate(-50%, -50%); font-size: calc(var(--w) * .5); line-height: 1; }
.cn-card.is-two .cn-c-mid, .cn-card.is-two .cn-c-tl { color: #7c3aed; }
.cn-card.is-joker .cn-c-mid { font-size: calc(var(--w) * .46); color: #7c3aed; }
.cn-card.is-joker .cn-c-tl { font-size: calc(var(--w) * .2); color: #7c3aed; letter-spacing: -.02em; }
.cn-card.is-back { background: repeating-linear-gradient(45deg, var(--cn-back) 0 5px, var(--cn-back-2) 5px 10px); border: 3px solid #fff; }

/* ---- status + actions ---- */
.cn-status { margin: 8px 2px 6px; min-height: 2.7em; font-weight: 700; text-align: center; color: var(--cn-muted); line-height: 1.35; font-size: .92rem; display: flex; align-items: center; justify-content: center; }
.cn-status.is-you { color: var(--cn-accent); }
.cn-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; min-height: 52px; }
.cn-actions .cn-btn { padding: 6px 8px; font-size: .9rem; }
.cn-actions .cn-btn.is-hot { box-shadow: 0 0 0 3px var(--cn-gold); }

/* ---- your hand: one stack per rank ---- */
.cn-hand { display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 10px 5px; min-height: calc(var(--cn-gw) * 1.4 + 22px); margin: 12px 0 14px; padding-top: 8px; }
.cn-hand.is-hidden .cn-grp { pointer-events: none; }
.cn-grp { position: relative; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; touch-action: none; -webkit-tap-highlight-color: transparent; transition: transform .15s ease-out; }
.cn-grp .cn-card { transition: box-shadow .15s; }
.cn-grp.is-stack .cn-card { box-shadow: 2px -2px 0 -1px var(--cn-face), 2px -2px 0 0 var(--cn-face-border), 0 2px 6px rgba(0, 0, 0, .28); }
.cn-grp.is-stack3 .cn-card { box-shadow: 2px -2px 0 -1px var(--cn-face), 2px -2px 0 0 var(--cn-face-border), 4px -4px 0 -1px var(--cn-face), 4px -4px 0 0 var(--cn-face-border), 0 2px 6px rgba(0, 0, 0, .28); }
.cn-g-n { position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%); min-width: 22px; padding: 0 5px; border-radius: 999px; background: var(--cn-card-bg); border: 1px solid var(--cn-card-border); color: var(--text-color); font: 800 .72rem/16px system-ui, sans-serif; white-space: nowrap; }
.cn-g-s { position: absolute; left: 50%; bottom: calc(var(--cn-gw) * .17); transform: translateX(-50%); font-size: calc(var(--cn-gw) * .22); letter-spacing: -.5px; white-space: nowrap; line-height: 1; font-family: Georgia, serif; }
.cn-g-s .r { color: var(--cn-red); }
.cn-g-s .b { color: var(--cn-black); }
.cn-grp.is-sel { transform: translateY(-9px); }
.cn-grp.is-sel .cn-card { box-shadow: 0 0 0 3px var(--cn-gold), 0 6px 14px rgba(0, 0, 0, .3); }
.cn-g-sel { position: absolute; top: -8px; right: -7px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: var(--cn-gold); color: #1f1300; font: 900 .78rem/22px system-ui, sans-serif; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
.cn-g-dot { position: absolute; bottom: 4px; left: 4px; width: 9px; height: 9px; border-radius: 50%; background: #16a34a; box-shadow: 0 0 0 2px #fff; }
.cn-g-dot.is-meld { background: #2563eb; }
.cn-hand.is-hidden .cn-g-dot, .cn-hand.is-hidden .cn-g-s, .cn-hand.is-hidden .cn-g-n { display: none; }
.cn-grp.is-new .cn-card { animation: cn-pop .35s ease-out; }

.cn-ghost { position: fixed; z-index: 3000; pointer-events: none; transform: translate(-50%, -60%) rotate(-4deg) scale(1.08); filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .4)); }
.cn-ghost .cn-g-sel { top: -8px; right: -7px; }
.cn-fly { position: fixed; z-index: 2500; pointer-events: none; transition: transform .38s cubic-bezier(.2, .8, .2, 1), opacity .38s; }

/* ---- below the table ---- */
.cn-tools { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; }
.cn-tools #cn-sound { width: 52px; padding: 0; }
.cn-record { text-align: center; color: var(--cn-muted); font-size: .88rem; margin: 10px 0 0; min-height: 1.3em; }
.cn-record b { color: var(--text-color); }
.cn-help { max-width: 820px; margin: 14px auto 0; padding: 12px 16px; border-radius: 14px; background: var(--cn-card-bg); border: 1px solid var(--cn-card-border); }
.cn-help summary { cursor: pointer; font-weight: 700; }
.cn-help ol { margin: 10px 0 0; padding-left: 20px; color: var(--cn-muted); line-height: 1.55; }
.cn-help li { margin-bottom: 4px; }
.cn-help strong, .cn-help em { color: var(--text-color); }
.cn-help em { font-style: normal; font-weight: 700; }
.cn-help p { color: var(--cn-muted); margin: 10px 0 0; line-height: 1.55; font-size: .93rem; }
.cn-help kbd { background: var(--cn-accent-soft); color: var(--cn-accent); border-radius: 5px; padding: 0 5px; font-size: .85em; }
.cn-help .cn-credit { font-size: .8rem; }
.cn-powered { text-align: center; color: var(--cn-muted); font-size: .85rem; margin: 26px 0 0; }
.cn-powered a { color: var(--cn-accent); }

/* ---- dialogs ---- */
.cn-overlay { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .5); animation: cn-fade .2s ease-out; }
.cn-overlay[hidden] { display: none; }
@keyframes cn-fade { from { opacity: 0; } }
.cn-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(--cn-card-bg); color: var(--text-color); text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); animation: cn-rise .25s ease-out; }
@keyframes cn-rise { from { transform: translateY(16px) scale(.97); opacity: 0; } }
.cn-dialog h2 { font-weight: 800; font-size: 1.35rem; margin: 2px 0 4px; }
.cn-dialog-icon { font-size: 32px; color: var(--cn-accent); }
.cn-gold { color: var(--cn-gold); }
.cn-dialog-sub { color: var(--cn-muted); margin: 0 0 10px; line-height: 1.4; }
.cn-dialog-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 14px; }
.cn-cover-card { max-width: 340px; }
.cn-sum-wrap { overflow-x: auto; }
.cn-sum-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.cn-sum-table th { font-size: .78rem; color: var(--cn-muted); font-weight: 800; padding: 4px; }
.cn-sum-table td { padding: 6px 4px; border-top: 1px solid var(--cn-card-border); font-weight: 700; font-variant-numeric: tabular-nums; }
.cn-sum-table td:first-child, .cn-sum-table th:first-child { text-align: left; color: var(--cn-muted); font-weight: 600; }
.cn-sum-table tr.is-total td { font-weight: 900; font-size: 1rem; border-top: 2px solid var(--cn-card-border); }
.cn-sum-table tr.is-score td { font-weight: 900; background: var(--cn-accent-soft); }
.cn-pos { color: var(--cn-ok); }
.cn-neg { color: var(--cn-ko); }
.cn-final { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 0; }
.cn-final div { padding: 10px 6px; border-radius: 14px; background: var(--cn-page-bg); font-weight: 800; }
.cn-final b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.cn-final .is-win { box-shadow: 0 0 0 2px var(--cn-gold); }

.cn-sheet-card { max-width: 560px; text-align: left; padding: 14px 10px 12px; }
.cn-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.cn-x { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--cn-card-border); background: var(--cn-card-bg); color: inherit; font-size: 1.1rem; cursor: pointer; }
.cn-sheet-legend { color: var(--cn-muted); font-size: .8rem; margin: 2px 4px 8px; line-height: 1.35; }
.cn-sheet-wrap { overflow-x: auto; }
.cn-sheet-table { width: 100%; border-collapse: collapse; font-size: .84rem; font-variant-numeric: tabular-nums; }
.cn-sheet-table th, .cn-sheet-table td { border: 1px solid var(--cn-card-border); padding: 5px 4px; text-align: center; }
.cn-sheet-table thead th { font-size: .76rem; }
.cn-sheet-table td small { display: block; color: var(--cn-muted); font-weight: 600; font-size: .7rem; }
.cn-sheet-table td.is-pos { color: var(--cn-ok); font-weight: 700; }
.cn-sheet-table td.is-neg { color: var(--cn-ko); font-weight: 700; }
.cn-sheet-table td.cn-tot { font-weight: 900; }
.cn-sheet-table tfoot td { font-weight: 900; font-size: .95rem; background: var(--cn-accent-soft); }

/* ---- desktop ---- */
@media (min-width: 700px) {
    :root { --cn-gw: 58px; --cn-mw: 48px; --cn-ow: 40px; }
    .cn-stock .cn-card, .cn-pile .cn-card { --w: 60px; }
    .cn-pile-cards { width: 60px; height: 84px; }
    .cn-center { min-height: 108px; gap: 22px; }
    .cn-cinfo { font-size: .84rem; max-width: 200px; }
    .cn-av { width: 40px; height: 40px; }
    .cn-name { font-size: .92rem; }
    .cn-cnt { font-size: .82rem; }
    .cn-side-head { font-size: .86rem; }
    .cn-bar { font-size: 1rem; }
    .cn-hand { gap: 12px 7px; }
}

/* wide screens: the table on the left, your hand and the buttons on the right */
@media (min-width: 1000px) {
    .cn-game .container { max-width: 1180px; }
    body.cn-playing .cn-hero .container { max-width: 1180px; }
    .cn-play { max-width: 1180px; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); grid-template-areas: "bar bar" "table controls"; column-gap: 16px; align-items: start; }
    .cn-bar { grid-area: bar; }
    .cn-table { grid-area: table; }
    .cn-controls { grid-area: controls; display: flex; flex-direction: column; min-height: 100%; }
    .cn-controls .cn-status { margin-top: 0; min-height: 3.2em; padding: 8px 12px; border-radius: 14px; background: var(--cn-card-bg); border: 1px solid var(--cn-card-border); }
    .cn-controls .cn-hand { flex: 1 1 auto; margin: 16px 0 16px; }
}

@media (max-width: 380px) {
    :root { --cn-gw: 42px; --cn-mw: 36px; --cn-ow: 29px; }
    .cn-mode { font-size: .82rem; }
    .cn-bar { font-size: .82rem; gap: 5px; padding: 5px 8px; }
    .cn-score .cn-tm { padding: 2px 6px; }
    .cn-bar-target { display: none; }
    .cn-name { font-size: .76rem; }
    .cn-av { width: 30px; height: 30px; }
    .cn-actions .cn-btn { font-size: .84rem; }
}

@media (prefers-reduced-motion: reduce) {
    .cn-grp, .cn-meld, .cn-dialog, .cn-overlay, .cn-toast, .cn-fly, .cn-grp .cn-card { transition: none !important; animation: none !important; }
}
