/* EEBBK 模拟器专属样式。
   外壳 / LCD 面板 / 按键 / 卡片等通用样式与变量来自 ../css/portal.css，
   这里只补充模拟器独有的画面层、设置区与触控按键。 */

#screen {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* 原图以固定像素坐标排版，再整体缩放，屏幕与热区始终一起对齐。 */
#realistic-device {
    position: relative;
    width: 100%;
    aspect-ratio: 1254 / 1254;
    overflow: hidden;
    border-radius: 12px;
    background: transparent;
}

#realistic-device[hidden], #game-screen-host[hidden], #touchpad[hidden] { display: none; }

.device-photo-layer {
    position: absolute;
    left: 0;
    top: 0;
    width: 1254px;
    height: 1254px;
    transform-origin: top left;
}

.device-photo {
    position: absolute;
    left: 0;
    top: 0;
    width: 1254px;
    height: 1254px;
    max-width: none;
    pointer-events: none;
    user-select: none;
}

#realistic-device #screen-wrapper {
    --simulator-lcd-bg: rgb(120, 140, 104);
    position: absolute;
    z-index: 1;
    /* 外层与照片 LCD 对齐；159×96 游戏画面只覆盖中间像素区，
       照片里更真实的左右状态栏保持可见。 */
    left: 254px;
    top: 128px;
    width: 748px;
    height: 340px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 5px;
    box-shadow: none;
    overflow: hidden;
    background: transparent;
}

.screen-viewport { position: relative; }

#realistic-device .screen-viewport {
    position: absolute;
    z-index: 1;
    left: 103px;
    top: 6px;
    width: 543.25px;
    height: 328px;
    overflow: hidden;
    background: var(--simulator-lcd-bg);
}

#realistic-device #screen { width: 100%; height: 100%; }
#screen-wrapper.is-asleep > *,
#screen-wrapper.is-asleep .screen-viewport > * { visibility: hidden; }
/* 关机时仍遮住背景图中的示例游戏，避免露出静态画面。 */
#realistic-device #screen-wrapper.is-asleep .screen-viewport { visibility: visible; }

.screen-ornament { display: none; }

.screen-ornament-left { justify-content: flex-start; }

.lcd-clock {
    position: absolute;
    top: 8px;
    left: 6px;
    width: 46px;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    opacity: .48;
}

.lcd-clock .lcd-digit {
    position: relative;
    width: 8px;
    height: 12px;
}

.lcd-clock .lcd-digit::before {
    position: absolute;
    top: 0;
    left: 1px;
    width: 6px;
    height: 2px;
    background: currentColor;
    box-shadow: 0 5px currentColor, 0 10px currentColor;
    border-radius: 1px;
    content: "";
}

.lcd-clock .lcd-digit::after {
    position: absolute;
    top: 1px;
    left: 0;
    width: 2px;
    height: 4px;
    background: currentColor;
    box-shadow: 6px 0 currentColor, 0 6px currentColor, 6px 6px currentColor;
    border-radius: 1px;
    content: "";
}

.lcd-clock b {
    align-self: flex-end;
    width: 2px;
    height: 2px;
    margin-bottom: 0;
    border-radius: 50%;
    background: currentColor;
}

.lcd-key-flags {
    position: absolute;
    top: 30px;
    left: 25px;
    display: grid;
    gap: 5px;
}
.lcd-key-flags b {
    width: 27px;
    height: 14px;
    border: 1px solid currentColor;
    font: 700 6px/12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: 0;
    text-align: center;
    opacity: .53;
}

.lcd-bracket-icon {
    position: absolute;
    top: 92px;
    left: 31px;
    width: 20px;
    height: 12px;
    opacity: .55;
}
.lcd-bracket-icon::before,
.lcd-bracket-icon::after {
    position: absolute;
    top: 1px;
    width: 5px;
    height: 10px;
    border: 1px solid currentColor;
    content: "";
}
.lcd-bracket-icon::before { left: 0; border-right: 0; border-radius: 7px 0 0 7px; }
.lcd-bracket-icon::after { right: 0; border-left: 0; border-radius: 0 7px 7px 0; }
.lcd-bracket-icon i {
    position: absolute;
    top: 3px;
    left: 7px;
    width: 6px;
    height: 6px;
    border: 1px solid currentColor;
    border-radius: 50%;
}

.lcd-volume {
    position: absolute;
    top: 117px;
    left: 32px;
    width: 19px;
    height: 15px;
    opacity: .5;
}
.lcd-volume i {
    position: absolute;
    top: 4px;
    left: 0;
    width: 9px;
    height: 8px;
    background: currentColor;
    clip-path: polygon(0 32%, 38% 32%, 100% 0, 100% 100%, 38% 68%, 0 68%);
}
.lcd-volume::before,
.lcd-volume::after {
    position: absolute;
    border-right: 1px solid currentColor;
    border-radius: 50%;
    content: "";
}
.lcd-volume::before { top: 5px; right: 4px; width: 4px; height: 7px; }
.lcd-volume::after { top: 2px; right: 0; width: 8px; height: 13px; }

.lcd-page-arrows {
    position: absolute;
    top: 144px;
    left: 38px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    opacity: .55;
}
.lcd-page-arrows i {
    width: 7px;
    height: 6px;
    background: currentColor;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.lcd-page-arrows .is-down { transform: rotate(180deg); }
.lcd-page-arrows i:nth-child(3) { margin-top: 3px; }

.lcd-progress {
    position: absolute;
    top: 32px;
    bottom: 8px;
    left: 8px;
    width: 8px;
    height: auto;
    background: repeating-linear-gradient(to bottom, currentColor 0 2px, transparent 2px 4px);
    clip-path: polygon(50% 0, 100% 7px, 100% calc(100% - 7px), 50% 100%, 0 calc(100% - 7px), 0 7px);
    opacity: .5;
}
.lcd-progress i { display: none; }

.lcd-battery {
    position: absolute;
    top: 184px;
    left: 28px;
    width: 22px;
    height: 10px;
    border: 2px solid currentColor;
    border-radius: 1px;
    opacity: .6;
}
.lcd-battery::after {
    position: absolute;
    top: 2px;
    right: -5px;
    width: 3px;
    height: 4px;
    background: currentColor;
    content: "";
}
.lcd-battery i { position: absolute; inset: 2px 6px 2px 2px; background: currentColor; }

.lcd-back-arrow {
    position: absolute;
    top: 211px;
    left: 33px;
    width: 15px;
    height: 10px;
    opacity: .52;
}
.lcd-back-arrow::before {
    position: absolute;
    top: 3px;
    left: 10px;
    width: 5px;
    height: 4px;
    background: currentColor;
    content: "";
}
.lcd-back-arrow::after {
    position: absolute;
    top: 0;
    left: 0;
    border-top: 5px solid transparent;
    border-right: 10px solid currentColor;
    border-bottom: 5px solid transparent;
    content: "";
}

.lcd-menu-pointers {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: space-between;
    padding: 0 0 1px;
}

.lcd-menu-pointers i {
    position: relative;
    width: 15px;
    height: 10px;
    opacity: .52;
}

.lcd-menu-pointers i::before,
.lcd-menu-pointers i::after {
    position: absolute;
    content: "";
}

.lcd-menu-pointers i::before {
    top: 1px;
    left: 0;
    width: 8px;
    height: 8px;
    background: currentColor;
}

.lcd-menu-pointers i::after {
    top: 0;
    left: 8px;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 7px solid currentColor;
}

.lcd-menu-pointers i:last-child::before {
    top: 3px;
    width: 5px;
    height: 4px;
}

.lcd-menu-pointers i:last-child::after {
    left: 5px;
    border-left-width: 10px;
}

#realistic-device #placeholder,
#realistic-device #error-overlay {
    inset: 0;
    font-size: 23px;
    gap: 10px;
}

#realistic-device #placeholder .drop-icon,
#realistic-device #error-overlay .drop-icon { display: none; }
#realistic-device #placeholder .lcd-help,
#realistic-device #error-detail { font-size: 20px; }
#realistic-device #error-overlay strong { font-size: 25px; }
#realistic-device #restart-btn { font-size: 22px; min-height: 48px; }

.device-hotspots {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.device-key {
    position: absolute;
    z-index: 2;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 35%;
    background: transparent;
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.device-key:active,
.device-key.is-pressed,
.device-key.is-pointer-pressed { background: rgba(255, 255, 255, .25); }
.device-key:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.realistic-interface #desktop-controls { display: none; }

/* 拖拽提示与关机/出错浮层：覆盖在 LCD 屏幕之上 */
#placeholder,
#error-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px;
    text-align: center;
    color: var(--lcd-ink);
    background: var(--simulator-lcd-bg, var(--lcd));
    font: 800 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

#placeholder.show,
#error-overlay.show { display: flex; }

.drop-icon {
    font-size: 1.8rem;
    line-height: 1;
    opacity: .7;
}

#error-overlay strong { font-size: 14px; }

#restart-btn {
    margin-top: 8px;
    padding: 8px 18px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    background: var(--accent);
    box-shadow: inset 0 -3px 0 #7d3a2f;
    font: 800 12px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    cursor: pointer;
}

#restart-btn:active { transform: translateY(2px); }

/* 游戏界面：桌面仅显示按键说明，窄屏 / 触屏显示游戏按键。 */
#touchpad {
    display: none;
    max-width: 460px;
    margin: 14px auto 0;
    touch-action: pan-y;
}

#touchpad .kb-row {
    display: flex;
    gap: 8px;
}

#touchpad .kb-row + .kb-row {
    margin-top: 8px;
}

#touchpad [hidden] { display: none; }

#touchpad .btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 100%;
    min-width: 0;
    min-height: 52px;
    padding: 6px 2px 9px;
    border: 0;
    border-radius: 8px;
    color: #eef0e7;
    background: var(--key);
    box-shadow: inset 0 -4px 0 var(--key-edge);
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    -webkit-appearance: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    user-select: none;
}

#touchpad .kb-row .btn {
    flex: 1 1 0;
}

#touchpad .btn small {
    font: 500 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

#touchpad .direction-key {
    font-size: 21px;
}

#touchpad .space-key {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 8px;
    margin-top: 8px;
}

#touchpad .space-key .btn {
    min-height: 42px;
}

#touchpad .btn:active,
#touchpad .btn.is-pressed,
#touchpad .btn.is-pointer-pressed {
    transform: translateY(2px);
    filter: brightness(.88);
    box-shadow: inset 0 -1px 0 var(--key-edge);
}

#touchpad .btn.enter:active,
#touchpad .btn.enter.is-pressed,
#touchpad .btn.enter.is-pointer-pressed {
    box-shadow: inset 0 -1px 0 #7d3a2f;
}

#touchpad .btn:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

#touchpad .btn.enter {
    background: var(--accent);
    box-shadow: inset 0 -4px 0 #7d3a2f;
}

/* 拖拽悬停高亮 */
#screen-wrapper.drag-over {
    box-shadow: inset 0 0 0 3px var(--accent);
}

/* 模拟器控制台：显示模式、速度与三个动作集中排列。 */
.utility-footer {
    flex-wrap: wrap;
}

.footer-actions {
    display: grid;
    grid-template-columns: 1.12fr .9fr repeat(3, 1fr);
    gap: 7px;
    order: -1;
    width: 100%;
    padding: 8px;
    border: 1px solid rgba(48, 59, 46, .26);
    border-radius: 16px;
    background: rgba(197, 208, 155, .34);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, .65);
}

.control-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 42px;
    margin: 0;
    border: 1px solid var(--key-edge);
    border-radius: 999px;
    color: #eef0e7;
    background: linear-gradient(#596257, var(--key));
    box-shadow: inset 0 -3px 0 var(--key-edge), 0 2px 5px rgba(37, 45, 35, .18);
}

.footer-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 42px;
    margin: 0;
    padding: 0 12px 3px;
    border: 1px solid var(--key-edge);
    border-radius: 8px;
    color: #eef0e7;
    background: var(--key);
    box-shadow: inset 0 -3px 0 var(--key-edge), 0 2px 5px rgba(37, 45, 35, .18);
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    -webkit-appearance: none;
    touch-action: manipulation;
}

/* display:inline-flex 会覆盖 UA 样式对 [hidden] 的 display:none，
   恢复出厂等按需显示的按钮必须显式提供隐藏规则。 */
.footer-action[hidden] {
    display: none;
}

.interface-control {
    justify-content: space-between;
    gap: 8px;
    padding: 0 10px 3px 13px;
    cursor: pointer;
}

.interface-control input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.interface-control .switch-track {
    position: relative;
    flex: 0 0 36px;
    height: 20px;
    border: 1px solid rgba(224, 231, 209, .32);
    border-radius: 999px;
    background: #30372f;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, .55);
    transition: background-color .16s ease;
}

.interface-control .switch-track::after {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #dfe3d1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .55);
    content: "";
    transition: transform .16s ease;
}

.interface-control input:checked + .switch-track { background: var(--accent); }
.interface-control input:checked + .switch-track::after { transform: translateX(16px); }
.interface-control input:focus-visible + .switch-track {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.speed-control {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 7px;
    min-width: 0;
    min-height: 42px;
    margin: 0;
    padding: 0 7px 3px 12px;
    border: 1px solid var(--key-edge);
    border-radius: 8px;
    color: #eef0e7;
    background: var(--key);
    box-shadow: inset 0 -3px 0 var(--key-edge), 0 2px 5px rgba(37, 45, 35, .18);
    white-space: nowrap;
}

.speed-control span {
    font-size: 10px;
    letter-spacing: 0;
}

.speed-control select {
    min-width: 58px;
    height: 26px;
    padding: 0 5px;
    border: 1px solid rgba(224, 231, 209, .35);
    border-radius: 5px;
    color: #eef0e7;
    background: var(--key-edge);
    font: 800 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    cursor: pointer;
}

.footer-action:hover,
.footer-action:focus-visible {
    background: #596257;
}

.footer-action:active {
    padding-top: 2px;
    padding-bottom: 1px;
    box-shadow: inset 0 -1px 0 var(--key-edge);
    transform: translateY(2px);
}

.footer-action:disabled {
    cursor: not-allowed;
    opacity: .46;
    transform: none;
}

.footer-link {
    font-size: 11px;
    font-weight: 800;
    text-decoration: none;
}

/* 触屏 / 窄屏通过键帽查看映射，省去额外的键盘说明。 */
@media (max-width: 759px), (pointer: coarse) {
    .utility-shell {
        -webkit-user-select: none;
        -webkit-touch-callout: none;
        user-select: none;
    }

    .desktop-controls { display: none; }

    #touchpad { display: block; }

    .utility-footer {
        align-items: center;
    }

    .footer-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .speed-control,
    .footer-action {
        min-width: 0;
    }

    .speed-control {
        justify-content: space-between;
    }

    .speed-control select {
        min-width: 0;
        width: 54px;
    }

    .footer-link {
        margin-left: auto;
    }

    .reset-game-control { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
