/* Whist românesc (1-8-1) — you against 2-5 phone players, or friends on one phone (js/whist.js).
   Theme-aware like the other game pages: tokens on :root, redefined under body.dark-theme. */
:root {
    --wh-accent: #166534;
    --wh-accent-2: #15803d;
    --wh-accent-soft: #e3f4e8;
    --wh-page-bg: #f3f7f2;
    --wh-card-bg: #ffffff;
    --wh-card-border: #dbe5dc;
    --wh-muted: #5d6b61;
    --wh-shadow: 0 10px 30px rgba(20, 60, 30, .10);
    --wh-felt: #1d7a4c;
    --wh-felt-2: #115436;
    --wh-wood: #7a4a22;
    --wh-wood-2: #5a3415;
    --wh-felt-text: #eafff2;
    --wh-face: #ffffff;
    --wh-face-2: #f3f1ea;
    --wh-face-border: #cfc8b8;
    --wh-black: #1b1f27;
    --wh-red: #c4202a;
    --wh-back: #9f1239;
    --wh-back-2: #e11d48;
    --wh-ok: #15803d;
    --wh-ko: #dc2626;
    --wh-gold: #f59e0b;
    --wh-turn: #fde047;
    --wh-cw: 62px;   /* a card in your hand */
    --wh-tw: 50px;   /* a card on the table */
}

body.dark-theme {
    --wh-accent: #4ade80;
    --wh-accent-2: #22c55e;
    --wh-accent-soft: #10291a;
    --wh-page-bg: #0f1713;
    --wh-card-bg: #1a2620;
    --wh-card-border: #2e4337;
    --wh-muted: #9fb3a6;
    --wh-shadow: 0 10px 30px rgba(0, 0, 0, .4);
    --wh-felt: #145a37;
    --wh-felt-2: #0b3622;
    --wh-wood: #4a2c12;
    --wh-wood-2: #331d09;
    --wh-face: #f4f1e8;
    --wh-face-2: #e4dfd2;
    --wh-face-border: #a59d8a;
    --wh-ok: #4ade80;
    --wh-ko: #f87171;
    --wh-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. */
.wh-body, body.wh-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--wh-page-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: clip;
}
.wh-main { padding-top: 92px; padding-bottom: 40px; }
.wh-game .container, .wh-hero .container { max-width: 760px; }

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

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

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

/* ---- status bar ---- */
.wh-play { max-width: 760px; margin: 0 auto; }
.wh-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 10px 6px 12px; margin: 0 0 8px; min-height: 46px; border-radius: 14px; background: var(--wh-card-bg); border: 1px solid var(--wh-card-border); font-size: .9rem; font-weight: 700; }
.wh-bar-round { font-weight: 800; }
.wh-bar-cards, .wh-bar-bids { color: var(--wh-muted); }
.wh-bar-bids.is-over { color: var(--wh-ko); }
.wh-bar-bids.is-under { color: var(--wh-accent-2); }
.wh-bar-trump { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.wh-tchip { display: inline-flex; align-items: center; gap: 1px; height: 30px; padding: 0 7px; border-radius: 6px; background: linear-gradient(160deg, var(--wh-face) 0%, var(--wh-face-2) 100%); border: 1px solid var(--wh-face-border); box-shadow: 0 0 0 2px var(--wh-gold); color: var(--wh-black); font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-size: 1rem; }
.wh-tchip b { font-size: 1.15rem; }
.wh-tchip.is-red { color: var(--wh-red); }
.wh-notrump { padding: 3px 8px; border-radius: 999px; background: var(--wh-accent-soft); color: var(--wh-accent); font-size: .82rem; }

/* ---- the table (felt) ---- */
.wh-table { position: relative; padding: 8px 6px 6px; border-radius: 26px; background: radial-gradient(ellipse at 50% 40%, var(--wh-felt) 0%, var(--wh-felt-2) 100%); border: 8px solid var(--wh-wood); box-shadow: inset 0 0 0 2px var(--wh-wood-2), inset 0 8px 30px rgba(0, 0, 0, .35), var(--wh-shadow); color: var(--wh-felt-text); }
.wh-seats { display: flex; justify-content: space-around; gap: 4px; min-height: 88px; }
.wh-seat { position: relative; flex: 1 1 0; min-width: 0; max-width: 130px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 2px; border-radius: 14px; transform: translateY(var(--drop, 0px)); transition: background .2s, box-shadow .2s; text-align: center; }
.wh-seat.is-turn { background: rgba(253, 224, 71, .16); box-shadow: 0 0 0 2px var(--wh-turn); }
.wh-av { position: relative; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1rem; color: #fff; background: var(--av, #475569); box-shadow: 0 2px 6px rgba(0, 0, 0, .35); flex: none; }
.wh-dealer { position: absolute; right: -6px; bottom: -4px; width: 18px; height: 18px; border-radius: 50%; background: #fff; color: #111; font-size: .66rem; font-weight: 900; display: grid; place-items: center; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.wh-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; font-size: .84rem; line-height: 1.2; }
.wh-stat { font-size: .78rem; line-height: 1.2; opacity: .95; white-space: nowrap; }
.wh-stat b { font-size: .9rem; }
.wh-stat .is-made { color: #86efac; }
.wh-stat .is-over { color: #fca5a5; }
.wh-tot { font-size: .74rem; opacity: .85; white-space: nowrap; }
.wh-backs { display: flex; justify-content: center; height: 10px; margin-top: 1px; }
.wh-backs i { display: block; width: 7px; height: 10px; margin-left: -2px; border-radius: 2px; background: linear-gradient(135deg, var(--wh-back-2), var(--wh-back)); border: 1px solid rgba(255, 255, 255, .7); }
.wh-bubble { position: absolute; top: 2px; left: 50%; transform: translate(14px, -4px); min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--wh-gold); color: #1f1300; font-weight: 900; font-size: .85rem; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); }
.wh-bubble.is-new { animation: wh-pop .3s ease-out; }
@keyframes wh-pop { from { transform: translate(14px, -4px) scale(.3); opacity: 0; } }

.wh-trick { position: relative; height: 172px; margin-top: 2px; }
.wh-tcard { position: absolute; transform: translate(-50%, -50%); transition: transform .32s cubic-bezier(.2, .8, .2, 1), opacity .32s; will-change: transform; }
.wh-tcard.is-win .wh-card { box-shadow: 0 0 0 3px var(--wh-gold), 0 6px 14px rgba(0, 0, 0, .4); }
.wh-tname { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 2px; font-size: .68rem; font-weight: 700; white-space: nowrap; opacity: .85; }

.wh-bidpad { position: absolute; inset: 4px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; z-index: 3; }
.wh-bidpad[hidden] { display: none; }
.wh-bidpad-title { margin: 0; font-weight: 800; font-size: 1.05rem; text-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.wh-bidpad-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 330px; }
.wh-bid { width: 52px; height: 48px; border-radius: 12px; border: 2px solid rgba(255, 255, 255, .55); background: rgba(255, 255, 255, .95); color: #102a1b; font-weight: 900; font-size: 1.2rem; cursor: pointer; touch-action: manipulation; box-shadow: 0 3px 8px rgba(0, 0, 0, .3); }
.wh-bid:hover:not(:disabled) { background: #fff; border-color: var(--wh-gold); }
.wh-bid.is-hint { border-color: var(--wh-gold); }
.wh-bid:disabled { background: rgba(255, 255, 255, .25); color: rgba(255, 255, 255, .7); text-decoration: line-through; cursor: not-allowed; box-shadow: none; }
.wh-bidpad-note { margin: 0; font-size: .8rem; line-height: 1.3; min-height: 1.3em; opacity: .95; max-width: 320px; }

/* ---- you ---- */
.wh-me { display: flex; align-items: center; gap: 10px; margin: 8px 0 0; padding: 6px 10px; min-height: 52px; border-radius: 14px; background: var(--wh-card-bg); border: 2px solid var(--wh-card-border); }
.wh-me.is-turn { border-color: var(--wh-gold); box-shadow: 0 0 0 3px rgba(245, 158, 11, .2); }
.wh-me .wh-av { width: 34px; height: 34px; }
.wh-me-name { font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wh-me-stat { font-weight: 700; color: var(--wh-muted); white-space: nowrap; font-size: .9rem; }
.wh-me-stat b { color: var(--text-color); }
.wh-me-stat .is-made { color: var(--wh-ok); }
.wh-me-stat .is-over { color: var(--wh-ko); }
.wh-me-tot { font-weight: 800; color: var(--wh-accent); white-space: nowrap; }
.wh-status { margin: 6px 2px 0; min-height: 1.5em; font-weight: 700; text-align: center; color: var(--wh-muted); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wh-status.is-you { color: var(--wh-accent); }

/* ---- your hand ---- */
.wh-hand { position: relative; height: calc(var(--wh-cw) * 1.4 + 26px); margin: 2px 0 18px; touch-action: manipulation; }
.wh-hcard { position: absolute; bottom: 4px; padding: 0; border: 0; background: none; cursor: default; transform-origin: 50% 120%; transition: transform .18s ease-out, filter .18s; -webkit-tap-highlight-color: transparent; }
.wh-hcard .wh-card { --w: var(--wh-cw); }
.wh-hand.is-playing .wh-hcard.is-legal { cursor: pointer; }
.wh-hand.is-playing .wh-hcard.is-legal .wh-card { box-shadow: 0 0 0 2px var(--wh-gold), 0 6px 14px rgba(0, 0, 0, .3); }
.wh-hand.is-playing .wh-hcard:not(.is-legal) .wh-card { filter: brightness(.72) saturate(.6); }
.wh-hcard.is-hint .wh-card { box-shadow: 0 0 0 3px #38bdf8, 0 6px 14px rgba(0, 0, 0, .3) !important; }
.wh-hand.is-hidden .wh-hcard { pointer-events: none; }

/* ---- cards (pure CSS, no images) ---- */
.wh-card { --w: var(--wh-tw); position: relative; display: block; width: var(--w); height: calc(var(--w) * 1.4); border-radius: calc(var(--w) * .12); background: linear-gradient(160deg, var(--wh-face) 0%, var(--wh-face-2) 100%); border: 1px solid var(--wh-face-border); box-shadow: 0 3px 8px rgba(0, 0, 0, .28); color: var(--wh-black); font-family: Georgia, "Times New Roman", serif; user-select: none; -webkit-user-select: none; overflow: hidden; }
.wh-card.is-red { color: var(--wh-red); }
.wh-c-tl, .wh-c-br { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: .95; font-weight: 700; font-size: calc(var(--w) * .26); }
.wh-c-tl { top: calc(var(--w) * .06); left: calc(var(--w) * .07); }
.wh-c-br { bottom: calc(var(--w) * .06); right: calc(var(--w) * .07); transform: rotate(180deg); }
.wh-c-tl small, .wh-c-br small { font-size: .85em; }
.wh-c-mid { position: absolute; left: 50%; top: 54%; transform: translate(-50%, -50%); font-size: calc(var(--w) * .58); line-height: 1; }
.wh-card.is-face .wh-c-mid { font-size: calc(var(--w) * .42); font-weight: 700; }
.wh-card.is-face .wh-c-mid small { display: block; text-align: center; font-size: .9em; }
.wh-card.is-back { background: repeating-linear-gradient(45deg, var(--wh-back) 0 5px, var(--wh-back-2) 5px 10px); border: 3px solid #fff; }

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

/* ---- dialogs ---- */
.wh-overlay { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .5); animation: wh-fade .2s ease-out; }
.wh-overlay[hidden] { display: none; }
@keyframes wh-fade { from { opacity: 0; } }
.wh-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(--wh-card-bg); color: var(--text-color); text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); animation: wh-rise .25s ease-out; }
@keyframes wh-rise { from { transform: translateY(16px) scale(.97); opacity: 0; } }
.wh-dialog h2 { font-weight: 800; font-size: 1.4rem; margin: 2px 0 4px; }
.wh-dialog-icon { font-size: 32px; color: var(--wh-accent); }
.wh-gold { color: var(--wh-gold); }
.wh-dialog-sub { color: var(--wh-muted); margin: 0 0 10px; }
.wh-dialog-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 14px; }
.wh-cover-card { max-width: 340px; }
.wh-sum-table-wrap { overflow-x: auto; }
.wh-sum-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.wh-sum-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--wh-muted); font-weight: 700; padding: 4px; }
.wh-sum-table td { padding: 7px 4px; border-top: 1px solid var(--wh-card-border); font-weight: 700; }
.wh-sum-table td:first-child, .wh-sum-table th:first-child { text-align: left; }
.wh-sum-table .is-you td { background: var(--wh-accent-soft); }
.wh-pts-ok { color: var(--wh-ok); }
.wh-pts-ko { color: var(--wh-ko); }
.wh-star { display: inline-block; margin-left: 3px; padding: 0 5px; border-radius: 8px; font-size: .75rem; background: var(--wh-gold); color: #1f1300; }
.wh-star.is-neg { background: var(--wh-ko); color: #fff; }
.wh-final { text-align: left; margin: 6px auto 0; padding-left: 26px; max-width: 280px; font-weight: 700; line-height: 1.7; }
.wh-final .is-you { color: var(--wh-accent); }

.wh-sheet-card { max-width: 760px; text-align: left; padding: 14px 10px 12px; }
.wh-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.wh-x { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--wh-card-border); background: var(--wh-card-bg); color: inherit; font-size: 1.1rem; cursor: pointer; }
.wh-sheet-legend { color: var(--wh-muted); font-size: .8rem; margin: 2px 4px 8px; line-height: 1.35; }
.wh-ok { color: var(--wh-ok); font-weight: 700; }
.wh-ko { color: var(--wh-ko); font-weight: 700; }
.wh-sheet-wrap { overflow-x: auto; }
.wh-sheet-table { width: 100%; border-collapse: collapse; font-size: .82rem; table-layout: fixed; }
.wh-sheet-table th, .wh-sheet-table td { border: 1px solid var(--wh-card-border); padding: 3px 2px; text-align: center; vertical-align: middle; }
.wh-sheet-table thead th { position: sticky; top: 0; background: var(--wh-card-bg); font-size: .74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wh-sheet-table th.wh-col-r { width: 30px; }
.wh-sheet-table th.wh-col-k { width: 40px; }
.wh-sheet-table td.wh-k { color: var(--wh-muted); font-weight: 700; white-space: nowrap; }
.wh-sheet-table td.wh-k .is-red { color: var(--wh-red); }
.wh-sheet-table .wh-cell-tot { display: block; font-weight: 800; font-size: .9rem; color: var(--text-color); }
.wh-sheet-table .wh-cell-bt { display: block; font-size: .72rem; }
.wh-sheet-table tr.is-now td { background: var(--wh-accent-soft); }
.wh-sheet-table tr.is-future td { color: var(--wh-muted); opacity: .55; }
.wh-sheet-table tfoot td { font-weight: 900; font-size: .95rem; background: var(--wh-accent-soft); }

/* ---- desktop ---- */
@media (min-width: 700px) {
    :root { --wh-cw: 84px; --wh-tw: 68px; }
    .wh-trick { height: 212px; }
    .wh-seats { min-height: 104px; }
    .wh-av { width: 46px; height: 46px; font-size: 1.15rem; }
    .wh-name { font-size: .95rem; }
    .wh-stat { font-size: .88rem; }
    .wh-bar { font-size: 1rem; }
}

@media (max-width: 380px) {
    :root { --wh-cw: 58px; --wh-tw: 46px; }
    .wh-mode { font-size: .82rem; }
    .wh-bar { font-size: .84rem; gap: 4px 8px; }
    .wh-av { width: 34px; height: 34px; }
    .wh-name { font-size: .78rem; }
    .wh-bid { width: 48px; }
}

@media (prefers-reduced-motion: reduce) {
    .wh-tcard, .wh-hcard, .wh-bubble, .wh-dialog, .wh-overlay { transition: none !important; animation: none !important; }
}
