
  :root{ --ink:#3a2740; --plum:#b85c93; --plum-dark:#8d3f70; --gold:#ffcf5c; --gold-dark:#d99b22; }
  *{ box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
  html,body{ margin:0; height:100%; overflow:hidden; background:#2a1830;
    font-family:"Fredoka","Baloo 2","Comic Sans MS","Segoe UI",system-ui,sans-serif;
    color:var(--ink); user-select:none; -webkit-user-select:none; touch-action:manipulation; }
  #stage{ position:fixed; inset:0; overflow:hidden; background:#f5d9e8; }
  #lane{ position:absolute; inset:0; width:100%; height:100%; display:block; touch-action:none; }

  /* ---------- scorecard ---------- */
  #card{ position:absolute; left:0; right:0; top:46px; z-index:40; display:flex; justify-content:center;
    padding:2px 4px; pointer-events:none; }
  #card .grid{ display:flex; background:rgba(255,255,255,.92); border:2px solid var(--plum-dark);
    border-radius:10px; overflow:hidden; box-shadow:0 3px 0 var(--plum-dark); max-width:100%; }
  .fr{ min-width:26px; border-right:1px solid #e3c6d6; display:flex; flex-direction:column; }
  .fr:last-child{ border-right:none; }
  .fr.tenth{ min-width:38px; }
  .fr .rolls{ display:flex; height:15px; }
  .fr .rc{ flex:1; font-size:11px; font-weight:800; text-align:center; line-height:15px;
    border-left:1px solid #eed7e4; color:#7a3a5e; }
  .fr .rc:first-child{ border-left:none; }
  .fr .tot{ height:18px; font-size:13px; font-weight:800; text-align:center; line-height:18px;
    border-top:1px solid #e3c6d6; color:var(--ink); }
  .fr.active{ background:#fff3c4; }
  .fr .fnum{ font-size:8px; color:#b58; text-align:center; line-height:9px; }

  /* ---------- controls ---------- */
  #controls{ position:absolute; left:0; right:0; bottom:0; z-index:40;
    display:flex; align-items:flex-end; justify-content:center; gap:10px;
    padding:10px 14px calc(12px + env(safe-area-inset-bottom)); pointer-events:none; }
  #controls[hidden], #card[hidden], #hud[hidden], #coins[hidden]{ display:none !important; }
  #controls > *{ pointer-events:auto; }
  .ctl-label{ font-size:11px; font-weight:800; color:#fff; text-shadow:0 1px 2px rgba(0,0,0,.5); }
  .rbtn{ font-family:inherit; font-weight:800; border:none; cursor:pointer; color:#5b3a17;
    background:linear-gradient(#ffe39a,var(--gold)); border-radius:14px; padding:10px 14px; font-size:18px;
    box-shadow:0 4px 0 var(--gold-dark); }
  .rbtn:active{ transform:translateY(3px); box-shadow:0 1px 0 var(--gold-dark); }
  .ctl-stack{ display:flex; flex-direction:column; align-items:center; gap:4px; pointer-events:auto; }
  .ctl-hint{ font-size:11px; font-weight:700; color:#fff; opacity:.85; text-shadow:0 1px 2px rgba(0,0,0,.5); }
  .bowl-row{ display:flex; align-items:flex-end; gap:12px; }
  #rollBtn{ font-size:22px; padding:18px 40px; min-width:150px; }
  .pmeter{ position:relative; width:30px; height:108px; background:rgba(255,255,255,.45);
    border:2px solid var(--plum-dark); border-radius:15px; overflow:hidden; box-shadow:0 3px 0 var(--plum-dark); }
  .pmeter .pfill{ position:absolute; left:0; right:0; bottom:0; height:0%;
    background:linear-gradient(0deg,#7fd06a 0%,#ffd24d 55%,#ff6f6f 100%); }
  .pmeter .pcap{ position:absolute; left:0; right:0; height:3px; background:rgba(255,255,255,.95); box-shadow:0 0 4px rgba(255,255,255,.8); }
  .pmeter .plabel{ position:absolute; top:3px; left:0; right:0; text-align:center; font-size:9px; font-weight:800; color:var(--plum-dark); }

  /* ---------- overlays ---------- */
  .screen{ position:absolute; inset:0; z-index:100; display:flex; flex-direction:column; align-items:center;
    justify-content:center; gap:18px; padding:24px; text-align:center; transition:opacity .4s ease; }
  .screen.hide{ opacity:0; pointer-events:none; } .screen[hidden]{ display:none; }
  #intro{ background:transparent; }
  #title-art{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; z-index:0; }
  #intro::after{ content:""; position:absolute; inset:0; background:linear-gradient(to bottom, rgba(60,20,50,.15), rgba(60,20,50,.05) 40%, rgba(60,20,50,.5)); z-index:1; }
  #title-text{ position:relative; z-index:2; margin-top:-4vh; }
  #title-text .t1{ display:block; font-size:clamp(40px,12vw,84px); font-weight:800; color:#fff; letter-spacing:2px; line-height:.92;
    text-shadow:-3px 0 0 #8d3f70,3px 0 0 #8d3f70,0 -3px 0 #8d3f70,0 3px 0 #8d3f70,0 8px 18px rgba(0,0,0,.4); }
  #title-text .t2{ display:block; font-size:clamp(16px,4.4vw,26px); font-weight:700; color:#fff7d6; margin-top:6px; text-shadow:0 2px 6px rgba(0,0,0,.5); }
  .title-actions{ position:relative; z-index:2; }
  /* Gender / voice picker on the title screen — two big chips above the Play button.
     The active one gets the gold ring; tapping the other switches and rewrites localStorage. */
  .voice-picker{ display:flex; gap:10px; justify-content:center; margin-bottom:14px; position:relative; z-index:2; }
  .voice-chip{ font:inherit; font-weight:800; cursor:pointer; padding:8px 14px; border-radius:14px;
    border:3px solid #5b3a17; background:#fff8e1; color:#5b3a17; font-size:clamp(15px,3.8vw,18px);
    box-shadow:0 3px 0 #5b3a17; transition:transform .08s, box-shadow .08s; }
  .voice-chip:active{ transform:translateY(2px); box-shadow:0 1px 0 #5b3a17; }
  .voice-chip.active{ background:#fff7d6; border-color:var(--gold-dark); box-shadow:0 3px 0 var(--gold-dark), 0 0 0 3px rgba(255,207,92,.35); }
  .wood-btn{ font-family:inherit; font-weight:800; cursor:pointer; font-size:clamp(20px,5vw,28px); color:#5b3a17;
    padding:14px 34px; border:none; border-radius:18px; background:linear-gradient(#ffe39a,var(--gold));
    box-shadow:0 6px 0 var(--gold-dark),0 10px 18px rgba(0,0,0,.3); transition:transform .08s ease, box-shadow .08s ease; }
  .wood-btn:active{ transform:translateY(4px); box-shadow:0 2px 0 var(--gold-dark); }
  .wood-btn:disabled{ filter:grayscale(.5) brightness(.95); cursor:default; }
  #over{ background:rgba(60,20,50,.62); color:#fff; }
  #over h2{ font-size:clamp(26px,7vw,40px); margin:0; text-shadow:0 3px 0 rgba(0,0,0,.3); }
  #over .big{ font-size:clamp(48px,16vw,84px); font-weight:800; color:var(--gold); text-shadow:0 3px 0 var(--gold-dark); }
  #over .sub{ font-size:18px; opacity:.95; }

  #toast{ position:absolute; left:50%; top:38%; transform:translate(-50%,-50%); z-index:60; pointer-events:none;
    font-size:clamp(40px,12vw,80px); font-weight:800; color:#fff; opacity:0;
    text-shadow:0 3px 0 var(--plum-dark),0 0 24px rgba(255,200,90,.8); }
  #toast.show{ animation:pop 1.2s ease-out forwards; }
  @keyframes pop{ 0%{ opacity:0; transform:translate(-50%,-50%) scale(.4);} 20%{ opacity:1; transform:translate(-50%,-50%) scale(1.1);} 80%{ opacity:1;} 100%{ opacity:0; transform:translate(-50%,-65%) scale(1);} }

  .hint{ position:absolute; left:50%; bottom:96px; transform:translateX(-50%); z-index:45;
    background:rgba(255,255,255,.9); color:var(--plum-dark); font-weight:800; border-radius:999px; padding:7px 16px;
    font-size:14px; box-shadow:0 3px 0 var(--plum-dark); }
  .hint[hidden]{ display:none; }

  /* ---------- aim guide: labels on right edge ---------- */
  #aim-guide{ position:absolute; inset:0; z-index:38; pointer-events:none; }
  #aim-guide[hidden]{ display:none; }
  .ag-zone{ position:absolute; right:8px; display:flex; align-items:center; }
  .ag-top{ top:40%; transform:translateY(-50%); }   /* curve label */
  .ag-bot{ top:74%; transform:translateY(-50%); }   /* move-ball label */
  .ag-label{ font-size:clamp(11px,2.6vw,18px); font-weight:900; letter-spacing:1px; color:#fff;
    white-space:nowrap; background:rgba(60,20,50,.6); padding:5px 12px; border-radius:999px;
    box-shadow:0 3px 0 rgba(0,0,0,.3); text-shadow:0 1px 2px rgba(0,0,0,.55); }

  /* ---------- stars HUD ---------- */
  #hud{ position:absolute; left:8px; top:48px; z-index:45; display:flex; align-items:center; gap:4px;
    background:rgba(255,255,255,.9); color:var(--plum-dark); font-weight:800; border-radius:999px;
    padding:5px 12px; font-size:15px; box-shadow:0 3px 0 var(--plum-dark); }
  #hud[hidden]{ display:none; }
  #hud .star{ font-size:16px; }
  #hud.pulse{ animation:hudpop .5s ease; }
  @keyframes hudpop{ 0%{transform:scale(1);} 40%{transform:scale(1.25);} 100%{transform:scale(1);} }
  #wind{ position:absolute; right:8px; top:48px; z-index:45; background:rgba(255,255,255,.9); color:var(--plum-dark);
    font-weight:800; border-radius:999px; padding:5px 12px; font-size:14px; box-shadow:0 3px 0 var(--plum-dark); letter-spacing:1px; }
  #wind[hidden]{ display:none; }

  /* ---------- coins HUD ---------- */
  #coins{ position:absolute; left:8px; top:80px; z-index:45; display:flex; align-items:center; gap:4px;
    background:rgba(255,255,255,.9); color:#a76c12; font-weight:800; border-radius:999px;
    padding:5px 12px; font-size:15px; box-shadow:0 3px 0 #a76c12; }
  #coins[hidden]{ display:none; }
  #coins .coin{ font-size:16px; }
  #coins.pulse{ animation:hudpop .5s ease; }

  /* ---------- in-game shop FAB ---------- */
  /* Small floating button so the player can pop open the shop any time
     (during aim, while a roll is in motion, etc). Tucked top-right under
     the topbar buttons so it doesn't overlap the wind / scorecard. */
  #shopFab{ position:absolute; right:8px; top:110px; z-index:46; cursor:pointer;
    background:linear-gradient(#ffe39a,var(--gold)); color:#5b3a17; font-weight:800;
    border:none; border-radius:50%; width:42px; height:42px; font-size:22px;
    box-shadow:0 3px 0 var(--gold-dark); font-family:inherit; padding:0; line-height:1; }
  #shopFab[hidden]{ display:none !important; }

  /* ---------- picker (start screen + game-over re-pick) ---------- */
  /* Reuses .shop-item styles via the picker-item alias; the active ball gets a
     thicker gold border so Katherine can see which one she's currently using. */
  #picker{ background:linear-gradient(160deg,#f7c9de 0%,#e9b1cf 45%,#caa0e0 100%); color:#fff; }
  #picker .picker-card{ background:#fff; color:var(--ink); border-radius:18px; padding:14px 14px 18px;
    box-shadow:0 8px 0 rgba(0,0,0,.25); max-width:min(560px,94vw); width:100%;
    max-height:84vh; display:flex; flex-direction:column; gap:10px; }
  #picker h2{ margin:0; font-size:clamp(20px,5vw,28px); color:var(--plum-dark); }
  #picker .shop-list{ display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr));
    gap:10px; overflow-y:auto; padding:4px 2px 6px; }
  .picker-item.active{ border-color:var(--gold-dark); box-shadow:0 3px 0 var(--gold-dark), 0 0 0 3px rgba(255,207,92,.35); background:#fff7d6; }

  /* ---------- store modal ---------- */
  #store{ background:rgba(60,20,50,.78); color:#fff; }
  #store .store-card{ background:#fff; color:var(--ink); border-radius:18px; padding:14px 14px 18px;
    box-shadow:0 8px 0 rgba(0,0,0,.25); max-width:min(560px,94vw); width:100%;
    max-height:84vh; display:flex; flex-direction:column; gap:10px; }
  #store h2{ margin:0; font-size:clamp(20px,5vw,28px); color:var(--plum-dark); }
  #store .store-coins{ display:inline-flex; align-items:center; gap:4px; background:#fff7d6;
    border:2px solid #a76c12; border-radius:999px; padding:3px 12px; font-weight:800; color:#a76c12; font-size:15px; }
  #store .shop-list{ display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr));
    gap:10px; overflow-y:auto; padding:4px 2px 6px; }
  .shop-item{ background:#faf2f8; border:2px solid var(--plum); border-radius:14px; padding:8px;
    display:flex; flex-direction:column; align-items:center; gap:5px; box-shadow:0 3px 0 var(--plum-dark); }
  .shop-item .preview{ width:60px; height:60px; border-radius:50%; box-shadow:inset -8px -10px 14px rgba(0,0,0,.25), inset 6px 6px 10px rgba(255,255,255,.5); }
  .shop-item .name{ font-weight:800; font-size:13px; text-align:center; color:var(--ink); line-height:1.1; }
  .shop-item .stats{ font-size:11px; color:#7a3a5e; font-weight:700; text-align:center; line-height:1.2; }
  .shop-item button{ font-family:inherit; font-weight:800; cursor:pointer; border:none; padding:6px 10px;
    border-radius:10px; font-size:12px; box-shadow:0 2px 0 rgba(0,0,0,.25); }
  .shop-item .buy{ background:linear-gradient(#ffe39a,var(--gold)); color:#5b3a17; }
  .shop-item .equip{ background:linear-gradient(#d6e9ff,#8fc4ff); color:#1a3a5b; }
  .shop-item .equipped{ background:#b6f08a; color:#2a5a1a; cursor:default; }
  .shop-item button:disabled{ filter:grayscale(.6); cursor:default; opacity:.6; }
  #store .store-close{ align-self:center; margin-top:4px; }

  /* ---------- challenge banner ---------- */
  .chal{ position:absolute; left:50%; top:96px; transform:translateX(-50%); z-index:45;
    background:linear-gradient(#fff3c4,#ffe39a); color:#7a3a5e; font-weight:800; border:2px solid var(--gold-dark);
    border-radius:999px; padding:6px 16px; font-size:14px; box-shadow:0 3px 0 var(--gold-dark); white-space:nowrap;
    max-width:92vw; overflow:hidden; text-overflow:ellipsis; }
  .chal[hidden]{ display:none; }
  .chal.win{ background:linear-gradient(#b6f08a,#7fd06a); color:#2a5a1a; border-color:#4a8a2a; box-shadow:0 3px 0 #4a8a2a; }

  .game-version{ position:fixed; bottom:2px; right:4px; font-size:10px; opacity:.5; color:#fff; pointer-events:none; z-index:99999; text-shadow:0 1px 1px rgba(0,0,0,.5); }
