:root {
    color-scheme: dark;
    --ink: #f2e8cf;
    --muted: #b9c7a2;
    --panel: rgba(19, 30, 28, 0.82);
    --panel-strong: rgba(13, 20, 21, 0.94);
    --line: rgba(224, 211, 156, 0.28);
    --accent: #e0b95f;
    --good: #94c973;
    --bad: #d16d59;
}

* {
    box-sizing: border-box;
}

html,
body,
#app {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: #071012;
    font-family: "Courier New", monospace;
    color: var(--ink);
}

canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    image-rendering: pixelated;
    cursor: crosshair;
    background: #071012;
}

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

.splash {
    position: fixed;
    inset: 0;
    z-index: 5;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background:
        radial-gradient(circle at 50% 42%, rgba(75, 105, 90, 0.32), rgba(7, 16, 18, 0.92) 58%),
        rgba(7, 16, 18, 0.82);
}

.splash.show {
    display: flex;
}

.splash-panel {
    width: min(420px, 94vw);
    border: 1px solid var(--line);
    background: var(--panel-strong);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.48);
    padding: 18px;
}

.splash-panel h1 {
    margin-bottom: 16px;
    font-size: 28px;
}

.splash-panel label,
.splash-panel fieldset {
    display: block;
    margin: 0 0 14px;
}

.splash-panel span,
.splash-panel legend {
    display: block;
    margin-bottom: 6px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
}

.splash-panel input[type="text"],
.splash-panel input:not([type]) {
    width: 100%;
    border: 1px solid rgba(242, 232, 207, 0.34);
    border-radius: 4px;
    padding: 9px 10px;
    background: rgba(8, 14, 16, 0.9);
    color: var(--ink);
    font: 700 15px "Courier New", monospace;
}

.splash-panel fieldset {
    border: 1px solid rgba(242, 232, 207, 0.22);
    padding: 10px;
}

.splash-panel fieldset label {
    margin: 6px 0;
    color: #eadfbd;
    font-size: 13px;
}

.splash-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

#hud::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.04),
        rgba(255, 255, 255, 0.04) 1px,
        rgba(0, 0, 0, 0) 3px,
        rgba(0, 0, 0, 0) 5px
    );
    mix-blend-mode: soft-light;
}

.topbar,
.sidebar,
#log,
#toast {
    pointer-events: auto;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(4px);
}

.topbar {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 19px;
    line-height: 1.1;
    color: #fff4be;
}

h2 {
    margin: 0 0 7px;
    font-size: 13px;
    color: var(--accent);
}

#era {
    margin-top: 3px;
    font-size: 12px;
    color: var(--muted);
}

.controls,
.button-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.power-meter {
    width: min(260px, 28vw);
    min-width: 180px;
}

.meter-label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 5px;
    color: #fff4be;
    font-size: 12px;
    font-weight: 700;
}

.meter-track {
    width: 100%;
    height: 12px;
    border: 1px solid rgba(242, 232, 207, 0.38);
    background: rgba(5, 10, 12, 0.72);
    overflow: hidden;
}

#powerFill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #6db6ff, #d6a8ff, #fff2a6);
    box-shadow: 0 0 12px rgba(214, 168, 255, 0.58);
    transition: width 140ms linear;
}

button {
    min-height: 30px;
    border: 1px solid rgba(242, 232, 207, 0.32);
    border-radius: 4px;
    padding: 5px 8px;
    background: rgba(37, 57, 50, 0.9);
    color: var(--ink);
    font: 700 12px/1 "Courier New", monospace;
    cursor: pointer;
}

button:hover,
button.active {
    border-color: #ffe29a;
    background: rgba(103, 83, 45, 0.95);
    color: #fff7cf;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    border-color: rgba(242, 232, 207, 0.16);
    background: rgba(25, 31, 31, 0.86);
    color: rgba(242, 232, 207, 0.6);
}

.sidebar {
    position: absolute;
    top: 78px;
    bottom: 112px;
    width: min(280px, 31vw);
    min-width: 210px;
    overflow: auto;
    padding: 10px;
}

.sidebar.left {
    left: 10px;
}

.sidebar.right {
    right: 10px;
}

#selection,
#stats {
    margin-bottom: 13px;
    font-size: 12px;
    line-height: 1.45;
    color: #e9dfbf;
}

.row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 3px 0;
}

.row span:last-child {
    text-align: right;
    color: #fff4be;
}

#log {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    min-height: 86px;
    max-height: 94px;
    overflow: hidden;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.35;
}

.event {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #dccfa8;
}

.event:first-child {
    color: #fff6ca;
}

#toast {
    position: absolute;
    left: 50%;
    bottom: 118px;
    transform: translateX(-50%);
    max-width: min(620px, 90vw);
    padding: 8px 12px;
    color: #fff7ca;
    opacity: 0;
    transition: opacity 160ms linear;
}

#toast.show {
    opacity: 1;
}

@media (max-width: 820px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .power-meter {
        width: 100%;
    }

    .sidebar {
        top: auto;
        bottom: 108px;
        width: calc(50vw - 15px);
        min-width: 0;
        max-height: 32vh;
    }

    .sidebar.left {
        left: 10px;
    }

    .sidebar.right {
        right: 10px;
    }

    button {
        padding: 5px 6px;
        font-size: 11px;
    }
}
