/* DK Games — follows the phone's Light / Dark setting. */
:root{
  color-scheme:light dark;
  --bg:#ffffff; --ink:#17191c; --panel:#f1f2f6; --panel2:#e4e7ee; --line:#d3d7e2; --dim:#677085;
  --yellow:#F7C948; --accent:#d9480f; --good:#1f9d55; --bad:#d6336c;
  --c-yz:#C8102E; --c-gin:#2F8A5F; --c-dice:#C07A2A; --c-cs:#6741D9; --c-gd:#0C8599; --c-cb:#B0306A;
  --p0:#e03131; --p1:#1c7ed6; --p2:#2f9e44; --p3:#d99a00; --p4:#9c36b5; --p5:#0c8599;
  --die:#ffffff; --pip:#17191c; --shadow:rgba(0,0,0,.18);
}
@media (prefers-color-scheme:dark){
  :root{
    --bg:#0f1115; --ink:#f2f4f8; --panel:#1a1d24; --panel2:#232733; --line:#2d3240; --dim:#8b93a7;
    --accent:#ffb020; --good:#3ddc84; --bad:#ff6b6b;
    --p0:#ff6b6b; --p1:#4dabf7; --p2:#51cf66; --p3:#fcc419; --p4:#cc5de8; --p5:#22d3c5;
    --die:#f4f4f2; --pip:#17191c; --shadow:rgba(0,0,0,.5);
  }
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
html,body{margin:0;height:100%;background:var(--bg);color:var(--ink);font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text",system-ui,sans-serif;overscroll-behavior:none;touch-action:manipulation}
button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:pointer}
input{-webkit-user-select:text;user-select:text}
.cond{font-family:"Avenir Next Condensed","Arial Narrow","Roboto Condensed",system-ui,sans-serif;font-weight:700;text-transform:uppercase;letter-spacing:.03em}

.screen{display:none;height:100vh;height:100dvh;flex-direction:column;gap:8px;overflow:hidden;
  padding:calc(env(safe-area-inset-top) + 8px) 12px calc(env(safe-area-inset-bottom) + 8px)}
.screen.active{display:flex}
.topbar{flex:none;display:flex;align-items:center;gap:8px;min-height:38px}
.topbar .ttl{flex:1;text-align:center;font-size:21px}
.topbar .sp{width:64px}
.brand{flex:1;margin:0;font-size:26px}
.pill{background:var(--yellow);color:#17191c;border-radius:10px;height:36px;padding:0 14px;font-weight:700;font-size:15px;min-width:64px}
.pill:active{filter:brightness(.92)}
.bar2{flex:none;display:grid;grid-template-columns:1fr 1fr;gap:8px}
.bar2.one{grid-template-columns:1fr}
.bar2 button{background:var(--panel);border-radius:12px;height:44px;font-weight:700;font-size:15px}
.bar2 button:disabled{opacity:.35}
.bar2 button:active{background:var(--panel2)}
.nogame{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;color:var(--dim);text-align:center}
.nogame button{background:var(--accent);color:#fff;border-radius:12px;height:48px;padding:0 24px;font-weight:700;font-size:16px}

/* ---------- home ---------- */
.tiles{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:8px}
.tile{background:var(--c);color:#fff;border-radius:20px;min-height:132px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;padding:14px 8px;text-align:center}
.tile:active{transform:scale(.96)}
.tile svg{width:36px;height:36px}
.tile .nm{font-size:20px}
.tile .sub{font-size:11.5px;font-weight:500;opacity:.92;min-height:14px;line-height:1.2}

/* ---------- bottom sheet ---------- */
.overlay{position:fixed;inset:0;background:rgba(0,0,0,.5);display:none;align-items:flex-end;justify-content:center;z-index:20}
.overlay.on{display:flex}
.sheet{width:100%;max-width:520px;background:var(--bg);color:var(--ink);border-radius:20px 20px 0 0;padding:14px 12px calc(env(safe-area-inset-bottom) + 12px);max-height:92dvh;overflow:auto;box-shadow:0 -6px 24px var(--shadow);-webkit-overflow-scrolling:touch}
@media (prefers-color-scheme:dark){.sheet{background:var(--panel)}}
.sheet h2{margin:0 0 2px;font-size:20px}
.sheet .sub{color:var(--dim);font-size:13px;margin-bottom:12px;line-height:1.35}
.wide{display:block;width:100%;background:var(--panel2);border-radius:12px;min-height:46px;font-weight:700;font-size:15px;margin-top:8px;padding:0 12px}
.wide.primary{background:var(--accent);color:#fff}
@media (prefers-color-scheme:dark){.wide.primary{color:#000}}
.wide.danger{color:var(--bad)}
.wide small{display:block;font-weight:500;color:var(--dim);font-size:11.5px}
.row2{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:10px}
.row2 button{background:var(--panel2);border-radius:12px;height:46px;font-weight:700;font-size:15px}
.danger{color:var(--bad)}
.opts{display:grid;gap:8px}
.opts button{background:var(--panel2);border-radius:12px;min-height:52px;font-size:20px;font-weight:800;display:flex;flex-direction:column;align-items:center;justify-content:center;line-height:1.1}
.opts button small{font-size:11px;font-weight:600;color:var(--dim)}
.opts button.cur{outline:3px solid var(--accent)}
.opts button.zero{color:var(--bad)}
.opts button:active{background:var(--accent);color:#000}
.switch{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;background:var(--panel2);border-radius:12px;min-height:50px;padding:6px 14px;margin-top:8px;text-align:left}
.switch b{font-size:15px}
.switch small{display:block;font-size:11.5px;color:var(--dim);font-weight:500}
.switch i{flex:none;width:46px;height:28px;border-radius:14px;background:var(--line);position:relative;transition:background .15s}
.switch i::after{content:"";position:absolute;left:3px;top:3px;width:22px;height:22px;border-radius:50%;background:#fff;transition:left .15s}
.switch.on i{background:var(--good)}
.switch.on i::after{left:21px}
.counts{display:grid;gap:6px;margin-bottom:14px}
.counts button{height:46px;border-radius:10px;background:var(--panel2);font-size:20px;font-weight:800}
.counts button.on{background:var(--accent);color:#fff}
@media (prefers-color-scheme:dark){.counts button.on{color:#000}}
.field{display:flex;align-items:center;gap:10px;margin-bottom:8px}
.field i{width:12px;height:36px;border-radius:4px;background:var(--c);flex:none}
.field input{flex:1;height:44px;border-radius:10px;border:2px solid var(--line);background:var(--panel2);color:var(--ink);font-size:17px;padding:0 12px;font-family:inherit;min-width:0}
.rank{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:12px;background:var(--panel2);margin-bottom:6px}
.rank .pos{font-size:20px;width:28px}
.rank .n{flex:1;font-weight:700;font-size:17px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rank .s{font-weight:800;font-size:22px;font-variant-numeric:tabular-nums}
.rank.win{outline:3px solid var(--accent)}
.stat{display:flex;justify-content:space-between;padding:9px 4px;border-bottom:1px solid var(--line);font-size:15px;gap:10px}
.stat span:last-child{color:var(--dim);text-align:right}
.note{font-size:12.5px;color:var(--dim);margin-top:10px;line-height:1.45}
.rules details{background:var(--panel2);border-radius:12px;margin-bottom:8px;padding:0 14px}
.rules summary{list-style:none;padding:13px 0;font-weight:700;font-size:15px;display:flex;justify-content:space-between;align-items:center}
.rules summary::-webkit-details-marker{display:none}
.rules summary::after{content:"+";font-size:20px;font-weight:600;color:var(--dim)}
.rules details[open] summary::after{content:"–"}
.rbody{font-size:14.5px;line-height:1.5;padding:0 0 14px}
.rbody p{margin:0 0 9px}
.rbody ul{margin:0 0 9px;padding-left:19px}
.rbody li{margin-bottom:4px}
.rbody table{width:100%;border-collapse:collapse;margin-bottom:9px;font-size:14px}
.rbody td{padding:5px 0;border-bottom:1px solid var(--line);vertical-align:top}
.rbody td:last-child{text-align:right;font-weight:700;padding-left:10px;white-space:nowrap}
.rbody tr:last-child td{border-bottom:0}
.keypad{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:10px 0}
.keypad button{background:var(--panel2);border-radius:12px;height:54px;font-size:24px;font-weight:700}
.keydisp{background:var(--panel2);border-radius:12px;text-align:center;font-size:44px;font-weight:800;padding:6px 0;font-variant-numeric:tabular-nums}
.preview{min-height:40px;text-align:center;font-weight:700;font-size:16px;margin:8px 0 2px;line-height:1.3}

/* ---------- Yahtzee ---------- */
.yz-board{flex:none;display:grid;gap:6px}
.yz-chip{position:relative;background:var(--panel);border:2px solid transparent;border-radius:12px;padding:5px 2px 6px;text-align:center;min-width:0;overflow:hidden}
.yz-chip .nm{font-size:12px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding:0 3px;color:var(--dim)}
.yz-chip .tt{font-size:22px;font-weight:800;line-height:1.1;font-variant-numeric:tabular-nums}
.yz-chip.sel{border-color:var(--c);background:var(--panel2)}
.yz-chip.sel .nm{color:var(--ink)}
.yz-chip::before{content:"";position:absolute;left:0;right:0;top:0;height:4px;background:var(--c)}
.yz-chip .turn{position:absolute;top:6px;right:5px;width:8px;height:8px;border-radius:50%;background:var(--accent)}
.yz-chip.full .tt{color:var(--good)}
.yz-chip.one .nm{font-size:13px}
.yz-chip.one .tt{font-size:26px}
.yz-status{flex:none;display:flex;justify-content:space-between;align-items:center;font-size:13px;color:var(--dim);padding:0 4px;min-height:20px}
.yz-status b{color:var(--ink)}
.yz-status .turnname{font-weight:700}
.yz-goal{flex:none;background:var(--panel);border-radius:10px;padding:6px 10px}
.yz-goal .t{display:flex;justify-content:space-between;font-size:12.5px;font-weight:600;margin-bottom:5px}
.yz-goal .t span:last-child{color:var(--dim);font-weight:500}
.yz-goal .gb{position:relative;height:8px;background:var(--panel2);border-radius:4px;overflow:hidden}
.yz-goal .gb i.f{position:absolute;left:0;top:0;bottom:0;background:var(--good);width:0}
.yz-goal .gb i.m{position:absolute;top:0;bottom:0;width:2px;background:var(--bg)}
.yz-card{flex:1;min-height:0;display:grid;grid-template-columns:1fr 1fr;gap:8px}
.yz-col{display:grid;grid-template-rows:repeat(7,minmax(34px,1fr));gap:5px;min-height:0}
.yz-cell{background:var(--panel);border-radius:10px;display:flex;align-items:center;justify-content:space-between;padding:0 10px;border:2px solid transparent;text-align:left;min-width:0}
.yz-cell .lb{font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.yz-cell .vl{font-size:22px;font-weight:800;font-variant-numeric:tabular-nums;min-width:30px;text-align:right}
.yz-cell.empty{border-color:var(--line);background:transparent}
.yz-cell.empty .vl{color:var(--line);font-weight:600}
.yz-cell.zero .vl{color:var(--bad)}
.yz-cell.max .vl{color:var(--good)}
.yz-cell:active{transform:scale(.97)}
.yz-bonus{background:var(--panel);border-radius:10px;padding:6px 10px;display:flex;flex-direction:column;justify-content:center;gap:4px;min-width:0}
.yz-bonus .t{display:flex;justify-content:space-between;font-size:13px;font-weight:600}
.yz-bonus .t span:last-child{font-variant-numeric:tabular-nums}
.yz-bonus .bar{height:6px;background:var(--panel2);border-radius:3px;overflow:hidden}
.yz-bonus .bar i{display:block;height:100%;background:var(--accent);width:0}
.yz-bonus .s{font-size:11px;color:var(--dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.yz-bonus.got .bar i{background:var(--good)}
.yz-bonus.got .s{color:var(--good)}
.yz-bonus.lost .s{color:var(--bad)}
.yz-foot{flex:none;display:grid;grid-template-columns:1fr auto;gap:8px;align-items:stretch}
.yz-yb{background:var(--panel);border-radius:12px;display:flex;align-items:center;justify-content:space-between;padding:6px 8px 6px 12px;gap:6px}
.yz-yb .t{font-size:12px;font-weight:600;line-height:1.2}
.yz-yb .t small{display:block;color:var(--dim);font-weight:500;font-size:10px}
.stp{display:flex;align-items:center;gap:6px}
.stp button{width:38px;height:38px;border-radius:10px;background:var(--panel2);font-size:22px;font-weight:700;line-height:1}
.stp button:disabled{opacity:.3}
.stp span{min-width:18px;text-align:center;font-weight:800;font-size:18px}
.jkbtn{background:var(--accent);color:#fff;border-radius:10px;height:38px;padding:0 12px;font-weight:800;font-size:14px}
@media (prefers-color-scheme:dark){.jkbtn{color:#000}}
.jkbtn:disabled{opacity:.3}
.yz-big{background:var(--panel);border-radius:12px;padding:4px 14px;text-align:center;min-width:104px;border-bottom:4px solid var(--c)}
.yz-big .n{font-size:11px;color:var(--dim);font-weight:600;max-width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.yz-big .v{font-size:34px;font-weight:800;line-height:1;font-variant-numeric:tabular-nums}

/* ---------- Gin Rummy ---------- */
.gin-root{flex:1;min-height:0;display:flex;flex-direction:column;gap:10px}
.gin-panels{flex:none;display:grid;grid-template-columns:1fr 1fr;gap:10px}
.gin-panel{background:var(--panel);border-radius:14px;border-top:5px solid var(--c);padding:10px 8px 12px;text-align:center;min-width:0}
.gin-panel .nm{font-size:15px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.gin-panel .sc{font-size:56px;font-weight:800;line-height:1.05;font-variant-numeric:tabular-nums}
.gin-panel .mt{font-size:12px;color:var(--dim);margin-bottom:6px}
.gin-panel .pb{height:7px;background:var(--panel2);border-radius:4px;overflow:hidden}
.gin-panel .pb i{display:block;height:100%;background:var(--c);width:0}
.gin-panel.lead .sc{color:var(--good)}
.gin-info{flex:none;text-align:center;font-size:13px;color:var(--dim)}
.gin-cta{flex:none;background:var(--c-gin);color:#fff;border-radius:14px;height:58px;font-size:19px;font-weight:800}
.gin-cta:active{filter:brightness(.92)}
.gin-log{flex:1;min-height:0;overflow:auto;display:flex;flex-direction:column;gap:5px;-webkit-overflow-scrolling:touch}
.gin-row{display:flex;align-items:center;gap:8px;background:var(--panel);border-radius:10px;padding:8px 10px;font-size:14px}
.gin-row .h{color:var(--dim);font-size:12px;width:48px;flex:none}
.gin-row .d{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.gin-row .p{font-weight:800;font-variant-numeric:tabular-nums}
.gin-row .dot{width:9px;height:9px;border-radius:50%;background:var(--c);flex:none}
.who{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.who button{height:84px;border-radius:14px;background:var(--c);color:#fff;font-size:20px;font-weight:800;padding:0 6px;overflow:hidden;text-overflow:ellipsis}
.gridn{display:grid;grid-template-columns:repeat(5,1fr);gap:8px}
.gridn button{height:54px;border-radius:12px;background:var(--panel2);font-size:22px;font-weight:800}
.gridn button:active{background:var(--accent);color:#000}

/* ---------- Dice ---------- */
.dice-root{flex:1;min-height:0;display:flex;flex-direction:column;gap:10px}
.dice-area{flex:1;min-height:0;display:grid;gap:12px;align-content:center;justify-content:center;padding:4px}
.die{position:relative;background:var(--die);border-radius:18%;box-shadow:0 3px 0 var(--shadow),0 8px 14px var(--shadow);display:grid;grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(3,1fr);padding:11%;border:4px solid transparent;aspect-ratio:1}
.die .pip{width:78%;height:78%;border-radius:50%;background:var(--pip);align-self:center;justify-self:center;opacity:0}
.die .pip.on{opacity:1}
.die.held{border-color:var(--accent);transform:translateY(5px)}
.die .hl{position:absolute;left:0;right:0;bottom:-19px;text-align:center;font-size:10px;font-weight:800;letter-spacing:.08em;color:var(--accent)}
.die.rolling{animation:shake .12s linear infinite}
@keyframes shake{0%{transform:rotate(-5deg)}50%{transform:rotate(5deg) translateY(-3px)}100%{transform:rotate(-5deg)}}
.dice-info{flex:none;display:flex;justify-content:space-between;align-items:center;min-height:46px;padding:0 4px}
.dice-info .tot{font-size:34px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1}
.dice-info .tot small{font-size:12px;color:var(--dim);font-weight:600;margin-left:4px}
.dice-info .combo{font-size:16px;font-weight:800;color:var(--good);text-align:right}
.dice-info .rc{font-size:13px;color:var(--dim);text-align:right}
.dice-ctl{flex:none;display:grid;grid-template-columns:1fr auto;gap:8px;align-items:stretch}
.dice-n{background:var(--panel);border-radius:12px;display:flex;align-items:center;justify-content:space-between;padding:6px 8px 6px 12px;gap:8px}
.dice-n .t{font-size:13px;font-weight:600}
.dice-new{background:var(--panel2);border-radius:12px;padding:0 16px;font-weight:700;font-size:15px}
.dice-roll{flex:none;background:var(--c-dice);color:#fff;border-radius:16px;height:64px;font-size:24px;font-weight:800}
.dice-roll:disabled{opacity:.4}
.dice-roll:active{filter:brightness(.92)}
[hidden]{display:none!important}

/* ---------- Yahtzee: phone dice strip + priced boxes ---------- */
#screen-yahtzee{overflow-y:auto}
.yz-card{min-height:290px}
.yz-dice{flex:none;display:grid;grid-template-columns:repeat(5,1fr) 98px;gap:6px;align-items:stretch}
.yz-dice .die.sm{border-width:3px;box-shadow:0 2px 0 var(--shadow);padding:10%;width:100%}
.yz-dice .die.sm.held{transform:translateY(3px);box-shadow:none}
.yz-roll{background:var(--accent);color:#fff;border-radius:12px;font-weight:800;font-size:16px;line-height:1.1;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:0 4px}
@media (prefers-color-scheme:dark){.yz-roll{color:#000}}
.yz-roll small{font-size:10px;font-weight:700;opacity:.8}
.yz-roll:disabled{opacity:.45}
.yz-roll:active{filter:brightness(.92)}
.yz-cell.pot .vl{color:var(--dim);font-weight:700}
.yz-cell.pot.hit{border-color:var(--accent)}
.yz-cell.pot.hit .vl{color:var(--accent)}
.jkbtn.hot,.stp button.hot{box-shadow:0 0 0 3px var(--good)}
.switch.dis{opacity:.45}
.yz-dice .die.sm{border-color:rgba(128,128,128,.5)}
.yz-dice .die.sm.held{border-color:var(--accent)}
/* tighter layout so the whole card fits on a 13 mini with the strip on */
.yz-dice{grid-template-columns:repeat(5,40px) 1fr;gap:6px;justify-content:space-between}
.yz-dice .die.sm{width:40px;height:40px;padding:6px;border-width:2px}
.yz-roll{min-height:40px}
.yz-bonus{padding:2px 10px;gap:2px}
.yz-bonus .t{font-size:12px;line-height:1.15}
.yz-bonus .s{font-size:10px;line-height:1.1}
/* laptop/desktop: same phone layout, scaled up (--z set in app-shell.js) */
:root{--z:1}
.screen{width:100%;max-width:560px;margin-left:auto;margin-right:auto}
@media (min-width:700px){
  .screen{zoom:var(--z);height:calc(100vh / var(--z));height:calc(100dvh / var(--z))}
  .sheet{zoom:var(--z);max-height:calc(92dvh / var(--z))}
}

/* ---------- Can't Stop ---------- */
#screen-cantstop{overflow-y:auto}
.cs-root{flex:1;min-height:0;display:flex;flex-direction:column;gap:8px}
.cs-chips{display:grid;gap:6px;flex:none}
.cs-chip{background:var(--panel);border-radius:12px;border-top:4px solid var(--c);padding:4px 4px 6px;text-align:center;border-bottom:2px solid transparent;min-width:0}
.cs-chip.sel{outline:2px solid var(--c);outline-offset:-1px;background:var(--panel2)}
.cs-chip .n{font-size:13px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.cs-chip .w{display:flex;gap:4px;justify-content:center;margin-top:4px}
.cs-chip .w i{width:10px;height:10px;border-radius:50%;border:2px solid var(--c)}
.cs-chip .w i.on{background:var(--c)}
.cs-board{flex:none;display:grid;grid-template-columns:repeat(11,1fr);gap:3px;align-items:end;background:var(--panel);border-radius:12px;padding:8px 6px 6px}
.cs-col{display:flex;flex-direction:column;align-items:center;gap:4px;min-width:0}
.cs-track{width:100%;display:flex;gap:1px;align-items:stretch;justify-content:center;background:repeating-linear-gradient(to top,transparent 0,transparent 14px,var(--line) 14px,var(--line) 15px);border-radius:5px;position:relative;padding:0 1px}
.cs-s{flex:1;position:relative;min-width:0}
.cs-b,.cs-t{position:absolute;left:0;right:0;bottom:0;border-radius:2px}
.cs-b{background:var(--c)}
.cs-t{background:repeating-linear-gradient(45deg,var(--c) 0,var(--c) 2px,transparent 2px,transparent 4px);border:1px solid var(--c)}
.cs-num{font-size:12px;font-weight:800;color:var(--dim);width:100%;text-align:center;border-radius:6px;padding:1px 0}
.cs-num.mk{background:var(--accent);color:#fff}
@media (prefers-color-scheme:dark){.cs-num.mk{color:#000}}
.cs-col.won .cs-track{background:var(--w);opacity:.9}
.cs-col.won .cs-s{opacity:.25}
.cs-col.won .cs-num{color:var(--w)}
.cs-ck{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#fff;font-weight:800;font-size:14px}
.cs-dice{flex:none;display:flex;gap:10px;justify-content:center}
.cs-dice .die{width:54px;height:54px;padding:8px;border-width:2px;box-shadow:0 2px 0 var(--shadow)}
.cs-status{flex:none;text-align:center;font-size:13px;color:var(--dim);min-height:18px;line-height:1.3}
.cs-status b{color:var(--ink)}
.cs-status b.bad{color:var(--bad)}.cs-status b.good{color:var(--good)}
.cs-act{flex:none;display:grid;grid-template-columns:1fr;gap:8px}
.cs-act.two{grid-template-columns:1fr 1fr}
.cs-go,.cs-stop{border-radius:14px;min-height:56px;font-size:19px;font-weight:800}
.cs-go{background:var(--accent);color:#fff}
@media (prefers-color-scheme:dark){.cs-go{color:#000}}
.cs-go:disabled{opacity:.45}
.cs-stop{background:var(--panel2)}
.cs-parts{flex:none;display:grid;gap:8px}
.cs-part{background:var(--panel2);border-radius:14px;min-height:54px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;padding:4px}
.cs-part .s{display:flex;gap:18px;font-size:24px;font-weight:800;line-height:1.1}
.cs-part .s b.dead{color:var(--dim);text-decoration:line-through;font-weight:600;opacity:.7}
.cs-part small{font-size:11px;color:var(--dim);font-weight:600}
.cs-part:active{background:var(--accent);color:#000}
.cs-part.off{opacity:.4}
.cs-dice .die{border-color:rgba(128,128,128,.5)}

/* ---------- Gemdor ---------- */
#screen-gemdor,#screen-codebreaker{overflow-y:auto}
.gd-root,.cb-root{flex:1 0 auto;min-height:0;display:flex;flex-direction:column;gap:6px}
.gd-g{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;background:var(--g);color:#fff;font-size:12px;font-weight:800;border:2px solid rgba(128,128,128,.55);line-height:1;flex:none}
.gd-g.lt{color:#17191c}
.gd-g.part{opacity:.55}
.gd-chips{display:grid;gap:6px;flex:none}
.gd-chip{background:var(--panel);border-radius:12px;border-top:4px solid var(--c);padding:3px 4px 4px;text-align:center;min-width:0;display:flex;flex-direction:column;align-items:center}
.gd-chip.sel{outline:2px solid var(--c);outline-offset:-1px;background:var(--panel2)}
.gd-chip .n{font-size:12px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.gd-chip .v{font-size:20px;font-weight:800;line-height:1.05}
.gd-chip .v small{font-size:10px;color:var(--dim);font-weight:600;margin-left:2px}
.gd-market{display:flex;flex-direction:column;gap:5px;flex:none}
.gd-row{display:grid;grid-template-columns:38px repeat(4,1fr);gap:5px}
.gd-deck{background:var(--panel2);border-radius:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;font-weight:800}
.gd-deck b{font-size:16px}.gd-deck small{font-size:10px;color:var(--dim);font-weight:600}
.gd-deck:disabled{opacity:.35}
.gd-bank{display:grid;grid-template-columns:repeat(6,1fr);gap:5px;flex:none}
.gd-tk{background:var(--panel);border-radius:12px;height:44px;display:flex;align-items:center;justify-content:center;position:relative;border:2px solid transparent}
.gd-tk .gd-g{width:30px;height:30px;font-size:15px}
.gd-tk.sel{border-color:var(--accent);background:var(--panel2)}
.gd-tk.none{opacity:.35}
.gd-tk i{position:absolute;top:-5px;right:-3px;background:var(--accent);color:#fff;font-style:normal;font-size:11px;font-weight:800;border-radius:9px;min-width:17px;height:17px;display:flex;align-items:center;justify-content:center}
@media (prefers-color-scheme:dark){.gd-tk i{color:#000}}
.gd-hand{display:flex;align-items:center;gap:6px;background:var(--panel);border-radius:12px;padding:4px 6px;flex:none}
.gd-hand .who{font-size:11px;font-weight:800;border-left:4px solid var(--c);padding-left:5px;max-width:54px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.gd-hand .tk,.gd-hand .bn{display:flex;gap:3px}
.gd-hand .bn{margin-left:auto}
.gd-ht{padding:0;border-radius:50%}
.gd-ht .gd-g{width:24px;height:24px;font-size:12px}
.gd-ht.zero{opacity:.4}
.gd-ht.give{outline:2px solid var(--bad);border-radius:50%}
.gd-bo{width:24px;height:24px;border-radius:6px;background:var(--g);color:#fff;font-weight:800;font-size:13px;display:flex;align-items:center;justify-content:center;border:1px solid rgba(128,128,128,.55)}
.gd-bo.lt{color:#17191c}.gd-bo.zero{opacity:.4}
.gd-res{display:grid;grid-template-columns:repeat(3,1fr);gap:5px;flex:none}
.gd-status{flex:none;text-align:center;font-size:13px;color:var(--dim);min-height:18px;line-height:1.3}
.gd-status b{color:var(--ink)}.gd-status b.good{color:var(--good)}.gd-status b.bad{color:var(--bad)}
.gd-act{flex:none;display:grid;grid-template-columns:1fr;gap:8px}
.gd-act.two{grid-template-columns:1fr 1fr}
.gd-act .go,.cb-btns .go{background:var(--accent);color:#fff;border-radius:14px;min-height:48px;font-size:17px;font-weight:800}
@media (prefers-color-scheme:dark){.gd-act .go,.cb-btns .go{color:#000}}
.gd-act .alt,.cb-btns .alt{background:var(--panel2);border-radius:14px;min-height:48px;font-size:16px;font-weight:700}
.gd-act button:disabled,.cb-btns button:disabled{opacity:.4}
.gd-big{background:var(--panel);border-radius:14px;padding:10px 12px;margin-bottom:10px}
.gd-big .top{display:flex;justify-content:space-between;align-items:center;font-size:14px}
.gd-big .pt{font-size:22px}
.gd-big .cost{display:flex;gap:6px;margin-top:8px;flex-wrap:wrap}
.gd-big .cost .gd-g{width:30px;height:30px;font-size:15px}
.gd-big .top .gd-g{width:20px;height:20px;font-size:11px;vertical-align:middle}
.stat .gd-g{width:20px;height:20px;font-size:11px;margin-left:3px;vertical-align:middle}
/* ---------- Code Breaker ---------- */
.cb-info{flex:none;display:flex;justify-content:space-between;font-size:13px;color:var(--dim)}
.cb-info b{color:var(--ink)}
.cb-hist{flex:1;min-height:120px;overflow-y:auto;display:flex;flex-direction:column;gap:6px;background:var(--panel);border-radius:12px;padding:8px}
.cb-empty{color:var(--dim);font-size:13px;line-height:1.4;padding:6px 4px}
.cb-empty b{color:var(--ink)}
.cb-row{display:flex;align-items:center;gap:8px}
.cb-row .no{width:26px;font-size:12px;color:var(--dim);font-weight:700;text-align:right;flex:none}
.cb-row .pegs{display:flex;gap:6px;flex:1}
.cb-row.hint{opacity:.8}
.cb-peg{width:34px;height:34px;border-radius:50%;background:var(--g);color:#fff;display:inline-flex;align-items:center;justify-content:center;font-weight:800;font-size:16px;flex:none;border:2px solid rgba(255,255,255,.25)}
.cb-peg.c3{color:#17191c}
.cb-peg.empty{background:transparent;border:2px dashed var(--line)}
.cb-peg.q{border-style:dotted}
.cb-peg.ghost{opacity:.35}
.cb-row .cb-peg{width:30px;height:30px;font-size:14px}
.cb-fb{display:grid;gap:3px;width:34px;flex:none}
.cb-fb i{width:12px;height:12px;border-radius:50%;border:2px solid var(--dim);display:block;box-sizing:border-box}
.cb-fb i.b{background:var(--ink);border-color:var(--ink)}
.cb-fb i.w{background:transparent;border-color:var(--ink)}
.cb-fb i:not(.b):not(.w){border-color:var(--line);opacity:.6}
.cb-cur{flex:none;display:flex;gap:8px;justify-content:center}
.cb-slot{padding:4px;border-radius:50%;border:3px solid transparent}
.cb-slot.sel{border-color:var(--accent)}
.cb-slot .cb-peg{width:44px;height:44px;font-size:20px}
.cb-pal{flex:none;display:grid;gap:5px}
.cb-pal button{padding:0;display:flex;justify-content:center}
.cb-pal .cb-peg{width:min(100%,40px);height:40px}
.cb-btns{flex:none;display:grid;grid-template-columns:1fr;gap:8px}
.cb-btns.three{grid-template-columns:2fr 1fr 1fr}
.cb-note{flex:none;font-size:11px;color:var(--dim);text-align:center}
.cb-result{flex:none;text-align:center;background:var(--panel);border-radius:12px;padding:10px}
.cb-result .t{font-size:15px;margin-bottom:8px}
.cb-result .pegs{display:flex;gap:8px;justify-content:center}
.cb-lv{display:grid;gap:8px}
.cb-lv button{background:var(--panel2);border-radius:12px;padding:10px 12px;text-align:left;display:flex;flex-direction:column;gap:2px}
.cb-lv button b{font-size:17px}
.cb-lv button small{font-size:12px;color:var(--dim);font-weight:500}
.cb-lv button:active{background:var(--accent);color:#000}
.wide:disabled{opacity:.4}
.tile[data-game=codebreaker] .nm{font-size:16px;white-space:nowrap}

/* Gemdor: pennant nobles + gold-framed gem cards */
.gd-nobles{display:flex;flex-wrap:wrap;gap:4px;justify-content:center;flex:none}
.gd-nobles.pick{margin-bottom:8px;gap:8px}
.gd-noble{font-size:var(--nf,16px);width:7em;height:5.4em;flex:none;background:linear-gradient(180deg,#ffd75e,#e0a100);clip-path:polygon(0 0,100% 0,100% 100%,50% 84%,0 100%);display:flex;align-items:center;gap:.4em;padding:.5em .5em .9em .6em;box-sizing:border-box;color:#3b2a00;border-radius:0}
.gd-noble .lf{display:flex;flex-direction:column;align-items:center;gap:.05em}
.gd-noble .lf b{font-size:1.75em;line-height:1;font-weight:800;color:#3b2a00}
.gd-noble .lf svg{width:1.6em;height:1.6em}
.gd-noble .rt{display:flex;flex-direction:column;gap:.05em;margin-left:auto}
.gd-noble .rt span{display:flex;align-items:center;gap:.2em;font-size:.95em;font-weight:800;color:#3b2a00}
.gd-noble .rt svg{width:1.15em;height:1.15em}
.gd-card{position:relative;height:92px;border-radius:12px;overflow:hidden;border:2px solid #d4af37;background:linear-gradient(165deg,var(--c1),var(--c2));box-sizing:border-box;min-width:0;display:block;padding:0;text-align:left;color:#fff}
.gd-card::before{content:"";position:absolute;inset:0;background:radial-gradient(circle at 55% 52%,rgba(255,255,255,.28),transparent 62%)}
.gd-card.empty{background:transparent;border:2px dashed var(--line);display:flex;align-items:center;justify-content:center;color:var(--dim);font-size:10px}
.gd-card.empty::before{display:none}
.gd-card.can{box-shadow:0 0 0 3px var(--good)}
.gd-card:disabled{opacity:1}
.gd-card .df{position:absolute;left:8px;top:8px;width:25px;height:25px;transform:rotate(45deg);background:#d4af37;display:flex;align-items:center;justify-content:center;border-radius:3px}
.gd-card .df b{transform:rotate(-45deg);font-size:17px;font-weight:800;color:#1a1405;line-height:1}
.gd-card .gv{position:absolute;left:50%;top:34px;transform:translateX(-38%);filter:drop-shadow(0 3px 4px rgba(0,0,0,.45))}
.gd-card .cost{position:absolute;left:4px;right:4px;bottom:5px;display:flex;gap:2px;justify-content:center}
.gd-card .cost .gd-g{width:19px;height:19px;font-size:11px;border:2px solid rgba(255,255,255,.7)}
.gd-res .gd-card{height:76px}
.gd-res .gd-card .gv{left:auto;right:10px;top:8px;transform:none}
.gd-res .gd-card .cost{justify-content:flex-start;left:8px}

/* ---------- Yahtzee: phone order, then wide screen ---------- */
.ybx{display:none}
.yz-col.opu,.yz-col.opl{display:none}
.yz-top{display:contents}
#yz-top>.topbar{order:1}
#yz-board{order:2}
#yz-status{order:3}
#yz-goal{order:4}
#yz-dice{order:5}
#yz-card{order:6}
#yz-foot{order:7}
#yz-top>.bar2{order:8}
.yz-col .dt{display:none}
@media (min-width:900px){
  #screen-yahtzee{max-width:none;zoom:var(--zy,1);height:calc(100vh / var(--zy,1));height:calc(100dvh / var(--zy,1))}
  #screen-yahtzee.active{display:grid;grid-template-columns:240px 240px minmax(0,1fr);grid-template-rows:92px repeat(7,minmax(0,1fr)) auto;gap:10px;align-items:stretch}
  #yz-top{display:flex;grid-column:1/-1;grid-row:1;align-items:center;gap:12px;min-width:0}
  #yz-top>*,#yz-top>.topbar,#yz-top>.bar2{order:0}
  #yz-top>.topbar{flex:none;min-height:0}
  #yz-top .topbar .ttl,#yz-top .topbar .sp{display:none}
  #yz-top>.topbar{display:none}
  #yz-board:not([hidden]){display:flex;gap:10px;flex:0 1 auto;min-width:0;max-width:46%;height:76px}
  .yz-chip{flex:0 1 196px;width:196px;min-width:0;height:auto;display:flex;flex-direction:row;align-items:center;justify-content:center;gap:10px;padding:0 12px;border-width:3px;border-radius:16px}
  .yz-chip .nm,.yz-chip.one .nm{font-size:20px;padding:0;overflow:hidden;text-overflow:ellipsis;max-width:120px}
  .yz-chip .tt,.yz-chip.one .tt{font-size:36px;line-height:1}
  .yz-chip .turn{display:none}
  .yz-chip:has(.turn){background:var(--c);border-color:var(--c);box-shadow:0 0 0 4px var(--bg),0 0 0 7px var(--c)}
  .yz-chip:has(.turn) .nm,.yz-chip:has(.turn) .tt{color:#10131a}
  .yz-chip:has(.turn)::before{display:none}
  #yz-dice:not([hidden]){flex:1;display:flex;justify-content:center;align-items:center;gap:8px;background:none;padding:0;min-width:0}
  #yz-dice .die.sm{flex:0 1 74px;width:auto;height:auto;aspect-ratio:1;min-width:36px;padding:8px;border-width:3px}
  .yz-roll{min-height:74px;height:74px;width:auto;padding:0 16px;font-size:26px;border-radius:14px;flex:none;gap:2px}
  .yz-roll small{opacity:1;background:#fff;color:#c0182b;font-weight:800;font-size:19px;border-radius:9px;padding:0 9px;margin-top:2px}
  #yz-top>#yz-dice[hidden]{display:block!important;flex:1;visibility:hidden}
  #screen-yahtzee.active{position:relative}
  #yz-status{position:absolute;left:50%;top:52%;transform:translate(-50%,-50%);font-size:44px;display:flex;padding:0;min-height:0;white-space:nowrap;pointer-events:none}
  #yz-status span:last-child{display:none}
  #yz-top>.bar2{display:flex;gap:10px;flex:none}
  #yz-top>.bar2 button{height:52px;padding:0 18px;font-size:19px;white-space:nowrap}
  #yz-goal{grid-column:1/-1;grid-row:9;order:0}
  #yz-card.yz-card,.yz-col{display:contents}
  #yz-card.nogame{grid-column:1/-1;grid-row:2/-1;order:0}
  .yz-col:first-child>:nth-child(1){grid-column:1;grid-row:2}
  .yz-col:nth-child(2)>:nth-child(1){grid-column:2;grid-row:2}
  .yz-col:first-child>:nth-child(2){grid-column:1;grid-row:3}
  .yz-col:nth-child(2)>:nth-child(2){grid-column:2;grid-row:3}
  .yz-col:first-child>:nth-child(3){grid-column:1;grid-row:4}
  .yz-col:nth-child(2)>:nth-child(3){grid-column:2;grid-row:4}
  .yz-col:first-child>:nth-child(4){grid-column:1;grid-row:5}
  .yz-col:nth-child(2)>:nth-child(4){grid-column:2;grid-row:5}
  .yz-col:first-child>:nth-child(5){grid-column:1;grid-row:6}
  .yz-col:nth-child(2)>:nth-child(5){grid-column:2;grid-row:6}
  .yz-col:first-child>:nth-child(6){grid-column:1;grid-row:7}
  .yz-col:nth-child(2)>:nth-child(6){grid-column:2;grid-row:7}
  .yz-col:first-child>:nth-child(7){grid-column:1;grid-row:8}
  .yz-col:nth-child(2)>:nth-child(7){grid-column:2;grid-row:8}
  .yz-cell,.yz-cell.empty{flex-direction:column;justify-content:center;align-items:center;gap:2px;padding:0 8px;border-radius:14px;text-align:center;min-width:0;background:var(--panel);border:2px solid transparent;border-left:5px solid var(--pc,var(--line))}
  .yz-cell.pot.hit{border-color:var(--accent);border-left-color:var(--pc,var(--accent))}
  .yz-cell .lb{font-size:20px;color:var(--dim);font-weight:600;white-space:nowrap;overflow:visible;text-overflow:clip}
  .yz-cell .vl{font-size:40px;font-weight:800;line-height:1;min-width:0;min-height:40px;text-align:center;color:var(--ink)}
  .yz-cell.empty .vl{color:var(--ink);font-weight:800}
  .yz-cell.pot .vl{color:var(--dim)}
  .yz-cell.pot.hit .vl{color:var(--accent)}
  .yz-cell.zero .vl{color:var(--bad)}
  .yz-cell.max .vl{color:var(--good)}
  .yz-col .yz-bonus{padding:4px 14px;gap:2px;border-radius:14px;justify-content:center}
  .yz-col .yz-bonus{border-left:5px solid var(--pc,var(--line));align-items:center;text-align:center}
  .yz-col .yz-bonus .t{font-size:22px;white-space:nowrap;justify-content:center;gap:12px;color:var(--dim)}
  .yz-col .yz-bonus .t span:last-child{display:none}
  .yz-col .yz-bonus .bar{display:none}
  .yz-col .yz-bonus .s{font-size:30px;font-weight:800;line-height:1.05;white-space:nowrap;overflow:visible}
  .yz-col .yz-bonus .s small{display:none}
  .yz-col .yz-bonus:not(.got):not(.lost) .s{color:var(--accent)}
  .yz-col .yz-bonus.lost .s{font-size:24px}
  .yz-col .yz-bonus.lost .s small{display:none}
  #yz-foot{display:none}
  .yz-cell .dg{display:none}
  .yz-chip:not(:has(.turn)){background:linear-gradient(180deg,rgba(150,155,170,.16),rgba(150,155,170,.05)),var(--panel);border-color:transparent}
  .yz-chip.sel:not(:has(.turn)){border-color:var(--c)}
  .yz-chip:not(:has(.turn))::before{opacity:.3}
  .yz-chip:not(:has(.turn)) .nm,.yz-chip:not(:has(.turn)) .tt{color:var(--dim)}
  .yz-cell.yzsplit{display:grid;grid-template-columns:1fr 1fr;grid-template-rows:auto auto;grid-template-areas:"lb ybx" "vl ybx";align-content:center;padding:0}
  .yz-cell.yzsplit .lb{grid-area:lb;align-self:end;font-size:20px;padding-left:6px}
  .yz-cell.yzsplit .vl{grid-area:vl;align-self:start}
  .ybx{grid-area:ybx;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;border-left:2px solid var(--line);margin:10px 0}
  .ybl{font-size:15px;color:var(--dim);font-weight:600}
  .ybs{display:flex;align-items:center;gap:5px}
  .ybb{width:34px;height:34px;border-radius:9px;background:var(--panel2);display:flex;align-items:center;justify-content:center;font-size:22px;font-weight:700;line-height:1}
  .ybb.off{opacity:.3}
  .ybb.hot{background:var(--accent);color:#000}
  .ybb.jk{width:auto;padding:0 12px;height:38px;font-size:17px;font-weight:800}
  .ybn{min-width:22px;text-align:center;font-weight:800;font-size:24px}
}
@media (min-width:1250px){
  #screen-yahtzee.active.hasop{grid-template-columns:240px 240px minmax(0,1fr) 240px 240px}
  .yz-col.opu,.yz-col.opl{display:contents}
  .yz-col.opu>:nth-child(1){grid-column:4;grid-row:2}
  .yz-col.opl>:nth-child(1){grid-column:5;grid-row:2}
  .yz-col.opu>:nth-child(2){grid-column:4;grid-row:3}
  .yz-col.opl>:nth-child(2){grid-column:5;grid-row:3}
  .yz-col.opu>:nth-child(3){grid-column:4;grid-row:4}
  .yz-col.opl>:nth-child(3){grid-column:5;grid-row:4}
  .yz-col.opu>:nth-child(4){grid-column:4;grid-row:5}
  .yz-col.opl>:nth-child(4){grid-column:5;grid-row:5}
  .yz-col.opu>:nth-child(5){grid-column:4;grid-row:6}
  .yz-col.opl>:nth-child(5){grid-column:5;grid-row:6}
  .yz-col.opu>:nth-child(6){grid-column:4;grid-row:7}
  .yz-col.opl>:nth-child(6){grid-column:5;grid-row:7}
  .yz-col.opu>:nth-child(7){grid-column:4;grid-row:8}
  .yz-col.opl>:nth-child(7){grid-column:5;grid-row:8}
  .flip .yz-col:first-child>:nth-child(1){grid-column:4}
  .flip .yz-col:nth-child(2)>:nth-child(1){grid-column:5}
  .flip .yz-col.opu>:nth-child(1){grid-column:1}
  .flip .yz-col.opl>:nth-child(1){grid-column:2}
  .flip .yz-col:first-child>:nth-child(2){grid-column:4}
  .flip .yz-col:nth-child(2)>:nth-child(2){grid-column:5}
  .flip .yz-col.opu>:nth-child(2){grid-column:1}
  .flip .yz-col.opl>:nth-child(2){grid-column:2}
  .flip .yz-col:first-child>:nth-child(3){grid-column:4}
  .flip .yz-col:nth-child(2)>:nth-child(3){grid-column:5}
  .flip .yz-col.opu>:nth-child(3){grid-column:1}
  .flip .yz-col.opl>:nth-child(3){grid-column:2}
  .flip .yz-col:first-child>:nth-child(4){grid-column:4}
  .flip .yz-col:nth-child(2)>:nth-child(4){grid-column:5}
  .flip .yz-col.opu>:nth-child(4){grid-column:1}
  .flip .yz-col.opl>:nth-child(4){grid-column:2}
  .flip .yz-col:first-child>:nth-child(5){grid-column:4}
  .flip .yz-col:nth-child(2)>:nth-child(5){grid-column:5}
  .flip .yz-col.opu>:nth-child(5){grid-column:1}
  .flip .yz-col.opl>:nth-child(5){grid-column:2}
  .flip .yz-col:first-child>:nth-child(6){grid-column:4}
  .flip .yz-col:nth-child(2)>:nth-child(6){grid-column:5}
  .flip .yz-col.opu>:nth-child(6){grid-column:1}
  .flip .yz-col.opl>:nth-child(6){grid-column:2}
  .flip .yz-col:first-child>:nth-child(7){grid-column:4}
  .flip .yz-col:nth-child(2)>:nth-child(7){grid-column:5}
  .flip .yz-col.opu>:nth-child(7){grid-column:1}
  .flip .yz-col.opl>:nth-child(7){grid-column:2}
  .yz-cell.ro{pointer-events:none}
}
