:root {
    color-scheme: dark;
    --bg: #090b0e;
    --panel: #12171d;
    --panel2: #0d1217;
    --line: #29313b;
    --text: #edf2f7;
    --muted: #8fa0b3;
    --accent: #e7a72e;
    --good: #63d391;
    --bad: #ef6d6d;
    --blue: #79aef7;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body { min-height: 100vh; }

a { color: inherit; }

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 26px 0 50px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.brand {
    font-size: 14px;
    font-weight: 900;
    letter-spacing: .14em;
    text-transform: uppercase;
}

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

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
}

.hero {
    padding: 28px;
    margin-bottom: 18px;
}

.hero h1 {
    margin: 0 0 9px;
    font-size: clamp(28px, 5vw, 48px);
    line-height: 1;
}

.hero p {
    margin: 0;
    color: var(--muted);
    max-width: 780px;
    line-height: 1.6;
}

.status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 31px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.badge.good { color: var(--good); border-color: rgba(99, 211, 145, .35); }
.badge.bad { color: var(--bad); border-color: rgba(239, 109, 109, .35); }
.badge.warn { color: #ffd377; border-color: rgba(255, 211, 119, .35); }

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.game-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 190px;
}

.game-title {
    margin: 0;
    font-size: 21px;
}

.game-subtitle {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}

.spacer { flex: 1; }

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

.btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 15px;
    border: 1px solid #46505f;
    border-radius: 9px;
    background: #18202a;
    color: #fff;
    text-decoration: none;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.btn:hover { filter: brightness(1.09); }
.btn.primary { background: #66470c; border-color: #9a7018; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: #733; background: #2a1515; }

.notice {
    margin-top: 14px;
    padding: 13px 14px;
    border-radius: 10px;
    border: 1px solid #62531e;
    background: #29230e;
    color: #f1d58f;
    line-height: 1.55;
    font-size: 13px;
}

.notice.error {
    border-color: #733;
    background: #251313;
    color: #f4aaaa;
}

.notice.good {
    border-color: #29583c;
    background: #102319;
    color: #a8e9bf;
}

.emulator-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 16px;
    align-items: start;
}

.game-shell {
    overflow: hidden;
    min-height: 300px;
    aspect-ratio: 4 / 3;
    background: #000;
    border: 1px solid var(--line);
    border-radius: 12px;
}

#game {
    width: 100%;
    height: 100%;
}

.side h2 {
    margin: 0 0 12px;
    font-size: 18px;
}

.side p, .side li {
    color: var(--muted);
    line-height: 1.55;
    font-size: 13px;
}

.side ol, .side ul {
    padding-left: 20px;
}

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

.kv div:nth-child(odd) { color: var(--muted); }
.kv div:nth-child(even) { font-weight: 800; text-align: right; }

.login {
    width: min(440px, 100%);
    margin: 80px auto 0;
}

.field {
    display: grid;
    gap: 7px;
    margin: 15px 0;
}

.field label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.field input {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #090d12;
    color: #fff;
    font: inherit;
}

.code {
    padding: 12px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #080b0e;
    font-family: Consolas, "Cascadia Mono", monospace;
    font-size: 12px;
    color: #b8c6d5;
    white-space: pre-wrap;
}

.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px;
}

.health-card strong {
    display: block;
    margin-top: 6px;
    overflow-wrap: anywhere;
}

.obs-lock {
    color: #ffc45c;
    font-weight: 900;
}

@media (max-width: 850px) {
    .emulator-layout { grid-template-columns: 1fr; }
    .side { order: -1; }
}
