/* Ledger paper, ink and one red stamp. */
:root{--paper:#f6efdb;--desk:#e6dcbc;--ink:#1f3a4d;--green:#2f6b57;--red:#c8452f;--edge:#cbbd96}
*{box-sizing:border-box}
html,body{margin:0}
body{background:var(--desk) repeating-linear-gradient(0deg,transparent 0 31px,rgba(47,107,87,.13) 31px 32px);color:var(--ink);font-family:Georgia,"Times New Roman",serif;-webkit-tap-highlight-color:transparent}
[hidden]{display:none!important}
.game-header{display:flex;justify-content:space-between;align-items:center;gap:.5rem;padding:.6rem 1rem;background:var(--green);color:var(--paper);font:600 .9rem system-ui,sans-serif;padding-left:max(1rem,env(safe-area-inset-left));padding-right:max(1rem,env(safe-area-inset-right))}
.game-header a{color:var(--paper);text-decoration:none;min-height:44px;display:inline-flex;align-items:center}
.game-wrap{padding-left:max(16px,env(safe-area-inset-left));padding-right:max(16px,env(safe-area-inset-right));padding-bottom:max(16px,env(safe-area-inset-bottom))}
#top{display:flex;justify-content:space-between;align-items:center;margin-bottom:.4rem}
h1{margin:0;font-size:1.7rem;letter-spacing:.02em;border-bottom:3px double var(--ink);padding-bottom:2px}
h2{margin:.2rem 0;font-size:1.4rem}
p{margin:.3rem 0;line-height:1.35}
.ico{width:44px;height:44px;border:2px solid var(--ink);background:var(--paper);color:var(--ink);border-radius:10px;display:grid;place-items:center;box-shadow:0 3px 0 var(--ink);cursor:pointer}
.ico:active{transform:translateY(2px);box-shadow:0 1px 0 var(--ink)}
.btn{min-height:46px;min-width:46px;padding:.5rem .9rem;border:2px solid var(--ink);background:var(--paper);color:var(--ink);border-radius:10px;font:700 1rem system-ui,sans-serif;box-shadow:0 3px 0 var(--ink);cursor:pointer;touch-action:manipulation}
.btn:active{transform:translateY(2px);box-shadow:0 1px 0 var(--ink)}
.btn:disabled{opacity:.45;box-shadow:none}
.btn:focus-visible,.ico:focus-visible,#board:focus-visible{outline:3px solid var(--red);outline-offset:2px}
.btn.primary{background:var(--green);color:var(--paper)}
.btn.big{display:block;width:100%;margin:.6rem 0;font-size:1.1rem;min-height:54px}
#hud{display:flex;align-items:stretch;gap:.5rem;margin:.2rem 0 .5rem}
.stat{flex:1;background:var(--paper);border:2px solid var(--ink);border-radius:10px;padding:.2rem .5rem;display:flex;flex-direction:column;justify-content:center;min-height:56px}
.k{font:600 .68rem system-ui,sans-serif;text-transform:uppercase;letter-spacing:.06em;opacity:.75}
.v{font:700 1.4rem ui-monospace,Menlo,Consolas,monospace}
.v.bump{animation:bump .25s ease-out}
.v.low{color:var(--red)}
@keyframes bump{0%{transform:scale(1.35)}100%{transform:scale(1)}}
#peekc{width:56px;height:56px;border-radius:6px;background:var(--paper);transition:opacity .2s}
#peekc.off{opacity:.12}
#stage{display:flex;justify-content:center}
#board{touch-action:none;user-select:none;-webkit-user-select:none;border-radius:12px;border:2px solid var(--ink);background:var(--desk);display:block}
#board.shake{animation:shake .4s}
@keyframes shake{20%{transform:translateX(-7px)}40%{transform:translateX(7px)}60%{transform:translateX(-4px)}80%{transform:translateX(4px)}}
#msg{min-height:1.4rem;text-align:center;font-style:italic}
#bar,.row{display:flex;gap:.5rem;flex-wrap:wrap;justify-content:center;margin:.4rem 0}
#bar .btn{flex:1 1 0;padding:.5rem .3rem;font-size:.9rem}
#result{text-align:center;background:var(--paper);border:2px solid var(--ink);border-radius:12px;padding:.8rem;animation:rise .3s ease-out}
@keyframes rise{from{transform:translateY(14px);opacity:0}to{transform:none;opacity:1}}
#rStars svg{width:40px;height:40px;margin:0 3px}
#rStars svg.pop{animation:pop .4s ease-out both}
@keyframes pop{0%{transform:scale(.2) rotate(-30deg);opacity:0}70%{transform:scale(1.25)}100%{transform:none;opacity:1}}
#title{text-align:center}
#demo{display:flex;justify-content:center;margin:.6rem 0}
#democ{width:120px;height:120px;border:2px solid var(--ink);border-radius:8px;background:var(--paper)}
.lede{max-width:30ch;margin:.4rem auto}
#best{font:.85rem system-ui,sans-serif;opacity:.85}
#albGrid{display:grid;grid-template-columns:repeat(4,1fr);gap:.5rem;margin:.5rem 0}
#albGrid button{padding:4px;border:2px solid var(--ink);background:var(--paper);border-radius:8px;min-height:64px;cursor:pointer;display:grid;place-items:center}
#albGrid canvas{width:100%;height:auto;aspect-ratio:1;display:block}
#padc{touch-action:none;display:block;margin:.4rem auto;border-radius:6px}
footer{text-align:center;font:.8rem system-ui,sans-serif;padding:1rem}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
#levels[hidden]{display:none}
#lvGrid{display:grid;grid-template-columns:repeat(4,1fr);gap:.5rem;margin:.5rem 0}
.lvbtn{min-height:56px;padding:4px;border:2px solid var(--ink);background:var(--paper);color:var(--ink);border-radius:8px;box-shadow:0 3px 0 var(--ink);display:flex;flex-direction:column;align-items:center;justify-content:center;cursor:pointer;touch-action:manipulation}
.lvbtn:active{transform:translateY(2px);box-shadow:0 1px 0 var(--ink)}
.lvbtn.now{background:var(--green);color:var(--paper)}
.lvbtn .ln{font:700 1.1rem ui-monospace,Menlo,Consolas,monospace}
.lvbtn .ls{font:.7rem system-ui,sans-serif;color:var(--red);letter-spacing:.05em}
.lvbtn.now .ls{color:var(--paper)}
#bar .btn{font-size:.85rem}
#msg.good{color:var(--green);font-weight:700}
#board.win{box-shadow:0 0 0 4px var(--green)}

/* Full screen (native and immersive both add html.pip-immersive): board fills the stage, no scrolling in play. */
html.pip-immersive .game-header,html.pip-immersive .ad-well,html.pip-immersive #top,html.pip-immersive .lede,html.pip-immersive #similar-games,html.pip-immersive footer{display:none!important}
html.pip-immersive body .game-wrap.pip-stage{display:flex;flex-direction:column;max-width:none;margin:0;padding:8px 10px;overflow:hidden;background:var(--desk) repeating-linear-gradient(0deg,transparent 0 31px,rgba(47,107,87,.13) 31px 32px)}
html.pip-immersive #app{flex:1;min-height:0;display:flex;flex-direction:column;overflow-y:auto;overflow-x:hidden}
html.pip-immersive #play:not([hidden]){flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}
html.pip-immersive #hud{margin:0 0 6px;flex:none}
html.pip-immersive .stat{min-height:48px}
html.pip-immersive #stage{flex:1;min-height:0;min-width:0;position:relative;overflow:hidden;display:block}
html.pip-immersive #board{position:absolute;inset:0;margin:auto}
html.pip-immersive #msg{flex:none;min-height:1.2rem;margin:4px 0 0}
html.pip-immersive #bar{flex:none;margin:6px 0 0}
html.pip-immersive #result{flex:none;max-height:45%;overflow:auto;margin-top:6px}
html.pip-immersive #title,html.pip-immersive #levels,html.pip-immersive #album,html.pip-immersive #pad{margin:auto 0}
@media (orientation:landscape) and (max-height:600px){
  html.pip-immersive #play:not([hidden]){display:grid;grid-template-columns:minmax(0,1fr) minmax(190px,240px);grid-template-rows:auto auto 1fr;column-gap:10px;align-content:stretch}
  html.pip-immersive #stage{grid-column:1;grid-row:1/4}
  html.pip-immersive #hud{grid-column:2;grid-row:1;display:grid;grid-template-columns:1fr 1fr;gap:6px}
  html.pip-immersive #peekc{justify-self:center;align-self:center}
  html.pip-immersive #msg{grid-column:2;grid-row:2}
  html.pip-immersive #bar{grid-column:2;grid-row:3;display:grid;grid-template-columns:1fr 1fr;gap:6px;align-content:start}
  html.pip-immersive #result{grid-column:2;grid-row:2/4;max-height:none;margin:0;min-height:0}
  html.pip-immersive .btn.big{min-height:46px;margin:.3rem 0}
}
