/* Yams — five 3D dice in a felt tray, 1-4 players or the phone (js/yams.js).
   Theme-aware like the other game pages: tokens on :root, redefined under body.dark-theme. */
:root {
    --ym-accent: #9a3412;
    --ym-accent-2: #c2410c;
    --ym-accent-soft: #fdeee3;
    --ym-on-accent: #ffffff;
    --ym-page-bg: #f8f4ef;
    --ym-card-bg: #ffffff;
    --ym-card-border: #e6dccf;
    --ym-muted: #6b5d50;
    --ym-shadow: 0 10px 30px rgba(80, 40, 10, .10);
    --ym-stage-bg: #3b2416;
    --ym-cell: #faf6f1;
    --ym-cell-alt: #f3ece3;
    --ym-cur: #fff4d6;
    --ym-cur-border: #e8b64c;
    --ym-pot: #a8724a;
    --ym-pot-zero: #b9ada0;
    --ym-pick: #15803d;
    --ym-pick-soft: #dcfce7;
    --ym-ok: #15803d;
    --ym-gold: #d97706;
    --ym-die: #fbf7ee;
    --ym-die-border: #d6cbb8;
    --ym-pip: #1c1917;
    --ym-overlay: rgba(30, 18, 10, .55);
}

body.dark-theme {
    --ym-accent: #fb923c;
    --ym-accent-2: #f97316;
    --ym-accent-soft: #3a2314;
    --ym-on-accent: #1c0d03;
    --ym-page-bg: #13100d;
    --ym-card-bg: #1e1915;
    --ym-card-border: #3a3028;
    --ym-muted: #b8a999;
    --ym-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    --ym-stage-bg: #1a100a;
    --ym-cell: #241e19;
    --ym-cell-alt: #2b241e;
    --ym-cur: #3a2e17;
    --ym-cur-border: #d9a441;
    --ym-pot: #f0b27a;
    --ym-pot-zero: #7d7065;
    --ym-pick: #4ade80;
    --ym-pick-soft: #12341f;
    --ym-ok: #4ade80;
    --ym-gold: #fbbf24;
    --ym-die: #f2ece0;
    --ym-die-border: #9d927f;
    --ym-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. */
.ym-body, body.ym-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--ym-page-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: clip;
}
.ym-main { padding-top: 92px; padding-bottom: 40px; }
.ym-game .container, .ym-hero .container { max-width: 1080px; }

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

/* ---- buttons ---- */
.ym-btn { min-height: 48px; padding: 8px 16px; border-radius: 14px; border: 1px solid var(--ym-card-border); background: var(--ym-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; }
.ym-btn:hover { border-color: var(--ym-accent); }
.ym-btn:active { transform: scale(.98); }
.ym-btn[hidden] { display: none; }
.ym-btn:disabled { opacity: .5; cursor: default; transform: none; }
.ym-btn-primary { background: var(--ym-accent); border-color: var(--ym-accent); color: var(--ym-on-accent); }
.ym-btn-primary:hover { background: var(--ym-accent-2); border-color: var(--ym-accent-2); }
.ym-btn-accent { background: var(--ym-pick); border-color: var(--ym-pick); color: #fff; }
body.dark-theme .ym-btn-accent { color: #052e16; }
.ym-btn-ghost { background: transparent; border-color: transparent; color: var(--ym-muted); }
.ym-wide { width: 100%; }
.ym-btn:focus-visible, .ym-chip:focus-visible, .ym-die:focus-visible, .ym-cell-btn:focus-visible, .ym-round:focus-visible, .ym-seg button:focus-visible { outline: 3px solid var(--ym-accent); outline-offset: 2px; }

/* ---- setup ---- */
.ym-setup { max-width: 560px; margin: 6px auto 0; padding: 16px; border-radius: 18px; background: var(--ym-card-bg); border: 1px solid var(--ym-card-border); box-shadow: var(--ym-shadow); display: flex; flex-direction: column; gap: 12px; }
.ym-setup[hidden] { display: none; }
.ym-setup-title { margin: 0; font-size: 1.35rem; font-weight: 800; text-align: center; }
.ym-field { display: flex; flex-direction: column; gap: 6px; }
.ym-label { font-weight: 700; font-size: .92rem; color: var(--ym-muted); }
.ym-note { color: var(--ym-muted); font-size: .84rem; line-height: 1.4; }
.ym-chips { display: flex; gap: 6px; }
.ym-chip { flex: 1; min-height: 46px; border-radius: 12px; border: 1px solid var(--ym-card-border); background: var(--ym-page-bg); color: inherit; font-weight: 800; font-size: 1.05rem; cursor: pointer; touch-action: manipulation; }
.ym-chip[aria-checked="true"] { background: var(--ym-accent); border-color: var(--ym-accent); color: var(--ym-on-accent); }
.ym-seats { display: grid; gap: 8px; }
.ym-seat { display: grid; grid-template-columns: auto 1fr; gap: 6px 8px; align-items: center; padding: 8px; border-radius: 14px; background: var(--ym-page-bg); border: 1px solid var(--ym-card-border); }
.ym-seat .ym-dot { width: 18px; height: 18px; }
.ym-seat input { min-width: 0; width: 100%; min-height: 42px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--ym-card-border); background: var(--ym-card-bg); color: inherit; font-size: 1rem; }
.ym-seat input:focus { outline: 2px solid var(--ym-accent); outline-offset: 1px; }
.ym-seat input:disabled { opacity: .75; }
.ym-seg { grid-column: 1 / -1; display: grid; grid-template-columns: 1.15fr 1fr 1fr 1fr; gap: 4px; padding: 3px; border-radius: 12px; background: var(--ym-card-bg); border: 1px solid var(--ym-card-border); }
.ym-seg button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: inherit; font-weight: 700; font-size: .9rem; cursor: pointer; touch-action: manipulation; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 0 4px; }
.ym-seg button[aria-checked="true"] { background: var(--ym-accent); color: var(--ym-on-accent); }
.ym-seg small { font-weight: 600; opacity: .8; font-size: .72rem; }

/* ---- the table ---- */
.ym-play { display: grid; gap: 14px; align-items: start; }
.ym-play[hidden] { display: none; }
@media (min-width: 900px) {
    .ym-play { grid-template-columns: minmax(0, 1.25fr) minmax(330px, 1fr); }
}
.ym-left { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.ym-turn { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 4px 6px 4px 12px; border-radius: 14px; background: var(--ym-card-bg); border: 1px solid var(--ym-card-border); }
.ym-dot { width: 16px; height: 16px; flex: none; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .7), transparent 45%), var(--c, #9a3412); box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.ym-turn-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.ym-turn-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1rem; }
.ym-turn-text small { color: var(--ym-muted); font-size: .78rem; white-space: nowrap; }
.ym-throws { display: inline-flex; gap: 4px; margin-right: 4px; }
.ym-throws span { width: 11px; height: 11px; border-radius: 3px; background: var(--ym-accent); transition: background .2s, opacity .2s; }
.ym-throws span.is-used { background: var(--ym-card-border); }
.ym-round { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 1px solid var(--ym-card-border); display: grid; place-items: center; background: var(--ym-page-bg); color: inherit; font-size: 15px; cursor: pointer; touch-action: manipulation; }
.ym-round[hidden], .ym-round span[hidden] { display: none; }

.ym-stage { position: relative; width: 100%; aspect-ratio: 16 / 11; max-height: calc(100vh - 330px); min-height: 300px; border-radius: 18px; overflow: hidden; background: var(--ym-stage-bg); box-shadow: var(--ym-shadow); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
@media (max-width: 899px) {
    .ym-stage { aspect-ratio: auto; height: clamp(200px, 32vh, 320px); max-height: none; min-height: 0; }
}
.ym-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; }
.ym-loading { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 12px; text-align: center; color: #f3d9c2; font-weight: 700; }
.ym-loading[hidden] { display: none; }
.ym-banner { position: absolute; left: 50%; top: 42%; z-index: 2; transform: translate(-50%, -50%) scale(.9); margin: 0; padding: 10px 22px; border-radius: 18px; max-width: 92%; text-align: center; color: #fff; font-weight: 900; font-size: clamp(1.4rem, 7vw, 2.4rem); line-height: 1.15; text-shadow: 0 3px 12px rgba(0, 0, 0, .55); background: linear-gradient(135deg, rgba(194, 65, 12, .92), rgba(190, 18, 60, .92)); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.ym-banner.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.ym-banner small { display: block; font-size: .5em; font-weight: 700; opacity: .92; }
.ym-swipe { position: absolute; left: 50%; top: 10px; z-index: 2; transform: translateX(-50%); margin: 0; padding: 7px 14px; border-radius: 999px; background: rgba(20, 10, 4, .62); color: #fff; font-weight: 700; font-size: .88rem; white-space: nowrap; pointer-events: none; }
.ym-swipe[hidden] { display: none; }
.ym-swipe-icon { display: inline-block; animation: ym-swipe 1.6s ease-in-out infinite; }
@keyframes ym-swipe { 0%, 15% { transform: translateY(6px); opacity: .4; } 60% { transform: translateY(-8px); opacity: 1; } 100% { transform: translateY(-8px); opacity: 0; } }

/* the five dice (the keep row): a die you keep is lifted and framed */
.ym-dice { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; padding: 0 2px; }
.ym-die { position: relative; aspect-ratio: 1; max-height: 64px; width: 100%; justify-self: center; max-width: 64px; padding: 0; border-radius: 14px; border: 2px solid var(--ym-die-border); background: var(--ym-die); box-shadow: 0 3px 0 var(--ym-die-border); cursor: pointer; touch-action: manipulation; transition: transform .15s, box-shadow .15s, border-color .15s, background .15s; }
.ym-die:disabled { cursor: default; }
.ym-die.is-blank { background: repeating-linear-gradient(135deg, var(--ym-cell), var(--ym-cell) 6px, var(--ym-cell-alt) 6px, var(--ym-cell-alt) 12px); border-style: dashed; box-shadow: none; }
.ym-die.is-kept { transform: translateY(-5px); border-color: var(--ym-accent); box-shadow: 0 0 0 3px var(--ym-accent), 0 6px 10px rgba(0, 0, 0, .18); }
.ym-die.is-kept::after { content: "ține"; position: absolute; left: 50%; bottom: -19px; transform: translateX(-50%); font-size: .68rem; font-weight: 800; color: var(--ym-accent); letter-spacing: .02em; }
.ym-pips { position: absolute; inset: 14%; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); }
.ym-pips span { width: 72%; height: 72%; place-self: center; border-radius: 50%; background: var(--ym-pip); visibility: hidden; }
.ym-pips[data-v="1"] span:nth-child(5) { background: #b91c1c; width: 88%; height: 88%; }
.ym-pips[data-v="1"] span:nth-child(5),
.ym-pips[data-v="2"] span:nth-child(3), .ym-pips[data-v="2"] span:nth-child(7),
.ym-pips[data-v="3"] span:nth-child(3), .ym-pips[data-v="3"] span:nth-child(5), .ym-pips[data-v="3"] span:nth-child(7),
.ym-pips[data-v="4"] span:nth-child(1), .ym-pips[data-v="4"] span:nth-child(3), .ym-pips[data-v="4"] span:nth-child(7), .ym-pips[data-v="4"] span:nth-child(9),
.ym-pips[data-v="5"] span:nth-child(1), .ym-pips[data-v="5"] span:nth-child(3), .ym-pips[data-v="5"] span:nth-child(5), .ym-pips[data-v="5"] span:nth-child(7), .ym-pips[data-v="5"] span:nth-child(9),
.ym-pips[data-v="6"] span:nth-child(1), .ym-pips[data-v="6"] span:nth-child(3), .ym-pips[data-v="6"] span:nth-child(4), .ym-pips[data-v="6"] span:nth-child(6), .ym-pips[data-v="6"] span:nth-child(7), .ym-pips[data-v="6"] span:nth-child(9) { visibility: visible; }

.ym-bar { display: flex; gap: 8px; margin-top: 14px; min-height: 52px; }
.ym-bar .ym-btn { flex: 1; min-height: 52px; font-size: 1.05rem; }
.ym-throw small { font-weight: 600; opacity: .85; }
.ym-status { margin: 0; min-height: 2.7em; text-align: center; color: var(--ym-muted); font-size: .9rem; line-height: 1.35; }

/* ---- the score sheet ---- */
.ym-right { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.ym-sheet-wrap { border-radius: 16px; overflow: hidden; background: var(--ym-card-bg); border: 1px solid var(--ym-card-border); box-shadow: var(--ym-shadow); }
.ym-sheet { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; }
.ym-sheet th, .ym-sheet td { padding: 0; height: 30px; border-bottom: 1px solid var(--ym-card-border); text-align: center; font-size: .92rem; }
.ym-sheet tr:last-child th, .ym-sheet tr:last-child td { border-bottom: 0; }
.ym-sheet thead th { height: 38px; font-size: .8rem; font-weight: 800; background: var(--ym-cell-alt); padding: 2px 3px; }
.ym-sheet .ym-hcell { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 0; line-height: 1.1; }
.ym-sheet .ym-hname { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ym-sheet .ym-htag { font-size: .66rem; font-weight: 600; color: var(--ym-muted); white-space: nowrap; }
.ym-sheet .ym-hdot { width: 10px; height: 10px; display: inline-block; border-radius: 50%; background: var(--c); margin-right: 3px; vertical-align: 0; }
.ym-sheet tbody th { text-align: left; padding: 0 6px 0 10px; font-weight: 700; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--ym-cell); }
.ym-sheet thead th:first-child { width: 36%; }
.ym-sheet.is-many thead th:first-child { width: 31%; }
.ym-sheet.is-many thead th { font-size: .74rem; }
.ym-sheet.is-many .ym-hdot { display: block; margin: 0 auto 2px; }
.ym-sheet .ym-face { display: inline-block; width: 16px; height: 16px; margin-right: 5px; vertical-align: -3px; border-radius: 4px; border: 1.5px solid var(--ym-die-border); background: var(--ym-die); position: relative; }
.ym-sheet .ym-face .ym-pips { inset: 8%; }
.ym-sheet .ym-face .ym-pips span { width: 80%; height: 80%; }
.ym-sheet td.is-cur { background: var(--ym-cur); box-shadow: inset 2px 0 0 var(--ym-cur-border), inset -2px 0 0 var(--ym-cur-border); }
.ym-sheet thead th.is-cur { background: var(--ym-cur); box-shadow: inset 2px 0 0 var(--ym-cur-border), inset -2px 0 0 var(--ym-cur-border), inset 0 2px 0 var(--ym-cur-border); }
.ym-sheet td.is-done { font-weight: 800; }
.ym-sheet td.is-new { animation: ym-new 1s ease-out; }
@keyframes ym-new { 0% { background: var(--ym-pick-soft); } 100% { background: inherit; } }
.ym-sheet tr.ym-sum th, .ym-sheet tr.ym-sum td { background: var(--ym-cell-alt); font-size: .82rem; color: var(--ym-muted); height: 26px; }
.ym-sheet tr.ym-sum td.is-got { color: var(--ym-ok); font-weight: 800; }
.ym-sheet tr.ym-total th, .ym-sheet tr.ym-total td { background: var(--ym-cell-alt); font-weight: 900; font-size: 1rem; height: 36px; color: var(--text-color); }
.ym-sheet tr.ym-total td.is-lead { color: var(--ym-gold); }
.ym-cell-btn { width: 100%; height: 100%; min-height: 30px; padding: 0; border: 0; background: transparent; color: var(--ym-pot); font-weight: 700; font-size: .92rem; cursor: pointer; touch-action: manipulation; font-variant-numeric: tabular-nums; }
.ym-cell-btn.is-zero { color: var(--ym-pot-zero); font-weight: 600; }
.ym-cell-btn:hover { background: var(--ym-pick-soft); }
.ym-cell-btn.is-pick { background: var(--ym-pick); color: #fff; font-weight: 900; }
body.dark-theme .ym-cell-btn.is-pick { color: #052e16; }
.ym-cell-ai { display: inline-block; padding: 0 6px; border-radius: 6px; background: var(--ym-pick); color: #fff; font-weight: 900; }
body.dark-theme .ym-cell-ai { color: #052e16; }
.ym-sheet tr.is-row-pick th { color: var(--ym-pick); }
.ym-actions { display: flex; justify-content: center; }
.ym-actions .ym-btn { min-width: 170px; }

.ym-record { margin: 14px 0 0; text-align: center; color: var(--ym-muted); font-size: .9rem; }
.ym-record:empty { display: none; }
.ym-reset-wrap { text-align: center; margin: 2px 0 10px; }
.ym-reset-wrap[hidden] { display: none; }
.ym-link { border: 0; background: none; padding: 6px; color: var(--ym-muted); font-size: .85rem; text-decoration: underline; cursor: pointer; }

/* ---- help ---- */
.ym-help { max-width: 760px; margin: 12px auto 0; padding: 12px 14px; border-radius: 14px; background: var(--ym-card-bg); border: 1px solid var(--ym-card-border); }
.ym-help summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.ym-help ul { margin: 10px 0 4px; padding-left: 20px; line-height: 1.55; }
.ym-help li { margin-bottom: 4px; }
.ym-credit { margin: 8px 0 0; font-size: .82rem; color: var(--ym-muted); }
.ym-credit a, .ym-powered a { color: var(--ym-accent); }
.ym-powered { text-align: center; color: var(--ym-muted); font-size: .85rem; margin: 22px 0 0; }

/* ---- game over ---- */
.ym-overlay { position: fixed; inset: 0; z-index: 1060; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--ym-overlay); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); overflow-y: auto; }
.ym-overlay[hidden] { display: none; }
.ym-dialog { width: 100%; max-width: 380px; margin: auto; display: flex; flex-direction: column; gap: 10px; padding: 20px 16px; border-radius: 20px; background: var(--ym-card-bg); border: 1px solid var(--ym-card-border); box-shadow: var(--ym-shadow); color: var(--text-color); text-align: center; }
.ym-dialog h2 { margin: 0; font-weight: 800; font-size: 1.4rem; }
.ym-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, #f59e0b, #c2410c); }
.ym-final { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ym-final li { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 12px; background: var(--ym-page-bg); font-weight: 700; text-align: left; }
.ym-final li .ym-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ym-final li strong { font-size: 1.15rem; }
.ym-final li.is-win { background: linear-gradient(135deg, rgba(245, 158, 11, .25), rgba(194, 65, 12, .18)); }
.ym-over-sub { margin: 0; color: var(--ym-muted); font-size: .92rem; }
.ym-over-sub:empty { display: none; }
.ym-dialog-actions { display: grid; gap: 8px; }

@media (max-width: 899px) {
    .ym-main { padding-top: 84px; }
    body.ym-playing .ym-main { padding-bottom: 96px; }
    /* on a phone the sheet is below the dice: "Scrie" floats at the bottom, always in reach */
    .ym-bar .ym-write { position: fixed; left: 16px; right: 16px; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 1040; min-height: 56px; box-shadow: 0 8px 24px rgba(0, 0, 0, .28); }
    .ym-bar .ym-write:disabled { opacity: 1; background: var(--ym-card-bg); border-color: var(--ym-card-border); color: var(--ym-muted); }
    .ym-play { gap: 10px; }
    .ym-right { gap: 8px; }
}
@media (max-width: 420px) {
    .ym-sheet th, .ym-sheet td { height: 28px; font-size: .88rem; }
    .ym-sheet tbody th { font-size: .82rem; padding: 0 4px 0 8px; }
    .ym-cell-btn { min-height: 28px; font-size: .88rem; }
    .ym-dice { gap: 6px; }
    .ym-setup { padding: 12px; }
    .ym-seg button { font-size: .84rem; }
}
@media (prefers-reduced-motion: reduce) {
    .ym-swipe-icon { animation: none; }
    .ym-banner, .ym-die { transition: none; }
    .ym-sheet td.is-new { animation: none; }
}
