/* Luanti
 * SPDX-License-Identifier: LGPL-2.1-or-later
 * Copyright (C) 2026 The Luanti Contributors
 */

:root {
	color-scheme: dark;
	font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-synthesis: none;
	--ink: #f1f5ed;
	--muted: #aebcad;
	--panel: rgba(18, 29, 22, .9);
	--panel-solid: #142019;
	--line: rgba(202, 225, 201, .16);
	--leaf: #a6d85f;
	--leaf-dark: #203d26;
	--danger: #ffb2a9;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; background: #0c1510; color: var(--ink); }
body { min-height: 100vh; min-height: 100dvh; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, canvas:focus-visible {
	outline: 3px solid rgba(166, 216, 95, .72);
	outline-offset: 2px;
}

.launcher {
	min-height: 100vh;
	min-height: 100dvh;
	display: grid;
	grid-template-columns: minmax(0, 1.05fr) minmax(320px, 540px);
	gap: clamp(2rem, 7vw, 7rem);
	align-items: center;
	padding: clamp(2rem, 6vw, 6.5rem);
	background:
		radial-gradient(circle at 10% 15%, rgba(83, 129, 73, .28), transparent 34rem),
		linear-gradient(125deg, rgba(7, 14, 9, .2), rgba(4, 9, 6, .86)),
		repeating-linear-gradient(45deg, rgba(255,255,255,.018) 0 1px, transparent 1px 16px),
		#0d1711;
}

.hero { max-width: 720px; }
.brand-mark {
	width: 56px; height: 56px; position: relative; margin-bottom: 2rem;
	background: linear-gradient(145deg, #b2e870, #5c9546); transform: rotate(30deg);
	border-radius: 13px 23px 12px 21px; box-shadow: 0 18px 50px rgba(61, 114, 57, .3);
}
.brand-mark::before, .brand-mark::after, .brand-mark span {
	content: ""; position: absolute; inset: 13px; border: 4px solid #122118; border-radius: 4px;
}
.brand-mark::after { inset: 22px -7px 22px 22px; border-width: 4px 0 0; }
.brand-mark span { inset: -5px 22px 22px 22px; border-width: 0 0 0 4px; }
.eyebrow { margin: 0 0 .7rem; color: var(--leaf); font-size: .78rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
h1 { max-width: 13ch; margin: 0; font-size: clamp(3rem, 6.6vw, 7rem); font-weight: 760; letter-spacing: -.065em; line-height: .94; }
.lede { max-width: 34rem; margin: 1.8rem 0; color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.3rem); line-height: 1.6; }
.feature-row { display: flex; flex-wrap: wrap; gap: .65rem; }
.feature-row span { padding: .45rem .75rem; border: 1px solid var(--line); border-radius: 999px; color: #cbd7c9; font-size: .78rem; }

.launch-card {
	padding: clamp(1.3rem, 3vw, 2.2rem);
	border: 1px solid var(--line); border-radius: 24px;
	background: var(--panel); box-shadow: 0 32px 90px rgba(0, 0, 0, .38);
	backdrop-filter: blur(20px);
}
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; margin-bottom: 1.5rem; padding: .3rem; border-radius: 12px; background: rgba(0,0,0,.23); }
.tab { padding: .75rem; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 700; }
.tab.is-active { background: var(--leaf-dark); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(166,216,95,.14); }
.auth-controls { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 0 1.25rem; padding: .75rem .85rem; border: 1px solid var(--line); border-radius: 11px; background: rgba(0,0,0,.16); }
.auth-controls[hidden] { display: none; }
.auth-label, .auth-status { display: block; }
.auth-label { color: var(--muted); font-size: .72rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.auth-status { margin-top: .2rem; color: #d7e1d5; font-size: .78rem; }
.auth-status[data-state="signed-in"] { color: var(--leaf); }
.auth-status[data-state="error"] { color: var(--danger); }
.auth-button { flex: 0 0 auto; padding: .55rem .75rem; border: 1px solid rgba(166,216,95,.48); border-radius: 8px; background: var(--leaf-dark); color: var(--ink); font-size: .8rem; font-weight: 750; text-decoration: none; }
.auth-button:hover { border-color: var(--leaf); background: rgba(166,216,95,.18); }
.auth-button[hidden] { display: none; }
label { display: block; margin: 1rem 0 .45rem; color: #d7e1d5; font-size: .82rem; font-weight: 700; }
input, select {
	width: 100%; min-height: 46px; padding: 0 .85rem; border: 1px solid var(--line); border-radius: 10px;
	background: rgba(2, 7, 4, .42); color: var(--ink);
}
input::placeholder { color: #728172; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.address-grid { grid-template-columns: minmax(0, 1fr) 100px; }
.world-save-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .8rem; align-items: end; }
.world-save-row > div { min-width: 0; }
.world-new-button { min-height: 46px; margin: 0 0 .05rem; padding: 0 .8rem; border: 1px solid var(--line); border-radius: 10px; }
.field-note { margin: .5rem 0 0; color: #829181; font-size: .75rem; line-height: 1.4; }
.advanced { margin: 1.25rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.advanced summary { padding: .85rem 0; color: var(--muted); cursor: pointer; font-size: .84rem; font-weight: 700; }
.advanced[open] { padding-bottom: 1rem; }
.text-button { margin-top: .7rem; padding: 0; border: 0; background: transparent; color: var(--leaf); font-size: .82rem; font-weight: 750; }
.server-list { max-height: 210px; margin-top: .7rem; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.server-entry { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem 1rem; padding: .75rem; border: 0; border-bottom: 1px solid var(--line); background: rgba(0,0,0,.16); color: var(--ink); text-align: left; }
.server-entry:last-child { border-bottom: 0; }
.server-entry:hover { background: rgba(166,216,95,.08); }
.server-entry small { color: var(--muted); white-space: nowrap; }
.server-address { grid-column: 1 / -1; color: #829181; font-size: .7rem; }
.inline-status { margin-top: .6rem; color: var(--muted); font-size: .75rem; }
.inline-status[data-state="ready"] { color: var(--leaf); }
.form-error { margin: .75rem 0; padding: .65rem .75rem; border-radius: 8px; background: rgba(111, 36, 31, .55); color: var(--danger); font-size: .8rem; white-space: pre-wrap; }
.play-button {
	width: 100%; min-height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 1.1rem;
	border: 0; border-radius: 12px; background: var(--leaf); color: #142016; font-weight: 850;
}
.play-button:hover:not(:disabled) { background: #b9ea76; transform: translateY(-1px); }
.play-button:disabled { cursor: wait; opacity: .52; }
.mobile-warning { margin: 1rem 0 0; padding: .75rem; border-radius: 9px; background: rgba(135, 91, 27, .24); color: #f1d3a0; font-size: .78rem; line-height: 1.4; }

.game-shell { position: fixed; inset: 0; overflow: hidden; background: #050806; }
#canvas { display: block; width: 100%; height: 100%; border: 0; outline: 0; }
.loading-panel { position: absolute; inset: 0; z-index: 4; display: grid; place-content: center; justify-items: center; padding: 2rem; background: radial-gradient(circle, #1d3123, #09100c 65%); text-align: center; }
.loading-panel[hidden] { display: none; }
.loading-mark { width: 42px; height: 42px; margin-bottom: 1.7rem; animation: breathe 1.7s ease-in-out infinite; }
.loading-panel h2 { max-width: 36rem; margin: 0; font-size: clamp(1.35rem, 3vw, 2.2rem); }
.progress-track { width: min(360px, 72vw); height: 4px; margin-top: 1.5rem; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.12); }
.progress-value { width: 12%; height: 100%; border-radius: inherit; background: var(--leaf); transition: width .2s ease; }
.persistence-toast { position: absolute; z-index: 6; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); max-width: min(28rem, calc(100% - 24px)); }
#luanti-persistence-status, #luanti-persistence-error { padding: .55rem .8rem; border-radius: 9px; background: rgba(7,13,9,.85); font-size: .75rem; }
#luanti-persistence-status[data-state="saved"] { color: var(--leaf); }
#luanti-persistence-error { margin-top: .5rem; background: #61231f; color: var(--danger); white-space: pre-wrap; }
.game-tools { position: absolute; z-index: 5; left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); display: flex; gap: .45rem; opacity: .42; transition: opacity .2s; }
.game-tools:hover, .game-tools:focus-within { opacity: 1; }
.game-tools button, .console-panel button, .resume-panel button { padding: .55rem .72rem; border: 1px solid var(--line); border-radius: 8px; background: rgba(7,13,9,.82); color: var(--ink); }
.console-panel { position: absolute; z-index: 6; left: 12px; right: 12px; bottom: 58px; max-height: 44vh; padding: .7rem; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: rgba(4,8,5,.95); }
.console-panel:not([open]) { display: none; }
.console-panel summary { color: var(--muted); }
.console-panel pre { min-height: 5rem; white-space: pre-wrap; overflow-wrap: anywhere; color: #b9c7b7; font: .72rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; }
/* A small corner hint, not a full-canvas overlay: the engine releases
 * pointer lock for its own GUI too (inventory, formspecs, pause menu), and
 * those need clicks to reach the canvas underneath, not this panel. */
.resume-panel { position: absolute; z-index: 3; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: grid; justify-items: center; gap: .3rem; padding: .55rem; border: 1px solid var(--line); border-radius: 10px; background: rgba(4, 8, 5, .88); }
.resume-panel[hidden] { display: none; }
.resume-panel button { padding: .55rem .72rem; background: var(--leaf); color: #142016; font-weight: 800; }
.resume-panel p { margin: 0; font-size: .7rem; color: var(--muted); }
.touch-controls { position: absolute; z-index: 4; inset: 0; overflow: hidden; pointer-events: none; touch-action: none; user-select: none; -webkit-user-select: none; }
.touch-controls[hidden], body:not(.has-touch) .touch-controls { display: none !important; }
.touch-look { position: absolute; inset: 0 34% 0 0; pointer-events: auto; touch-action: none; }
.touch-dpad { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: max(18px, calc(env(safe-area-inset-bottom) + 18px)); width: clamp(150px, 30vw, 230px); height: clamp(150px, 30vw, 230px); pointer-events: none; }
.touch-actions { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(18px, calc(env(safe-area-inset-bottom) + 18px)); display: grid; grid-template-columns: repeat(2, minmax(60px, 1fr)); gap: .55rem; width: min(34vw, 250px); pointer-events: none; }
.touch-button { display: grid; place-items: center; min-width: clamp(48px, 9vw, 70px); min-height: clamp(48px, 9vw, 70px); padding: .25rem; border: 1px solid rgba(222, 245, 213, .42); border-radius: 14px; background: rgba(7, 13, 9, .58); box-shadow: 0 8px 22px rgba(0, 0, 0, .25); color: var(--ink); font-size: clamp(.7rem, 1.8vw, .88rem); font-weight: 800; pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent; }
.touch-button:active, .touch-button.is-pressed { background: rgba(166, 216, 95, .78); border-color: var(--leaf); color: #142016; transform: scale(.96); }
.touch-dpad .touch-button { position: absolute; }
.touch-up { left: 50%; top: 0; transform: translateX(-50%); }
.touch-left { left: 0; top: 50%; transform: translateY(-50%); }
.touch-down { left: 50%; bottom: 0; transform: translateX(-50%); }
.touch-right { right: 0; top: 50%; transform: translateY(-50%); }
.touch-dpad .touch-up:active, .touch-dpad .touch-down:active { transform: translateX(-50%) scale(.96); }
.touch-dpad .touch-left:active, .touch-dpad .touch-right:active { transform: translateY(-50%) scale(.96); }
.touch-actions .touch-button { min-width: 0; }
.touch-jump { grid-column: 1; }
.touch-menu { grid-column: 2; }
.touch-menu { background: rgba(20, 32, 22, .76); }
.game-shell:fullscreen { width: 100vw; height: 100vh; }
@keyframes breathe { 50% { transform: rotate(35deg) scale(1.08); filter: brightness(1.18); } }

@media (max-width: 860px) {
	.launcher { grid-template-columns: 1fr; align-content: start; gap: 2.5rem; padding: 2rem max(1rem, env(safe-area-inset-left)); }
	.hero { padding-top: 1rem; }
	h1 { font-size: clamp(3rem, 13vw, 5.2rem); }
	.brand-mark { margin-bottom: 1.4rem; }
}
@media (max-width: 480px) {
	.field-grid { grid-template-columns: 1fr; gap: 0; }
	.address-grid { grid-template-columns: minmax(0, 1fr) 88px; gap: .7rem; }
	.launch-card { border-radius: 17px; }
}
@media (orientation: portrait) and (max-width: 700px) {
	.touch-look { right: 38%; }
	.touch-dpad { transform: scale(.88); transform-origin: bottom left; }
	.touch-actions { width: min(42vw, 220px); transform: scale(.88); transform-origin: bottom right; }
}
@media (orientation: landscape) and (max-height: 600px) {
	.touch-dpad { left: max(10px, env(safe-area-inset-left)); bottom: max(10px, calc(env(safe-area-inset-bottom) + 10px)); transform: scale(.82); transform-origin: bottom left; }
	.touch-actions { right: max(10px, env(safe-area-inset-right)); bottom: max(10px, calc(env(safe-area-inset-bottom) + 10px)); transform: scale(.82); transform-origin: bottom right; }
}
/* Theater Tier B: the browser video overlay (client/web/theater.js).
 * z-index 7 puts it above the resume panel (3) and the persistence toast (6);
 * the engine has released pointer lock by the time it appears, so its own
 * controls have to be the thing a click reaches. */
.theater-overlay { position: absolute; z-index: 7; inset: 0; display: grid; grid-template-rows: 1fr auto; gap: .6rem; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); background: rgba(3, 6, 4, .92); }
.theater-overlay[hidden] { display: none; }
.theater-overlay:focus { outline: none; }
.theater-stage { position: relative; display: grid; place-items: center; min-height: 0; border: 1px solid var(--line); border-radius: 12px; background: #050806; overflow: hidden; }
.theater-stage video { max-width: 100%; max-height: 100%; background: #000; }
.theater-stage video[hidden] { display: none; }
.theater-message { max-width: 34rem; margin: 0; padding: 1.4rem; color: var(--muted); font-size: .9rem; text-align: center; }
.theater-message[hidden] { display: none; }
.theater-bar { display: flex; align-items: center; gap: .5rem; }
.theater-caption { flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--ink); font-size: .85rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.theater-bar button { padding: .55rem .9rem; border: 1px solid var(--line); border-radius: 8px; background: rgba(7, 13, 9, .82); color: var(--ink); font: inherit; font-size: .8rem; cursor: pointer; }
.theater-bar button:hover { border-color: var(--leaf); }

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