/* MultiCraft — base layer (round 6): reset, the one UI scale, type roles, icons, focus, scroll fades, motion rules.
   Owner: foundation (shared, read-only). Tokens: tokens.css. Components: components.css. Shell: style.css. */

/* The `hidden` attribute must always win over component display rules. */
[hidden] { display: none !important; }

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* ONE scale (SPEC 2.6): rem = 16 px x --ui-scale for every menu surface. body keeps the round-5 HUD base so everything
   that still inherits its size (HUD, slot screens, CSS-in-JS) renders exactly as before. */
html { font-size: calc(16px * var(--ui-scale)); }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg-app); color: var(--text-1);
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
body {
  font-family: var(--font-ui); font-size: calc(15px * var(--gui-scale)); line-height: 1.45;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  font-synthesis-weight: none;
}
/* menus: a drag anywhere (cards, images, the gaps between them) scrolls the page under it; play keeps touch-action none */
html:not(.playing) body { touch-action: pan-x pan-y; }
input, textarea, select { -webkit-user-select: text; user-select: text; touch-action: manipulation; font: inherit; color: inherit; }
button { font: inherit; color: inherit; touch-action: manipulation; }
h1, h2, h3, h4, h5, p, figure, ul, ol { margin: 0; }
ul, ol { padding: 0; }
a { color: var(--amber-200); }
p { text-wrap: pretty; }
:focus { outline: none; }
::selection { background: rgba(255, 178, 63, .32); color: var(--text-0); }

/* pixel art is opt-in in the menus (photos stay smooth); in-game surfaces keep the round-5 pixelated default */
img, canvas { image-rendering: pixelated; }
:where(.menu-root, .dlg-root, .toast-lane, #boot) img:not(.px) { image-rendering: auto; }
.px, img.px, .px img, .px canvas { image-rendering: pixelated; }

#game-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; z-index: 0; touch-action: none; outline: none; }
#ui { position: fixed; inset: 0; z-index: 10; pointer-events: none; overflow: hidden; }
/* Interactive elements opt in (zero specificity so module styles can override). */
:where(#ui) :where(button, input, select, textarea, a, label, summary, [role="button"], .menu-root, .dlg-root, .modal-backdrop, .toast, .pop-menu, .scr-root, [class^="touch-"], [class*=" touch-"]) { pointer-events: auto; }
#ui.ui-hidden :where([class^="touch-"], [class*=" touch-"]) { visibility: hidden !important; }

/* menu surfaces read the rem scale (SPEC R5); in-game layers keep their own sizes */
.menu-root, .dlg-root, .toast-lane, .ui-tooltip, .pop-menu { font-size: var(--fs-md); line-height: var(--lh-body); font-family: var(--font-ui); }

/* ---------------------------------------------------------------- screen-reader text + helpers */
.sr, .sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.grow { flex: 1 1 auto; min-width: 0; }
.nowrap { white-space: nowrap; }
.ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- icons (uiIcons.js: 24 grid, 2 px round, currentColor) */
.ico { flex: none; display: block; }
.i { width: 1.25rem; height: 1.25rem; flex: none; }
.i-sm { width: 1rem; height: 1rem; }
.i-lg { width: 1.5rem; height: 1.5rem; }

/* ---------------------------------------------------------------- type roles (SPEC 3.4) */
.display { margin: 0; font-family: var(--font-display); font-weight: 800; text-transform: uppercase; letter-spacing: var(--tr-display);
  line-height: var(--lh-display); color: var(--text-0); font-feature-settings: "tnum" 1, "lnum" 1; font-synthesis: none; text-wrap: balance; }
.display.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.d1 { font-size: var(--fs-d1); } .d2 { font-size: var(--fs-d2); } .d3 { font-size: var(--fs-d3); }
.d4 { font-size: var(--fs-d4); } .d5 { font-size: var(--fs-d5); }
.mtitle { font-family: var(--font-display); font-weight: 800; text-transform: uppercase; font-size: 1.5rem; line-height: .95; letter-spacing: .01em;
  color: var(--text-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kicker { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: var(--fs-k1); letter-spacing: var(--tr-kicker);
  text-transform: uppercase; color: var(--amber-200); line-height: 1.1; }
.kicker.sm { font-size: var(--fs-k2); }
.kicker.muted { color: var(--text-3); }
.kicker.ok { color: var(--success-text); }
/* künye: the billing block (ONE line, items separated by a thin dot, numbers tabular) */
.kunye { display: flex; flex-wrap: wrap; align-items: center; gap: .15em .7em; margin: 0; min-width: 0;
  font-family: var(--font-display); font-weight: 600; font-size: var(--fs-k1); letter-spacing: var(--tr-kunye);
  text-transform: uppercase; color: var(--text-2); line-height: 1.2; font-feature-settings: "tnum" 1, "lnum" 1; }
.kunye > * + *::before { content: ""; display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: currentColor;
  opacity: .55; vertical-align: middle; margin-right: .7em; transform: translateY(-.12em); }
.kunye.sm { font-size: var(--fs-k2); }
.kunye.xs { font-size: var(--fs-k3); letter-spacing: .06em; }
.kunye.one { flex-wrap: nowrap; white-space: nowrap; overflow: hidden; }
.kunye b { font-weight: 700; color: var(--text-0); }
.kunye .ok { color: var(--success-text); } .kunye .acc { color: var(--amber-200); } .kunye .bad { color: var(--danger-text); }
.num { font-family: var(--font-display); font-weight: 700; font-feature-settings: "tnum" 1, "lnum" 1; letter-spacing: .01em; }
.num.n1 { font-size: var(--fs-n1); line-height: 1; } .num.n2 { font-size: var(--fs-n2); line-height: 1; } .num.n3 { font-size: var(--fs-n3); line-height: 1.1; }
.tnum { font-variant-numeric: tabular-nums; }
.t-2xl { margin: 0; font-size: var(--fs-2xl); font-weight: 700; line-height: 1.2; letter-spacing: -.01em; color: var(--text-0); }
.t-xl { margin: 0; font-size: var(--fs-xl); font-weight: 600; line-height: 1.25; letter-spacing: -.005em; color: var(--text-0); }
.t-lg { margin: 0; font-size: var(--fs-lg); font-weight: 600; line-height: 1.3; color: var(--text-0); }
.t-md { font-size: var(--fs-md); } .t-sm { font-size: var(--fs-sm); } .t-xs { font-size: var(--fs-xs); font-weight: 500; }
.muted { color: var(--text-2); } .dim { color: var(--text-3); }
.prose { max-width: 60ch; line-height: var(--lh-body); }
@media (max-width: 599px) {
  .d1 { font-size: 2.75rem; } .display.d2, .display.d3 { font-size: var(--fs-d4); }
  .mtitle { font-size: 1.25rem; }
  .t-2xl { font-size: 1.5rem; } .t-xl { font-size: 1.25rem; } .t-lg { font-size: 1.0625rem; }
}

/* ---------------------------------------------------------------- focus (keyboard / gamepad only; never removed) */
:where(.menu-root, .dlg-root, .toast-lane, .pop-menu) :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: none; box-shadow: 0 0 0 2px var(--bg-app), 0 0 0 4px var(--focus);
}

/* ---------------------------------------------------------------- scroll edges: fade instead of a hard cut (R6) */
.fade-b { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - var(--fade)), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - var(--fade)), transparent); }
.fade-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent); }
.fade-y { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 1.25rem, #000 calc(100% - var(--fade)), transparent); mask-image: linear-gradient(to bottom, transparent, #000 1.25rem, #000 calc(100% - var(--fade)), transparent); }
/* JS (dom.js scrollFade) toggles .at-start / .at-end so a list that is fully visible shows no fade */
.fade-b.at-end, .fade-r.at-end { -webkit-mask-image: none; mask-image: none; }
.fade-y.at-start.at-end { -webkit-mask-image: none; mask-image: none; }
.fade-y.at-start:not(.at-end) { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - var(--fade)), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - var(--fade)), transparent); }
.fade-y.at-end:not(.at-start) { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 1.25rem); mask-image: linear-gradient(to bottom, transparent, #000 1.25rem); }
.scroll-y { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: var(--carbon-5) transparent; }
.scroll-x { overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; touch-action: pan-x; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }

/* ---------------------------------------------------------------- keyframes (one set; old duplicates removed) */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(1.5rem); } to { opacity: 1; transform: none; } }
@keyframes sink { to { opacity: 0; transform: translateY(1rem); } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheetDown { to { transform: translateY(100%); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-.75rem); } to { opacity: 1; transform: none; } }
@keyframes toastInUp { from { opacity: 0; transform: translateY(.75rem); } to { opacity: 1; transform: none; } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes gateRun { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes gateRunY { from { transform: translateY(-100%); } to { transform: translateY(250%); } }
/* legacy names still used by other modules' styles */
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { transform: translateY(6px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes popOut { to { transform: scale(.97); opacity: 0; } }
@keyframes blink { 50% { opacity: .35; } }

/* ---------------------------------------------------------------- reduced motion (media query + in-game setting)
   every transition becomes a cut or a fade; spinners PULSE instead of freezing (UX-37); progress keeps updating */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .spin, .spinner, .gate-run { animation: pulse 1.6s ease-in-out infinite !important; }
  /* indeterminate gate lines (boot band, .gate.run): a still segment that pulses (the travel animation would end off-screen) */
  .gate.run > i, .band-gate.run > i { animation: pulse 1.6s ease-in-out infinite !important; transform: none !important; }
}
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
.reduce-motion .spin, .reduce-motion .spinner, .reduce-motion .gate-run { animation: pulse 1.6s ease-in-out infinite !important; }
.reduce-motion .gate.run > i, .reduce-motion .band-gate.run > i { animation: pulse 1.6s ease-in-out infinite !important; transform: none !important; }
