:root {
    color-scheme: dark;
    color: #eef2ed;
    background: #111;
    font: 100% system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }

.cabinet {
    width: min(100% - 2rem, 68rem, max(30rem, calc((100svh - 9rem) * 1.3333)));
    margin: 0 auto;
    padding: 1rem 0 1.5rem;
    container-type: inline-size;
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: .75rem;
    margin-bottom: .75rem;
}

h1 { margin: 0; font-size: 1.4rem; }
h1 span { margin-left: .4rem; color: #a9b7ad; font-size: .95rem; font-weight: 400; }

.copyright-notice {
    grid-column: 2;
    margin: 0;
    color: #a9b7ad;
    font-size: .85rem;
    line-height: 1.4;
    text-align: center;
}

#game-controls {
    grid-column: 3;
    justify-self: end;
    display: flex;
    gap: .35rem;
    white-space: nowrap;
}

#game-controls button { padding-inline: .6rem; }

@container (max-width: 40rem) {
    .toolbar { grid-template-columns: minmax(0, 1fr) auto; row-gap: .5rem; }
    .copyright-notice { grid-column: 1 / -1; grid-row: 2; }
    #game-controls { grid-column: 2; grid-row: 1; }
    h1 span { display: block; margin-left: 0; }
}

.monitor {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 4 / 3;
    border: 1px solid #35443b;
    background: #000;
}

.monitor:has(#rom-panel[hidden]) { cursor: none; }

canvas { position: absolute; width: 100%; height: 100%; touch-action: none; }

.rom-panel {
    position: relative;
    width: min(100% - 1.5rem, 26rem);
    margin: 0;
    padding: clamp(.75rem, 3vw, 1.5rem);
    background: #141b16;
    border: 1px solid #52665a;
    text-align: center;
    overflow-wrap: anywhere;
}

button {
    padding: .5rem .8rem;
    border: 1px solid #52665a;
    border-radius: .3rem;
    color: inherit;
    background: #222e26;
    font: inherit;
    cursor: pointer;
    touch-action: none;
}

button:disabled { opacity: .55; cursor: default; }
button[aria-pressed="true"] { background: #354b3e; }
:focus-visible { outline: 2px solid #c6ebcd; outline-offset: 2px; }

.paused {
    position: absolute;
    top: 1rem;
    padding: .35rem .75rem;
    background: #000;
    color: #f99;
    font: 600 1.15rem monospace;
    text-transform: uppercase;
}

.touch-controls { display: none; margin-top: .75rem; gap: .5rem; flex-wrap: wrap; }
.controls-hint, .rom-panel { color: #b9c5bc; }
details { color: #b9c5bc; }
summary { cursor: pointer; }
output { display: block; margin-top: .5rem; font-family: monospace; }
.loading { margin: 2rem; text-align: center; }

@media (any-pointer: coarse) {
    .touch-controls { display: flex; }
}
