html,
body {
    margin: 0;
    height: 100%;
    background: #d0e7f9;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.main {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    box-sizing: border-box;
    max-width: 812px;
    border-radius: 10px;
    margin: auto;
    box-shadow: 0 0 0 5px #da4a4a, 0 0 0 20px #474f51;
    background: #da4a4a;
    height: 100%;
    max-height: 414px;
    padding: 10px;
    transform: translateY(-50px);
}

.panel {
    position: relative;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    background: #f8f1d7;
    border-radius: 15px;
    display: flex;
    flex-direction: row;
    box-shadow: inset 8px 8px #fffef7;
}

.function-area {
    flex: 1;
    display: flex;
    padding: 0 20px;
    justify-content: center;
    flex-direction: column;
}

.controller-area {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: row;
}

.action-area {
    display: flex;
    flex-direction: row;
}

.controller {
    position: relative;
    width: 140px;
    height: 140px;
    align-self: flex-end;
    filter: drop-shadow(5px 5px 0px rgba(255, 255, 255, .8));
}

.controller button {
    position: absolute;
    z-index: 1;
    border: 8px solid #474f51;
    background: #857b7a;
    color: transparent;
    border-radius: 15px;
    box-sizing: border-box;
    outline: 0;
    width: 56px;
    height: 56px;
    left: 50%;
    top: 50%;
    user-select: none;
    transform: translate(-50%, -50%);
}

.controller::before {
    content: '';
    position: absolute;
    z-index: 0;
    pointer-events: none;
    box-sizing: border-box;
    left: 50%;
    top: 50%;
    width: 56px;
    height: 56px;
    background: #857b7a;
    transform: translate(-50%, -50%);
}

.controller::after {
    content: '';
    z-index: 2;
    position: absolute;
    pointer-events: none;
    box-sizing: border-box;
    width: 42px;
    height: 42px;
    border: 8px solid #474f51;
    border-radius: 50%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow: inset 0px 8px 0 0px #736a6d, inset 0px -8px 0 0px rgba(255, 255, 255, .4);
}

button.up.joydirection {
    top: 0;
    transform: translate(-50%, 0);
    border-bottom: 0;
    height: 50px;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
    box-shadow: inset 0px 8px 0 0px rgba(255, 255, 255, .5);
}

button.right.joydirection {
    left: auto;
    right: 0;
    transform: translate(0, -50%);
    border-left: 0;
    width: 50px;
    border-bottom-left-radius: 0;
    border-top-left-radius: 0;
    box-shadow: inset 8px 0 0 0px #857b7a, inset 6px 6px 0 0px rgba(255, 255, 255, .4), inset 8px -8px 0 0px rgba(0, 0, 0, .1);
}

button.down.joydirection {
    top: auto;
    transform: translate(-50%, 0);
    bottom: 0;
    border-top: 0;
    height: 50px;
    border-top-right-radius: 0;
    border-top-left-radius: 0;
    box-shadow: inset 0px -8px 0 0px rgba(0, 0, 0, .1);
}

button.left.joydirection {
    left: 0;
    transform: translate(0, -50%);
    border-right: 0;
    width: 50px;
    border-bottom-right-radius: 0;
    border-top-right-radius: 0;
    box-shadow: inset 0px 8px 0 0px rgba(255, 255, 255, .4), inset -8px 0px 0 0px #857b7a, inset -8px -8px 0 0px rgba(0, 0, 0, .1);
}

.function {
    display: flex;
    padding: 8px 15px;
    border-radius: 50px;
    align-self: center;
    background: #da4a4a;
    box-shadow: 5px 5px 0 rgba(255, 255, 255, .8);
}

.function button {
    user-select: none;
    margin: 10px;
    height: 24px;
    width: 60px;
    outline: 0;
    /*border: 8px solid #474f51;鑾�*/
    box-shadow: 0 0 0 8px rgba(255, 255, 255, .1), inset 4px 4px 0 0px rgba(255, 255, 255, .4);
    background: #857b7a;
    /*color: transparent;鑾�*/
    color: #000000;
    border-radius: 15px;
}

.action {
    display: flex;
    align-self: flex-end;
}

.action button {
    user-select: none;
    width: 56px;
    height: 56px;
    background: #857b7a;
    border-radius: 50%;
    outline: 0;
    /*color: transparent;鑾�*/
    color: #000000;
    border: 8px solid #474f51;
    box-shadow: 0 0 0 10px rgba(255, 255, 255, .8), inset 5px 8px 0 0px rgba(255, 255, 255, .4), inset -5px -8px 0 0px rgba(0, 0, 0, .1);
    transition: transform 0.05s ease, box-shadow 0.05s ease;
}

.action button:first-child {
    margin-right: 24px;
}

.action button:active,
.action button.active {
    transform: translateY(2px);
    box-shadow: 0 0 0 8px rgba(255, 255, 255, .8), inset 5px 8px 0 0px rgba(255, 255, 255, .4), inset -5px -8px 0 0px rgba(0, 0, 0, .1);
}

.sign {
    position: absolute;
    font-weight: bold;
    font-size: 20px;
    font-style: italic;
    height: 40px;
    right: 0;
    top: 0;
    background: #da4a4a;
    color: #f8f1d7;
    text-shadow: 0 -2px #fffef7;
    padding: 0 0 15px 15px;
    letter-spacing: 0.1em;
    border-bottom-left-radius: 15px;
    filter: drop-shadow(0 8px #fffef7)
}

.sign::before {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    left: -15px;
    top: 0;
    background: radial-gradient(circle at left bottom, transparent 14px, #da4a4a 15px);
}

.sign::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    bottom: -15px;
    right: 0;
    background: radial-gradient(circle at left bottom, transparent 14px, #da4a4a 15px);
}

.joy {
    position: absolute;
    left: 0;
    top: 0;
    width: 50px;
    height: 50px;
    background: #857b7a;
    border-radius: 5px;
    text-align: center;
    line-height: 50px;
    color: #f8f1d7;
    font-weight: bold;
    font-size: 30px;
}

.res {
    position: absolute;
    left: 66px;
    top: 0;
    width: 50px;
    height: 50px;
    background: #857b7a;
    border-radius: 5px;
    text-align: center;
    line-height: 50px;
    color: #f8f1d7;
    font-weight: bold;
    font-size: 30px;
}

.fd {
    position: absolute;
    left: 100;
    top: 70px;
    width: 50px;
    height: 30px;
    background: #857b7a;
    border-radius: 5px;
    text-align: center;
    line-height: 30px;
    color: #f8f1d7;
    font-weight: bold;
    font-size: 20px;
}

.set_sy {
    position: absolute;
    right: 20;
    top: 85px;
    width: 90px;
    height: 30px;
    background: #857b7a;
    border-radius: 5px;
    text-align: center;
    line-height: 30px;
    color: #f8f1d7;
    font-weight: bold;
    font-size: 20px;
    transition: background 0.15s ease, color 0.15s ease;
}

.readme {
    position: absolute;
    left: 0;
    top: 65px;
    width: 90px;
    height: 30px;
    background: #857b7a;
    border-radius: 5px;
    text-align: center;
    line-height: 30px;
    color: #f8f1d7;
    font-weight: bold;
    font-size: 20px;
    transition: background 0.15s ease, color 0.15s ease;
}

.set_sy:hover,
.readme:hover {
    background: #978d8c;
    color: #f8f1d7;
}

.screen {
    position: relative;
    flex: 1;
    display: flex;
    width: 100%;
    transition: .3s;
    background: #000;
    margin-bottom: 5px;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.screen-hint {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    box-sizing: border-box;
    text-align: center;
    color: #f8f1d7;
    pointer-events: none;
    user-select: none;
}

.screen-hint.hidden {
    display: none;
}

.screen-hint-icon {
    font-size: 48px;
    line-height: 1;
    filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .3));
}

.screen-hint-icon img {
    display: block;
    width: 80px;
    height: auto;
    filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .35));
}

.screen-hint-text {
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 0.05em;
    text-shadow: 0 2px 0 rgba(0, 0, 0, .4);
}

.screen-hint-sub {
    font-size: 13px;
    opacity: 0.85;
    text-shadow: 0 1px 0 rgba(0, 0, 0, .4);
}

.screen-hint-sub.hint-mobile {
    display: none;
}

.mobile-ui .screen-hint-sub.hint-desktop {
    display: none;
}

.mobile-ui .screen-hint-sub.hint-mobile {
    display: block;
}

.screen canvas,
.nes-screen {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
}

.nes-roms {
    position: relative;
    display: inline-block;
    z-index: 100;
}

.nes-rom-select {
    position: relative;
    width: 200px;
    font-family: "HelveticaNeue", "Helvetica", "Arial", sans-serif;
    font-size: 14px;
    user-select: none;
}

.nes-rom-selected {
    position: relative;
    padding: 0 32px 0 12px;
    height: 38px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    background: #f8f1d7;
    color: #474f51;
    border: 2px solid #474f51;
    border-radius: 6px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15), inset 2px 2px 0 #fffef7;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s ease;
}

.nes-rom-selected::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    width: 0;
    height: 0;
    margin-top: -3px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #474f51;
    transition: transform 0.2s ease;
}

.nes-rom-select.open .nes-rom-selected {
    background: #fffef7;
}

.nes-rom-select.open .nes-rom-selected::after {
    transform: rotate(180deg);
}

.nes-rom-dropdown {
    position: absolute;
    left: 0;
    right: auto;
    top: calc(100% + 6px);
    width: auto;
    min-width: 100%;
    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f8f1d7;
    border: 3px solid #474f51;
    border-radius: 8px;
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.nes-rom-select.open .nes-rom-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nes-rom-group-label {
    padding: 8px 12px;
    background: #da4a4a;
    color: #f8f1d7;
    font-weight: bold;
    font-size: 13px;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
    border-bottom: 2px solid #474f51;
    position: sticky;
    top: 0;
    z-index: 1;
}

.nes-rom-group:not(:first-child) .nes-rom-group-label {
    border-top: 2px solid #474f51;
}

.nes-rom-option {
    padding: 8px 12px 8px 22px;
    color: #474f51;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.1s ease, color 0.1s ease;
}

.nes-rom-option:hover,
.nes-rom-option.active {
    background: #da4a4a;
    color: #f8f1d7;
}

.nes-rom-dropdown::-webkit-scrollbar {
    width: 8px;
}

.nes-rom-dropdown::-webkit-scrollbar-track {
    background: #f8f1d7;
}

.nes-rom-dropdown::-webkit-scrollbar-thumb {
    background: #857b7a;
    border-radius: 4px;
    border: 2px solid #f8f1d7;
}

.nes-bottombar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    width: 100%;
}

.nes-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 2px;
}

.nes-controls input[type="button"] {
    padding: 0 10px;
    margin: 0 5px 0 0;
    height: 38px;
    box-sizing: border-box;
    background: #f8f1d7;
    color: #474f51;
    border: 2px solid #474f51;
    border-radius: 6px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15), inset 2px 2px 0 #fffef7;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    font-weight: bold;
    outline: 0;
}

.nes-controls input[type="button"]:hover {
    background: #fffef7;
}

.nes-controls input[type="button"]:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15), inset 2px 2px 0 #fffef7;
}

.nes-controls input[type="button"]:disabled {
    background: #d0d0d0;
    color: #999;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.nes-controls input[type="button"]:last-child {
    margin-right: 0;
}

@media screen and (orientation: portrait) {

    /*绔栧睆 css*/
    .main {
        max-height: 100%;
        transform: none;
    }

    .function-area {
        position: absolute;
        left: 0;
        right: 0;
        top: 125px;
        bottom: 90px;
        padding-bottom: 80px;
    }

    .function {
        position: absolute;
        bottom: 0;
        align-self: flex-end;
        transform: translateX(20px);
        padding: 8px 10px;
        border-radius: 50px 0 0 50px;
        box-shadow: 0px 5px 0 rgba(255, 255, 255, .8);
    }

    .function::before {
        content: '';
        position: absolute;
        width: 15px;
        height: 15px;
        right: 0;
        top: -15px;
        background: radial-gradient(circle at left top, transparent 14px, #da4a4a 15px);
    }

    .function::after {
        content: '';
        position: absolute;
        width: 15px;
        height: 15px;
        bottom: -15px;
        right: 0;
        background: radial-gradient(circle at left bottom, transparent 14px, #da4a4a 15px);
    }

    .screen {
        margin-bottom: 0;
        flex: 1;
        min-height: 0;
        max-height: none;
    }

    .screen canvas {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        object-fit: contain;
    }

    .function button {
        width: 56px;
        margin: 10px;
    }

    .action-area {
        flex: 1;
        justify-content: flex-end;
    }

    .action button:first-child {
        margin-right: 20px
    }
}

/*手机端（任意方向）：选择框与控制按钮在同一排显示，下拉弹窗向上弹出*/
.mobile-ui .nes-bottombar {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 6px;
    margin-bottom: 30px;
}

.mobile-ui .nes-roms {
    width: auto;
    flex: 0 0 auto;
}

.mobile-ui .nes-rom-select {
    width: 120px;
}

.mobile-ui .nes-rom-selected {
    padding: 7px 32px 7px 12px;
    font-size: 13px;
}

.mobile-ui .nes-controls {
    flex: 1 1 auto;
    justify-content: center;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 4px;
}

.mobile-ui .nes-controls input[type="button"] {
    padding: 7px 4px;
    font-size: 13px;
    margin: 0;
    flex: 1 1 0;
    white-space: nowrap;
}

.mobile-ui .nes-rom-dropdown {
    top: auto;
    bottom: calc(100% + 6px);
}

/*手机端：游戏画面默认占满屏幕区域*/
.mobile-ui .screen {
    flex: 1;
    min-height: 0;
    max-height: none;
}

.mobile-ui .screen canvas {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
}

.mobile-ui .readme {
    top: 70px;
}

.mobile-ui .set_sy {
    top: 90px;
    right: 20px;
    left: auto;
}

.mobile-ui .function-area {
    top: 125px;
    bottom: 90px;
}

/*手机端：缩小 F / C 标记*/
.mobile-ui .joy,
.mobile-ui .res {
    width: 34px;
    height: 34px;
    font-size: 20px;
    line-height: 34px;
    border-radius: 4px;
}

.mobile-ui .res {
    left: 38px;
}

/*手机端：额外显示 游 / 戏 / 机 三个标记*/
.joy-extra {
    display: none;
}

.mobile-ui .joy-extra {
    display: block;
    left: 76px;
}

.mobile-ui .joy-extra-2 {
    left: 114px;
}

.mobile-ui .joy-extra-3 {
    left: 152px;
}

/*桌面端：将底部栏放到右上角，并把返回主页移到左侧按键说明下方*/
.desktop-ui .set_sy {
    left: 0;
    right: auto;
    top: 115px;
    width: 116px;
    height: 44px;
    line-height: 44px;
}

.desktop-ui .readme {
    width: 116px;
    height: 44px;
    line-height: 44px;
}

.desktop-ui .nes-bottombar.desktop-side {
    position: absolute;
    right: 20px;
    top: 85px;
    width: 130px;
    margin: 0;
    flex-direction: column;
    gap: 8px;
    z-index: 20;
}

.desktop-ui .nes-bottombar.desktop-side .nes-roms,
.desktop-ui .nes-bottombar.desktop-side .nes-rom-select,
.desktop-ui .nes-bottombar.desktop-side .nes-controls {
    width: 100%;
}

.desktop-ui .nes-bottombar.desktop-side .nes-controls {
    flex-direction: column;
}

.desktop-ui .nes-bottombar.desktop-side .nes-controls input[type="button"] {
    margin: 0 0 5px 0;
    width: 100%;
}

.desktop-ui .nes-bottombar.desktop-side .nes-controls input[type="button"]:last-child {
    margin-bottom: 0;
}

.desktop-ui .nes-bottombar.desktop-side .nes-rom-dropdown {
    top: calc(100% + 6px);
    bottom: auto;
    right: 0;
    left: auto;
    max-height: 220px;
}

/*弹窗打开时，禁用底部控制栏（选择游戏 / 暂停 / 重启 / 开启声音）的点击*/
body.modal-open .nes-bottombar {
    pointer-events: none;
    opacity: 0.5;
}

/*手机端：按键说明弹窗自适应屏幕尺寸（左右各 20px，上下各 40px）*/
.mobile-ui .reveal-modal {
    position: fixed;
    left: 20px;
    top: 40px;
    width: calc(100% - 40px);
    height: calc(100% - 80px);
    margin-left: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-ui .reveal-modal center {
    flex: 1 1 auto;
    min-height: 0;
    display: block;
}

.mobile-ui .reveal-modal iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}