:root {
    --bg0: #06070b;
    --bg1: #111820;
    --bg2: #1b2631;
    --panel: rgba(12, 16, 22, 0.9);
    --panel-edge: #3c556a;
    --line: rgba(154, 193, 210, 0.2);
    --text: #ecf7ff;
    --muted: #92aab9;
    --accent: #f2b45c;
    --danger: #ff6b77;
    --good: #7de0a8;
    --warning: #ffd66f;
    --scan: rgba(0, 0, 0, 0.18);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Courier New", monospace;
    color: var(--text);
    background:
        radial-gradient(circle at top, rgba(92, 120, 139, 0.18), transparent 35%),
        linear-gradient(180deg, #040507 0%, var(--bg0) 45%, #090b10 100%);
}

#app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 1.15fr) minmax(300px, 0.95fr);
    gap: 18px;
    padding: 18px;
    align-items: stretch;
}

#stage,
#panel {
    min-width: 0;
}

#wrap {
    position: relative;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    aspect-ratio: 16 / 9;
    border: 3px solid var(--panel-edge);
    box-shadow: 0 0 0 3px #05060a, 0 18px 50px rgba(0, 0, 0, 0.45);
    background: linear-gradient(180deg, #0b1116, #050608);
    overflow: hidden;
}

#wrap::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0px,
        rgba(0, 0, 0, 0) 2px,
        var(--scan) 3px,
        var(--scan) 4px
    );
    mix-blend-mode: multiply;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

#panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

header, .card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(22, 28, 36, 0.94), rgba(11, 15, 20, 0.96));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

header {
    padding: 18px 18px 16px;
}

.card {
    padding: 14px 16px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 11px;
}

h1, h2, p {
    margin: 0;
}

h1 {
    font-size: 28px;
    line-height: 1;
    margin-bottom: 8px;
}

#subtitle {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 11px;
    margin-bottom: 10px;
}

.meta-row-secondary {
    margin-top: -4px;
    margin-bottom: 12px;
    color: var(--accent);
}

.resource-list,
.faction-list,
.choice-list {
    display: grid;
    gap: 8px;
}

.resource-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 10px;
}

.resource,
.faction,
.choice-list button,
#start-button,
#restart-button {
    border: 1px solid rgba(157, 187, 208, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
}

.resource,
.faction {
    padding: 8px 10px;
    font-size: 11px;
    line-height: 1.35;
}

.resource strong,
.faction strong {
    display: block;
    font-size: 12px;
    margin-bottom: 2px;
}

.choice-list {
    margin-top: 10px;
}

.choice-list button,
#start-button,
#restart-button {
    padding: 10px 12px;
    font: inherit;
    cursor: pointer;
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.choice-list button:hover,
#start-button:hover,
#restart-button:hover {
    transform: translateY(-1px);
    border-color: rgba(242, 180, 92, 0.65);
    background: rgba(242, 180, 92, 0.12);
}

.choice-list button[disabled] {
    cursor: default;
    opacity: 0.56;
}

#choice-list .option-meta {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 10px;
}

.log ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 11px;
    max-height: 190px;
    overflow: auto;
}

.log li {
    padding-bottom: 6px;
    border-bottom: 1px dashed rgba(157, 187, 208, 0.14);
}

.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

#start-button {
    background: linear-gradient(180deg, rgba(242, 180, 92, 0.22), rgba(242, 180, 92, 0.08));
}

.secondary {
    color: var(--muted);
}

.ending {
    border-color: rgba(125, 224, 168, 0.45);
}

.ending h2 {
    margin-bottom: 8px;
    font-size: 20px;
}

.ending p {
    color: var(--muted);
    line-height: 1.5;
    font-size: 12px;
}

.hidden {
    display: none;
}

@media (max-width: 980px) {
    #app {
        grid-template-columns: 1fr;
    }

    #wrap {
        max-width: 100%;
    }
}
