:root {
    --bg: #050811;
    --panel: #101831;
    --line: #29457f;
    --ink: #e7efff;
    --muted: #98acda;
    --cyan: #36f3ff;
    --pink: #ff5fd7;
    --amber: #ffc867;
    --good: #7dff9e;
    --bad: #ff6f93;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 18% 10%, rgba(54, 243, 255, 0.14), transparent 42%),
        radial-gradient(circle at 82% 8%, rgba(255, 95, 215, 0.13), transparent 46%),
        linear-gradient(168deg, #04060d, #050811 45%, #04050a);
    display: flex;
    justify-content: center;
    padding: 1rem;
}

.app {
    width: min(1080px, 100%);
    display: grid;
    gap: 0.95rem;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(16, 24, 49, 0.96), rgba(9, 13, 28, 0.96));
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.topbar {
    padding: 0.95rem 1rem;
}

.back {
    color: var(--amber);
    text-decoration: none;
    font-weight: 700;
}

h1 {
    margin: 0.6rem 0 0.3rem;
    font-size: clamp(1.35rem, 3vw, 2rem);
}

.topbar p {
    margin: 0;
    color: var(--muted);
}

.controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(110px, 1fr));
    gap: 0.6rem;
    padding: 0.8rem;
}

button {
    border: 1px solid #3a5398;
    border-radius: 8px;
    background: #101d44;
    color: var(--ink);
    padding: 0.52rem 0.74rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 120ms ease, border-color 120ms ease;
}

button:hover {
    transform: translateY(-1px);
    border-color: #6284da;
}

button:active { transform: translateY(1px); }

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

button.accent {
    border-color: #9a59ec;
    background: linear-gradient(180deg, #6f3dbc, #512b8b);
}

.meters {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(100px, 1fr));
    gap: 0.6rem;
}

.meters div {
    border: 1px solid #28427c;
    border-radius: 9px;
    padding: 0.45rem 0.6rem;
    background: rgba(5, 8, 19, 0.74);
    display: grid;
    gap: 0.1rem;
}

.meters span {
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.meters strong {
    font-size: 0.98rem;
}

.board-wrap {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 0.85rem;
    padding: 0.85rem;
}

canvas {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
    border: 1px solid #284580;
    background: #04070f;
    image-rendering: pixelated;
}

.scanlines {
    position: absolute;
    inset: 0.85rem 240px 0.85rem 0.85rem;
    border-radius: 10px;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.06) 0px,
        rgba(255, 255, 255, 0.06) 1px,
        transparent 1px,
        transparent 4px
    );
    mix-blend-mode: soft-light;
}

.legend {
    border: 1px solid #28427c;
    border-radius: 10px;
    background: rgba(6, 10, 22, 0.8);
    padding: 0.72rem;
    display: grid;
    align-content: start;
    gap: 0.55rem;
    font-size: 0.86rem;
}

.legend div {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid #355596;
}

.depot { background: #36f3ff; }
.delivery { background: #ffc867; }
.block { background: #2a3250; }
.route { background: #ff5fd7; }

#status {
    margin-top: 0.25rem;
    color: var(--muted);
    line-height: 1.45;
}

#status.good { color: var(--good); }
#status.bad { color: var(--bad); }

@media (max-width: 980px) {
    .board-wrap {
        grid-template-columns: 1fr;
    }

    .scanlines {
        inset: 0.85rem;
    }
}

@media (max-width: 700px) {
    .controls {
        grid-template-columns: repeat(2, minmax(130px, 1fr));
    }

    .meters {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }
}
