:root {
    color-scheme: dark;
    --bg: #2e3143;
    --bg-deep: #191c29;
    --case: #c5beb0;
    --panel: #403e59;
    --screen-shell: #222538;
    --ink: #f4f0e8;
    --muted: #cdc6ba;
    --muted-dark: #9a93a5;
    --accent: #6f7df1;
    --accent-hot: #ff7f52;
    --lime: #9fdc78;
    --shadow: rgba(8, 11, 21, 0.45);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top, rgba(124, 120, 173, 0.35), transparent 34%),
        linear-gradient(180deg, #3a3d57 0%, var(--bg-deep) 100%);
    color: var(--ink);
    font-family: "Press Start 2P", system-ui;
    font-weight: 400;
    font-style: normal;
}

header,
main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 4vw;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding-top: 26px;
    padding-bottom: 22px;
}

a {
    color: inherit;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 23px;
    font-weight: 700;
    letter-spacing: -1px;
    text-decoration: none;
}

.mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ffffff, #d8d1c2);
    color: #32354b;
    box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.18);
    font-style: italic;
}

.subbrand,
.tag,
.eyebrow,
.step,
.spec dt,
.machine-footer,
footer,
.machine-bar h2,
.drive-state {
    font-size: 14px;
    font-family: "Press Start 2P", system-ui;
    font-weight: 400;
    font-style: normal;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.subbrand {
    margin-left: 10px;
    color: var(--muted-dark);
}

.tag {
    font-size: 10px;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--muted);
}

.intro {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 360px);
    gap: 28px;
    align-items: end;
    padding: 18px 0 32px;
}

.intro-copy {
    padding: 28px 30px 34px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    box-shadow: 0 20px 50px var(--shadow);
}

.eyebrow {
    margin: 0 0 14px;
    color: var(--lime);
}

h1 {
    margin: 0;
    font-size: clamp(26px, 6vw, 30px);
    letter-spacing: -3px;
}

h1 span {
    color: #b9beff;
}

.lede {
    margin: 18px 0 0;
    max-width: 42rem;
    color: var(--muted);
    font-size: 17px;
}

.spec {
    margin: 0;
    padding: 18px 22px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    background: rgba(12, 16, 28, 0.34);
    box-shadow: 0 18px 42px var(--shadow);
}

.spec > div {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.spec > div:last-child {
    border-bottom: 0;
}

.spec dt {
    color: var(--muted-dark);
}

.spec dd {
    margin: 0;
    font-size: 13px;
    text-align: right;
}

.workbench {
    overflow: hidden;
    border-radius: 30px;
    background: linear-gradient(180deg, #d8d1c1 0%, var(--case) 100%);
    color: #202331;
    box-shadow: 0 30px 80px var(--shadow);
}

.machine-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 22px;
    background: linear-gradient(180deg, #e8e2d6, #c8c0b3);
    border-bottom: 1px solid rgba(43, 44, 52, 0.18);
}

.machine-bar h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.led {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #888273;
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.12);
}

.led.ready {
    background: var(--lime);
    box-shadow: 0 0 14px rgba(159, 220, 120, 0.7);
}

#status {
    max-width: 60%;
    overflow-wrap: anywhere;
    font-size: 13px;
    color: #333543;
}

.machine-shell {
    display: grid;
    grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
    gap: 20px;
    padding: 22px;
}

.control-deck,
.display-stage,
.panel,
details {
    border-radius: 22px;
}

.control-deck {
    padding: 18px;
    background: linear-gradient(180deg, #b1a99d, #9f9789);
    box-shadow: inset -10px -10px 18px rgba(63, 58, 51, 0.16), inset 10px 10px 18px rgba(255, 255, 255, 0.18);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.toolbar-primary {
    margin-bottom: 16px;
}

button,
.file-button,
.file-select select,
.control-chip {
    min-height: 42px;
    border: 1px solid rgba(34, 35, 44, 0.28);
    border-radius: 14px;
    background: linear-gradient(180deg, #f0ece5, #d9d0c3);
    color: #262837;
    font-size: 9px;
    font-family: "Press Start 2P", system-ui;
    font-weight: 400;
    font-style: normal;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 3px 10px rgba(40, 34, 31, 0.12);
}

button,
.file-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
}

button:hover,
.file-button:hover,
.file-select select:hover {
    transform: translateY(-1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    transform: none;
}

.primary-button {
    background: linear-gradient(180deg, #7484ff, #5e6ee4);
    color: #f9fbff;
    border-color: rgba(35, 44, 113, 0.4);
}

.file-button input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.file-button:focus-within,
button:focus-visible,
.file-select select:focus-visible,
.control-chip:focus-within,
#screen:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--accent-hot);
    outline-offset: 3px;
}

.control-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: #35384c;
}

.joystick-option input {
    accent-color: var(--accent);
}

.file-select {
    display: inline-flex;
    min-width: 0;
    flex: 1 1 190px;
}

.file-select-primary {
    flex: 1 1 220px;
    max-width: 320px;
}

.file-select-disk {
    flex: 0 1 190px;
}

.file-select-mode {
    flex: 0 1 180px;
}

.file-select select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 999px;
}

.drive-rack {
    display: grid;
    gap: 12px;
}

.drive-bay {
    position: relative;
    padding: 16px 18px 18px;
    border: 1px solid rgba(24, 25, 31, 0.16);
    border-radius: 26px;
    overflow: hidden;
    background:
        radial-gradient(circle at 8% 14%, rgba(255, 255, 255, 0.28), transparent 18%),
        linear-gradient(180deg, #e6ddd0, #c9c0b4);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        inset 0 -20px 32px rgba(0, 0, 0, 0.08);
}

.drive-bay::before {
    content: "";
    position: absolute;
    inset: 12px 12px auto auto;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(30, 31, 36, 0.18);
    box-shadow: -30px 0 0 rgba(30, 31, 36, 0.12);
}

.drive-bay::after {
    content: "";
    position: absolute;
    inset: auto 16px 14px 16px;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.24);
}

.drive-bay p,
.drive-bay .muted {
    margin: 10px 0 0;
    color: #4c4e5d;
    font-size: 13px;
}

.drive-bay-active {
    background:
        radial-gradient(circle at 12% 12%, rgba(255, 255, 255, 0.14), transparent 20%),
        linear-gradient(180deg, #5c6edd, #273d9f 58%, #1b2d7a);
    color: var(--ink);
}

.drive-bay-active p,
.drive-bay-active .muted,
.drive-bay-active #disk-info,
.drive-bay-active #disk-bytes,
.drive-bay-active #disk-label,
.drive-bay-active #disk-sublabel {
    color: #25316f;
}

.drive-bay-active #disk-label,
.drive-bay-active #disk-sublabel{
    font-family: "Indie Flower", cursive;
}

.drive-label-face {
    position: relative;
    display: grid;
    gap: 2px;
    min-height: 118px;
    margin-top: 12px;
    padding: 18px 20px 16px 22px;
    border-radius: 21px 21px 18px 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(229, 223, 212, 0.86));
    border: 1px solid rgba(24, 25, 31, 0.14);
    color: #25316f;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.drive-label-face::after {
    content: "";
    position: absolute;
    right: 14px;
    top: 15px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(68, 76, 146, 0.22);
    box-shadow: -28px 0 0 rgba(68, 76, 146, 0.14);
}

.drive-label-face span {
    display: block;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1.1px;
    text-transform: uppercase;
}

.drive-label-face small {
    font: 12px/1.4 "Courier New", monospace;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.drive-label-face-empty {
    background:
        linear-gradient(180deg, rgba(243, 240, 233, 0.94), rgba(216, 210, 201, 0.9));
    color: #454851;
}

.drive-label-face-empty::after {
    background: rgba(83, 87, 99, 0.2);
    box-shadow: -28px 0 0 rgba(83, 87, 99, 0.12);
}

.drive-bay-ghost {
    min-height: 136px;
    opacity: 0.95;
    background:
        radial-gradient(circle at 12% 12%, rgba(255, 255, 255, 0.18), transparent 20%),
        linear-gradient(180deg, #d7d2ca, #bbb4a9);
}

.drive-bay-ghost .drive-label-face {
    margin-top: 10px;
    min-height: 98px;
}

.drive-bay-ghost .drive-label-face span {
    font-size: 15px;
}

.drive-bay-ghost .drive-label-face small {
    color: #575c69;
}

.drive-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.drive-head h3,
.panel-heading h3,
.guide h3,
summary {
    margin: 0;
    font-size: 18px;
    letter-spacing: -0.5px;
}

.drive-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.game-disk-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.game-disk-actions button {
    min-width: 88px;
    padding: 8px 12px;
    border-radius: 999px;
}

#disk-bytes,
#registers {
    margin: 14px 0 0;
    padding: 14px;
    border-radius: 16px;
    background: rgba(9, 12, 21, 0.7);
    color: #dce6ff;
    font: 12px/1.8 "Courier New", monospace;
    letter-spacing: 0.35px;
    white-space: pre-wrap;
    word-break: break-word;
}

#disk-bytes {
    display: none;
}

.display-stage {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.display {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 640px;
    padding: 28px;
    border-radius: 24px;
    background:
        linear-gradient(180deg, rgba(7, 9, 20, 0.84), rgba(10, 12, 22, 0.95)),
        radial-gradient(circle at center, rgba(45, 84, 255, 0.16), transparent 55%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.display canvas {
    width: min(100%, 880px);
    height: auto;
    aspect-ratio: 5 / 4;
    border: 18px solid #7e7c88;
    border-radius: 18px;
    background: #000;
    box-shadow: 0 24px 40px rgba(0, 0, 0, 0.45);
    image-rendering: pixelated;
}

.display[data-display-mode="pal"] canvas,
.display[data-display-mode="pal"] canvas {
    aspect-ratio: 4 / 3;
}

.display[data-display-mode="ntsc"] canvas {
    aspect-ratio: 11 / 8;
}

.screen-overlay {
    position: absolute;
    inset: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px;
    border-radius: 18px;
    background: radial-gradient(circle at center, rgba(43, 71, 197, 0.36), rgba(8, 10, 18, 0.92));
    text-align: center;
}

.screen-overlay h2 {
    margin: 14px 0 10px;
    font-size: clamp(32px, 4vw, 46px);
    letter-spacing: -1.5px;
}

.screen-overlay p {
    margin: 0;
    max-width: 32rem;
    color: #d8def7;
}

.capture-overlay {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 5;
}

.machine-footer {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 18px;
    border-radius: 18px;
    background: rgba(32, 35, 52, 0.92);
    color: #d3d8f5;
}

.service-bay {
    display: grid;
    grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.1fr);
    gap: 20px;
    margin-top: 22px;
}

.panel,
details {
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 19, 32, 0.7);
    box-shadow: 0 18px 48px var(--shadow);
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.toolbar-secondary {
    padding-top: 4px;
}

.muted,
.panel p,
details p,
footer,
.guide p {
    font-size: 12px;
    color: var(--muted);
}

.guide {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    margin-top: 22px;
    font-family: 'Courier New', Courier, monospace;
}

.guide article {
    padding: 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

details {
    margin-top: 22px;
}

summary {
    cursor: pointer;
    list-style: none;
}

summary::-webkit-details-marker {
    display: none;
}

footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 24px 0 34px;
}

.display:fullscreen {
    width: 100%;
    height: 100%;
    padding: 0;
    border-radius: 0;
}

.display:fullscreen canvas {
    width: auto;
    max-width: 100vw;
    max-height: 100vh;
    height: 100%;
    border-radius: 0;
    border-width: 0;
}

@media (max-width: 1100px) {
    .intro,
    .machine-shell,
    .service-bay,
    .guide {
        grid-template-columns: 1fr;
    }

    .display {
        min-height: 480px;
    }
}

@media (max-width: 720px) {
    header,
    .machine-bar,
    .machine-footer,
    footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .brand {
        flex-wrap: wrap;
    }

    .machine-shell,
    .control-deck,
    .panel,
    .guide article,
    details {
        padding-left: 16px;
        padding-right: 16px;
    }

    .display {
        min-height: 360px;
        padding: 16px;
    }

    .screen-overlay {
        inset: 16px;
    }

    .display canvas {
        border-width: 10px;
    }

    #status {
        max-width: 100%;
    }
}
