/* Base reset and page layout. Owned by the UI agent. */

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

html {
  /* 1rem = 16px at 1280x720; scales with the smaller of the two viewport ratios. */
  font-size: clamp(11px, min(1.25vw, 2.2222vh), 48px);
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--c-bg-0);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
p,
ul,
ol,
figure {
  margin: 0;
  padding: 0;
}

ul,
ol {
  list-style: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
}

button:disabled,
button.is-disabled {
  cursor: not-allowed;
}

input,
textarea {
  -webkit-user-select: text;
  user-select: text;
}

[hidden] {
  display: none !important;
}

/* ── Layers ── */
#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: var(--z-canvas);
  touch-action: none;
  background: var(--c-bg-0);
}

#ui {
  position: fixed;
  inset: 0;
  z-index: var(--z-screen);
  pointer-events: none; /* clicks fall through to the canvas except on real controls */
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ── Screens and overlays: shown only with .is-active (opacity/visibility so transitions can be added) ── */
.screen,
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.screen.is-active,
.overlay.is-active {
  opacity: 1;
  visibility: visible;
}

/* ── Focus ring (keyboard only) ── */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--c-white-hot);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(0, 229, 255, 0.35);
}

/* ── Scrollbars ── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--c-line) transparent;
}

::-webkit-scrollbar {
  width: 0.55rem;
  height: 0.55rem;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--c-line);
  border-radius: 1rem;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--c-text-mute);
  background-clip: padding-box;
  border: 2px solid transparent;
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  :focus-visible {
    outline-color: Highlight;
    box-shadow: none;
  }
}
