:root {
	--bg: #05070d;
	--bg-2: #080c16;
	--panel: rgba(9, 15, 28, 0.86);
	--panel-solid: #0a1222;
	--panel-edge: rgba(120, 180, 255, 0.14);
	--edge-strong: rgba(120, 200, 255, 0.34);
	--hover: rgba(79, 209, 255, 0.07);
	--text: #dce6f5;
	--dim: #8b9ab3;
	--faint: #5b6a84;
	--accent: #4fd1ff;
	--amber: #ffb545;
	--amber-2: #ff8a2a;
	--good: #4dffa6;
	--bad: #ff5470;

	--f-display: "Chakra Petch", "Exo 2", system-ui, sans-serif;
	--f-body: "Exo 2", system-ui, -apple-system, "Segoe UI", sans-serif;
	--f-mono: "JetBrains Mono", ui-monospace, monospace;
	--cut: 9px;

	font: 14px/1.45 var(--f-body);
	color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; -webkit-font-smoothing: antialiased; }
::selection { background: rgba(79, 209, 255, 0.35); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header: brand, breadcrumbs, the actions. */
#bar {
	position: relative;
	z-index: 5;
	height: 52px;
	display: flex;
	align-items: center;
	gap: 22px;
	padding: 0 16px;
	background: rgba(5, 8, 15, 0.92);
	border-bottom: 1px solid var(--panel-edge);
	backdrop-filter: blur(12px);
}
#bar::after {
	content: "";
	position: absolute;
	left: 0; right: 0; bottom: -1px; height: 1px;
	background: linear-gradient(90deg, transparent, var(--edge-strong), transparent);
	pointer-events: none;
}

.brand { display: inline-flex; align-items: center; gap: 9px; font-family: var(--f-display); font-weight: 700; font-size: 19px; letter-spacing: .06em; color: var(--text); text-decoration: none; flex: none; }
.brand b { color: var(--accent); font-weight: 700; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); filter: drop-shadow(0 0 7px rgba(79, 209, 255, .6)); }

#crumbs { display: flex; gap: 10px; align-items: center; min-width: 0; font-family: var(--f-display); font-weight: 500; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; }
#crumbs a { color: var(--dim); text-decoration: none; transition: color .2s; }
#crumbs a:hover { color: #fff; }
#crumb-sector { color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#crumb-sector::before { content: "//"; color: var(--accent); margin-right: 10px; font-family: var(--f-mono); letter-spacing: 0; }

#actions { display: flex; gap: 10px; align-items: center; margin-left: auto; flex: none; }

/* Buttons: clipped corners like the game's HUD. */
.join, .login, #pick button, dialog button, #trade td.deal button {
	font-family: var(--f-display);
	font-weight: 600;
	letter-spacing: .08em;
	text-transform: uppercase;
	clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
	cursor: pointer;
	transition: filter .2s, background .2s, color .2s;
}
.join {
	font-size: 12px;
	padding: 8px 18px;
	color: #1a0d00;
	background: linear-gradient(180deg, #ffd27a 0%, var(--amber) 45%, var(--amber-2) 100%);
	text-decoration: none;
	filter: drop-shadow(0 0 12px rgba(255, 160, 50, .3));
}
.join:hover { filter: drop-shadow(0 0 20px rgba(255, 170, 60, .55)) brightness(1.06); }

.login {
	font-size: 12px;
	padding: 7px 14px;
	border: 0;
	color: #e6f6ff;
	background: linear-gradient(180deg, rgba(79, 209, 255, .16), rgba(79, 209, 255, .05));
	box-shadow: inset 0 0 0 1px var(--edge-strong);
}
.login:hover { background: linear-gradient(180deg, rgba(79, 209, 255, .28), rgba(79, 209, 255, .08)); }
.login.in { color: var(--accent); }
select.login { clip-path: none; text-transform: none; letter-spacing: 0; font-family: var(--f-body); font-weight: 500; padding: 6px 8px; }
select.login option { background: var(--panel-solid); color: var(--text); }

.status {
	display: inline-flex; align-items: center; gap: 7px;
	font-family: var(--f-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
	padding: 4px 10px; border: 1px solid var(--panel-edge); color: var(--dim);
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.online { color: var(--good); border-color: rgba(77, 255, 166, .3); }
.status.online::before { animation: ping 2s infinite; }
.status.offline { color: var(--bad); border-color: rgba(255, 84, 112, .3); }
@keyframes ping {
	0% { box-shadow: 0 0 0 0 rgba(77, 255, 166, .6); }
	70% { box-shadow: 0 0 0 7px rgba(77, 255, 166, 0); }
	100% { box-shadow: 0 0 0 0 rgba(77, 255, 166, 0); }
}

main { position: absolute; top: 52px; bottom: 0; left: 0; right: 0; display: flex; }

/* The map. */
#view {
	position: relative; flex: 1; min-width: 0; overflow: hidden;
	background:
		radial-gradient(1100px 700px at 70% 35%, rgba(40, 90, 180, .14), transparent 70%),
		radial-gradient(800px 600px at 10% 85%, rgba(120, 60, 200, .08), transparent 70%),
		var(--bg);
}
#view canvas { display: block; }
#view .corner { position: absolute; z-index: 3; width: 18px; height: 18px; border: 2px solid var(--accent); opacity: .8; pointer-events: none; }
#view .corner.tl { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
#view .corner.tr { top: 10px; right: 10px; border-left: 0; border-bottom: 0; }
#view .corner.bl { bottom: 10px; left: 10px; border-right: 0; border-top: 0; }
#view .corner.br { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }

/* The side panel. */
#panel {
	width: 310px;
	overflow-y: auto;
	background: var(--panel);
	border-left: 1px solid var(--panel-edge);
	padding: 16px 16px 24px;
	scrollbar-width: thin;
	scrollbar-color: var(--edge-strong) transparent;
}
#panel h2 {
	font-family: var(--f-mono); font-weight: 400; font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
	color: var(--accent); margin: 22px 0 8px; display: flex; align-items: center; gap: 8px;
}
#panel h2::before { content: "//"; color: var(--faint); }
#panel h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--panel-edge), transparent); }
#panel h2:first-child { margin-top: 0; }
#panel ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
#panel li {
	padding: 6px 8px; cursor: pointer; display: flex; gap: 9px; align-items: baseline;
	border: 1px solid transparent; transition: background .15s, border-color .15s;
}
#panel li:hover { background: var(--hover); border-color: var(--panel-edge); }
#panel li .meta { color: var(--faint); font-size: 12px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; text-align: right; }
#panel .empty { color: var(--faint); font-style: normal; cursor: default; }
#panel .empty:hover { background: none; border-color: transparent; }
#panel .swatch { width: 10px; height: 10px; flex: none; align-self: center; box-shadow: 0 0 8px currentColor; }
#panel .sub { padding-left: 24px; font-size: 12px; color: var(--dim); }
#panel .player-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; align-self: center; background: var(--amber); box-shadow: 0 0 8px var(--amber); }

/* Territory legend (galaxy): a filter per owner. */
#panel li.legend[aria-pressed="true"] { background: rgba(79, 209, 255, .1); border-color: var(--edge-strong); }
#panel li.legend .meta { font-family: var(--f-mono); font-size: 11px; }
#panel .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#panel .stat { border: 1px solid var(--panel-edge); background: rgba(6, 12, 24, .55); padding: 8px 10px; }
#panel .stat span { display: block; font-family: var(--f-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
#panel .stat b { font-family: var(--f-display); font-size: 20px; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }

/* Tooltip. */
#tooltip {
	position: fixed;
	pointer-events: none;
	z-index: 10;
	background: rgba(5, 10, 20, .95);
	border: 1px solid var(--edge-strong);
	box-shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 0 20px rgba(79, 209, 255, .12);
	padding: 9px 13px;
	font-size: 13px;
	max-width: 300px;
}
#tooltip b { font-family: var(--f-display); font-weight: 600; font-size: 15px; color: #fff; }
#tooltip .dim { color: var(--faint); }
#tooltip .tip-name { font-family: var(--f-display); font-weight: 600; font-size: 17px; color: #fff; }
#tooltip .tip-race { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 13px; margin-top: 2px; }
#tooltip .tip-race i { width: 10px; height: 10px; display: inline-block; }
#tooltip .tip-live { color: var(--amber); font-family: var(--f-mono); font-size: 12px; margin-top: 4px; }
#tooltip .tip-coord { font-family: var(--f-mono); font-size: 11px; color: var(--faint); margin-top: 6px; letter-spacing: .06em; }

/* Labels drawn by CSS2DRenderer over the canvas. */
.label {
	color: var(--text);
	font-size: 11px;
	white-space: nowrap;
	text-shadow: 0 0 3px #000, 0 0 2px #000, 0 0 6px #000;
	pointer-events: none;
	user-select: none;
}
.label.sector-name {
	font-family: var(--f-display);
	font-weight: 500;
	font-size: 11px;
	letter-spacing: .02em;
	color: rgba(220, 235, 255, .78);
	text-align: center;
	line-height: 1.15;
	white-space: normal;
	width: max-content;
	max-width: var(--tile-px, 80px);
}
.label.sector-name .count { display: block; font-family: var(--f-mono); color: var(--faint); font-size: 9.5px; margin-top: 2px; }
.label.player { font-family: var(--f-display); color: #ffe2b0; font-weight: 600; font-size: 12px; }
.label.gate { font-family: var(--f-display); color: var(--accent); font-weight: 500; }
.label.station { color: var(--dim); }
.far .label.sector-name .count, .far .label.station { display: none; }
.veryfar .label.sector-name { display: none; }
.filtering .label.sector-name.dimmed { opacity: .15; }

/* Fleet command: the ship menu, the target banner, answers, the login dialog. */
#menu {
	position: fixed;
	z-index: 20;
	min-width: 200px;
	background: rgba(7, 12, 23, .97);
	border: 1px solid var(--edge-strong);
	padding: 5px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .6), 0 0 20px rgba(79, 209, 255, .1);
	clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}
#menu .menu-head { padding: 5px 9px 7px; font-size: 12px; border-bottom: 1px solid var(--panel-edge); margin-bottom: 4px; }
#menu .menu-head b { font-family: var(--f-display); font-size: 14px; color: #fff; }
#menu .menu-note { padding: 4px 9px; font-size: 12px; color: var(--dim); max-width: 230px; }
#menu button {
	display: block;
	width: 100%;
	text-align: left;
	font: inherit;
	font-size: 13px;
	color: var(--text);
	background: none;
	border: 0;
	border-left: 2px solid transparent;
	padding: 5px 9px;
	cursor: pointer;
}
#menu button:hover { background: var(--hover); border-left-color: var(--accent); color: #fff; }
#menu button:disabled { color: var(--faint); cursor: default; background: none; border-left-color: transparent; }
#menu hr { border: 0; border-top: 1px solid var(--panel-edge); margin: 4px 0; }
/* The command console (section 7.2): vanilla's lines with their number key, the submenu mark, the short name in
   [ ] at the right, grey entries (shown, not selectable, no reason: D-CMD-5) and the help text (page 2022). */
#menu { max-width: min(380px, calc(100vw - 8px)); max-height: calc(100vh - 8px); overflow-y: auto; }
#menu .menu-current { font-size: 11px; color: var(--accent); margin-top: 2px; }
#menu button.cmd { display: flex; align-items: baseline; gap: 6px; }
#menu .cmd .key { flex: 0 0 12px; font: 10.5px var(--f-mono); color: var(--faint); }
#menu .cmd .name { flex: 1 1 auto; }
#menu .cmd .sub { color: var(--accent); margin-right: 5px; }
#menu .cmd .short { font: 11px var(--f-mono); color: var(--faint); white-space: nowrap; }
#menu .cmd .info {
	flex: 0 0 auto; width: 15px; height: 15px; line-height: 13px; text-align: center; border-radius: 50%;
	border: 1px solid var(--edge-strong); font: italic 600 10px var(--f-display); color: var(--dim);
}
#menu .cmd .info:hover { color: #fff; border-color: var(--accent); }
#menu button.cmd.grey, #menu button.cmd.grey:hover { color: var(--faint); background: none; border-left-color: transparent; cursor: default; }
#menu button.cmd.grey .info { cursor: pointer; }
#menu button.cmd.refused { animation: refused .25s; }
@keyframes refused { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
#menu button.menu-back { color: var(--accent); font-family: var(--f-display); font-size: 12px; letter-spacing: .04em; }
#menu .menu-help {
	margin: 4px 2px 2px; padding: 6px 8px; font-size: 12px; color: var(--dim);
	border-top: 1px solid var(--panel-edge); max-height: 30vh; overflow-y: auto;
}

/* A step's pick on the sector map: what the step can take stands out, the rest fades. */
body.picking .label.unpickable { opacity: .25; }
body.picking .label.pickable { color: var(--amber); }

/* A step's list, box or question (section 7.2). */
#steps {
	position: fixed;
	z-index: 19;
	top: 66px;
	left: 16px;
	width: min(420px, calc(100vw - 32px));
	max-height: calc(100vh - 130px);
	display: flex;
	flex-direction: column;
	background: rgba(7, 12, 23, .97);
	border: 1px solid var(--amber);
	padding: 12px 16px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .6), 0 0 24px rgba(255, 181, 69, .12);
	font-size: 13px;
	clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
}
#steps[hidden] { display: none; }
#steps .steps-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-family: var(--f-display); font-size: 15px; }
#steps .steps-head b { color: #fff; font-weight: 600; }
#steps .steps-close { font-size: 20px; line-height: 1; background: none; border: 0; color: var(--dim); cursor: pointer; }
#steps .steps-close:hover { color: var(--accent); }
#steps .steps-prompt { margin: 8px 0; color: var(--text); }
#steps input {
	width: 100%;
	font: 13px var(--f-mono);
	padding: 7px 9px;
	background: var(--bg);
	color: var(--text);
	border: 1px solid var(--panel-edge);
	outline: none;
}
#steps input:focus { border-color: var(--accent); }
#steps .steps-input { display: flex; gap: 8px; align-items: center; }
#steps .steps-input .dim { white-space: nowrap; font: 11px var(--f-mono); }
#steps .steps-choices { display: flex; flex-direction: column; margin-top: 6px; }
#steps .steps-choices button {
	text-align: left;
	font: 13px var(--f-body, inherit);
	color: var(--text);
	background: none;
	border: 0;
	border-bottom: 1px solid var(--panel-edge);
	padding: 7px 4px;
	cursor: pointer;
}
#steps .steps-choices button:hover, #steps .steps-choices button:focus { background: var(--hover); color: #fff; }
#steps .steps-list { overflow-y: auto; min-height: 0; flex: 1 1 auto; margin-top: 6px; }
#steps .steps-list input[data-amount] { width: 7em; }
#steps table { width: 100%; border-collapse: collapse; }
#steps td { padding: 5px 4px; border-bottom: 1px solid var(--panel-edge); cursor: pointer; }
#steps tr[data-ware]:hover td, #steps tr[data-ware]:focus td { background: var(--hover); color: #fff; }
#steps td.num { text-align: right; font-family: var(--f-mono); font-size: 12px; color: var(--dim); }
#steps .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
#steps .buttons button, #pick button {
	font-size: 11px;
	color: #e6f6ff;
	background: linear-gradient(180deg, rgba(79, 209, 255, .16), rgba(79, 209, 255, .05));
	border: 0;
	box-shadow: inset 0 0 0 1px var(--edge-strong);
	padding: 6px 14px;
	cursor: pointer;
}
#steps .buttons button.primary { color: #1a0d00; box-shadow: none; background: linear-gradient(180deg, #ffd27a 0%, var(--amber) 45%, var(--amber-2) 100%); }
#pick button:disabled { opacity: .35; cursor: default; }
.dim { color: var(--dim); }
.bad { color: var(--bad); }

#pick {
	position: fixed;
	z-index: 15;
	top: 66px;
	left: 50%;
	transform: translateX(-50%);
	background: rgba(5, 10, 20, .95);
	border: 1px solid var(--amber);
	box-shadow: 0 0 24px rgba(255, 181, 69, .2);
	padding: 8px 14px;
	font-size: 13px;
	max-width: calc(100vw - 32px);
}
#pick button, dialog button {
	font-size: 11px;
	color: #e6f6ff;
	background: linear-gradient(180deg, rgba(79, 209, 255, .16), rgba(79, 209, 255, .05));
	border: 0;
	box-shadow: inset 0 0 0 1px var(--edge-strong);
	padding: 5px 12px;
	--cut: 7px;
}
#pick button:hover, dialog button:hover { background: linear-gradient(180deg, rgba(79, 209, 255, .28), rgba(79, 209, 255, .08)); }
body.picking #view canvas { cursor: crosshair !important; }

#toast {
	position: fixed;
	z-index: 25;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	background: rgba(5, 10, 20, .95);
	border: 1px solid var(--panel-edge);
	border-left: 3px solid var(--good);
	color: var(--text);
	padding: 8px 16px;
	font-size: 13px;
	max-width: calc(100vw - 32px);
	box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
#toast.bad { border-left-color: var(--bad); }

dialog {
	background: var(--panel-solid);
	color: var(--text);
	border: 1px solid var(--edge-strong);
	width: min(440px, calc(100vw - 32px));
	padding: 20px 24px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, .6), 0 0 30px rgba(79, 209, 255, .1);
	clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
}
dialog::backdrop { background: rgba(2, 4, 8, .7); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 10px; font-family: var(--f-display); font-weight: 600; font-size: 22px; text-transform: uppercase; letter-spacing: .04em; }
dialog p { font-size: 13px; margin: 8px 0; color: var(--dim); }
dialog p b { color: var(--text); }
dialog input {
	width: 100%;
	font: 13px var(--f-mono);
	padding: 9px 10px;
	background: var(--bg);
	color: var(--text);
	border: 1px solid var(--panel-edge);
	outline: none;
}
dialog input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 209, 255, .12); }
dialog .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
dialog button { font-size: 12px; padding: 8px 16px; --cut: 8px; }
dialog button.primary {
	color: #1a0d00; box-shadow: none;
	background: linear-gradient(180deg, #ffd27a 0%, var(--amber) 45%, var(--amber-2) 100%);
}
dialog button.primary:hover { filter: brightness(1.08); background: linear-gradient(180deg, #ffd27a 0%, var(--amber) 45%, var(--amber-2) 100%); }

/* Trading (section 9): the trade panel of a docked ship. */
#trade {
	position: fixed;
	z-index: 18;
	top: 66px;
	left: 16px;
	width: min(620px, calc(100vw - 32px));
	max-height: calc(100vh - 130px);
	overflow: auto;
	background: rgba(7, 12, 23, .97);
	border: 1px solid var(--edge-strong);
	padding: 14px 16px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .6), 0 0 24px rgba(79, 209, 255, .08);
	font-size: 13px;
	clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
}
#trade .trade-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-family: var(--f-display); font-size: 16px; }
#trade .trade-head b { color: #fff; font-weight: 600; }
#trade .trade-close { font-size: 20px; line-height: 1; background: none; border: 0; color: var(--dim); cursor: pointer; }
#trade .trade-close:hover { color: var(--accent); }
#trade .trade-sums { display: flex; flex-wrap: wrap; gap: 16px; margin: 8px 0 10px; color: var(--faint); font-family: var(--f-mono); font-size: 12px; }
#trade .trade-sums b { color: var(--text); font-weight: 600; }
#trade table { width: 100%; border-collapse: collapse; }
#trade th { text-align: left; font-family: var(--f-mono); font-weight: 400; color: var(--faint); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; padding: 4px; border-bottom: 1px solid var(--edge-strong); }
#trade td { padding: 5px 4px; border-bottom: 1px solid var(--panel-edge); white-space: nowrap; }
#trade tr:hover td { background: var(--hover); }
#trade td:first-child { white-space: normal; }
#trade td.num { text-align: right; font-family: var(--f-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
#trade td.deal { display: flex; gap: 4px; justify-content: flex-end; }
#trade input {
	width: 64px;
	font: 12px var(--f-mono);
	padding: 3px 5px;
	background: var(--bg);
	color: var(--text);
	border: 1px solid var(--panel-edge);
}
#trade input:focus { border-color: var(--accent); outline: none; }
#trade td.deal button {
	font-size: 10.5px;
	color: #e6f6ff;
	background: linear-gradient(180deg, rgba(79, 209, 255, .16), rgba(79, 209, 255, .05));
	border: 0;
	box-shadow: inset 0 0 0 1px var(--edge-strong);
	padding: 4px 9px;
	--cut: 6px;
}
#trade td.deal button:disabled { opacity: .3; cursor: default; }
#trade td.deal button:not(:disabled):hover { background: linear-gradient(180deg, rgba(79, 209, 255, .3), rgba(79, 209, 255, .1)); }

@media (max-width: 700px) {
	#bar { gap: 12px; padding: 0 10px; }
	.brand span { display: none; }
	#crumbs { font-size: 12px; letter-spacing: .06em; }
	#actions { gap: 6px; }
	.login, .join { padding: 6px 10px; font-size: 11px; }
	.status { padding: 3px 7px; font-size: 0; gap: 0; }
	.status::before { width: 8px; height: 8px; }
	main { flex-direction: column; }
	#panel { width: auto; height: 38%; border-left: 0; border-top: 1px solid var(--panel-edge); }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}
