:root {
    --nes-red: #e33036;
    --nes-cream: #d8d7d2;
    --nes-mid: #8b8b87;
    --nes-ink: #202024;
    --nes-screen: #080b0d;
}

.nes-page {
    background: #000;
}

.nes-main {
    width: min(1600px, 96%);
    margin-top: 45px;
}

.nes-intro {
    text-align: center;
    margin-bottom: 9.5px;
}

.nes-eyebrow {
    margin: 0 0 8px;
    color: var(--nes-red);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: 5px;
}

.nes-logo-heading {
    margin: 0;
    line-height: 0;
}

.nes-logo {
    display: block;
    width: min(500px, 88vw);
    height: auto;
    margin-inline: auto;
}

.console-deck {
    padding: 25px clamp(18px, 4vw, 48px) 42px;
    color: var(--nes-cream);
    background: #000;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 16px;
    box-shadow: 0 35px 70px rgba(0,0,0,.58);
}

.console-topbar,
.console-controls,
.controller-panel {
    width: min(1400px, 100%);
    margin-inline: auto;
}

.console-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 17px;
    font: 800 .72rem/1 Arial, sans-serif;
    letter-spacing: 2px;
}

.console-wordmark span {
    color: var(--nes-red);
    font-size: 1.25rem;
    font-style: italic;
}

.power-state {
    display: flex;
    align-items: center;
    gap: 8px;
}

.power-state i {
    width: 9px;
    height: 9px;
    background: #5f5f5c;
    border-radius: 50%;
    box-shadow: inset 0 1px 2px #222;
}

.power-state i.on {
    background: var(--nes-red);
    box-shadow: 0 0 10px var(--nes-red);
}

.tv-stage {
    position: relative;
    width: min(1215px, 100%);
    margin-inline: auto;
}

.nes-console-unit {
    position: relative;
    z-index: 7;
    width: 50%;
    aspect-ratio: 1362 / 557;
    margin: 0 auto -1px;
    transform: translateY(5%);
    overflow: hidden;
    pointer-events: none;
    user-select: none;
    filter:
        drop-shadow(0 10px 7px rgba(0,0,0,.46))
        drop-shadow(0 0 10px rgba(0,0,0,.35));
}

.nes-console-unit img {
    position: absolute;
    top: -37.88%;
    left: -6.17%;
    display: block;
    width: 112.78%;
    max-width: none;
    height: auto;
}

.nes-console-unit::after {
    content: "";
    position: absolute;
    z-index: 1;
    left: 12.1%;
    top: 74.96%;
    width: 1.55%;
    aspect-ratio: 1;
    background: #170607;
    border-radius: 15%;
    box-shadow: inset 0 0 0 .09cqw #050505;
}

.nes-console-unit.powered-on::after {
    background: #ff171d;
    box-shadow:
        inset 0 0 0 .09cqw #180002,
        0 0 .45cqw #ff171d,
        0 0 1.1cqw rgba(255, 23, 29, .9);
}

.screen-bezel {
    position: relative;
    width: 100%;
    aspect-ratio: 1599 / 1144;
    filter: drop-shadow(0 30px 26px rgba(0,0,0,.62));
}

.screen-bezel::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 5;
    background: url("/weather/images/tv/cabinet.png") center / 100% 100% no-repeat;
    pointer-events: none;
}

.screen {
    position: absolute;
    left: 8%;
    top: 11.5%;
    width: 69%;
    height: 75%;
    overflow: hidden;
    background: var(--nes-screen);
    border-radius: 10% / 12%;
    box-shadow: inset 0 0 45px #000;
}

.screen::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    background: repeating-linear-gradient(0deg, rgba(0,0,0,.14) 0 1px, transparent 1px 3px);
    mix-blend-mode: multiply;
}

.screen canvas {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.screen canvas[hidden] {
    display: none;
}

.screen.zapper-enabled {
    cursor: crosshair;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.zapper-crosshair {
    position: absolute;
    z-index: 6;
    left: 50%;
    top: 50%;
    width: clamp(24px, 5.5%, 42px);
    aspect-ratio: 1;
    opacity: 0;
    transform: translate(-50%, -50%);
    border: 2px solid #ff272d;
    border-radius: 50%;
    background:
        linear-gradient(transparent 46%, #fff 46% 54%, transparent 54%),
        linear-gradient(90deg, transparent 46%, #fff 46% 54%, transparent 54%);
    box-shadow: 0 0 8px #000, 0 0 10px rgba(255, 39, 45, .8);
    pointer-events: none;
    transition: opacity .12s ease;
}

.screen.zapper-enabled .zapper-crosshair {
    opacity: 1;
}

.screen.zapper-enabled.zapper-crosshair-hidden .zapper-crosshair {
    opacity: 0;
}

.screen-idle {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
}

.screen-idle.hidden {
    display: none;
}

.idle-grid {
    position: absolute;
    inset: -20%;
    background:
        linear-gradient(rgba(73, 153, 178, .12) 1px, transparent 1px),
        linear-gradient(90deg, rgba(73, 153, 178, .12) 1px, transparent 1px);
    background-size: 26px 26px;
    transform: perspective(300px) rotateX(55deg) translateY(20%);
    mask-image: linear-gradient(to bottom, transparent, black);
}

.idle-copy {
    position: relative;
    z-index: 1;
    display: grid;
    justify-items: center;
    gap: 10px;
    color: #dadada;
    font-family: "Courier New", monospace;
    text-align: center;
    text-shadow: 0 0 10px rgba(103,217,255,.5);
}

.idle-copy strong { letter-spacing: 4px; }
.idle-copy small { color: #6f9daa; letter-spacing: 2px; }

.pixel-cart {
    width: 50px;
    height: 42px;
    border: 4px solid #93bac5;
    box-shadow: inset 0 -10px #416975, 0 0 14px rgba(103,217,255,.25);
}

.screen-badge {
    display: none;
}

.console-controls {
    padding-top: 26px;
}

.rom-loader {
    display: grid;
    grid-template-columns: minmax(220px, 1.3fr) 190px minmax(0, 1fr);
    gap: 20px;
    align-items: center;
}

.game-picker label {
    display: block;
    margin-bottom: 6px;
    color: var(--nes-red);
    font: 800 .58rem/1 Arial, sans-serif;
    letter-spacing: 2px;
}

.game-picker select {
    width: 100%;
    min-height: 48px;
    padding: 0 38px 0 13px;
    color: #252529;
    background: #e8e7e2;
    border: 2px solid #686865;
    border-radius: 4px;
    font: 800 .74rem/1 Arial, sans-serif;
    letter-spacing: 1px;
}

.game-picker select:focus-visible {
    outline: 3px solid var(--nes-red);
    outline-offset: 2px;
}

.deck-button {
    appearance: none;
    min-height: 48px;
    padding: 11px 15px;
    color: #28282c;
    background: linear-gradient(#f2f1ec, #b8b7b2);
    border: 2px solid #686865;
    border-radius: 4px;
    box-shadow: 0 4px 0 #666663, inset 0 1px white;
    font: 800 .7rem/1 Arial, sans-serif;
    letter-spacing: 1.5px;
    cursor: pointer;
}

.deck-button:hover:not(:disabled) { color: var(--nes-red); transform: translateY(-1px); }
.deck-button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #666663; }
.deck-button:disabled { cursor: not-allowed; opacity: .42; }

.load-button {
    color: white;
    background: linear-gradient(#ef454a, #aa171c);
    border-color: #801317;
    box-shadow: 0 5px 0 #761216, inset 0 1px rgba(255,255,255,.4);
}

.load-button:hover:not(:disabled) { color: white; filter: brightness(1.08); }

.load-button span,
.load-button small { display: block; }
.load-button small { margin-top: 5px; font-size: .52rem; opacity: .75; letter-spacing: 1px; }

.rom-info {
    min-width: 0;
    padding: 10px 14px;
    background: rgba(255,255,255,.08);
    border-left: 4px solid #8c8c88;
}

.rom-info span,
.rom-info strong,
.rom-info small { display: block; }
.rom-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 800 .9rem/1.5 Arial, sans-serif; }
.rom-info small { color: #aaa9a5; }
.rom-label { color: var(--nes-red); font: 800 .58rem/1 Arial, sans-serif; letter-spacing: 2px; }

.action-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    margin-top: 22px;
}

.zapper-button.active {
    color: #fff;
    background: linear-gradient(#ef454a, #aa171c);
    border-color: #801317;
    box-shadow: 0 4px 0 #761216, inset 0 1px rgba(255,255,255,.4);
}

.zapper-help {
    margin: 16px 0 0;
    color: var(--nes-red);
    font: 800 .65rem/1.4 "Courier New", monospace;
    letter-spacing: 1px;
    text-align: center;
}

.console-status {
    margin: 19px 0 0;
    color: #aaa9a5;
    font: 700 .72rem/1.4 "Courier New", monospace;
    letter-spacing: 1px;
    text-align: center;
}

.console-status.error { color: #a20e14; }

.controller-panel {
    margin-top: 65px;
    padding: 35px;
    background: linear-gradient(145deg, #25252a, #17171a);
    border: 1px solid #444449;
    border-radius: 12px;
    box-shadow: 0 18px 45px rgba(0,0,0,.4);
}

.controller-copy { text-align: center; }
.controller-copy h2 { color: white; font-size: 1.6rem; font-weight: 700; }
.controller-copy p:last-child { margin: 10px auto 24px; font-size: .95rem; }

.key-guide {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 11px;
}

.key-guide div {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 11px;
    color: #85858b;
    border: 1px solid #3b3b40;
    border-radius: 5px;
    font: 700 .6rem/1 Arial, sans-serif;
    letter-spacing: 1px;
}

kbd {
    color: white;
    font: 700 .7rem/1 "Courier New", monospace;
}

.touch-controller {
    position: relative;
    isolation: isolate;
    display: none;
    container-type: inline-size;
    box-sizing: border-box;
    width: min(560px, 100%);
    aspect-ratio: 495 / 222;
    margin: 26px auto 0;
    padding: 0;
    overflow: hidden;
    background: linear-gradient(160deg, #dededc, #a7a7a4 72%);
    border: .6cqw solid #b9b9b7;
    border-radius: 2.2cqw;
    box-shadow: inset 0 .6cqw rgba(255,255,255,.9), inset 0 -1.2cqw #858582;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.touch-controller,
.touch-controller * {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-user-drag: none;
}

.touch-controller button {
    appearance: none;
    -webkit-appearance: none;
    color: white;
    background: #050505;
    border: 0;
    box-shadow: inset 0 0 0 .35cqw #242424, 0 .6cqw 0 #000;
    cursor: pointer;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    will-change: transform;
}

.touch-controller::before {
    content: "";
    position: absolute;
    left: 2.6%;
    right: 3%;
    top: 19.8%;
    bottom: 6.5%;
    z-index: 0;
    background: #050505;
    border-radius: 1cqw;
    box-shadow: inset 0 2px 4px rgba(255,255,255,.08), inset 0 -2px 3px #111;
}

.controller-brand {
    position: absolute;
    z-index: 3;
    left: 67%;
    top: 35.5%;
    width: 17.5%;
}

.controller-brand img {
    display: block;
    width: 100%;
    height: auto;
    filter: contrast(260%) brightness(115%);
}

.touch-controller button.pressed { transform: translate3d(0, .45cqw, 0); }

.dpad {
    position: absolute;
    z-index: 2;
    left: 7.1%;
    top: 40.5%;
    display: grid;
    width: 20.5%;
    aspect-ratio: 1;
    grid-template: repeat(3, 1fr) / repeat(3, 1fr);
    filter: drop-shadow(0 .65cqw 0 #111);
}
.dpad::before {
    content: "";
    position: absolute;
    inset: -.8cqw;
    z-index: -1;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M36 2H64Q68 2 68 6V32H94Q98 32 98 36V64Q98 68 94 68H68V94Q68 98 64 98H36Q32 98 32 94V68H6Q2 68 2 64V36Q2 32 6 32H32V6Q32 2 36 2Z' fill='%23050505' stroke='%23bdbdbb' stroke-width='4' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.dpad button { position: relative; z-index: 1; color: #77777a; background: #050505; border-radius: .35cqw; box-shadow: inset 0 0 0 .35cqw #242424; font-size: 2.1cqw; text-shadow: 0 -.2cqw #000; }
.dpad button:nth-child(1) { grid-area: 1 / 2; }
.dpad button:nth-child(2) { grid-area: 2 / 1; }
.dpad i { position: relative; z-index: 1; grid-area: 2 / 2; background: #050505; box-shadow: inset 0 0 0 .35cqw #242424; }
.dpad i::after { content: ""; position: absolute; inset: 28%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #888 0 12%, #080808 18% 55%, #000 60%); box-shadow: 0 .2cqw .35cqw #000; }
.dpad button:nth-child(4) { grid-area: 2 / 3; }
.dpad button:nth-child(5) { grid-area: 3 / 2; }

.center-controls {
    position: absolute;
    z-index: 2;
    left: 31.5%;
    top: 19.8%;
    width: 28.5%;
    height: 73.7%;
    display: grid;
    grid-template-rows: 14% 14% 15% 30% 10%;
    row-gap: 4.25%;
}

.center-bar {
    display: block;
    background: #8d8d8d;
    border-radius: .8cqw;
    box-shadow: inset 0 .2cqw rgba(255,255,255,.32);
}

.system-labels {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4%;
    padding: 0 3%;
    background: #8d8d8d;
    border-radius: .8cqw;
}

.system-labels img {
    display: block;
    width: 44%;
    height: auto;
    object-fit: contain;
}

.system-labels img:last-child {
    clip-path: inset(0 6% 0 0);
}

.system-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12%;
    padding: 0 8%;
    background: #d7d7d4;
    border-radius: .8cqw;
    box-shadow: inset 0 0 0 .45cqw #f0f0ee;
}

.system-buttons button {
    width: 29%;
    height: 34%;
    padding: 0;
    background: linear-gradient(#171717, #020202);
    border-radius: 2cqw;
    transform: none;
    box-shadow: inset 0 .35cqw .35cqw #111, 0 .2cqw #777;
}

.ab-buttons { position: absolute; z-index: 2; left: 64.6%; top: 61.5%; width: 24%; height: 32%; display: flex; align-items: stretch; gap: 14%; padding: 0; background: transparent; }
.ab-buttons label { position: relative; display: grid; grid-template-rows: 76% 24%; justify-items: center; width: 43%; padding: 0; color: #d43b42; font: 800 2.5cqw/1 Arial, sans-serif; }
.ab-buttons label::before { content: ""; position: absolute; inset: 0 0 24%; z-index: -1; background: #d7d7d4; border-radius: 1cqw; box-shadow: inset 0 0 0 .45cqw #f0f0ee; }
.ab-buttons button { align-self: center; width: 82%; aspect-ratio: 1; background: radial-gradient(circle at 35% 30%, #f65b61, #c5232c 58%, #8a1118 100%); border-radius: 50%; box-shadow: inset 0 0 0 .4cqw #e34a51, 0 .6cqw 0 #681016; font-size: 0; }
.ab-buttons span { align-self: end; justify-self: end; margin-right: 9%; }

.rom-notice {
    width: min(760px, 94%);
    margin: 32px auto 0;
    color: #777;
    font-size: .78rem;
    text-align: center;
}

.connection-alert[hidden] {
    display: none;
}

.connection-alert {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(0, 0, 0, .86);
}

.connection-alert-card {
    position: relative;
    width: min(960px, 96vw);
    aspect-ratio: 3 / 2;
}

.connection-alert-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.connection-alert-description {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.connection-alert-ok {
    position: absolute;
    left: 37.8%;
    top: 78%;
    width: 24.5%;
    height: 13.5%;
    padding: 0;
    cursor: pointer;
    border: 0;
    border-radius: 12%;
    background: transparent;
    -webkit-tap-highlight-color: transparent;
}

.connection-alert-ok:disabled {
    cursor: default;
}

.connection-alert-ok:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 4px;
}

.connection-alert-open {
    overflow: hidden;
}

.screen-bezel:fullscreen {
    width: min(100vw, 139.77vh);
    height: auto;
    margin: auto;
    background: #050505;
}

.screen-bezel:fullscreen .screen-badge { display: none; }

@media (min-width: 781px) {
    .tv-stage,
    .console-topbar,
    .console-controls,
    .controller-panel {
        width: min(1215px, 100%, calc(100vw - 32px), calc((100vh - 32px) * 1.2006));
        width: min(1215px, 100%, calc(100vw - 32px), calc((100svh - 32px) * 1.2006));
    }
}

@media (hover: none), (pointer: coarse) {
    .touch-controller { display: block; }
}

@media (max-width: 780px) {
    #homeLink {
        top: 14px;
        left: 16px;
        font-size: 13px;
        letter-spacing: 1px;
        opacity: .85;
    }
    .nes-main { margin-top: 64px; }
    .console-deck { padding-inline: 12px; }
    .rom-loader { grid-template-columns: 1fr; gap: 12px; }
    .action-row { grid-template-columns: repeat(2, 1fr); }
    .action-row .zapper-button { grid-column: 1 / -1; }
    .controller-panel { display: none; }
    .touch-controller { display: block; }
}

@media (max-width: 480px) {
    .console-topbar { letter-spacing: 1px; }
    .console-wordmark { font-size: .58rem; }
}
