:root {
  color-scheme:light;
  --paper:#fbf5ec; --ink:#413024; --edge:#d9cfc1; --hover:#eee5d9; --focus:#925b36; --muted:#756456; --control:rgba(251,245,236,.86);
  --h:100vh; --pad:max(7px,env(safe-area-inset-top));
  background:var(--paper); color:var(--ink);
  font-family:"PingFang SC","Hiragino Sans GB","Microsoft YaHei",system-ui,sans-serif;
}
@supports (height:100svh) { :root { --h:100svh; } }
:root[data-theme="dark"] {
  color-scheme:dark;
  --paper:#141923; --ink:#eaedf3; --edge:#465264; --hover:#293241; --focus:#c4d9f7; --muted:#aab6c8; --control:rgba(23,31,44,.88);
}
* { box-sizing:border-box; }
body { min-height:var(--h); margin:0; padding:var(--pad) 7px; display:grid; place-items:center; -webkit-tap-highlight-color:transparent; }
main { width:100%; min-width:0; }
#viewer { --w:max(1px,calc((var(--h) - 2*var(--pad) - 106px)*.5625)); display:flex; flex-direction:column; align-items:center; width:100%; }
.playfield { position:relative; width:min(100%,var(--w)); }
#stage {
  position:relative; width:100%; aspect-ratio:9/16; overflow:hidden; isolation:isolate;
  border-radius:clamp(12px,1.32vw,23px); background:var(--hover);
  touch-action:none; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none;
}
#stage.petting { cursor:none; }
#stage canvas { position:absolute; inset:0; width:100%; height:100%; display:block; pointer-events:none; }
:root[data-theme="dark"] #scene { filter:url(#moonlight) brightness(.6); }
#status { position:absolute; inset:0; display:grid; place-items:center; background:var(--paper); }
[data-ready] #status { display:none; }
[data-error] #status { padding:24px; text-align:center; }
.spinner { width:34px; height:34px; border:3px solid var(--edge); border-top-color:var(--focus); border-radius:50%; animation:spin .8s linear infinite; }
@keyframes spin { to { transform:rotate(1turn); } }
#cue { position:absolute; left:50%; top:55.5%; pointer-events:none; }
#cue i { position:absolute; left:-22px; top:-22px; width:44px; height:44px; border:2px solid #fffaf0; border-radius:50%; box-shadow:0 0 5px #0006; animation:ring 1.6s ease-out infinite; }
#cue i+i { animation-delay:.5s; }
@keyframes ring { from { opacity:1; transform:scale(.35); } to { opacity:0; transform:scale(1.35); } }
button { color:inherit; font:inherit; touch-action:manipulation; cursor:pointer; }
button:focus-visible, a:focus-visible, #stage:focus-visible { outline:3px solid var(--focus); outline-offset:2px; }
.icon-button { display:grid; place-items:center; flex:none; width:44px; height:44px; padding:10px; border:0; border-radius:50%; background:transparent; }
.icon-button svg { width:23px; height:23px; fill:none; stroke:currentColor; stroke-width:1.85; stroke-linecap:round; stroke-linejoin:round; }
@media (hover:hover) { .icon-button:hover { background:var(--hover); } }
#theme { position:absolute; top:9px; right:9px; background:var(--control); box-shadow:inset 0 0 0 1px var(--edge); }
:root[data-theme="dark"] #theme .moon, :root:not([data-theme="dark"]) #theme .sun,
#sound[aria-checked="false"] .waves, #sound[aria-checked="true"] .muted,
#expand[aria-pressed="false"] .exit, #expand[aria-pressed="true"] .full { display:none; }
.toolbar { display:flex; align-items:center; justify-content:flex-end; width:min(100%,max(var(--w),366px)); gap:4px; padding-top:6px; }
.coats { flex:1; min-width:0; max-width:270px; margin-right:auto; display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:2px; }
.coats button { position:relative; display:grid; place-items:center; appearance:none; justify-self:center; width:100%; max-width:46px; aspect-ratio:1; padding:3px; border:2px solid transparent; border-radius:50%; background:transparent; }
.coats span { display:block; width:100%; aspect-ratio:1; border-radius:50%; background:#eee center/cover; box-shadow:inset 0 0 0 1px #0002; }
.coats button[aria-pressed="true"] { border-color:var(--ink); }
.coats button[aria-pressed="true"]::after {
  content:""; position:absolute; right:-1px; bottom:0; width:15px; height:15px; border:2px solid var(--paper); border-radius:50%;
  background:#413024 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='m3 7 2.4 2.4L11 4.4' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100%;
}
@media (hover:hover) { .coats button:not([aria-pressed="true"]):hover { border-color:var(--edge); } }
footer { margin-top:6px; font-size:.8rem; }
footer nav { display:flex; justify-content:center; align-items:center; gap:8px; }
footer a { color:var(--muted); padding:5px 0; text-underline-offset:3px; }
footer details { max-width:480px; margin:2px auto 0; text-align:center; color:var(--muted); font-size:.72rem; }
footer summary { cursor:pointer; }
.sr { position:absolute; overflow:hidden; clip-path:inset(50%); width:1px; height:1px; margin:0; }
#viewer:fullscreen, #viewer.full { --w:max(1px,calc((var(--h) - 72px)*.5625)); position:fixed; inset:0; z-index:10; height:var(--h); padding:var(--pad) 7px; justify-content:center; background:var(--paper); }
