*, *::before, *::after { box-sizing: border-box; }

html {
  min-width: 320px;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 18px);
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(23, 26, 25, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 32px;
  font: 16px/1.62 var(--sans);
  text-rendering: optimizeLegibility;
}

body.battle-page { background: var(--command); }

img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 750; text-wrap: balance; }
h1 { letter-spacing: -0.035em; }
p { text-wrap: pretty; }

.container {
  width: min(var(--container), calc(100% - 2 * var(--gutter)));
  margin-inline: auto;
}

.reading { max-width: var(--reading); }
.eyebrow {
  margin: 0 0 12px;
  color: var(--copper-dark);
  font: 700 0.72rem/1.2 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

html:lang(ja) .eyebrow,
html:lang(zh-Hans) .eyebrow {
  letter-spacing: 0.08em;
}

.lede {
  max-width: 62ch;
  color: var(--ink-soft);
  font-size: clamp(1.04rem, 1.4vw, 1.25rem);
  line-height: 1.55;
}

.muted { color: var(--muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: white;
  background: var(--focus);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

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

::selection { color: var(--paper-light); background: var(--oxblood-dark); }

.loading-state,
.error-state {
  min-height: 55vh;
  display: grid;
  place-items: center;
  padding: 80px var(--gutter);
  text-align: center;
}
.loading-state span {
  width: 42px;
  height: 42px;
  border: 2px solid var(--line);
  border-top-color: var(--copper);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.error-state h1 { font-size: clamp(2.2rem, 6vw, 5rem); margin-bottom: 12px; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  :root { --header-h: 64px; }
  body { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (forced-colors: active) {
  :focus-visible { outline: 3px solid CanvasText; }
}
