:root{--ink:#2f3a24;--ink-soft:#4e5b40;--card:#fffdf5;--wood:#6d4526;--btn:#fff6df;--go:#5f8a33;--go-dark:#46692a;--bar:#b9d99a;--bar-hi:#5f8a33;
  --gut-l:max(12px,env(safe-area-inset-left));--gut-r:max(12px,env(safe-area-inset-right))}
*{box-sizing:border-box}
html,body{margin:0;height:100%;overflow:hidden;overscroll-behavior:none}
body{
  background:
    radial-gradient(60px 20px at 14% 7%,rgba(255,255,255,.8) 0 60%,transparent 62%),
    radial-gradient(42px 16px at 20% 5.5%,rgba(255,255,255,.75) 0 60%,transparent 62%),
    radial-gradient(70px 22px at 86% 11%,rgba(255,255,255,.7) 0 60%,transparent 62%),
    radial-gradient(46px 16px at 80% 9.5%,rgba(255,255,255,.65) 0 60%,transparent 62%),
    radial-gradient(120% 60% at 15% 110%,#8fc66d 0 40%,transparent 41%),
    radial-gradient(120% 60% at 90% 115%,#9ccf78 0 42%,transparent 43%),
    radial-gradient(160% 50% at 50% 118%,#a8d684 0 48%,transparent 49%),
    linear-gradient(#dff0f6 0,#e8f4dc 38%,#c9e6ae 100%);
  background-color:#e4f2dd;
  font-family:ui-rounded,"SF Pro Rounded",system-ui,sans-serif;color:var(--ink);
  -webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-text-size-adjust:100%
}
#app{position:relative;display:flex;flex-direction:column;height:100%;height:100dvh;max-width:600px;margin:0 auto;
  padding:env(safe-area-inset-top) var(--gut-r) env(safe-area-inset-bottom) var(--gut-l)}
/* The column is centred: auto margins above the header and below the toolbar split the free height (and fall to 0
   when there's none), and the stage is exactly the board's height (main.js layout() sizes it). */
#top{display:flex;align-items:center;gap:10px;padding:10px 0 2px;margin-top:auto}
.logo{font-weight:800;font-size:21px;letter-spacing:.2px;white-space:nowrap}
#title{flex:1;min-width:0;text-align:right;font-weight:700;font-size:16px;color:var(--ink-soft);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#hud{display:flex;justify-content:center;align-items:baseline;gap:8px;font-weight:800;font-size:19px;padding:6px 0 2px;font-variant-numeric:tabular-nums}
#hud .sep{opacity:.5}
#hud-target{font-weight:700;font-size:16px;color:var(--ink-soft);margin-left:6px}
/* The hint line keeps its height when empty, so a hint coming or going never resizes the board mid-play. */
#hint{min-height:44px;margin:2px auto 6px;display:flex;align-items:center;justify-content:center;gap:4px;max-width:100%;padding:0 12px;background:rgba(255,253,245,.82);border-radius:12px;font-weight:650;font-size:15px;line-height:1.25;text-align:center}
#hint.off{visibility:hidden}
#stage{flex:none;height:var(--bs,320px);position:relative;display:flex;align-items:center;justify-content:center;touch-action:none}
#board{display:block;border-radius:16px;box-shadow:0 6px 18px rgba(40,60,20,.25);cursor:grab;touch-action:none}
.overlay{position:absolute;left:50%;top:50%;width:var(--bs,100%);height:var(--bs,100%);transform:translate(-50%,-50%);display:flex;align-items:center;justify-content:center;background:rgba(40,60,25,.32);border-radius:16px;z-index:2}
/* Result and stats cover the whole column below the header (the menu button stays live); only the card takes taps. */
.overlay.full{width:100%;height:100%;background:none;border-radius:0;padding-top:calc(env(safe-area-inset-top) + 64px);pointer-events:none}
.overlay.full .card{pointer-events:auto}
.overlay.full .card{box-shadow:0 12px 40px rgba(30,45,15,.38),0 0 0 1px rgba(109,69,38,.12)}
#stats{z-index:3}
.overlay[hidden]{display:none}
.card{background:var(--card);border-radius:18px;padding:16px 18px 14px;text-align:center;box-shadow:0 10px 30px rgba(30,45,15,.3);width:min(340px,calc(100% - 16px));max-height:calc(100% - 8px);overflow-y:auto;overscroll-behavior:contain;touch-action:pan-y}
.card p{margin:4px 0 14px;font-weight:650;font-size:16px}
.medal{font-size:48px;line-height:1.1}
.res-title{font-weight:800;font-size:22px;margin-top:2px}
.res-line{font-weight:700;font-size:17px;color:var(--ink-soft);margin:4px 0 10px;font-variant-numeric:tabular-nums}
.res-extra{font-size:15px;font-weight:600;color:var(--ink-soft);margin:0 0 12px;font-variant-numeric:tabular-nums}
.res-extra:empty{display:none}
.row{display:flex;gap:10px;justify-content:center;flex-wrap:wrap}
button.wide{width:100%;margin-bottom:12px}
.stats{margin:0 0 10px}
.stats[hidden]{display:none}
.tiles{display:grid;grid-template-columns:repeat(4,1fr);gap:4px;margin-bottom:10px}
.tiles div{display:flex;flex-direction:column;align-items:center}
.tiles b{font-size:22px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1.1}
.tiles span{font-size:12px;font-weight:650;color:var(--ink-soft);line-height:1.15}
.hist{display:grid;grid-template-columns:repeat(6,1fr);gap:6px;align-items:end;height:92px;padding:0 2px}
.hist .col{display:flex;flex-direction:column;align-items:center;justify-content:flex-end;height:100%}
.hist .n{font-size:13px;font-weight:750;font-variant-numeric:tabular-nums}
.hist i{display:block;width:100%;min-height:4px;border-radius:5px 5px 2px 2px;background:var(--bar)}
.hist .hl i{background:var(--bar-hi)}
.hist .l{font-size:12px;font-weight:700;color:var(--ink-soft);margin-top:3px;white-space:nowrap}
.hist-cap{font-size:12px;font-weight:650;color:var(--ink-soft);margin-top:4px}
#toolbar{display:flex;gap:12px;justify-content:center;padding:10px 0 12px;margin-bottom:auto}
button{font:inherit;font-weight:750;font-size:17px;min-height:48px;padding:0 22px;border-radius:14px;border:2px solid var(--wood);background:var(--btn);color:var(--ink);cursor:pointer;touch-action:manipulation}
button:active{transform:translateY(1px)}
button:disabled{opacity:.45;cursor:default}
button.primary{background:var(--go);border-color:var(--go-dark);color:#fff}
button.round{width:44px;min-height:44px;height:44px;padding:0;border-radius:50%;font-size:20px;display:flex;align-items:center;justify-content:center;flex:none}
button.link{border:0;background:none;min-height:44px;padding:0 8px;text-decoration:underline;font-size:inherit;color:var(--ink-soft)}
button[hidden]{display:none}
#toolbar button{min-width:120px}
#menu{position:absolute;inset:0;z-index:5;background:rgba(40,60,25,.14)}
#menu[hidden]{display:none}
/* main.js sets the card's top to just under the menu button (the column is centred, so the header moves). */
.menu-card{position:absolute;top:calc(env(safe-area-inset-top) + 58px);right:var(--gut-r);width:220px;background:var(--card);border-radius:16px;padding:8px;box-shadow:0 10px 30px rgba(30,45,15,.3);display:flex;flex-direction:column;gap:6px}
.menu-card button{width:100%;text-align:left;border-width:0;background:transparent;padding:0 14px}
.menu-card button:hover{background:var(--btn)}
#toast{position:absolute;left:50%;bottom:calc(env(safe-area-inset-bottom) + 20px);transform:translateX(-50%);z-index:6;background:var(--ink);color:#fff;font-weight:750;font-size:16px;padding:10px 18px;border-radius:20px;box-shadow:0 6px 18px rgba(20,30,10,.3);white-space:nowrap}
#toast[hidden]{display:none}
@media (max-height:640px){#top{padding-top:6px}.logo{font-size:18px}#hud{font-size:17px}#toolbar{padding:6px 0 8px}.medal{font-size:40px}.hist{height:72px}}
/* Phones: the board runs edge to edge (its own green margin is the gutter). Tall phones spend some of the spare
   height on a roomier header, HUD and bigger thumb buttons, so the frame above and below the column stays small. */
@media (max-width:480px){#stage{margin:0 calc(-1 * var(--gut-r)) 0 calc(-1 * var(--gut-l))}#board{border-radius:0;box-shadow:0 4px 12px rgba(40,60,20,.22)}}
@media (max-width:480px) and (min-height:740px){#top{padding:14px 0 6px}.logo{font-size:23px}#hud{font-size:22px;padding:10px 0 6px}#hint{min-height:48px;margin-bottom:10px}
  #toolbar{padding:18px 0 16px}#toolbar button{min-height:56px;min-width:140px;font-size:19px}}
@media (max-width:360px){.logo{font-size:18px}#title{font-size:15px}}
