/* yap.vn shared styles: tokens, base, header, buttons, footer */
:root{
  --bg:#F3F5FB; --surface:#FFFFFF; --ink:#16204A; --muted:#5A6386;
  --line:#D6DCEC; --cobalt:#2F54EB; --cobalt-soft:#E3E9FF; --mint:#12A37A; --rose:#D6455D; --warm:#E8743B;
  color-scheme:light;
  box-sizing:border-box;
  padding-top:env(safe-area-inset-top,0px); padding-bottom:env(safe-area-inset-bottom,0px);
}
@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    --bg:#0E1430; --surface:#161E42; --ink:#E6EAFB; --muted:#9AA3C7;
    --line:#2C3768; --cobalt:#7C95FF; --cobalt-soft:#222D63; --mint:#3FD3A6; --rose:#FF7A90; --warm:#FF9A5C;
    color-scheme:dark;
  }
}
:root[data-theme="dark"]{
  --bg:#0E1430; --surface:#161E42; --ink:#E6EAFB; --muted:#9AA3C7;
  --line:#2C3768; --cobalt:#7C95FF; --cobalt-soft:#222D63; --mint:#3FD3A6; --rose:#FF7A90; --warm:#FF9A5C;
  color-scheme:dark;
}
*,*::before,*::after{box-sizing:inherit}
html{scroll-padding-top:env(safe-area-inset-top,0px)}
body{margin:0;background:var(--bg);color:var(--ink);
  font-family:"Be Vietnam Pro",system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
  font-size:1rem;line-height:1.6;-webkit-font-smoothing:antialiased;transition:background-color .8s,color .8s}
@media (prefers-reduced-motion:reduce){body{transition:none}}
button{font:inherit;color:inherit;cursor:pointer}
:focus-visible{outline:3px solid var(--cobalt);outline-offset:3px;border-radius:6px}
[hidden]{display:none!important}
.wrap{max-width:1040px;margin:0 auto;padding:0 20px}

/* Loading screen: drawn by CSS alone so it shows on the very first paint of a tool or game page,
   then fades out when site.js adds .ready to <html>. It hides itself after 8 s even if a script fails.
   ::before is the backdrop, ::after the logo with a moving bar under it. */
html::before,html::after{content:"";position:fixed;z-index:9999;pointer-events:none;transition:opacity .35s ease,visibility .35s;
  animation:yap-load-giveup 0s 8s forwards}
html::before{inset:0;background:var(--bg)}
html::after{left:50%;top:50%;width:124px;height:84px;margin:-50px 0 0 -62px;
  background:url(logo.png) center 0/112px auto no-repeat,
             linear-gradient(90deg,transparent,var(--cobalt),transparent) 0 76px/60px 5px no-repeat,
             linear-gradient(var(--line),var(--line)) center 76px/100% 5px no-repeat;
  border-radius:3px;animation:yap-load-bar 1.1s ease-in-out infinite,yap-load-giveup 0s 8s forwards}
html.ready::before,html.ready::after,html:has(body[data-home])::before,html:has(body[data-home])::after{opacity:0;visibility:hidden;animation:none}
@keyframes yap-load-bar{0%{background-position:center 0,-60px 76px,center 76px}100%{background-position:center 0,124px 76px,center 76px}}
@keyframes yap-load-giveup{to{opacity:0;visibility:hidden}}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"])::after{filter:brightness(1.9) saturate(.9)}}
:root[data-theme="dark"]::after{filter:brightness(1.9) saturate(.9)}
@media (prefers-reduced-motion:reduce){html::after{animation:yap-load-giveup 0s 8s forwards}}

/* Header */
.site-top{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:10px 0}
.brand{display:block;padding:10px 0;line-height:0;border-radius:8px}
.brand img{display:block;width:auto;height:32px;transition:transform .15s}
.brand:hover img{transform:rotate(-4deg)}
/* The wordmark is dark blue; lift it so it stays readable on the dark navy background */
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .brand img{filter:brightness(1.9) saturate(.9)}}
:root[data-theme="dark"] .brand img{filter:brightness(1.9) saturate(.9)}
@media (prefers-reduced-motion:reduce){.brand img{transition:none}}
.site-nav{display:flex;align-items:center;gap:18px}
.site-nav a{display:inline-block;padding:10px 0;color:var(--muted);text-decoration:none;font-size:.92rem;font-weight:500}
.site-nav a:hover{color:var(--ink)}
.lang{display:flex;border:1.5px solid var(--line);border-radius:999px;padding:3px}
.lang button{border:0;background:none;padding:8px 14px;border-radius:999px;font-size:.85rem;font-weight:600;color:var(--muted);
  touch-action:manipulation}
.lang button[aria-pressed="true"]{background:var(--ink);color:var(--bg)}

/* Buttons */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;border-radius:12px;
  padding:14px 26px;font-weight:600;font-size:1rem;background:var(--cobalt);color:#fff;text-decoration:none;transition:transform .12s}
.btn:active{transform:translateY(1px)}
.btn.ghost{background:transparent;color:var(--ink);border:1.5px solid var(--line)}
.btn:disabled{opacity:.4;cursor:default}

/* Footer and toast */
.site-footer{padding:24px 0 32px;color:var(--muted);font-size:.85rem;border-top:1.5px solid var(--line);margin-top:24px}
.quote{margin:0;max-width:60ch}
.quote blockquote{margin:0;font-size:1rem;font-style:italic;line-height:1.5;color:var(--ink)}
.quote figcaption{margin-top:6px;font-weight:600}
.quote figcaption::before{content:"— "}
.toast{position:fixed;left:50%;bottom:calc(24px + env(safe-area-inset-bottom,0px));transform:translateX(-50%);
  background:var(--ink);color:var(--bg);padding:10px 18px;border-radius:10px;font-size:.9rem;z-index:20}

/* Game toolbar: small icon-only buttons above the board */
.g-tools{display:flex;align-items:center;justify-content:flex-end;gap:6px;margin:0 0 8px}
.g-tools .g-name{margin-right:auto;font-weight:800;font-size:1.05rem;letter-spacing:-.02em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.g-tools button{flex:none;width:40px;height:40px;padding:0;border-radius:12px;border:1.5px solid var(--line);background:var(--surface);color:var(--ink);
  display:grid;place-items:center;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:background .12s,border-color .12s}
.g-tools button:hover{border-color:var(--cobalt)}
.g-tools button:active{background:var(--cobalt-soft)}
.g-tools button:disabled{opacity:.35;cursor:default}
.g-tools button[aria-pressed="true"]{color:var(--muted)}
.g-tools svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

/* Shared tool-page pieces */
.tool-head{padding:32px 0 8px;max-width:720px}
.tool-head h1{font-size:clamp(2rem,5vw,3rem);line-height:1.05;letter-spacing:-.03em;font-weight:800;margin:0 0 10px}
.tool-head p{color:var(--muted);margin:0;font-size:1.08rem;max-width:52ch}
.note{font-size:.88rem;color:var(--muted);border-left:3px solid var(--line);padding-left:14px;margin:0}
@media (max-width:520px){.site-nav{gap:12px}.site-nav a{font-size:.85rem}}
