/* Base styles of the client: design tokens, resets, utilities and the page shell.
   UI modules use the tokens (var(--panel), var(--accent), ...) and add their own stylesheet
   with loadStyle() (js/core/ui.js). */

:root {
	--bg: #0d1016;
	--bg-2: #141923;
	--panel: rgba(17, 21, 30, 0.92);
	--panel-solid: #161b26;
	--line: #2a3242;
	--line-2: #3a4458;
	--text: #e7e9ee;
	--muted: #8d96a8;
	--accent: #e0523c;
	--accent-2: #f07a5f;
	/* fills behind white text: #c9412c is 4.9:1, #a93524 is 6.4:1 (WCAG AA) */
	--accent-fill: #c9412c;
	--accent-fill-hover: #a93524;
	--teal: #4fb3a9;
	--gold: #e8b64c;
	--hp: #d9483b;
	--sp: #3f7fe0;
	--xp: #c9a227;
	--jxp: #4fb3a9;
	--danger: #ff6b5e;
	--radius: 10px;
	--shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--mono: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace;
	color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
	background: radial-gradient(1200px 700px at 20% -10%, #1d2433 0%, var(--bg) 60%) fixed;
	color: var(--text);
	font: 14px/1.45 var(--font);
	overflow: hidden;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: 0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

.panel {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	backdrop-filter: blur(6px);
}

/* --- shell: the 3D view (#world) under the UI layer (#ui-layer) ------------------------
   #ui-layer lets the pointer through to the 3D view except where a module draws something:
   direct children get pointer events back (full-screen containers turn them off again). */
#ui-layer { position: fixed; inset: 0; pointer-events: none; }
body[data-screen="game"] {
	--hud-ink: #252927;
	--hud-paper: #f2e6ca;
	--hud-red: #973f32;
	--hud-gold: #c5a367;
	--hud-rule: #b7a17c;
	--hud-display: Georgia, "Times New Roman", serif;
}
:where(#ui-layer > *) { pointer-events: auto; }
/* body[data-screen] is login | chars | game; .game-only hides an element outside the game */
body:not([data-screen="game"]) #world,
body:not([data-screen="game"]) .game-only { display: none !important; }
/* until the UI modules have mounted and loaded their styles (body[data-ready], js/core/ui.js) */
body:not([data-ready]) #ui-layer { opacity: 0; }

/* --- screens, form controls, buttons ---------------------------------------------------
   .screen sections (login, characters) are toggled by show() in js/core/game.js. */
.screen { display: none; position: fixed; inset: 0; }
.screen.active { display: block; }
label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 550; }
input, select {
	font: inherit;
	color: var(--text);
	background: var(--bg-2);
	border: 1px solid var(--line-2);
	border-radius: 8px;
	padding: 9px 11px;
	min-width: 0;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder { color: #8d96a8; opacity: 1; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(224, 82, 60, 0.22); }
label.check, label.radio { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; font-size: 13px; }
label.check input, label.radio input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
button {
	font: inherit;
	font-weight: 600;
	color: var(--text);
	background: #232a38;
	border: 1px solid var(--line-2);
	border-radius: 8px;
	padding: 9px 16px;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease, transform 0.06s ease;
}
button:hover { background: #2b3445; }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: 0.55; cursor: progress; }
button.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
button.primary:hover { background: var(--accent-fill-hover); border-color: var(--accent-fill-hover); }
button.ghost { background: transparent; }
button.ghost:hover { background: rgba(255, 255, 255, 0.06); }
button.icon { width: 34px; height: 34px; padding: 0; font-size: 18px; line-height: 1; }
button.small-btn { padding: 7px 12px; font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; }
.row.end { justify-content: flex-end; }
.status { min-height: 1.4em; margin: 0; font-size: 13px; color: var(--muted); }
.status.error { color: var(--danger); }
.nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
	* { transition: none !important; }
}
