/* Paper Games — shared look: a graph-paper notebook page, printed ink for the puzzle, blue pencil for the player, red pencil for misses.
   Layout: one-screen column per game — header bar, status line, play area that flexes, controls at thumb height. */
:root{
  --paper:#f2f4ef; --grid:rgba(52,96,128,.11); --ink:#26323b; --muted:#66727b;
  --hit:#2e5ea6; --miss:#c4353d; --key:#ffffff; --key-edge:#cfd6d2;
  --line:#b9c3c8; --sel:rgba(46,94,166,.26); --peer:rgba(46,94,166,.08); --same:rgba(46,94,166,.17);
  --sheet:#fbfcf9; --scrim:rgba(20,30,40,.38);
  --correct:#2e5ea6; --present:#c98a12; --absent:#8d989f; --on-tile:#ffffff;
  --hand:"Gochi Hand","Marker Felt","Comic Sans MS",cursive;
  --mono:"IBM Plex Mono",ui-monospace,"SF Mono",Menlo,monospace;
  --ui:-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;
  color-scheme:light;
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --paper:#102a43; --grid:rgba(150,195,235,.12); --ink:#e4edf6; --muted:#93a9bd;
  --hit:#8cc2ff; --miss:#ff8a8a; --key:#173756; --key-edge:#2a4d70;
  --line:#2f5276; --sel:rgba(140,194,255,.30); --peer:rgba(140,194,255,.08); --same:rgba(140,194,255,.18);
  --sheet:#15324f; --scrim:rgba(0,8,16,.55);
  --correct:#4f8fe0; --present:#d9a03a; --absent:#2d4863; --on-tile:#ffffff; color-scheme:dark}}
:root[data-theme="dark"]{
  --paper:#102a43; --grid:rgba(150,195,235,.12); --ink:#e4edf6; --muted:#93a9bd;
  --hit:#8cc2ff; --miss:#ff8a8a; --key:#173756; --key-edge:#2a4d70;
  --line:#2f5276; --sel:rgba(140,194,255,.30); --peer:rgba(140,194,255,.08); --same:rgba(140,194,255,.18);
  --sheet:#15324f; --scrim:rgba(0,8,16,.55);
  --correct:#4f8fe0; --present:#d9a03a; --absent:#2d4863; --on-tile:#ffffff; color-scheme:dark}
/* High-contrast tile colors for Five Letters (same in both themes) */
:root.hc{--correct:#e8742a; --present:#2fa0d4}

*{box-sizing:border-box}
[hidden]{display:none!important}
html,body{height:100%}
body{
  margin:0;background:var(--paper);color:var(--ink);font-family:var(--ui);font-size:15px;
  background-image:linear-gradient(var(--grid) 1px,transparent 1px),linear-gradient(90deg,var(--grid) 1px,transparent 1px);
  background-size:22px 22px;background-attachment:fixed;
  -webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;
  touch-action:manipulation;overscroll-behavior:none;-webkit-text-size-adjust:100%;
}
.app{
  height:100%;max-width:560px;margin:0 auto;
  padding:max(10px,env(safe-area-inset-top,0px)) 16px max(12px,env(safe-area-inset-bottom,0px));
  display:flex;flex-direction:column;gap:10px;
}
.bar{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:8px;min-height:44px}
.bar h1{font-family:var(--hand);font-weight:400;font-size:2rem;margin:0;line-height:1;text-align:center;white-space:nowrap}
.bar .end{justify-self:end}
.back{
  justify-self:start;font-family:var(--hand);font-size:1.3rem;color:var(--muted);text-decoration:none;
  padding:6px 4px;display:inline-flex;align-items:center;gap:2px;
}
.back svg{width:18px;height:18px}

.btn{
  font-family:var(--hand);font-size:1.25rem;line-height:1.1;padding:7px 18px;border-radius:999px;cursor:pointer;
  border:2px solid var(--ink);background:transparent;color:var(--ink);white-space:nowrap;
}
.btn.primary{background:var(--ink);color:var(--paper)}
.btn.small{font-size:1.1rem;padding:4px 14px}
.btn:disabled{opacity:.4;cursor:default}
button{font:inherit;color:inherit}
/* "Back to all games" on end-of-game sheets */
.btn.homebtn{display:flex;align-items:center;justify-content:center;gap:8px;text-decoration:none;width:100%}
.btn.homebtn svg{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
.endnav{display:flex;flex-direction:column;gap:8px}
.btn.upnext{border-style:dashed;gap:8px;flex-wrap:wrap}
.btn.upnext .label{font-family:var(--ui);font-size:.66rem}
.btn.upnext small{font-family:var(--ui);font-size:.75rem;color:var(--muted)}
.alldone{margin:0;text-align:center;font-family:var(--hand);font-size:1.1rem;line-height:1.2;color:var(--hit)!important}
:focus-visible{outline:2px solid var(--hit);outline-offset:2px}

/* Bottom sheets */
.sheet{position:fixed;inset:0;z-index:20;display:flex;align-items:flex-end;justify-content:center;background:var(--scrim)}
.sheet[hidden]{display:none!important}
.panel{
  width:100%;max-width:560px;max-height:88%;overflow:auto;background:var(--sheet);color:var(--ink);
  border-radius:18px 18px 0 0;padding:18px 18px max(18px,env(safe-area-inset-bottom,0px));
  display:flex;flex-direction:column;gap:14px;box-shadow:0 -8px 30px rgba(0,0,0,.18);
  animation:rise .22s ease-out;
}
.panel h2{font-family:var(--hand);font-weight:400;font-size:1.9rem;margin:0;line-height:1.05;text-wrap:balance}
.panel p{margin:0;line-height:1.45;color:var(--muted)}
.panel .row{display:flex;gap:10px;flex-wrap:wrap}
.panel .row .btn{flex:1 1 auto}
.label{font-size:.7rem;text-transform:uppercase;letter-spacing:.09em;color:var(--muted);font-weight:600}
@keyframes rise{from{transform:translateY(30px);opacity:0}to{transform:none;opacity:1}}

/* Settings rows */
.switch{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 0;border-bottom:1px solid var(--line);cursor:pointer}
.switch:last-child{border-bottom:0}
.switch span{display:flex;flex-direction:column;gap:2px;min-width:0}
.switch small{color:var(--muted);font-size:.8rem}
.switch input{appearance:none;-webkit-appearance:none;flex:none;width:46px;height:28px;border-radius:999px;background:var(--line);position:relative;cursor:pointer;margin:0;transition:background .15s}
.switch input::after{content:"";position:absolute;top:3px;left:3px;width:22px;height:22px;border-radius:50%;background:var(--sheet);transition:transform .15s;box-shadow:0 1px 2px rgba(0,0,0,.25)}
.switch input:checked{background:var(--hit)}
.switch input:checked::after{transform:translateX(18px)}

.seg{display:grid;grid-template-columns:repeat(4,1fr);gap:4px;padding:4px;border-radius:12px;background:var(--peer);border:1px solid var(--line)}
.seg button{border:0;background:transparent;border-radius:9px;padding:8px 2px;font-weight:600;font-size:.88rem;cursor:pointer;color:var(--muted)}
.seg button[aria-pressed="true"]{background:var(--key);color:var(--ink);box-shadow:0 1px 3px rgba(0,0,0,.12)}

@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;transition-duration:.01ms!important}}

/* Emblems (emblems.js) for Tendril, Starfish and Clover: the mark beside the title, and the picture atop the stats sheet */
:root{--em-tendril:#3f8f4f;--em-leaf:#8fcf86;--em-star:#e0763a;--em-clover:#2e8b57}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){--em-tendril:#79c27a;--em-leaf:#4f9a55;--em-star:#f2945e;--em-clover:#62c08a}}
:root[data-theme="dark"]{--em-tendril:#79c27a;--em-leaf:#4f9a55;--em-star:#f2945e;--em-clover:#62c08a}
.bar h1 .em{color:var(--em);flex:none}
.hero{display:flex;justify-content:center;margin:-2px 0 -4px}
.hero svg{width:92px;height:92px;display:block;overflow:visible}
.why{font-size:.85rem;color:var(--muted);display:flex;gap:10px;align-items:center;margin:0}
.why svg{width:30px;height:30px;flex:none;color:var(--em)}
@media (prefers-reduced-motion:no-preference){
  .hero svg{animation:em-in .7s cubic-bezier(.2,.8,.2,1.25) both}
  .hero .em-star{animation-name:em-spin}
}
@keyframes em-in{from{transform:scale(.4) rotate(-12deg);opacity:0}to{transform:none;opacity:1}}
@keyframes em-spin{from{transform:scale(.4) rotate(-144deg);opacity:0}to{transform:none;opacity:1}}
