/* Ghicitori — Romanian folk riddles: for children, against the clock, or the whole family (js/ghicitori.js).
   Theme-aware like the other game pages: tokens on :root, redefined under body.dark-theme. */
:root {
    --gh-accent: #991b1b;
    --gh-accent-2: #b91c1c;
    --gh-accent-soft: #fdecec;
    --gh-on-accent: #ffffff;
    --gh-page-bg: #f7f2ea;
    --gh-card-bg: #ffffff;
    --gh-card-border: #e5d9c8;
    --gh-muted: #6b5b4b;
    --gh-shadow: 0 10px 30px rgba(90, 40, 10, .10);
    --gh-paper: #fffaf1;
    --gh-paper-edge: #efe2cc;
    --gh-ink: #2a1a10;
    --gh-stitch: #b91c1c;
    --gh-stitch-2: #1c1917;
    --gh-ok: #15803d;
    --gh-ok-soft: #dcfce7;
    --gh-bad: #b91c1c;
    --gh-bad-soft: #fee2e2;
    --gh-gold: #b45309;
    --gh-slot: #f1e6d5;
    --gh-overlay: rgba(30, 14, 6, .55);
}

body.dark-theme {
    --gh-accent: #f87171;
    --gh-accent-2: #ef4444;
    --gh-accent-soft: #3b1414;
    --gh-on-accent: #1f0606;
    --gh-page-bg: #14100d;
    --gh-card-bg: #1f1915;
    --gh-card-border: #3b3029;
    --gh-muted: #bba897;
    --gh-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    --gh-paper: #231b15;
    --gh-paper-edge: #3a2d22;
    --gh-ink: #f4e9da;
    --gh-stitch: #ef4444;
    --gh-stitch-2: #e7d7c1;
    --gh-ok: #4ade80;
    --gh-ok-soft: #10301c;
    --gh-bad: #f87171;
    --gh-bad-soft: #3b1414;
    --gh-gold: #fbbf24;
    --gh-slot: #2e241c;
    --gh-overlay: rgba(0, 0, 0, .62);
}

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

/* ---- hero ---- */
.gh-hero { text-align: center; padding: 4px 0 8px; }
.gh-hero h1 { font-weight: 800; font-size: clamp(1.6rem, 5vw, 2.2rem); margin-bottom: 4px; }
.gh-hero-icon { color: var(--gh-accent); }
.gh-lead { margin: 0 auto; max-width: 600px; color: var(--gh-muted); font-size: .98rem; line-height: 1.45; }
body.gh-playing .gh-hero { display: none; }
body.gh-playing .gh-main { padding-top: 14px; }
.gh-loading { text-align: center; color: var(--gh-muted); margin: 30px 0; min-height: 300px; }
.gh-loading[hidden] { display: none; }

/* ---- buttons ---- */
.gh-btn { min-height: 48px; padding: 8px 16px; border-radius: 14px; border: 1px solid var(--gh-card-border); background: var(--gh-card-bg); color: inherit; font-weight: 700; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; touch-action: manipulation; transition: background .15s, border-color .15s, transform .1s; }
.gh-btn:hover { border-color: var(--gh-accent); }
.gh-btn:active { transform: scale(.98); }
.gh-btn[hidden] { display: none; }
.gh-btn:disabled { opacity: .45; cursor: default; transform: none; }
.gh-btn-primary { background: var(--gh-accent); border-color: var(--gh-accent); color: var(--gh-on-accent); }
.gh-btn-primary:hover { background: var(--gh-accent-2); border-color: var(--gh-accent-2); }
.gh-btn-ghost { background: transparent; border-color: transparent; color: var(--gh-muted); }
.gh-wide { width: 100%; }
.gh-btn:focus-visible, .gh-chip:focus-visible, .gh-mode:focus-visible, .gh-opt:focus-visible, .gh-round:focus-visible, .gh-select:focus-visible, .gh-input:focus-visible { outline: 3px solid var(--gh-accent); outline-offset: 2px; }

/* ---- setup ---- */
.gh-setup { max-width: 560px; margin: 6px auto 0; padding: 16px; border-radius: 18px; background: var(--gh-card-bg); border: 1px solid var(--gh-card-border); box-shadow: var(--gh-shadow); display: flex; flex-direction: column; gap: 14px; }
.gh-setup[hidden], .gh-play[hidden], .gh-field[hidden] { display: none; }
.gh-setup-title { margin: 0; font-size: 1.35rem; font-weight: 800; text-align: center; }
.gh-field { display: flex; flex-direction: column; gap: 6px; }
.gh-label { font-weight: 700; font-size: .92rem; color: var(--gh-muted); }
.gh-note { color: var(--gh-muted); font-size: .84rem; line-height: 1.4; min-height: 1.2em; }
.gh-modes { display: grid; gap: 8px; }
.gh-mode { display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left; min-height: 62px; padding: 8px 12px; border-radius: 14px; border: 1px solid var(--gh-card-border); background: var(--gh-page-bg); color: inherit; cursor: pointer; touch-action: manipulation; }
.gh-mode-icon { grid-row: 1 / 3; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; background: var(--gh-card-bg); color: var(--gh-accent); border: 1px solid var(--gh-card-border); }
.gh-mode strong { font-size: 1.02rem; }
.gh-mode small { color: var(--gh-muted); font-size: .82rem; }
.gh-mode[aria-checked="true"] { border-color: var(--gh-accent); background: var(--gh-accent-soft); box-shadow: inset 0 0 0 1px var(--gh-accent); }
.gh-mode[aria-checked="true"] .gh-mode-icon { background: var(--gh-accent); color: var(--gh-on-accent); border-color: var(--gh-accent); }
.gh-chips { display: flex; gap: 6px; }
.gh-chip { flex: 1; min-height: 46px; border-radius: 12px; border: 1px solid var(--gh-card-border); background: var(--gh-page-bg); color: inherit; font-weight: 800; font-size: 1rem; cursor: pointer; touch-action: manipulation; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 6px; }
.gh-chip[aria-checked="true"] { background: var(--gh-accent); border-color: var(--gh-accent); color: var(--gh-on-accent); }
.gh-names { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin: 2px 0 6px; }
.gh-name { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 12px; background: var(--gh-page-bg); border: 1px solid var(--gh-card-border); margin: 0; }
.gh-name input { min-width: 0; width: 100%; min-height: 40px; border: 0; background: transparent; color: inherit; font-size: 1rem; }
.gh-name input:focus { outline: none; }
.gh-name:focus-within { border-color: var(--gh-accent); }
.gh-name-dot, .gh-who-dot { width: 14px; height: 14px; flex: none; border-radius: 50%; background: var(--c); display: inline-block; }
.gh-select { min-height: 48px; padding: 6px 12px; border-radius: 12px; border: 1px solid var(--gh-card-border); background: var(--gh-page-bg); color: inherit; font-size: 1rem; font-weight: 600; }

/* ---- play ---- */
.gh-play { display: flex; flex-direction: column; gap: 10px; max-width: 640px; margin: 0 auto; }
.gh-top { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 4px 6px 4px 14px; border-radius: 14px; background: var(--gh-card-bg); border: 1px solid var(--gh-card-border); }
.gh-top-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.gh-top-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1rem; display: flex; align-items: center; gap: 6px; }
.gh-top-text small { color: var(--gh-muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gh-score { min-width: 48px; padding: 6px 10px; border-radius: 10px; background: var(--gh-accent-soft); color: var(--gh-accent); font-weight: 900; text-align: center; font-variant-numeric: tabular-nums; }
.gh-round { width: 42px; height: 42px; flex: none; border-radius: 50%; border: 1px solid var(--gh-card-border); display: grid; place-items: center; background: var(--gh-page-bg); color: inherit; font-size: 15px; cursor: pointer; touch-action: manipulation; }
.gh-round span[hidden] { display: none; }
.gh-timer { position: relative; width: 42px; height: 42px; flex: none; display: grid; place-items: center; }
.gh-timer[hidden] { display: none; }
.gh-timer svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.gh-timer-bg { fill: none; stroke: var(--gh-slot); stroke-width: 3.5; }
.gh-timer-fg { fill: none; stroke: var(--gh-ok); stroke-width: 3.5; stroke-linecap: round; transition: stroke-dashoffset .1s linear, stroke .3s; }
.gh-timer b { position: relative; font-size: .95rem; font-variant-numeric: tabular-nums; }
.gh-timer.is-low .gh-timer-fg { stroke: var(--gh-bad); }
.gh-timer.is-low b { color: var(--gh-bad); }
.gh-progress { height: 5px; border-radius: 3px; background: var(--gh-slot); overflow: hidden; }
.gh-progress span { display: block; height: 100%; width: 0; background: var(--gh-accent); transition: width .3s; }

/* the riddle card: a sheet of paper with an embroidered band top and bottom (like the motifs of an ie) */
.gh-card { position: relative; margin: 0; padding: 26px 18px 18px; border-radius: 18px; background: var(--gh-paper); border: 1px solid var(--gh-paper-edge); box-shadow: var(--gh-shadow); color: var(--gh-ink); text-align: center; overflow: hidden; min-height: 210px; }
.gh-card::before, .gh-card::after { content: ""; position: absolute; left: 0; right: 0; height: 12px;
    background:
        linear-gradient(135deg, transparent 33%, var(--gh-stitch) 33% 41%, transparent 41% 59%, var(--gh-stitch) 59% 67%, transparent 67%) 0 0 / 16px 12px,
        linear-gradient(45deg, transparent 33%, var(--gh-stitch) 33% 41%, transparent 41% 59%, var(--gh-stitch) 59% 67%, transparent 67%) 0 0 / 16px 12px,
        radial-gradient(circle, var(--gh-stitch-2) 1.6px, transparent 2px) 8px 6px / 16px 12px; opacity: .85; }
.gh-card::before { top: 6px; }
.gh-card::after { bottom: 6px; }
.gh-card.is-in { animation: gh-in .35s ease-out; }
.gh-card.is-shake { animation: gh-shake .35s ease-in-out; }
@keyframes gh-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes gh-shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
.gh-intro { margin: 0 0 8px; font-size: .82rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--gh-stitch); }
.gh-text { margin: 0 auto 10px; max-width: 34em; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.18rem, 4.6vw, 1.45rem); line-height: 1.45; font-style: italic; }
.gh-glosar { margin: 0 auto 8px; max-width: 34em; font-size: .82rem; color: var(--gh-muted); line-height: 1.4; }
.gh-glosar[hidden], .gh-hint[hidden] { display: none; }
.gh-glosar b { color: var(--gh-ink); }
.gh-hint { margin: 4px auto 10px; max-width: 30em; padding: 8px 12px; border-radius: 12px; background: var(--gh-accent-soft); color: var(--gh-ink); font-size: .95rem; line-height: 1.4; animation: gh-in .3s ease-out; }
.gh-hint svg, .gh-hint i { color: var(--gh-accent); }
.gh-slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin-top: 8px; min-height: 38px; }
.gh-slot { width: 30px; height: 38px; border-radius: 8px; background: var(--gh-slot); border-bottom: 3px solid var(--gh-paper-edge); display: grid; place-items: center; font-weight: 900; font-size: 1.15rem; text-transform: uppercase; color: var(--gh-ink); }
.gh-slot.is-on { background: var(--gh-card-bg); border-bottom-color: var(--gh-accent); animation: gh-pop .25s ease-out; }
.gh-slot.is-miss { color: var(--gh-bad); }
.gh-gap { width: 14px; }
.gh-dash { width: 10px; display: grid; place-items: center; font-weight: 900; }
@keyframes gh-pop { 0% { transform: scale(.6); } 70% { transform: scale(1.1); } 100% { transform: none; } }
@media (max-width: 400px) { .gh-slot { width: 25px; height: 34px; font-size: 1rem; } .gh-slots { gap: 4px; } }

.gh-form { display: flex; gap: 8px; }
.gh-form[hidden], .gh-options[hidden], .gh-helps[hidden], .gh-result[hidden], .gh-board[hidden] { display: none; }
.gh-input { flex: 1; min-width: 0; min-height: 52px; padding: 8px 14px; border-radius: 14px; border: 2px solid var(--gh-card-border); background: var(--gh-card-bg); color: inherit; font-size: 1.1rem; font-weight: 600; }
.gh-input:focus { border-color: var(--gh-accent); outline: none; }
.gh-send { min-height: 52px; }
.gh-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gh-opt { position: relative; min-height: 58px; padding: 8px 10px 8px 34px; border-radius: 14px; border: 2px solid var(--gh-card-border); background: var(--gh-card-bg); color: inherit; font-weight: 800; font-size: 1.05rem; line-height: 1.2; cursor: pointer; touch-action: manipulation; text-align: left; transition: background .15s, border-color .15s, transform .1s; }
.gh-opt:hover:not(:disabled) { border-color: var(--gh-accent); }
.gh-opt:active:not(:disabled) { transform: scale(.98); }
.gh-opt-key { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; border-radius: 5px; background: var(--gh-slot); color: var(--gh-muted); font-size: .72rem; display: grid; place-items: center; }
.gh-opt.is-wrong { background: var(--gh-bad-soft); border-color: var(--gh-bad); color: var(--gh-bad); text-decoration: line-through; opacity: .8; cursor: default; }
.gh-opt.is-right { background: var(--gh-ok-soft); border-color: var(--gh-ok); color: var(--gh-ok); opacity: 1; }
.gh-opt:disabled { cursor: default; }
.gh-helps { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.gh-help-btn { min-height: 46px; padding: 6px 8px; font-size: .9rem; gap: 6px; }
.gh-btn-giveup { color: var(--gh-muted); }
.gh-status { margin: 0; min-height: 1.4em; text-align: center; color: var(--gh-bad); font-weight: 700; font-size: .95rem; }
.gh-result { padding: 14px; border-radius: 16px; background: var(--gh-card-bg); border: 1px solid var(--gh-card-border); text-align: center; display: flex; flex-direction: column; gap: 6px; animation: gh-in .3s ease-out; }
.gh-result-title { margin: 0; font-weight: 900; font-size: 1.25rem; }
.gh-result-title.is-ok { color: var(--gh-ok); }
.gh-result-title.is-miss { color: var(--gh-accent); }
.gh-pts { color: var(--gh-gold); margin-left: 4px; letter-spacing: .04em; }
.gh-result-answer { margin: 0; font-size: 1.1rem; }
.gh-result-src { margin: 0 0 4px; color: var(--gh-muted); font-size: .82rem; }
.gh-board { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.gh-pl { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--gh-card-bg); border: 1px solid var(--gh-card-border); font-size: .9rem; max-width: 100%; }
.gh-pl-name { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gh-pl.is-turn { border-color: var(--gh-accent); box-shadow: inset 0 0 0 1px var(--gh-accent); }
.gh-actions { display: flex; justify-content: center; margin-top: 4px; }
.gh-actions .gh-btn { min-width: 170px; }
.gh-review { text-align: left; margin: 0; padding-left: 1.4em; font-style: normal; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: .92rem; display: grid; gap: 8px; }
.gh-review li { line-height: 1.35; }
.gh-rv-text { display: block; color: var(--gh-muted); font-style: italic; }
.gh-rv-ans { font-weight: 800; }
.gh-review li.is-ok .gh-rv-ans { color: var(--gh-ok); }
.gh-review li.is-miss .gh-rv-ans { color: var(--gh-accent); }

/* ---- stats + help ---- */
.gh-stats, .gh-help { max-width: 640px; margin: 14px auto 0; padding: 12px 14px; border-radius: 14px; background: var(--gh-card-bg); border: 1px solid var(--gh-card-border); }
.gh-stats summary, .gh-help summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.gh-st-big { margin: 10px 0; font-size: 1rem; }
.gh-st-big strong { font-size: 1.4rem; color: var(--gh-accent); }
.gh-st-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.gh-st-grid div { padding: 8px 4px; border-radius: 12px; background: var(--gh-page-bg); text-align: center; display: flex; flex-direction: column; }
.gh-st-grid b { font-size: 1.2rem; }
.gh-st-grid small { color: var(--gh-muted); font-size: .72rem; line-height: 1.2; }
@media (max-width: 420px) { .gh-st-grid { grid-template-columns: 1fr 1fr; } }
.gh-st-cats { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.gh-st-cats li { display: grid; grid-template-columns: minmax(0, 1.3fr) 1fr auto; gap: 8px; align-items: center; font-size: .86rem; }
.gh-st-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gh-st-bar { height: 8px; border-radius: 4px; background: var(--gh-slot); overflow: hidden; }
.gh-st-bar span { display: block; height: 100%; background: var(--gh-accent); }
.gh-st-num { font-variant-numeric: tabular-nums; color: var(--gh-muted); }
.gh-reset-wrap { text-align: center; margin: 8px 0 0; }
.gh-link { border: 0; background: none; padding: 6px; color: var(--gh-muted); font-size: .85rem; text-decoration: underline; cursor: pointer; }
.gh-help ul { margin: 10px 0 4px; padding-left: 20px; line-height: 1.55; }
.gh-help li { margin-bottom: 4px; }
.gh-credit { margin: 8px 0 0; font-size: .82rem; color: var(--gh-muted); }
.gh-credit a, .gh-powered a { color: var(--gh-accent); }
.gh-powered { text-align: center; color: var(--gh-muted); font-size: .85rem; margin: 22px 0 0; }

/* ---- dialogs ---- */
.gh-overlay { position: fixed; inset: 0; z-index: 1060; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--gh-overlay); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); overflow-y: auto; }
.gh-overlay[hidden] { display: none; }
.gh-dialog { width: 100%; max-width: 380px; margin: auto; display: flex; flex-direction: column; gap: 10px; padding: 20px 16px; border-radius: 20px; background: var(--gh-card-bg); border: 1px solid var(--gh-card-border); box-shadow: var(--gh-shadow); color: var(--text-color); text-align: center; }
.gh-dialog h2 { margin: 0; font-weight: 800; font-size: 1.4rem; overflow-wrap: anywhere; }
.gh-dialog-icon { width: 56px; height: 56px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 24px; color: #fff; background: linear-gradient(135deg, #dc2626, #7f1d1d); }
.gh-over-big { margin: 0; font-size: 1.1rem; color: var(--gh-muted); }
.gh-over-big:empty { display: none; }
.gh-over-big strong, .gh-stars { font-size: 2.2rem; font-weight: 900; color: var(--gh-gold); }
.gh-final { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.gh-final:empty { display: none; }
.gh-final li { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 12px; background: var(--gh-page-bg); font-weight: 700; text-align: left; }
.gh-final li .gh-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gh-final li small { color: var(--gh-muted); font-weight: 600; }
.gh-final li strong { font-size: 1.15rem; min-width: 2ch; text-align: right; }
.gh-final li.is-win { background: linear-gradient(135deg, rgba(245, 158, 11, .25), rgba(185, 28, 28, .16)); }
.gh-over-sub { margin: 0; color: var(--gh-muted); font-size: .92rem; }
.gh-over-sub:empty { display: none; }
.gh-dialog-actions { display: grid; gap: 8px; }

@media (max-width: 899px) {
    .gh-main { padding-top: 84px; }
}
@media (max-width: 420px) {
    .gh-setup { padding: 12px; }
    .gh-card { padding: 24px 12px 16px; }
    .gh-help-btn { font-size: .82rem; padding: 6px 4px; gap: 4px; }
    .gh-opt { font-size: .98rem; padding-left: 30px; }
}
@media (prefers-reduced-motion: reduce) {
    .gh-card.is-in, .gh-card.is-shake, .gh-slot.is-on, .gh-hint, .gh-result { animation: none; }
}
