:root {
	--ink: #f1e3c8;
	--ink-dim: #b9a585;
	--ink-faint: #7d6c55;
	--brass: #c99a4a;
	--brass-dim: #7a5a2a;
	--soot: rgba(18, 13, 10, 0.86);
	--soot-light: rgba(38, 28, 20, 0.9);
	--bad: #e0614a;
	--warn: #e8b04a;
	--good: #8fd07a;
	--water: #6ab8e0;
	--crystal: #7fe9ff;
	--display: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
	--ui: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
	--mono: "Consolas", "Lucida Console", monospace;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
	background: #120d0a;
	color: var(--ink);
	font-family: var(--ui);
	user-select: none;
	-webkit-user-select: none;
	overscroll-behavior: none;
	touch-action: none;
}

canvas#game {
	position: fixed;
	inset: 0;
	width: 100vw;
	height: 100vh;
	display: block;
}

.hidden { display: none !important; }

button {
	font-family: var(--ui);
	color: var(--ink);
	background: linear-gradient(#3a2a1c, #241910);
	border: 1px solid var(--brass-dim);
	border-radius: 3px;
	padding: 7px 14px;
	cursor: pointer;
	font-size: 14px;
	letter-spacing: 0.02em;
}
button:hover:not(:disabled) { border-color: var(--brass); background: linear-gradient(#4a3624, #2c1f14); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { border-color: var(--brass); color: #fff4dc; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

#crosshair {
	position: absolute;
	left: 50%; top: 50%;
	width: 6px; height: 6px;
	margin: -3px 0 0 -3px;
	border-radius: 50%;
	background: rgba(255, 240, 210, 0.85);
	box-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}
#crosshair.active { width: 10px; height: 10px; margin: -5px 0 0 -5px; background: transparent; border: 2px solid var(--brass); }

#holdRing { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; display: none; }
#holdRing svg { width: 100%; height: 100%; transform: rotate(-90deg); }
#holdRing .track { fill: none; stroke: rgba(0, 0, 0, 0.45); stroke-width: 4; }
#holdRing .fill { fill: none; stroke: var(--brass); stroke-width: 4; stroke-dasharray: 100.5; stroke-dashoffset: 100.5; }

#prompt {
	position: absolute;
	left: 50%; top: calc(50% + 34px);
	transform: translateX(-50%);
	text-align: center;
	font-size: 14px;
	text-shadow: 0 1px 3px #000, 0 0 8px #000;
	white-space: nowrap;
}
#prompt .pname { font-family: var(--display); font-size: 17px; color: #fff4dc; margin-bottom: 3px; }
#prompt .pinfo { color: var(--ink-dim); font-size: 12px; margin-bottom: 4px; }
#prompt .act { margin: 2px 0; }
#prompt .act.off { color: var(--ink-faint); }
.key {
	display: inline-block;
	min-width: 20px;
	padding: 0 5px;
	margin-right: 6px;
	border: 1px solid var(--brass);
	border-radius: 3px;
	background: rgba(20, 14, 10, 0.75);
	color: #fff0c8;
	font-family: var(--mono);
	font-size: 12px;
	line-height: 18px;
	text-align: center;
	text-shadow: none;
}

#compass {
	position: absolute;
	top: 10px; left: 50%;
	width: 460px; height: 30px;
	margin-left: -230px;
	overflow: hidden;
	background: linear-gradient(90deg, transparent, var(--soot) 18%, var(--soot) 82%, transparent);
	border-top: 1px solid rgba(201, 154, 74, 0.35);
	border-bottom: 1px solid rgba(201, 154, 74, 0.35);
}
#compassStrip { position: absolute; inset: 0; }
#compassStrip .tick { position: absolute; top: 7px; font-size: 12px; color: var(--ink-dim); transform: translateX(-50%); font-family: var(--mono); }
#compassStrip .tick.card { color: #fff0d0; font-weight: bold; font-size: 13px; top: 6px; }
#compassStrip .mark { position: absolute; top: 3px; transform: translateX(-50%); font-size: 11px; white-space: nowrap; text-align: center; line-height: 12px; }
#compassStrip .mark.city { color: #ffc070; }
#compassStrip .mark.machine { color: var(--crystal); }
#compassNeedle { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--brass); opacity: 0.8; }

#clock {
	position: absolute;
	top: 10px; left: 12px;
	padding: 6px 12px;
	background: var(--soot);
	border-left: 2px solid var(--brass);
	font-size: 13px;
	line-height: 1.45;
}
#clock .day { font-family: var(--display); font-size: 16px; color: #fff0d0; }
#clock .wx { color: var(--ink-dim); }
#clock .wx.warn { color: var(--warn); }
#clock .wx.bad { color: var(--bad); }

#objective {
	position: absolute;
	top: 10px; right: 12px;
	max-width: 330px;
	padding: 8px 12px;
	background: var(--soot);
	border-right: 2px solid var(--brass);
	font-size: 13px;
	line-height: 1.45;
}
#objective .ohead { font-family: var(--display); color: var(--brass); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 3px; }
#objective .otext { color: #fff0d0; }
#objective .otip { color: var(--ink-dim); font-size: 12px; margin-top: 4px; }

#messages {
	position: absolute;
	left: 12px; bottom: 210px;
	width: 440px;
	display: flex;
	flex-direction: column;
	gap: 3px;
	font-size: 13px;
}
#messages .msg { padding: 4px 9px; background: rgba(18, 13, 10, 0.7); border-left: 2px solid var(--ink-faint); text-shadow: 0 1px 2px #000; transition: opacity 0.6s; }
#messages .msg.warn { border-color: var(--warn); }
#messages .msg.bad { border-color: var(--bad); color: #ffd8cc; }
#messages .msg.good { border-color: var(--good); }

#stats {
	position: absolute;
	left: 12px; bottom: 12px;
	width: 250px;
	padding: 9px 11px;
	background: var(--soot);
	border-left: 2px solid var(--brass);
	font-size: 12px;
}
.bar { display: grid; grid-template-columns: 62px 1fr 34px; align-items: center; gap: 7px; margin: 3px 0; }
.bar .lbl { color: var(--ink-dim); }
.bar .track { height: 8px; background: rgba(255, 255, 255, 0.08); border-radius: 2px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 2px; transition: width 0.2s; }
.bar .val { text-align: right; font-family: var(--mono); color: var(--ink-dim); font-size: 11px; }
.bar.low .lbl { color: var(--bad); }
#stats .status { margin-top: 6px; font-size: 11px; color: var(--ink-dim); display: flex; flex-wrap: wrap; gap: 5px; }
#stats .tag { padding: 1px 6px; border: 1px solid var(--ink-faint); border-radius: 2px; }
#stats .tag.bad { border-color: var(--bad); color: var(--bad); }
#stats .tag.good { border-color: var(--good); color: var(--good); }
#stats .tag.warn { border-color: var(--warn); color: var(--warn); }

#machinePanel {
	position: absolute;
	right: 12px; bottom: 12px;
	width: 280px;
	padding: 9px 11px;
	background: var(--soot);
	border-right: 2px solid var(--brass);
	font-size: 12px;
}
#machinePanel .mhead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
#machinePanel .mtitle { font-family: var(--display); color: var(--brass); letter-spacing: 0.08em; text-transform: uppercase; font-size: 12px; }
#machinePanel .mmode { font-family: var(--mono); font-size: 12px; color: #fff0d0; }
#machinePanel .mmode.warn { color: var(--warn); }
#machinePanel .speed { font-family: var(--display); font-size: 22px; color: #fff0d0; }
#machinePanel .speed small { font-size: 12px; color: var(--ink-dim); font-family: var(--ui); }
#machinePanel .steerRow { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 7px; margin: 4px 0; }
#machinePanel .steerTrack { position: relative; height: 10px; background: rgba(255, 255, 255, 0.08); border-radius: 2px; }
#machinePanel .steerTrack .mid { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--ink-faint); }
#machinePanel .steerTrack .pos { position: absolute; top: 1px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--brass); }
#machinePanel .steerTrack .tgt { position: absolute; top: -3px; width: 2px; height: 16px; margin-left: -1px; background: #fff0d0; opacity: 0.6; }
#machinePanel .wheels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 5px; }
#machinePanel .wh { text-align: center; font-family: var(--mono); font-size: 10px; padding: 2px 0; border: 1px solid var(--ink-faint); border-radius: 2px; }
#machinePanel .wh.bad { border-color: var(--bad); color: var(--bad); }
#machinePanel .wh.warn { border-color: var(--warn); color: var(--warn); }
#machinePanel .dist { margin-top: 5px; color: var(--ink-dim); font-size: 11px; }

#hotbar {
	position: absolute;
	left: 50%; bottom: 14px;
	transform: translateX(-50%);
	display: flex;
	gap: 5px;
}
#hotbar .slot {
	width: 62px; height: 54px;
	background: var(--soot);
	border: 1px solid var(--ink-faint);
	border-radius: 3px;
	text-align: center;
	font-size: 11px;
	padding-top: 4px;
	position: relative;
}
#hotbar .slot.sel { border-color: var(--brass); box-shadow: 0 0 8px rgba(201, 154, 74, 0.5); }
#hotbar .slot.off { opacity: 0.35; }
#hotbar .slot .ico { font-size: 20px; line-height: 24px; }
#hotbar .slot .num { position: absolute; top: 2px; left: 4px; font-family: var(--mono); font-size: 10px; color: var(--ink-faint); }
#hotbar .slot .cnt { position: absolute; bottom: 2px; right: 4px; font-family: var(--mono); font-size: 10px; color: var(--ink-dim); }
#hotbar .charge { position: absolute; left: 4px; right: 4px; bottom: -6px; height: 3px; background: var(--brass); transform-origin: left; }

#driveHelp {
	position: absolute;
	left: 50%; bottom: 14px;
	transform: translateX(-50%);
	max-width: calc(100vw - 600px);
	min-width: 300px;
	padding: 7px 12px;
	background: var(--soot);
	border: 1px solid var(--brass-dim);
	border-radius: 3px;
	font-size: 12px;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 6px 14px;
	white-space: nowrap;
}

#buildBar {
	position: absolute;
	left: 50%; bottom: 14px;
	transform: translateX(-50%);
	width: min(1000px, 97vw);
	padding: 0 12px 10px;
	background: linear-gradient(180deg, rgba(46, 32, 21, 0.97), rgba(22, 15, 10, 0.97));
	border: 1px solid #6a4a2a;
	border-radius: 8px 8px 6px 6px;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 220, 160, 0.08);
	font-size: 12px;
}
#cityBanner {
	position: absolute;
	left: 50%; top: 24%;
	transform: translateX(-50%);
	text-align: center;
	font-family: var(--display);
	text-shadow: 0 2px 10px #000;
	animation: bannerIn 6s forwards;
}
#cityBanner .c1 { font-size: 15px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--brass); }
#cityBanner .c2 { font-size: 48px; color: #fff0d0; }
#cityBanner .c3 { font-size: 15px; color: var(--ink-dim); font-style: italic; }
@keyframes bannerIn { 0% { opacity: 0; } 12% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 2; }
#overlayFade { z-index: 8; }
#overlayHurt { background: radial-gradient(ellipse at center, transparent 40%, rgba(160, 20, 10, 0.75)); }
#overlayPoison { background: radial-gradient(ellipse at center, transparent 35%, rgba(70, 130, 20, 0.6)); }
#overlayDust { background: radial-gradient(ellipse at center, rgba(150, 100, 50, 0.1), rgba(110, 70, 30, 0.7)); }
#overlayMask { background: radial-gradient(ellipse at center, transparent 55%, rgba(10, 8, 6, 0.85) 80%); }
#overlayFade { background: #000; transition: opacity 1.2s; }

/* ---------- panels ---------- */
#panel {
	position: fixed;
	inset: 0;
	z-index: 10;
	background: rgba(8, 6, 4, 0.55);
	display: flex;
	align-items: center;
	justify-content: center;
}
#panelBox {
	width: min(860px, 94vw);
	max-height: 88vh;
	display: flex;
	flex-direction: column;
	background: var(--soot-light);
	border: 1px solid var(--brass-dim);
	border-radius: 4px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 220, 160, 0.05);
}
#panelHead {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 16px;
	border-bottom: 1px solid var(--brass-dim);
}
#panelTitle { font-family: var(--display); font-size: 20px; color: #fff0d0; letter-spacing: 0.04em; }
#panelBody { padding: 14px 16px; overflow-y: auto; font-size: 13px; line-height: 1.45; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sect { font-family: var(--display); color: var(--brass); letter-spacing: 0.06em; text-transform: uppercase; font-size: 12px; margin: 10px 0 6px; }
.sect:first-child { margin-top: 0; }
.item {
	display: grid;
	grid-template-columns: 26px 1fr auto;
	gap: 8px;
	align-items: center;
	padding: 5px 7px;
	border: 1px solid transparent;
	border-radius: 3px;
}
.item:hover { border-color: var(--brass-dim); background: rgba(255, 220, 160, 0.04); }
.item .ico { font-size: 18px; text-align: center; }
.item .nm { color: #fff0d0; }
.item .nm small { color: var(--ink-dim); margin-left: 4px; }
.item .ds { color: var(--ink-dim); font-size: 12px; }
.item .acts { display: flex; gap: 4px; }
.item .acts button { padding: 3px 8px; font-size: 12px; }
.item.cant .nm { color: var(--ink-faint); }
.cost { font-size: 12px; color: var(--ink-dim); }
.cost .miss { color: var(--bad); }
.note { color: var(--ink-dim); font-size: 12px; margin: 6px 0; }
.big { font-family: var(--display); font-size: 18px; color: #fff0d0; }
.rowbtns { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.meter { height: 12px; background: rgba(255, 255, 255, 0.08); border-radius: 2px; overflow: hidden; margin: 4px 0 8px; }
.meter > div { height: 100%; background: var(--water); }
.help h3 { font-family: var(--display); color: var(--brass); font-weight: normal; margin: 14px 0 6px; font-size: 16px; }
.help h3:first-child { margin-top: 0; }
.help table { border-collapse: collapse; width: 100%; }
.help td { padding: 3px 6px; vertical-align: top; border-bottom: 1px solid rgba(255, 220, 160, 0.06); }
.help td:first-child { white-space: nowrap; width: 150px; }
.help p { margin: 5px 0; color: var(--ink-dim); }

/* flag editor */
.flagWrap { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: start; }
#flagCanvas { width: 512px; height: 320px; image-rendering: pixelated; border: 1px solid var(--brass-dim); cursor: crosshair; background: #000; max-width: 60vw; }
.palette { display: grid; grid-template-columns: repeat(4, 32px); gap: 5px; margin-bottom: 10px; }
.swatch { width: 32px; height: 32px; border: 2px solid transparent; border-radius: 3px; cursor: pointer; }
.swatch.sel { border-color: #fff0d0; }
.toolrow { display: flex; flex-direction: column; gap: 5px; }

/* map */
#mapCanvas { width: 100%; height: 520px; background: #1e1610; border: 1px solid var(--brass-dim); }

/* ---------- screens ---------- */
.screen {
	position: fixed;
	inset: 0;
	z-index: 20;
	display: flex;
	align-items: center;
	justify-content: center;
	background: radial-gradient(ellipse at 50% 120%, rgba(201, 120, 50, 0.35), transparent 60%), linear-gradient(rgba(18, 13, 10, 0.35), rgba(18, 13, 10, 0.75));
}
#title { background: radial-gradient(ellipse at 50% 110%, rgba(210, 120, 50, 0.3), transparent 60%), linear-gradient(rgba(18, 13, 10, 0.15), rgba(18, 13, 10, 0.7)); }
.titleWrap { text-align: center; }
.titleKicker { font-family: var(--display); font-style: italic; color: var(--ink-dim); letter-spacing: 0.12em; margin-bottom: 10px; }
h1 {
	font-family: var(--display);
	font-weight: normal;
	font-size: clamp(42px, 7vw, 86px);
	line-height: 0.95;
	margin: 0 0 26px;
	color: #fff0d0;
	letter-spacing: 0.02em;
	text-shadow: 0 3px 18px rgba(0, 0, 0, 0.7), 0 0 40px rgba(201, 120, 50, 0.3);
}
h2 { font-family: var(--display); font-weight: normal; font-size: 46px; margin: 0 0 10px; color: #ffd0b8; }
.titleButtons { display: flex; flex-direction: column; gap: 9px; align-items: center; }
.titleButtons button { width: 230px; padding: 10px; font-size: 15px; background: rgba(36, 25, 16, 0.85); }
.titleFoot { margin-top: 30px; color: var(--ink-faint); font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; }
#deathCause { font-size: 18px; color: var(--ink); margin-bottom: 6px; }
#deathNote { color: var(--ink-dim); margin-bottom: 22px; }

#clickToPlay {
	position: fixed;
	z-index: 9;
	left: 50%; top: 50%;
	transform: translate(-50%, -50%);
	padding: 12px 22px;
	background: var(--soot);
	border: 1px solid var(--brass);
	border-radius: 4px;
	font-family: var(--display);
	font-size: 18px;
	cursor: pointer;
}

input[type=range] { width: 220px; accent-color: var(--brass); }

/* ---------- lore ---------- */
.lorePage {
	background: radial-gradient(ellipse at 30% 20%, #efe3c6, #d9c79f 70%, #c9b386);
	color: #33241a;
	padding: 22px 30px 26px;
	border-radius: 3px;
	box-shadow: inset 0 0 40px rgba(90, 60, 30, 0.35), 0 4px 18px rgba(0, 0, 0, 0.45);
	font-family: Georgia, 'Palatino Linotype', serif;
	font-size: 15px;
	line-height: 1.65;
	max-width: 640px;
	margin: 4px auto 10px;
}
.lorePage h3 { margin: 0 0 4px; font-size: 21px; font-weight: normal; letter-spacing: 0.02em; color: #2a1b10; }
.lorePage .src { font-style: italic; color: #6e5238; margin-bottom: 14px; font-size: 13px; }
.lorePage p { margin: 0 0 12px; }
.loreList { display: flex; flex-direction: column; gap: 6px; max-width: 640px; margin: 0 auto; }
.loreList button { text-align: left; display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; }
.loreList button small { opacity: 0.65; font-style: italic; }
.loreList .unread { color: #fff4dc; border-color: var(--brass); }
.loreList .locked { opacity: 0.45; font-style: italic; padding: 8px 12px; border: 1px dashed rgba(201, 154, 74, 0.3); border-radius: 4px; }
.loreCount { text-align: center; opacity: 0.75; margin: 2px 0 10px; }

/* ---------- build tabs and research ---------- */
.ricon { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; font-size: 20px; color: var(--brass); border: 1px solid var(--ink-faint); border-radius: 3px; }
.rbar { height: 8px; background: rgba(0, 0, 0, 0.4); border: 1px solid var(--ink-faint); border-radius: 2px; margin: 5px 0 3px; overflow: hidden; }
.rbar > div { height: 100%; background: linear-gradient(90deg, #a07a3a, #e8c070); }
.item .good { color: var(--good); }
.item .why { color: var(--bad); }

/* ---------- pack (inventory) ---------- */
#panelBox.wide { width: min(1040px, 96vw); }
.inv { display: grid; grid-template-columns: 300px 1fr; gap: 18px; min-height: 430px; }
.rig {
	background: linear-gradient(160deg, #4a3322, #2e1f14 70%);
	border: 1px solid #6a4a2a;
	border-radius: 6px;
	padding: 12px 12px 14px;
	box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.25), inset 0 0 0 4px rgba(214, 170, 110, 0.18);
	position: relative;
}
.rig::after { content: ''; position: absolute; inset: 7px; border: 1px dashed rgba(214, 170, 110, 0.28); border-radius: 4px; pointer-events: none; }
.rigsec { font-family: var(--display); font-size: 14px; color: #e6c48a; margin: 10px 2px 6px; font-style: italic; }
.rigsec:first-child { margin-top: 0; }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; position: relative; z-index: 1; }
.gslot {
	height: 64px; padding: 4px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
	background: radial-gradient(circle at 50% 35%, #2a1d13, #1a120c);
	border: 1px solid #5a3f25; border-radius: 5px;
	box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
}
.gslot .gico { font-size: 22px; line-height: 1; color: rgba(214, 170, 110, 0.22); }
.gslot .glbl { font-size: 10px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.gslot.full { background: radial-gradient(circle at 50% 35%, #4a3523, #2a1d13); border-color: #a07a44; }
.gslot.full .glbl { color: var(--ink); }
.gslot.fits { border-color: var(--good); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6), 0 0 0 2px rgba(143, 208, 122, 0.35); }
.gslot.sel, .tile.sel { border-color: #f0cc80; box-shadow: 0 0 0 2px rgba(240, 204, 128, 0.45); }
.gslot:hover:not(:disabled) { border-color: var(--brass); background: radial-gradient(circle at 50% 35%, #5a4029, #2a1d13); }
.canteen { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; position: relative; z-index: 1; }
.canteen button { padding: 5px 12px; }
.cbar { position: relative; height: 26px; background: #1a120c; border: 1px solid #5a3f25; border-radius: 4px; overflow: hidden; }
.cbar > div { height: 100%; background: linear-gradient(180deg, #7cc8ee, #3f8fbf); }
.cbar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #fff; text-shadow: 0 1px 2px #000; }
.rignote { font-size: 11px; color: var(--ink-faint); margin: 5px 2px 0; }
.cond { display: grid; grid-template-columns: 54px 1fr; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-dim); margin: 3px 2px; }
.cond > div { height: 6px; background: rgba(0, 0, 0, 0.35); border-radius: 3px; overflow: hidden; }
.cond i { display: block; height: 100%; }

.pile { display: flex; flex-direction: column; min-width: 0; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { padding: 4px 11px; font-size: 12px; border-radius: 14px; background: transparent; border-color: var(--ink-faint); color: var(--ink-dim); }
.chip.on { background: rgba(201, 154, 74, 0.18); border-color: var(--brass); color: #fff0d0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; align-content: start; min-height: 200px; max-height: 300px; overflow-y: auto; padding: 2px; }
.tile {
	position: relative; height: 78px; padding: 6px 3px 4px; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
	background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--tc) 22%, #2a1f16), #1d150f 75%);
	border: 1px solid #4a3828; border-radius: 5px;
}
.tile:hover:not(:disabled) { border-color: var(--brass); background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--tc) 32%, #2a1f16), #1d150f 75%); }
.tile .tico { font-size: 28px; line-height: 1.1; color: var(--tc); text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6); }
.tile .tnm { font-size: 10.5px; color: var(--ink); line-height: 1.15; text-align: center; max-height: 2.4em; overflow: hidden; }
.tile .tcnt { position: absolute; top: 3px; right: 5px; font-size: 11px; color: #fff0d0; background: rgba(0, 0, 0, 0.55); border-radius: 8px; padding: 0 5px; }
.emptypile { grid-column: 1 / -1; color: var(--ink-faint); font-style: italic; padding: 30px 0; text-align: center; }
.detail { margin-top: 12px; min-height: 104px; border-top: 1px solid rgba(201, 154, 74, 0.25); padding-top: 10px; }
.dhead { display: grid; grid-template-columns: 46px 1fr; gap: 10px; align-items: start; }
.dico { font-size: 34px; text-align: center; line-height: 1.1; }
.dnm { font-family: var(--display); font-size: 18px; color: #fff0d0; }
.dds { color: var(--ink-dim); font-size: 12.5px; margin-top: 2px; }
.dstats { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.dstats span { font-size: 11.5px; padding: 1px 7px; border-radius: 3px; background: rgba(0, 0, 0, 0.3); }
.dstats .up { color: var(--good); }
.dstats .down { color: var(--bad); }
.dacts { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 0 56px; }
.dacts button { padding: 5px 12px; font-size: 13px; }
.dhint { color: var(--ink-faint); font-size: 12.5px; font-style: italic; }
@media (max-width: 760px) { .inv { grid-template-columns: 1fr; } }

/* ---------- build tray ---------- */
.bt-tabs { display: flex; align-items: flex-end; gap: 4px; margin: -1px 0 8px; }
.bt-tab { font-family: var(--display); font-size: 14px; padding: 6px 16px 5px; color: var(--ink-faint); border: 1px solid transparent; border-top: none; border-radius: 0 0 6px 6px; }
.bt-tab.on { color: #fff0d0; background: #5a3f25; border-color: #a07a44; }
.bt-tabkeys { margin-left: auto; color: var(--ink-faint); font-size: 11px; padding-bottom: 4px; }
.bt-cards { display: flex; gap: 7px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: thin; }
.bt-card {
	position: relative; flex: 0 0 104px; padding: 4px 4px 5px; border-radius: 6px;
	background: radial-gradient(circle at 50% 30%, #3e2c1d, #1c140d 80%);
	border: 1px solid #4a3828; text-align: center;
}
.bt-card img, .bt-noimg { width: 96px; height: 72px; display: block; margin: 0 auto; }
.bt-card .bt-name { color: var(--ink); font-size: 11px; line-height: 1.2; margin-top: 2px; min-height: 2.4em; display: flex; align-items: center; justify-content: center; }
.bt-card .bt-cost { display: flex; flex-wrap: wrap; gap: 2px 6px; justify-content: center; font-size: 11px; color: var(--ink-dim); margin-top: 2px; }
.bt-card .bt-cost b { font-weight: normal; margin-right: 1px; }
.bt-card .bt-cost .miss { color: var(--bad); }
.bt-card .bt-num { position: absolute; top: 3px; left: 5px; font-size: 10px; color: var(--ink-faint); }
.bt-card .bt-lock { display: none; position: absolute; top: 26px; left: 0; right: 0; font-size: 20px; }
.bt-card.cant img { opacity: 0.55; filter: saturate(0.6); }
.bt-card.locked img { opacity: 0.25; filter: grayscale(1); }
.bt-card.locked .bt-lock { display: block; }
.bt-card.locked .bt-name { color: var(--ink-faint); }
.bt-card.sel { border-color: #f0cc80; background: radial-gradient(circle at 50% 30%, #6a4b2c, #2a1d12 80%); box-shadow: 0 0 0 2px rgba(240, 204, 128, 0.35), 0 4px 14px rgba(0, 0, 0, 0.5); }
.bt-info { padding: 6px 4px 2px; min-height: 52px; }
.bt-title { font-family: var(--display); font-size: 17px; color: #fff0d0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.bt-facts { display: inline-flex; gap: 5px; }
.bt-facts i { font-style: normal; font-family: var(--ui); font-size: 11px; color: #cde8b8; background: rgba(143, 208, 122, 0.12); border: 1px solid rgba(143, 208, 122, 0.3); border-radius: 3px; padding: 0 6px; }
.bt-desc { color: var(--ink-dim); margin-top: 2px; }
.bt-why { color: var(--bad); margin-top: 3px; }
.bt-ok { color: var(--good); margin-top: 3px; }
.bt-keys { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; color: var(--ink-faint); font-size: 11px; border-top: 1px solid rgba(201, 154, 74, 0.18); padding-top: 6px; margin-top: 4px; }
kbd { display: inline-block; min-width: 18px; padding: 1px 5px; margin: 0 1px; font-family: var(--ui); font-size: 10.5px; color: var(--ink); background: linear-gradient(#4a3624, #2c1f14); border: 1px solid #7a5a2a; border-bottom-width: 2px; border-radius: 3px; text-align: center; }

/* ---------- pouring ---------- */
#pourBar { position: absolute; left: 50%; top: calc(50% + 34px); transform: translateX(-50%); width: 220px; padding: 6px 10px 7px; background: rgba(18, 13, 10, 0.78); border: 1px solid var(--brass-dim); border-radius: 5px; text-align: center; }
#pourBar .pb-label { font-size: 12px; color: var(--ink-dim); margin-bottom: 4px; }
#pourBar .pb-track { height: 10px; background: rgba(0, 0, 0, 0.5); border-radius: 3px; overflow: hidden; }
#pourBar .pb-fill { height: 100%; background: linear-gradient(180deg, #7cc8ee, #3f8fbf); transition: width 0.08s linear; }
#pourBar .pb-text { font-size: 12px; color: #fff0d0; margin-top: 3px; font-family: var(--mono); }
.holdbtn { position: relative; }
.holdbtn.active { border-color: #7cc8ee; box-shadow: 0 0 0 2px rgba(124, 200, 238, 0.3); }
.pmeter { position: relative; height: 18px; background: rgba(0, 0, 0, 0.4); border: 1px solid var(--ink-faint); border-radius: 3px; overflow: hidden; margin: 4px 0 8px; }
.pmeter > div { height: 100%; background: linear-gradient(180deg, #7cc8ee, #3f8fbf); }
.pmeter span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11.5px; color: #fff; text-shadow: 0 1px 2px #000; }

/* ---------- kite painting ---------- */
.paintBox { position: relative; line-height: 0; }
.kiteBox #flagCanvas { width: 400px; height: 400px; max-width: 50vw; max-height: 60vh; }
.kiteGuide { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.kiteGuide polygon { fill: none; stroke: rgba(255, 240, 208, 0.75); stroke-width: 1.5; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }

/* menus opened from the title screen sit above it */
#panel.overTitle { z-index: 30; }

/* ---------- main menu pages ---------- */
#panelTitle .mtab { background: transparent; border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 4px 14px 6px; margin-right: 4px; font-family: var(--display); font-size: 19px; color: var(--ink-faint); }
#panelTitle .mtab:hover:not(:disabled) { background: transparent; color: var(--ink); border-bottom-color: var(--brass-dim); }
#panelTitle .mtab.on { color: #fff0d0; border-bottom-color: var(--brass); }
#panelTitle .mtab kbd { margin-left: 7px; font-size: 9.5px; vertical-align: 3px; opacity: 0.75; }
.rig.info { display: flex; flex-direction: column; }
.rig.info > * { position: relative; z-index: 1; }
.bigico { font-size: 54px; text-align: center; line-height: 1.2; margin: 4px 0 2px; text-shadow: 0 3px 8px rgba(0, 0, 0, 0.6); }
.bigthumb { display: block; width: 100%; max-width: 250px; height: auto; margin: 0 auto 4px; border-radius: 4px; background: radial-gradient(circle at 50% 40%, #4a3523, #1c140d 80%); }
.infoname { font-family: var(--display); font-size: 21px; color: #fff0d0; text-align: center; }
.infoname.small { font-size: 16px; text-align: left; }
.infoname small { font-size: 14px; color: var(--ink-dim); }
.infokind { font-size: 11.5px; color: #cde8b8; text-align: center; margin-top: 2px; }
.infodesc { font-size: 12.5px; color: var(--ink-dim); margin-top: 6px; line-height: 1.45; }
.needs { display: flex; flex-direction: column; gap: 3px; }
.need { display: grid; grid-template-columns: 20px 1fr auto; gap: 6px; align-items: center; font-size: 12.5px; padding: 2px 6px; background: rgba(0, 0, 0, 0.22); border-radius: 3px; }
.need b { font-weight: normal; text-align: center; }
.need i { font-style: normal; font-family: var(--mono); font-size: 11.5px; }
.need.ok i { color: var(--good); }
.need.miss i, .need.miss span { color: var(--bad); }
.lockednote { margin-top: 10px; color: var(--warn); font-size: 12.5px; }
.okline { margin-top: 10px; color: var(--good); font-size: 12.5px; }
button.big { width: 100%; padding: 9px 14px; font-size: 14.5px; margin-top: 4px; }
.gsec { font-family: var(--display); font-style: italic; color: #e6c48a; font-size: 15px; margin: 4px 2px 6px; }
.grid.tall { max-height: 380px; }
.tile.ready { box-shadow: inset 0 0 0 1px rgba(143, 208, 122, 0.35); }
.tile.dim .tico, .tile.dim .tnm { opacity: 0.45; }
.buildlist { max-height: 470px; overflow-y: auto; padding-right: 4px; }
.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 7px; margin-bottom: 12px; }
.bcard { position: relative; display: flex; flex-direction: column; align-items: center; padding: 4px 4px 6px; border-radius: 6px; background: radial-gradient(circle at 50% 30%, #3e2c1d, #1c140d 80%); border: 1px solid #4a3828; }
.bcard:hover:not(:disabled) { border-color: var(--brass); background: radial-gradient(circle at 50% 30%, #4e3824, #1f160e 80%); }
.bcard img, .bcard .bt-noimg { width: 100%; max-width: 110px; height: 70px; object-fit: contain; display: block; }
.bcard .bname { font-size: 11.5px; color: var(--ink); line-height: 1.2; min-height: 2.4em; display: flex; align-items: center; text-align: center; }
.bcard .bcost { display: flex; flex-wrap: wrap; gap: 1px 6px; justify-content: center; font-size: 11px; color: var(--ink-dim); }
.bcard .bcost b { font-weight: normal; margin-right: 1px; }
.bcard .bcost .miss { color: var(--bad); }
.bcard .block { position: absolute; top: 24px; left: 0; right: 0; font-size: 20px; text-align: center; }
.bcard.cant img { opacity: 0.6; filter: saturate(0.6); }
.bcard.locked img { opacity: 0.25; filter: grayscale(1); }
.bcard.locked .bname { color: var(--ink-faint); }
.bcard.sel { border-color: #f0cc80; box-shadow: 0 0 0 2px rgba(240, 204, 128, 0.35); }
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.rcard { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 3px; padding: 9px 11px; border-radius: 6px; background: radial-gradient(circle at 30% 20%, #3e2c1d, #1c140d 85%); border: 1px solid #4a3828; }
.rcard .rname { font-family: var(--display); font-size: 15.5px; color: #fff0d0; }
.rcard .rstate { font-size: 11px; padding: 0 6px; border-radius: 3px; background: rgba(0, 0, 0, 0.3); }
.rcard .rdesc { font-size: 11.5px; color: var(--ink-dim); line-height: 1.35; }
.rcard.done .rstate { color: var(--good); }
.rcard.active .rstate { color: #7cc8ee; }
.rcard.blocked { opacity: 0.6; }
.rcard.blocked .rstate { color: var(--warn); }
.rcard.open .rstate { color: #f0cc80; }
.rcard.sel { border-color: #f0cc80; box-shadow: 0 0 0 2px rgba(240, 204, 128, 0.35); }
.boxhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(201, 154, 74, 0.25); font-family: var(--display); font-size: 16px; color: #fff0d0; }
.boxhead small { font-family: var(--ui); font-size: 11.5px; color: var(--ink-dim); margin-left: 6px; }
.boxbtns { display: flex; gap: 6px; }
.boxbtns button { padding: 4px 10px; font-size: 12.5px; }
.grid.boxgrid { min-height: 120px; max-height: 170px; margin-top: 8px; }

/* ---------- placing strip ---------- */
#buildBar { width: min(640px, 96vw); padding: 10px 12px 8px; border-radius: 8px; }
#buildBar .pb-row { display: flex; gap: 12px; align-items: center; }
#buildBar .pb-row img { width: 84px; height: 63px; border-radius: 4px; background: radial-gradient(circle at 50% 40%, #4a3523, #1c140d 80%); }
#buildBar .pb-name { font-family: var(--display); font-size: 17px; color: #fff0d0; }
#buildBar .pb-cost { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12px; color: var(--ink-dim); margin-top: 2px; }
#buildBar .pb-cost b { font-weight: normal; margin-right: 3px; }
#buildBar .pb-cost .miss { color: var(--bad); }

/* one scrollbar style for every scrolling list in the menus */
#panel *, #buildBar * { scrollbar-width: thin; scrollbar-color: #8a6a3a rgba(0, 0, 0, 0.3); }
#panel *::-webkit-scrollbar, #buildBar *::-webkit-scrollbar { width: 9px; height: 9px; }
#panel *::-webkit-scrollbar-track, #buildBar *::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.3); border-radius: 5px; }
#panel *::-webkit-scrollbar-thumb, #buildBar *::-webkit-scrollbar-thumb { background: linear-gradient(90deg, #a07a44, #6a4a2a); border: 1px solid #3a2a1c; border-radius: 5px; }
#panel *::-webkit-scrollbar-thumb:hover, #buildBar *::-webkit-scrollbar-thumb:hover { background: linear-gradient(90deg, #c99a4a, #7a5a2a); }
#panel *::-webkit-scrollbar-corner { background: transparent; }

/* menu pages fill the window and scroll inside their own lists, never the whole page */
#panelBox.wide { height: min(88vh, 760px); }
#panelBox.wide #panelBody { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
#panelBox.wide .inv { flex: 1; min-height: 0; height: auto; }
.inv > .rig { overflow-y: auto; min-height: 0; }
.inv > .pile { min-height: 0; }
.inv .pile > .grid, .inv .pile > .buildlist, .inv .pile > .rgrid { flex: 1 1 auto; min-height: 90px; max-height: none; overflow-y: auto; align-content: start; }
.inv .pile > .grid.boxgrid { flex: 0 0 auto; height: 160px; }
.inv .pile > .detail { flex: 0 0 auto; }

/* ---------- opening scene ---------- */
#letterbox { position: fixed; inset: 0; pointer-events: none; z-index: 7; }
#letterbox > div { position: absolute; left: 0; right: 0; height: 10vh; background: #000; }
#letterbox > div:first-child { top: 0; }
#letterbox > div:last-child { bottom: 0; }
#introTitle { position: fixed; left: 0; right: 0; top: 32%; text-align: center; z-index: 9; pointer-events: none; font-family: var(--display); font-size: clamp(40px, 7vw, 92px); line-height: 0.95; color: #fff0d0; text-shadow: 0 4px 24px rgba(0, 0, 0, 0.75); letter-spacing: 0.02em; }
#introSkip { position: fixed; right: 22px; bottom: calc(10vh + 14px); z-index: 9; pointer-events: none; font-size: 12px; color: rgba(241, 227, 200, 0.6); }
