:root {
    --ink: #e6eef8;
    --muted: #93a4ba;
    --panel: rgba(11, 20, 34, 0.84);
    --line: rgba(148, 178, 214, 0.22);
    --accent: #6df2a4;
    --bad: #ff6b6b;
    --warn: #ffc24b;
    --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body, #app {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0b1422;
    color: var(--ink);
    font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#gl-canvas { touch-action: none; cursor: crosshair; user-select: none; }
#label-canvas { pointer-events: none; }

.hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
}

.panel {
    pointer-events: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    backdrop-filter: blur(6px);
}

button {
    font: inherit;
    font-weight: 600;
    color: var(--ink);
    background: rgba(148, 178, 214, 0.14);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 11px;
    cursor: pointer;
}

button:hover:not(:disabled) { background: rgba(148, 178, 214, 0.28); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #06231a; }
button.primary:hover:not(:disabled) { background: #93f7bd; }

.topbar {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 8px 14px;
}

.brand { font-size: 15px; white-space: nowrap; }
.spacer { flex: 1; }

.stat { display: flex; flex-direction: column; line-height: 1.15; white-space: nowrap; }
.stat span { font-size: 11px; color: var(--muted); }
.stat b { font: 600 15px var(--mono); }
.money { color: var(--accent); }
.money.debt { color: var(--bad); }

button.danger { border-color: var(--bad); color: #ffc9c9; }
button.danger:hover:not(:disabled) { background: rgba(255, 107, 107, 0.25); }

.tree-overlay { z-index: 5; }

.tree-card {
    display: flex;
    flex-direction: column;
    width: min(1180px, 100%);
    max-height: 100%;
    background: rgba(11, 20, 34, 0.97);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}

.tree-head {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.tree-head > div:first-child { flex: 1; min-width: 0; }
.tree-head h1 { margin: 0; font-size: 20px; }
.tree-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.tree-budget { display: flex; flex-direction: column; line-height: 1.15; }
.tree-budget span { font-size: 11px; color: var(--muted); }
.tree-budget b { font: 600 17px var(--mono); color: var(--accent); }

.tree-columns {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    padding: 18px 20px 22px;
    overflow-y: auto;
}

.tree-column h2 {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.tree-branch {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 26px;
}

.tree-node {
    position: relative;
    padding: 10px 12px;
    background: rgba(148, 178, 214, 0.08);
    border: 1px solid var(--line);
    border-radius: 8px;
}

/* Spojnice mezi úrovněmi téže větve. */
.tree-branch .tree-node + .tree-node::before {
    content: "";
    position: absolute;
    left: 50%;
    top: -17px;
    height: 16px;
    border-left: 2px solid var(--line);
}

.tree-node b { display: block; }
.tree-node p { margin: 4px 0 8px; font-size: 12px; color: var(--muted); }
.tree-node small { font-size: 12px; color: var(--muted); }
.tree-node > button { width: 100%; font-family: var(--mono); }

.tree-node.build { margin-bottom: 16px; }
.tree-node.build small { display: block; margin-bottom: 7px; }

.placement-status.ok { color: var(--accent); }
.placement-status.bad { color: var(--bad); }

.tree-node.owned { border-color: var(--accent); }
.tree-node.owned small { color: var(--accent); }
.tree-node.owned + .tree-node::before { border-left-color: var(--accent); }
.tree-node.locked { opacity: 0.55; }

.fee-slider { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.fee-slider input { flex: 1; min-width: 0; accent-color: var(--accent); }
.fee-slider output { font: 600 14px var(--mono); white-space: nowrap; }

.fee table { width: 100%; border-collapse: collapse; font-size: 12px; }
.fee th { font-weight: 500; color: var(--muted); text-align: right; padding: 3px 0; }
.fee td { border-top: 1px solid var(--line); padding: 4px 0; text-align: right; font-family: var(--mono); }
.fee td:first-child { text-align: left; font-family: inherit; }
.fee td.muted { font-family: inherit; color: var(--warn); }

.info-card { width: min(860px, 100%); }

.info-sections {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
    padding: 18px 20px 22px;
    overflow-y: auto;
}

.info-sections h2 {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.info-sections dl {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 7px 12px;
    margin: 0;
    font-size: 13px;
}

.info-sections dt { color: var(--muted); }
.info-sections dd { margin: 0; text-align: right; font: 600 13px var(--mono); }

.dialog h2 { margin: 0 0 8px; font-size: 14px; }

.difficulty { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.difficulty button { display: flex; flex-direction: column; gap: 4px; padding: 10px; text-align: left; }
.difficulty button:hover { border-color: var(--accent); }
.difficulty span { font-size: 12px; font-weight: 400; color: var(--muted); }

.toasts {
    position: absolute;
    top: 76px;
    left: 12px;
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toast {
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--panel);
    border-left: 3px solid var(--muted);
    font-size: 13px;
}

.toast.good { border-left-color: var(--accent); }
.toast.bad { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }

.bottom {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hint {
    margin: 0;
    font-size: 12px;
    color: #f4f8fc;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 8px 12px;
}

.callsign { display: flex; flex-direction: column; line-height: 1.15; }
.callsign b { font: 700 16px var(--mono); }
.callsign span { font-size: 11px; color: var(--muted); }

.intent { font-size: 13px; font-weight: 600; }
.intent.landing { color: var(--accent); }
.intent.transit { color: var(--warn); }

.fuel-state { width: 96px; font-size: 12px; color: var(--muted); }
.fuel-state.low { color: var(--bad); }
.fuel-bar { height: 5px; margin-top: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.fuel-bar i { display: block; height: 100%; background: var(--accent); }
.fuel-state.low .fuel-bar i { background: var(--bad); }

.levels { display: flex; align-items: center; gap: 4px; }
.levels span { margin-right: 4px; font-size: 12px; color: var(--muted); }
.levels button { font-family: var(--mono); padding: 4px 8px; }
.levels .level-0.active { background: #4fd6e8; border-color: #4fd6e8; color: #06222a; }
.levels .level-1.active { background: #ffc24b; border-color: #ffc24b; color: #2a1d04; }
.levels .level-2.active { background: #f277c6; border-color: #f277c6; color: #2c0b20; }

.route-state { flex: 1; min-width: 150px; font-size: 13px; color: var(--muted); }

.overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(6, 12, 22, 0.5);
}

.dialog {
    width: min(520px, 100%);
    max-height: 100%;
    overflow-y: auto;
    padding: 22px 26px;
    background: rgba(11, 20, 34, 0.95);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.dialog h1 { margin: 0 0 10px; font-size: 24px; }
.dialog ul { margin: 12px 0 18px; padding-left: 20px; color: var(--muted); }
.dialog li { margin-bottom: 5px; }

.boot { display: grid; place-items: center; height: 100%; }
.boot-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 8px 14px;
    background: #7a1f1f;
    z-index: 10;
}

#blazor-error-ui .dismiss { float: right; cursor: pointer; }
#blazor-error-ui a { color: inherit; }

@media (max-width: 820px) {
    .topbar { flex-wrap: wrap; gap: 10px 14px; }
    .toasts { top: 120px; width: auto; right: 12px; }
    .tree-columns, .info-sections, .difficulty { grid-template-columns: minmax(0, 1fr); }
    .tree-head { flex-wrap: wrap; gap: 10px 16px; }
}
