*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
/* Honor the OS "reduce motion" setting — neutralize tile slides, confetti, sparks, transitions. */
@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{
    animation-duration:.001ms!important;animation-iteration-count:1!important;
    transition-duration:.001ms!important;scroll-behavior:auto!important
  }
}
:root{
  --bg:#e6e2ea;
  --surface:#faf9f7;
  --card:#ffffff;
  --border:#e2ddd8;
  --border2:#ccc8c2;
  --text:#1a1816;
  --muted:#8a847c;
  --muted2:#b5b0aa;
  --ts:100px;
  --gap:9px;
  /* Netflix home palette */
  --nf-red:#e50914;
  --nf-dark:#141414;
}
body{background:var(--nf-dark);color:var(--text);font-family:'Inter',system-ui,sans-serif;min-height:100vh;display:flex;flex-direction:column;align-items:center;overflow-x:hidden;scrollbar-gutter:stable;overscroll-behavior:none}

/* ── GAME ── */
#game{display:none;flex-direction:column;align-items:center;justify-content:center;padding:.9rem 1rem 1rem;width:100%;height:100dvh;max-width:calc(4 * var(--ts) + 5 * var(--gap) + 2rem);position:relative;z-index:10;overflow:hidden;touch-action:none}
.ghdr{width:100%;display:flex;flex-direction:row;align-items:center;justify-content:space-between;margin-bottom:.7rem}
/* F1BONACCI title — top of game view */
.ghdr-brand{flex:1;line-height:1;text-align:center}
.game-title{font-size:2.4rem;font-weight:900;letter-spacing:-.04em;color:#e50914;display:block;line-height:1}
.page-header{position:sticky;top:0;z-index:50;width:100%;display:flex;align-items:center;padding:.7rem 1.25rem;background:rgba(10,0,0,.9);border-bottom:1px solid rgba(255,255,255,.08);backdrop-filter:blur(10px)}
.page-title{font-size:2rem;font-weight:900;letter-spacing:-.04em;color:#e50914}
@media(max-width:480px){.game-title{font-size:2rem}}
/* meta + timer row — theme name/tagline left, timer right */
.gmeta-timer-row{width:100%;max-width:calc(4 * var(--ts) + 5 * var(--gap));display:flex;flex-direction:row;align-items:center;justify-content:space-between;margin-top:.55rem;gap:.5rem}
.gmeta-below{display:flex;flex-direction:column;align-items:flex-start;gap:.15rem;text-align:left;min-width:0}
.gtheme{font-size:1.05rem;font-weight:800;letter-spacing:-.02em;line-height:1.15;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.gtagline-below{font-size:.68rem;color:var(--muted);font-weight:400;min-height:1.1em;line-height:1.4}
/* timer — right side of meta row */
.game-timer-below{flex-shrink:0;display:flex;align-items:center}
.sval{font-size:1.1rem;font-weight:700;color:#fff;letter-spacing:.04em;font-variant-numeric:tabular-nums;text-shadow:0 1px 6px rgba(0,0,0,.4)}
/* three centered icons below the meta row */
.game-actions{width:100%;max-width:calc(4 * var(--ts) + 5 * var(--gap));display:flex;justify-content:center;align-items:center;gap:1.6rem;margin-top:1.1rem}
.gaction-icon{width:42px;height:42px;border-radius:50%;background:rgba(255,255,255,.06);border:1.5px solid rgba(255,255,255,.14);display:flex;align-items:center;justify-content:center;color:rgba(255,255,255,.78);cursor:pointer;text-decoration:none;padding:0;transition:background .18s,border-color .18s,color .18s,transform .15s}
.gaction-icon:hover{background:rgba(255,255,255,.1);border-color:rgba(255,255,255,.34);color:#fff;transform:translateY(-1px)}
.gaction-icon:active{transform:translateY(0)}
.gaction-icon svg{width:18px;height:18px;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;fill:none}
/* legacy utility classes kept for other pages */
.srow{display:flex;gap:.4rem}
.gibtn{width:34px;height:34px;border-radius:50%;background:var(--text);border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:opacity .18s,transform .15s;box-shadow:0 1px 4px rgba(0,0,0,.22)}
.gibtn:hover{opacity:.82;transform:scale(1.06)}
.gibtn:active{transform:scale(.95)}
.gibtn svg{width:15px;height:15px;fill:none;stroke:var(--surface);stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
.cbtn{font-size:.55rem;font-weight:600;letter-spacing:.05em;text-transform:uppercase;padding:.35rem .75rem;background:var(--card);color:var(--muted);border:1.5px solid var(--border);border-radius:8px;cursor:pointer;transition:all .2s;white-space:nowrap;display:flex;align-items:center;justify-content:center;min-width:0}
.cbtn:hover{color:var(--text);border-color:var(--border2);background:var(--surface)}

/* ── BOARD ── */
#bwrap{position:relative;width:calc(4 * var(--ts) + 5 * var(--gap));height:calc(4 * var(--ts) + 5 * var(--gap));border-radius:14px;padding:var(--gap);touch-action:none;user-select:none}
.bbg{position:absolute;inset:0;border-radius:14px;display:grid;grid-template-columns:repeat(4,var(--ts));grid-template-rows:repeat(4,var(--ts));gap:var(--gap);padding:var(--gap);background:#e4e0da;border:1.5px solid var(--border2)}
.cbg{border-radius:9px;background:#d8d4ce}
#tlayer{position:absolute;inset:0;pointer-events:none}

/* ── TILES ── */
.tile{position:absolute;left:0;top:0;width:var(--ts);height:var(--ts);border-radius:10px;overflow:hidden;will-change:transform;display:flex;flex-direction:column;box-shadow:0 1px 2px rgba(0,0,0,.08),0 2px 6px rgba(0,0,0,.10),0 0 0 1px rgba(255,255,255,.35) inset,0 -1px 0 rgba(0,0,0,.06) inset;transition:transform 240ms cubic-bezier(.22,1,.36,1)}
.tile::before{content:"";position:absolute;inset:0;pointer-events:none;border-radius:inherit;background:linear-gradient(180deg,rgba(255,255,255,.22) 0%,rgba(255,255,255,.06) 32%,rgba(0,0,0,0) 55%,rgba(0,0,0,.04) 100%);mix-blend-mode:soft-light;z-index:2}
.tile>*{position:relative;z-index:1}
.tile svg{width:100%;flex:1;display:block;min-height:0;overflow:visible;filter:drop-shadow(0 .6px 0 rgba(0,0,0,.12)) drop-shadow(0 1px 1.5px rgba(0,0,0,.08))}
.tile svg *{stroke-linejoin:round;vector-effect:non-scaling-stroke}
.tlabel{font-family:'Inter',sans-serif;font-size:.48rem;font-weight:700;letter-spacing:.01em;text-align:center;padding:3px 3px 4px;flex-shrink:0;line-height:1.3;display:flex;flex-direction:column;gap:0px;position:relative}
.tlabel::before{content:"";position:absolute;left:6%;right:6%;top:0;height:1px;background:linear-gradient(90deg,transparent,rgba(255,255,255,.55),transparent);pointer-events:none}
.tl-name{font-size:.5rem;font-weight:800;letter-spacing:-.01em;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.tl-stat{font-size:.42rem;font-weight:500;opacity:0.72;letter-spacing:.02em;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.tile.tnew{animation:popIn .2s cubic-bezier(.34,1.56,.64,1) forwards}
.tile.tmerge{animation:mergeAnim .28s cubic-bezier(.34,1.56,.64,1) forwards}

@keyframes popIn{0%{transform:var(--pos) scale(0);opacity:0}100%{transform:var(--pos) scale(1);opacity:1}}
@keyframes mergeAnim{0%{transform:var(--pos) scale(1)}35%{transform:var(--pos) scale(1.22)}100%{transform:var(--pos) scale(1)}}


/* ── SPARKS ── */
.spark{position:absolute;border-radius:50%;animation:sparkFly var(--dur,.5s) ease-out forwards;pointer-events:none;z-index:30}
@keyframes sparkFly{0%{transform:translate(0,0) scale(1);opacity:1}100%{transform:translate(var(--tx),var(--ty)) scale(0);opacity:0}}

/* ── OVERLAY ── */
#overlay{display:none;width:100%;flex-direction:column;align-items:center;justify-content:center;gap:.35rem;padding:.6rem .5rem .5rem;text-align:center}
#overlay.show{display:flex}
#end-actions{display:none;width:100%;max-width:calc(4 * var(--ts) + 5 * var(--gap));gap:.6rem;padding:.5rem 0 .2rem}
.otitle{font-size:1.9rem;font-weight:900;letter-spacing:-.03em;text-align:center;padding:0 .5rem;line-height:1.1}
.omsg{color:var(--muted);font-size:.82rem;font-weight:400;text-align:center;padding:0 .5rem;line-height:1.5}
.otime{font-size:2.2rem;font-weight:800;letter-spacing:.06em;font-variant-numeric:tabular-nums;padding:.5rem 1.4rem;border-radius:14px;margin:.1rem 0}
.otime-lbl{font-size:.58rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;opacity:0.6;margin-top:-.3rem}
.obtn{flex:1;font-size:.78rem;font-weight:700;letter-spacing:.04em;text-transform:uppercase;padding:.85rem 1rem;background:var(--text);color:var(--surface);border:none;border-radius:12px;cursor:pointer;transition:all .2s}
.obtn:hover{opacity:.88}
.obtn.sec{background:transparent;color:var(--muted);border:1.5px solid var(--border2)}
.obtn-share{display:flex;align-items:center;justify-content:center;gap:.45rem;background:#e50914;color:#fff}
.obtn-share:hover{opacity:.92;background:#e50914}
.obtn-share svg{width:14px;height:14px;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;fill:none;flex-shrink:0}

/* ── SHARE FALLBACK MODAL ── */
#share-modal-backdrop{display:none;position:fixed;inset:0;background:rgba(0,0,0,.72);z-index:1000;backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}
#share-modal-backdrop.show{display:block}
#share-modal{display:none;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);z-index:1001;width:min(92vw,420px);max-height:92vh;overflow-y:auto;background:#1a0203;border:1.5px solid rgba(255,255,255,.12);border-radius:18px;box-shadow:0 24px 60px rgba(0,0,0,.6);padding:1.1rem}
#share-modal.show{display:flex;flex-direction:column;gap:.9rem}
#share-modal .smodal-title{font-size:.95rem;font-weight:800;letter-spacing:-.01em;color:#fff;text-align:center}
#share-modal .smodal-text{font-size:.78rem;line-height:1.5;color:rgba(255,255,255,.85);background:rgba(255,255,255,.04);border:1px solid rgba(255,255,255,.08);border-radius:10px;padding:.7rem .8rem;white-space:pre-wrap;word-break:break-word;font-family:inherit}
#share-modal .smodal-actions{display:grid;grid-template-columns:1fr 1fr;gap:.5rem}
#share-modal .smodal-actions .obtn{grid-column:1 / -1;min-width:0}
/* One-tap social targets — device-appropriate fallback when there's no native sheet. */
.sshare-btn{font-size:.75rem;font-weight:700;letter-spacing:.02em;padding:.72rem .5rem;border-radius:10px;background:rgba(255,255,255,.08);color:#fff;border:1.5px solid rgba(255,255,255,.16);cursor:pointer;font-family:inherit;transition:background .15s,border-color .15s}
.sshare-btn:hover{background:rgba(255,255,255,.14);border-color:rgba(255,255,255,.32)}
.sshare-btn.sshare-copy{grid-column:1 / -1;background:#fff;color:#1a0203;border-color:#fff}
.sshare-btn.sshare-copy:hover{opacity:.9;background:#fff}
#share-modal .smodal-close{position:absolute;top:.55rem;right:.55rem;width:30px;height:30px;border-radius:8px;background:none;border:none;color:rgba(255,255,255,.7);cursor:pointer;display:flex;align-items:center;justify-content:center}
#share-modal .smodal-close:hover{background:rgba(255,255,255,.08);color:#fff}
#share-modal .smodal-close svg{width:14px;height:14px;stroke:currentColor;stroke-width:2;stroke-linecap:round;fill:none}
#share-toast{position:fixed;bottom:1.5rem;left:50%;transform:translateX(-50%);background:#0a0a0a;color:#fff;font-size:.78rem;font-weight:600;padding:.6rem 1rem;border-radius:10px;z-index:1100;box-shadow:0 6px 24px rgba(0,0,0,.5);opacity:0;pointer-events:none;transition:opacity .2s}
#share-toast.show{opacity:1}
/* confetti piece */
.confetti{position:absolute;width:8px;height:8px;border-radius:2px;animation:confettiFall var(--cf-dur,1.2s) ease-in var(--cf-delay,0s) forwards;pointer-events:none;z-index:25}
@keyframes confettiFall{
  0%{transform:translate(var(--cf-x),calc(var(--cf-starty))) rotate(0deg);opacity:1}
  100%{transform:translate(calc(var(--cf-x) + var(--cf-dx)),-20px) rotate(var(--cf-rot));opacity:0}
}

/* ── PROGRESS BAR ── */
#gprog-wrap{width:100%;max-width:calc(4 * var(--ts) + 5 * var(--gap));margin-bottom:.7rem}
.gprog-row{display:flex;align-items:center;gap:.5rem}
.gprog-pips{display:flex;gap:3px;flex:1}
.gprog-pip{flex:1;height:5px;border-radius:99px;background:var(--border);transition:background .25s cubic-bezier(.34,1.4,.64,1),transform .2s}
.gprog-pip.lit{transform:scaleY(1.4)}
.gprog-label{font-size:.5rem;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--muted2);white-space:nowrap;min-width:28px;text-align:right;font-variant-numeric:tabular-nums}


/* ── INSIGHT PANEL ── */
#insight-wrap{position:fixed;bottom:0;left:0;right:0;z-index:50;display:flex;justify-content:center;padding:0 1rem calc(.6rem + env(safe-area-inset-bottom));pointer-events:none}
#insight-box{display:none;position:relative;border-radius:10px;border:1.5px solid var(--border);background:var(--card);padding:.6rem .75rem .6rem .9rem;box-shadow:0 2px 12px rgba(0,0,0,.12);animation:insightIn .35s cubic-bezier(.25,1.4,.5,1) forwards;pointer-events:all;width:100%;max-width:calc(4 * var(--ts) + 5 * var(--gap))}
#insight-box.show{display:block}
@keyframes insightIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}
@keyframes insightSparkPop{0%{transform:scale(0) translate(var(--ix),var(--iy));opacity:1}70%{opacity:1}100%{transform:scale(1) translate(var(--ix),var(--iy));opacity:0}}
.insight-spark{position:absolute;pointer-events:none;border-radius:50%;animation:insightSparkPop var(--idur,0.5s) ease-out forwards;z-index:10}
.insight-accent-bar{position:absolute;left:0;top:0;bottom:0;width:3px;border-radius:10px 0 0 10px}
.insight-top{display:flex;align-items:center;justify-content:space-between;margin-bottom:.3rem}
.insight-label{font-size:.52rem;font-weight:700;letter-spacing:.1em;text-transform:uppercase}
.insight-name{font-size:.58rem;font-weight:600;color:var(--muted);letter-spacing:-.01em}
.insight-close{width:16px;height:16px;border-radius:50%;border:1px solid var(--border2);background:var(--surface);display:flex;align-items:center;justify-content:center;cursor:pointer;flex-shrink:0;transition:background .15s}
.insight-close:hover{background:var(--border)}
.insight-close svg{pointer-events:none}
.insight-text{font-size:.65rem;line-height:1.6;color:var(--muted);font-weight:400}
.legend{margin-top:.75rem;display:flex;gap:.3rem;flex-wrap:wrap;justify-content:center;max-width:calc(4 * var(--ts) + 5 * var(--gap))}
.li{font-size:.58rem;color:var(--muted);font-weight:500;letter-spacing:.02em;display:flex;align-items:center;gap:3px}
.lido{width:8px;height:8px;border-radius:2px;flex-shrink:0}

/* ── GLOBAL FOOTER (always visible) ── */
#site-footer{position:fixed;bottom:0;left:0;right:0;z-index:200;display:flex;gap:1.2rem;justify-content:center;align-items:center;padding:.75rem 1.5rem;background:rgba(10,0,0,.85);border-top:1px solid rgba(255,255,255,.08);backdrop-filter:blur(8px)}
#site-footer a{font-size:.65rem;font-weight:500;color:rgba(255,255,255,.38);text-decoration:none;letter-spacing:-.01em;transition:color .15s}
#site-footer a:hover{color:rgba(255,255,255,.7)}
#site-footer span{font-size:.5rem;color:rgba(255,255,255,.2);opacity:.6}

/* ── SCORECARD ── */
.sc-hero{display:flex;width:100%;margin-bottom:1.6rem}
.sc-metric{flex:1;background:var(--card);border:1.5px solid var(--border);border-radius:14px;padding:.85rem 1.1rem;display:flex;flex-direction:column;gap:.5rem;box-shadow:0 1px 4px rgba(0,0,0,.05)}
.sc-metric-row{display:flex;align-items:center;justify-content:space-between;gap:.75rem}
.sc-metric-stats{display:flex;align-items:baseline;gap:.5rem;min-width:0}
.sc-metric-label{font-size:.58rem;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted2)}
.sc-metric-value{font-size:1.6rem;font-weight:800;letter-spacing:-.03em;color:var(--text);line-height:1}
.sc-metric-sub{font-size:.72rem;color:var(--muted);font-weight:400}
.sc-leaderboard-link{font-size:.62rem;font-weight:600;letter-spacing:.07em;text-transform:uppercase;color:var(--muted);text-decoration:none;display:inline-flex;align-items:center;gap:.35rem;white-space:nowrap;transition:color .15s}
.sc-leaderboard-link:hover{color:var(--text)}
.sc-leaderboard-link span{transition:transform .15s}
.sc-leaderboard-link:hover span{transform:translateX(2px)}
.sc-progress-track{width:100%;height:5px;background:var(--border);border-radius:99px;overflow:hidden}
.sc-progress-fill{height:100%;border-radius:99px;background:linear-gradient(90deg,#2563eb,#059669);transition:width .6s cubic-bezier(.34,1.2,.64,1)}
.sc-list{display:flex;flex-direction:column;gap:.4rem;width:100%}
.sc-list-header{display:grid;grid-template-columns:1fr auto auto;gap:.5rem;padding:0 .5rem .3rem;border-bottom:1px solid var(--border);margin-bottom:.1rem}
.sc-list-hcell{font-size:.55rem;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted2);text-align:right}
.sc-list-hcell:first-child{text-align:left}
.sc-row{display:grid;grid-template-columns:1fr auto auto;gap:.85rem;align-items:center;background:var(--card);border:1.5px solid var(--border);border-radius:14px;padding:.75rem 1.1rem;transition:border-color .15s}
.sc-row.played{border-color:var(--border2)}
.sc-row.completed{border-left:3px solid #059669}
.sc-theme-info{display:flex;align-items:center;gap:.7rem;min-width:0}
.sc-icon{font-size:22px;line-height:1;flex-shrink:0;width:34px;height:34px;border-radius:8px;display:flex;align-items:center;justify-content:center}
.sc-name{font-size:1.12rem;font-weight:700;letter-spacing:-.01em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;min-width:0}
.sc-tile-col{text-align:right;min-width:64px;display:flex;align-items:baseline;justify-content:flex-end;gap:2px}
.sc-tile-val{font-size:1.2rem;font-weight:700;color:var(--text);font-variant-numeric:tabular-nums;line-height:1}
.sc-tile-val.completed{color:#059669}
.sc-tile-denom{font-size:.94rem;color:var(--muted2);font-weight:500;line-height:1}
.sc-time-col{text-align:right;min-width:70px;display:flex;flex-direction:column;align-items:flex-end;justify-content:center}
.sc-time-val{font-size:1.15rem;font-weight:700;color:var(--text);font-variant-numeric:tabular-nums;line-height:1.1}
.sc-time-none{font-size:1.05rem;color:var(--muted2);font-weight:400}
.sc-time-partial{font-size:1.05rem;font-weight:600;color:var(--muted);font-variant-numeric:tabular-nums;display:block;line-height:1.2}
.sc-time-partial-label{font-size:.82rem;font-weight:400;color:var(--muted2);display:block;line-height:1.2;margin-top:1px}
.sc-empty{text-align:center;padding:2.5rem 1rem;color:var(--muted);font-size:.85rem;line-height:1.7}
.sc-cat-divider{font-size:.78rem;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted2);margin:1.2rem 0 .45rem .2rem}
.sc-act-btn{width:30px;height:30px;border-radius:8px;border:1.5px solid var(--border2);background:var(--surface);display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .15s;flex-shrink:0;padding:0;position:relative}
.sc-act-btn:hover{background:var(--card);border-color:var(--muted);box-shadow:0 1px 4px rgba(0,0,0,.1)}
.sc-act-btn svg{width:13px;height:13px;fill:var(--muted);flex-shrink:0}
.sc-act-btn.has-save{border-color:rgba(217,119,6,.55)}
.sc-act-btn.has-save::after{content:'';position:absolute;top:-3px;right:-3px;width:8px;height:8px;border-radius:50%;background:#d97706;border:2px solid var(--surface)}

/* popover for New Game / Resume when a saved game exists */
.sc-popover{position:fixed;z-index:200;background:var(--surface);border:1.5px solid var(--border2);border-radius:10px;padding:.35rem;display:flex;flex-direction:column;gap:2px;box-shadow:0 8px 28px rgba(0,0,0,.45);animation:sc-pop-in .14s cubic-bezier(.34,1.3,.64,1);min-width:130px}
.sc-popover-opt{background:transparent;border:none;color:var(--text);font-size:.88rem;font-weight:600;letter-spacing:-.005em;padding:.55rem .85rem;border-radius:6px;cursor:pointer;text-align:left;transition:background .12s;font-family:inherit;white-space:nowrap}
.sc-popover-opt:hover{background:var(--card)}
.sc-popover-opt.resume{color:#d97706}
@keyframes sc-pop-in{from{opacity:0;transform:translateY(-4px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}

@media(max-width:480px){:root{--ts:74px;--gap:7px}
.sc-metric-value{font-size:1.4rem}
.sc-name{font-size:.8rem}
.sc-act-btn{margin-left:.35rem}
.sc-tile-col{min-width:42px;margin-left:.25rem}
.sc-tile-val{font-size:.85rem;white-space:nowrap}
.sc-tile-denom{font-size:.68rem}
.sc-time-col{min-width:50px}
.sc-time-val{font-size:.82rem;white-space:nowrap}
.sc-time-none{font-size:.78rem}
.sc-time-partial{font-size:.78rem;white-space:nowrap}
.sc-time-partial-label{font-size:.6rem}}

/* ── RESTART CONFIRMATION MODAL ── */
#restart-modal-backdrop{display:none;position:fixed;inset:0;z-index:400;background:rgba(0,0,0,.55);backdrop-filter:blur(2px)}
#restart-modal-backdrop.show{display:block}
#restart-modal{display:none;position:fixed;left:50%;top:50%;transform:translate(-50%,-50%) scale(.94);z-index:401;background:var(--card);border:1.5px solid var(--border);border-radius:20px;padding:1.5rem 1.25rem 1.25rem;width:min(340px,90vw);box-shadow:0 8px 32px rgba(0,0,0,.18);text-align:center}
#restart-modal.show{display:block;animation:rmodalIn .22s cubic-bezier(.34,1.4,.64,1) forwards}
@keyframes rmodalIn{from{opacity:0;transform:translate(-50%,-50%) scale(.9)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}
.rmodal-title{font-size:1.3rem;font-weight:900;letter-spacing:-.03em;margin-bottom:.55rem}
.rmodal-msg{color:var(--muted);font-size:.82rem;line-height:1.55;margin-bottom:1.15rem}
.rmodal-actions{display:flex;flex-direction:column;gap:.5rem}
.rmodal-or{display:flex;align-items:center;gap:.6rem;margin:.35rem 0;color:var(--muted);font-size:.75rem;font-weight:600;letter-spacing:.05em}.rmodal-or::before,.rmodal-or::after{content:'';flex:1;height:1px;background:var(--border2)}.rmodal-or span{white-space:nowrap}
/* ── UNDO POWER-UP MODAL (confirm + always-visible earning logic) ── */
#undo-modal-backdrop{display:none;position:fixed;inset:0;z-index:402;background:rgba(0,0,0,.55);backdrop-filter:blur(2px)}
#undo-modal-backdrop.show{display:block}
#undo-modal{display:none;position:fixed;left:50%;top:50%;transform:translate(-50%,-50%) scale(.94);z-index:403;background:var(--card);border:1.5px solid var(--border);border-radius:20px;padding:1.6rem 1.25rem 1.25rem;width:min(360px,90vw);box-shadow:0 8px 32px rgba(0,0,0,.18);text-align:center}
#undo-modal.show{display:block;animation:rmodalIn .22s cubic-bezier(.34,1.4,.64,1) forwards}
#undo-modal .umodal-close{position:absolute;top:.6rem;right:.6rem;width:28px;height:28px;border-radius:8px;background:none;border:none;color:var(--muted);cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;transition:background .15s,color .15s}
#undo-modal .umodal-close:hover{background:var(--surface);color:var(--text)}
#undo-modal .umodal-close svg{width:14px;height:14px;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;fill:none}
.umodal-intro{color:var(--muted);font-size:.8rem;line-height:1.55;margin:.15rem 0 .9rem;text-align:center}
/* Big, uniform allowance readout — no alarm colours, matches the Replay modal. */
.umodal-count{display:flex;align-items:baseline;justify-content:center;gap:.4rem;font-size:.78rem;font-weight:600;color:var(--muted);margin:.1rem 0 .7rem}
.umodal-count .umodal-count-num{font-size:1.7rem;font-weight:900;letter-spacing:-.03em;color:var(--text);line-height:1}
.undo-earn-list{list-style:none;margin:0 0 1.15rem;padding:0;text-align:left}
.undo-earn-list li{display:flex;align-items:center;gap:.6rem;font-size:.78rem;line-height:1.4;color:var(--text);padding:.55rem .7rem;border:1.5px solid var(--border2);border-radius:10px;background:var(--surface)}
.undo-earn-list li + li{margin-top:.4rem}
.undo-earn-list .ue-text{flex:1;min-width:0}
.undo-earn-list .ue-text small{display:block;font-size:.66rem;color:var(--muted);font-weight:500;margin-top:1px}
.undo-earn-list .ue-plus{margin-left:auto;flex-shrink:0;font-weight:800;font-size:.7rem;letter-spacing:0;color:var(--text);background:var(--card);border:1.5px solid var(--border2);border-radius:999px;padding:.14rem .5rem;font-variant-numeric:tabular-nums}
/* Claimable rewards read as clear actions; the CTA matches the primary button. */
.undo-earn-list li.ue-claim{border-color:var(--border);background:var(--card)}
.undo-earn-list .ue-cta{margin-left:auto;flex-shrink:0;display:inline-flex;align-items:center;gap:.32rem;font-family:inherit;font-size:.66rem;font-weight:800;letter-spacing:.04em;text-transform:uppercase;color:var(--surface);background:var(--text);border:none;border-radius:8px;padding:.42rem .6rem;cursor:pointer;transition:opacity .15s}
.undo-earn-list .ue-cta:hover{opacity:.85}
.undo-earn-list .ue-cta b{font-weight:800}
/* Earned rewards grey out in place. */
.undo-earn-list li.ue-done{color:var(--muted);background:var(--surface);border-color:var(--border2);opacity:.72}
.undo-earn-list .ue-check{margin-left:auto;flex-shrink:0;font-size:.66rem;font-weight:700;color:var(--muted);white-space:nowrap}
/* ── POWER-UPS (restart modal) ── */
.rmodal-section-header{font-size:.56rem;font-weight:800;letter-spacing:.14em;text-transform:uppercase;color:var(--muted);text-align:center;margin-bottom:.15rem}
.obtn-undo{display:flex;align-items:center;justify-content:center;gap:.6rem;background:#0a0a0a;color:#fff;border:1.5px solid #0a0a0a;position:relative;transition:opacity .18s,background .18s,transform .15s,box-shadow .18s}
.obtn-undo:hover{background:#1a1a1a;opacity:1}
.obtn-undo .undo-label{flex:0 1 auto}
.undo-badge{display:inline-flex;align-items:center;justify-content:center;min-width:22px;height:22px;padding:0 7px;border-radius:999px;background:#e50914;color:#fff;font-size:.7rem;font-weight:800;letter-spacing:0;line-height:1;font-variant-numeric:tabular-nums;box-shadow:0 0 0 2px rgba(255,255,255,.18),0 1px 4px rgba(229,9,20,.45);flex-shrink:0}
.obtn-undo.disabled{background:#2a2a2a;border-color:#2a2a2a;color:rgba(255,255,255,.55);cursor:not-allowed;opacity:.85}
.obtn-undo.disabled:hover{background:#2a2a2a;transform:none}
.obtn-undo.disabled .undo-badge{background:#4a4a4a;box-shadow:0 0 0 2px rgba(255,255,255,.06);color:rgba(255,255,255,.7)}
.undo-tooltip{display:none;position:relative;margin:-.15rem 0 .1rem;padding:.6rem .8rem;background:#1a0203;color:rgba(255,255,255,.88);border:1px solid rgba(255,255,255,.12);border-radius:10px;font-size:.66rem;line-height:1.55;text-align:left;box-shadow:0 8px 24px rgba(0,0,0,.5)}
.undo-tooltip.show{display:block;animation:undoTipIn .22s cubic-bezier(.34,1.4,.64,1)}
.undo-tooltip::before{content:'';position:absolute;top:-6px;left:50%;transform:translateX(-50%) rotate(45deg);width:10px;height:10px;background:#1a0203;border-left:1px solid rgba(255,255,255,.12);border-top:1px solid rgba(255,255,255,.12)}
.undo-tooltip strong{color:#fff;font-weight:800;letter-spacing:.01em}
.undo-tip-msg{position:relative;z-index:1}
@keyframes undoTipIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}
a.obtn{display:block;text-align:center;text-decoration:none}
/* ── INSIGHT CARD (double-tap a tile) ── */
#insight-card-backdrop{display:none;position:fixed;inset:0;z-index:500;background:rgba(0,0,0,.55);backdrop-filter:blur(2px)}
#insight-card-backdrop.show{display:block}
#insight-card{display:none;position:fixed;left:50%;top:50%;transform:translate(-50%,-50%) scale(.94);z-index:501;background:var(--card);border:1.5px solid var(--border);border-radius:18px;padding:1.4rem 1.25rem 1.15rem;width:min(360px,92vw);box-shadow:0 14px 36px rgba(0,0,0,.34);text-align:left;--insight-accent:#b45309}
#insight-card.show{display:block;animation:insightCardIn .26s cubic-bezier(.34,1.4,.64,1) forwards}
@keyframes insightCardIn{from{opacity:0;transform:translate(-50%,-50%) scale(.9)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}
#insight-card::before{content:"";position:absolute;left:0;top:18%;bottom:18%;width:3px;border-radius:0 4px 4px 0;background:var(--insight-accent)}
#insight-card-close{position:absolute;top:.55rem;right:.55rem;width:26px;height:26px;border-radius:50%;border:1px solid var(--border2);background:var(--surface);display:flex;align-items:center;justify-content:center;cursor:pointer;padding:0;color:var(--muted);transition:background .15s,color .15s}
#insight-card-close:hover{background:var(--border);color:var(--text)}
#insight-card-close svg{width:12px;height:12px;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;fill:none}
.insight-card-eyebrow{font-size:.55rem;font-weight:800;letter-spacing:.18em;text-transform:uppercase;color:var(--insight-accent);margin-bottom:.3rem}
.insight-card-name{font-size:1.15rem;font-weight:800;letter-spacing:-.02em;color:var(--text);margin-bottom:.65rem;line-height:1.2}
.insight-card-text{font-size:.78rem;line-height:1.65;color:var(--text);font-weight:400;margin-bottom:1rem}
#insight-card-continue{display:block;width:100%}

/* ── PROGRESS SAVED TOAST ── */
#save-toast{position:fixed;bottom:calc(5.5rem + env(safe-area-inset-bottom));left:50%;transform:translateX(-50%) translateY(8px);z-index:200;opacity:0;pointer-events:none;transition:opacity .25s ease,transform .25s cubic-bezier(.34,1.4,.64,1);background:var(--text);color:var(--surface);font-size:.72rem;font-weight:600;letter-spacing:.03em;padding:.55rem 1.15rem;border-radius:50px;white-space:nowrap;display:flex;align-items:center;gap:.4rem;box-shadow:0 4px 18px rgba(0,0,0,.25)}
#save-toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
#save-toast .toast-icon{font-size:.85rem;opacity:.8}

/* ════════════════════════════════════════════════════════════════════
   FIRST-TIME ONBOARDING — the demo game
   A dimmed stage over the board on a brand-new player's first game, where a
   ghost hand plays a short game with the theme's own tiles: four swipes to
   show that every direction slides the whole board, then a twin tile dropped
   in and swiped home so the merge happens for real. The tiles are ordinary
   .tile elements — same art, same 240ms slide, same merge pop and sparks as
   the live board — positioned by onboarding.js in the board's --ts / --gap
   coordinate system. Dismisses on the first real input (or the "Got it"
   pill). Honors prefers-reduced-motion via the global rule at the top of this
   file plus the .ob-static held frame built by onboarding.js.

   Stacking, in DOM order: scrim and caption gradients sit under the tiles so
   nothing dims the art; the caption text and pill sit above them so they stay
   readable when a tile slides past underneath.
   ──────────────────────────────────────────────────────────────────── */
#onboard-layer{position:absolute;inset:0;z-index:40;pointer-events:none;opacity:0;animation:obFadeIn .45s ease forwards}
#onboard-layer.ob-dismiss{animation:obFadeOut .32s ease forwards}
/* dark scrim that turns the board into a stage. onboarding.js hides the real
   #tlayer underneath for the duration, so this only has to dim the empty cell
   grid — which stays faintly visible, and should: the demo is played on the
   player's own board, not on a picture of one. */
.ob-scrim{position:absolute;z-index:1;inset:0;border-radius:14px;background:rgba(16,10,10,.84);backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px)}
/* soft vignettes that keep the caption and the pill legible over moving tiles */
.ob-grad{position:absolute;z-index:2;left:0;right:0;height:32%;pointer-events:none}
.ob-grad-top{top:0;border-radius:14px 14px 0 0;background:linear-gradient(180deg,rgba(14,10,16,.88),rgba(14,10,16,.42) 52%,rgba(14,10,16,0))}
.ob-grad-bot{bottom:0;border-radius:0 0 14px 14px;background:linear-gradient(0deg,rgba(14,10,16,.88),rgba(14,10,16,.42) 52%,rgba(14,10,16,0))}
/* the demo's own tile + spark layers, sharing #tlayer's coordinate origin.
   z-index is explicit through the whole stack: .tile is a composited layer
   (will-change:transform), which paint order alone would let rise over the text. */
.ob-tlayer{position:absolute;z-index:3;inset:0}
.ob-fx{position:absolute;z-index:4;inset:0}
.ob-tlayer .tile{transition:transform 240ms cubic-bezier(.22,1,.36,1),opacity .3s ease}
.ob-tlayer .tile.ob-out{opacity:0}

/* ghost hand — glides a cell either side of centre, one swipe per direction */
.ob-finger{position:absolute;z-index:5;left:0;top:0;transition:transform 520ms cubic-bezier(.4,0,.2,1)}
.ob-finger-in{transform:translate(-50%,-50%);opacity:0;transition:transform .2s ease,opacity .22s ease}
.ob-finger.ob-on .ob-finger-in{opacity:1}
.ob-finger.ob-press .ob-finger-in{transform:translate(-50%,-50%) scale(.88)}
.ob-hand{display:block;width:46px;height:46px;filter:drop-shadow(0 3px 10px rgba(0,0,0,.6))}
.ob-ring{position:absolute;left:50%;top:50%;width:34px;height:34px;margin:-17px 0 0 -17px;border-radius:50%;border:2px solid rgba(255,255,255,.9);opacity:0}
.ob-finger.ob-press .ob-ring{animation:obRing .65s ease-out}
/* double chevron riding ahead of the hand; rotated to whichever way it travels.
   The box is wide enough that the chevrons lead the hand instead of sitting on it. */
.ob-dirarrow{position:absolute;left:50%;top:50%;width:104px;height:104px;margin:-52px 0 0 -52px;transform:rotate(var(--ob-rot,0deg));opacity:0;transition:opacity .22s ease;filter:drop-shadow(0 2px 6px rgba(0,0,0,.55))}
.ob-finger.ob-on .ob-dirarrow{opacity:.82}
.ob-dirarrow svg{width:100%;height:100%;display:block}

/* caption + arrow keycaps, parked over the top of the board. The caption is a
   chip rather than bare text: a tile can slide beneath it at any moment. */
.ob-ui-top{position:absolute;z-index:6;left:0;right:0;top:0;display:flex;flex-direction:column;align-items:center;gap:.34rem;padding:.45rem .5rem 0}
.ob-caption{max-width:100%;padding:.28rem .6rem;border-radius:9px;background:rgba(14,10,16,.78);backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);font-size:.75rem;font-weight:700;letter-spacing:-.01em;line-height:1.3;text-align:center;color:rgba(255,255,255,.95);text-shadow:0 1px 5px rgba(0,0,0,.7)}
.ob-caption b{color:#ffd9a0;font-weight:800}
.ob-caption.ob-swap{animation:obCapIn .34s ease}
.ob-keys{display:flex;gap:.22rem}
.ob-key{display:flex;align-items:center;justify-content:center;width:19px;height:19px;border-radius:5px;font-size:.62rem;line-height:1;color:rgba(255,255,255,.7);background:rgba(20,14,22,.75);border:1px solid rgba(255,255,255,.22);box-shadow:0 1px 4px rgba(0,0,0,.45);transition:background .16s,color .16s,border-color .16s,transform .16s}
.ob-key.on{background:#fff;border-color:#fff;color:#161016;transform:translateY(1px) scale(1.08)}
.ob-gotit{position:absolute;z-index:6;left:50%;bottom:3.5%;transform:translateX(-50%);pointer-events:auto;cursor:pointer;font-family:inherit;font-size:.62rem;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:rgba(255,255,255,.85);background:rgba(20,14,22,.8);border:1.5px solid rgba(255,255,255,.25);border-radius:50px;padding:.36rem .95rem;transition:background .18s,border-color .18s,color .18s}
.ob-gotit:hover{background:rgba(255,255,255,.2);border-color:rgba(255,255,255,.45);color:#fff}
/* held frame (reduced motion): tile + tile + chevron + result, nothing moves.
   onboarding.js parks .ob-finger on the empty cell between the pair, so only
   its chevron is wanted — the hand and its press ring have nothing to do. */
.ob-static .ob-finger{transition:none}
.ob-static .ob-hand,.ob-static .ob-ring{display:none}

@keyframes obFadeIn{to{opacity:1}}
@keyframes obFadeOut{to{opacity:0}}
@keyframes obCapIn{from{opacity:0;transform:translateY(-5px)}to{opacity:1;transform:none}}
@keyframes obRing{0%{opacity:.9;transform:scale(.5)}100%{opacity:0;transform:scale(2.1)}}

/* ── BLOCK PHONE LANDSCAPE ──
   iOS Safari ignores manifest "orientation":"portrait" and screen.orientation.lock().
   Cover the page when a phone-sized device is in landscape. max-height:500px keeps
   tablets and desktops unaffected (their landscape height is much taller). */
@media screen and (orientation:landscape) and (max-height:500px){
  body{overflow:hidden!important}
  body::before{
    content:"Please rotate your phone to portrait mode to play F1BONACCI.";
    position:fixed;inset:0;z-index:99999;
    background:var(--nf-dark);color:#fff;
    display:flex;align-items:center;justify-content:center;
    padding:1.5rem 2rem;text-align:center;
    font-family:'Inter',system-ui,sans-serif;
    font-size:1.05rem;font-weight:600;line-height:1.45;letter-spacing:-.01em
  }
}
