/* Base: reset, type, screens. Uses tokens only. */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--c-sea);
  color: var(--n-ink);
  font: 400 var(--fs-16)/var(--lh-body) var(--f-body);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
body:has(#app[data-world="orbit"]) { background: var(--c-dusk); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; }
h1, h2, h3 { margin: 0; font-family: var(--f-display); font-weight: 800; line-height: var(--lh-tight); letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: var(--fs-32); }
h3 { font-size: var(--fs-20); }
p { margin: 0; }
small { font-size: var(--fs-14); color: var(--ink-soft); }
kbd { font: 700 var(--fs-12)/1 var(--f-body); padding: 3px 7px; border-radius: 6px; background: var(--paper-2); border: var(--bw) solid var(--ink-faint); border-bottom-width: 3px; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.min0 { min-width: 0; }
.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 3px solid var(--c-sun); outline-offset: 2px; }

#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* Screens sit above the canvas. Paper surfaces float over the calm world scene. */
.screen {
  position: fixed; inset: 0; overflow-y: auto; touch-action: pan-y;
  padding-top: calc(env(safe-area-inset-top, 0px) + var(--s-4));
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--s-6));
  padding-left: max(var(--s-4), env(safe-area-inset-left, 0px));
  padding-right: max(var(--s-4), env(safe-area-inset-right, 0px));
  animation: screen-in var(--t-slow) var(--ease-out);
}
.screen--modal { display: grid; place-items: center; background: color-mix(in srgb, var(--n-ink) 45%, transparent); }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Paper grain: one shared texture, used at very low strength on paper surfaces */
:root { --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .11 0 0 0 0 .16 0 0 0 0 .19 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }

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

/* Large monitors: scale the whole interface so it never looks lost on a wide screen */
@media (min-width: 1700px) and (min-height: 950px) { .screen, .hud__bar, .hint, .toast, .wave-banner { zoom: 1.15; } }
@media (min-width: 2200px) and (min-height: 1250px) { .screen, .hud__bar, .hint, .toast, .wave-banner { zoom: 1.4; } }
