/* Tokens + shared pieces. Portrait phone first; wide and tv layouts widen. Motion is transform/opacity only. */
:root{--bg:#1b1410;--wood:#3a2a1e;--wood-hi:#5a4130;--wood-lo:#26190f;--ink:#fdf6ec;--muted:#c9b8a6;--goal:#ffcf33;--gold:#ffcf33;--danger:#b3261e;--ok:#1f7a46;--tap:44px;--r:12px;
  --bgn-anim:200ms;--ui:Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--display:"EB Garamond",Georgia,serif;
  font-family:var(--ui);color:var(--ink);background:var(--bg)}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;-webkit-text-size-adjust:100%}
:root{--bar:0px}
html.fb-site{--bar:var(--fb-bar-h,37px)} /* site top bar (_back-to-games.js) is fixed and --fb-bar-h tall; 37px holds the slot before it mounts */
body{min-height:calc(100dvh - var(--bar));padding-top:var(--bar);background:var(--bg)}
button,input,select,textarea{font:inherit;color:inherit}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.muted{color:var(--muted)}
[hidden]{display:none!important}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:var(--tap);min-width:var(--tap);padding:0 14px;
  border:0;border-radius:var(--r);background:var(--wood-hi);color:var(--ink);font-weight:600;text-decoration:none;cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.btn:active{transform:scale(.97)}
.btn.big{min-height:56px;font-size:1.1rem;padding:0 18px}
.btn.primary{background:var(--gold);color:#2a1d00}
.btn.icon{padding:0;font-size:1.3rem;background:transparent}
.btn[aria-disabled="true"],.btn:disabled{opacity:.5;cursor:default}
.btn:focus-visible,.box:focus-visible,.info:focus-visible,.switch:focus-visible{outline:3px solid var(--gold);outline-offset:2px}
select.btn{padding-right:8px;background-color:var(--wood-hi)}
/* Top-left corner, in the 10 px gutter above every page's top row (no control lives there): never covers a button, tab or action bar */
.vtag{position:fixed;left:6px;top:var(--bar);font-size:10px;line-height:10px;opacity:.35;pointer-events:none;z-index:2147483000}

/* Segmented row, stepper, switch, field */
.seg{display:flex;flex-wrap:wrap;gap:6px}
.seg .btn[aria-checked="true"]{background:var(--gold);color:#2a1d00}
.stepper{display:inline-flex;align-items:center;gap:6px}
.stepper output{min-width:2.4em;text-align:center;font-weight:700;font-size:1.1rem}
.switch{position:relative;width:64px;height:var(--tap);border:0;border-radius:999px;background:transparent;padding:0;cursor:pointer}
.switch::before{content:"";position:absolute;left:0;top:7px;width:64px;height:30px;border-radius:999px;background:var(--wood-lo);border:2px solid var(--wood-hi)}
.switch i{position:absolute;left:4px;top:11px;width:22px;height:22px;border-radius:50%;background:var(--muted);transition:transform var(--bgn-anim) ease-out}
.switch[aria-checked="true"]::before{background:var(--ok);border-color:var(--ok)}
.switch[aria-checked="true"] i{transform:translateX(34px);background:#fff}
.field{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px 12px;padding:8px 0;border-top:1px solid rgba(255,255,255,.08)}
.field.col{flex-direction:column;align-items:stretch}
.field .lbl{display:inline-flex;align-items:center;gap:2px;font-weight:600}
.field input,.field textarea{width:100%;min-height:var(--tap);padding:8px 12px;border-radius:var(--r);border:0;background:#fff;color:#1b1410}
.logbox{justify-content:flex-start}

/* ⓘ tap-for-detail: 44 px hit area, small visible disc */
.info{display:inline-flex;align-items:center;justify-content:center;width:var(--tap);height:var(--tap);padding:0;border:0;background:transparent;cursor:pointer;flex:none}
.info span{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;background:rgba(255,255,255,.16);font:italic 700 14px/1 Georgia,serif;color:var(--ink)}
.tip{position:fixed;z-index:2147483100;max-width:min(300px,calc(100vw - 16px));padding:10px 12px;border-radius:var(--r);background:#fff;color:#1b1410;box-shadow:0 6px 18px rgba(0,0,0,.45)}
.tip p{margin:0 0 6px;font-size:1rem;line-height:1.35}
.tip .btn{min-height:var(--tap);width:100%;background:#1b1410;color:#fff}

/* Sheets (native dialog): bottom sheet on phones, centred card on wide */
dialog{border:0;padding:0;color:var(--ink);background:transparent;max-width:none;max-height:none}
dialog::backdrop{background:rgba(0,0,0,.65)}
dialog.sheet{width:100%;max-width:560px;margin:auto auto 0;padding:14px 16px calc(16px + env(safe-area-inset-bottom));background:var(--wood);border-radius:20px 20px 0 0;max-height:92dvh;overflow:auto;animation:sheet-in var(--bgn-anim) ease-out}
@keyframes sheet-in{from{transform:translateY(24px);opacity:0}}
@media (min-width:700px){dialog.sheet{margin:auto;border-radius:20px}}
.sheet-head{display:flex;align-items:center;justify-content:space-between;gap:8px}
.sheet-head h2{margin:0;font-family:var(--display);font-size:1.6rem}
/* Sheet body copy is never smaller than 16 px */
.sheet .facts{font-size:1rem}.gcard{font-size:1rem}.gcard b{font-size:1.05rem}
.sheet .goal{margin:6px 0 10px;text-align:left}
.row{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0}
.row .btn{flex:1}

/* Goal line: coloured, with a slow transform pulse */
.goal{margin:6px 12px 0;text-align:center;color:var(--goal);font-weight:800;letter-spacing:.01em;animation:goal-pulse 2.6s ease-in-out infinite alternate}
/* Opacity only: a scale transform grows the scrollable width by a few px on wide screens */
@keyframes goal-pulse{from{opacity:1}to{opacity:.72}}

/* Designed empty / loading / error states */
.state{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;margin:auto;padding:32px 20px;text-align:center;color:var(--muted);min-height:40dvh}
.state h2{margin:0;color:var(--ink);font-family:var(--display);font-size:1.7rem}
.state p{margin:0;max-width:30ch;white-space:pre-line}
.state-icon{font-size:3rem}
.state-icon.spin{animation:spin 1.6s ease-in-out infinite alternate}
@keyframes spin{to{transform:rotate(25deg) scale(1.1)}}
.state .row{justify-content:center}

/* Zoom + rules + gallery */
.zoomer{position:fixed;inset:var(--bar) 0 0 0;z-index:2147483050;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;background:rgba(10,6,4,.92);padding:20px}
.zoom-card{transform:scale(1.8);transform-origin:center;max-width:70vw}
.zoomer .btn{position:absolute;bottom:calc(24px + env(safe-area-inset-bottom))}
.facts{list-style:none;margin:6px 0;padding:0;display:flex;flex-wrap:wrap;gap:6px 14px;color:var(--muted)}
.steps{padding-left:22px;line-height:1.5}
.rules h3{margin:12px 0 4px}.rules h4{margin:8px 0 4px;color:var(--muted)}
.gallery{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}
.gcard{position:relative;display:flex;flex-direction:column;gap:4px;min-height:84px;padding:8px;border-radius:8px;background:var(--tint,var(--wood-lo));border:1px solid rgba(255,255,255,.15);cursor:zoom-in}.gbadge{align-self:flex-end;font-weight:800;color:var(--gold)}.gbadge:empty{display:none}

.tabs{display:flex;flex-wrap:wrap;gap:6px;margin:10px 0}
.tab[aria-selected="true"]{background:var(--gold);color:#2a1d00}
.tab small{opacity:.8;font-weight:500}

@media (prefers-reduced-motion:reduce){:root{--bgn-anim:0ms}.goal,.state-icon.spin{animation:none}dialog.sheet{animation:none}}

/* Solo daily board (the site's shared .dcl-* rows, themed for the wood UI) */
.dboard{--ink-soft:var(--muted);--crimson:#ff8a80;--line:rgba(255,255,255,.12);align-self:stretch;width:100%;text-align:left;font-size:.95rem}
.dboard .dcl-list{max-height:34dvh;overflow:auto}
.dboard .dcl-av{width:24px;height:24px;border-radius:50%;flex:none}
.dboard .dcl-you{margin:6px 0 0;font-weight:700;color:var(--gold)}
.dboard .fb-savescore-cta{display:block;margin:6px 0;padding:10px 12px;border-radius:var(--r);background:var(--wood-lo);color:var(--ink);text-align:center;text-decoration:none}
.results-extra{align-self:stretch;width:100%;margin:4px 0}
.results-extra .rank-line{margin:0 0 6px;text-align:center;font-weight:700}
.results-extra .rank-now{color:var(--gold)}
.solo-modes{display:flex;flex-direction:column;gap:8px}
dialog.dboard-sheet{max-width:min(520px,94vw)}
