:root {
    --body: #c8cbbd;
    --shell: #dfe3d1;
    --shell-edge: #b4b9a9;
    --lcd: #c5d09b;
    --lcd-ink: #253024;
    --key: #4b5349;
    --key-edge: #30362f;
    --paper: rgba(255, 255, 255, .34);
    --line: rgba(48, 59, 46, .17);
    --accent: #ad4c3d;
    --focus: #d76145;
    --shadow: 0 24px 70px rgba(30, 35, 29, .22);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--body); }

html.gameplay-page {
    scrollbar-width: none;
}

html.gameplay-page::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

html.no-pull-to-refresh,
html.no-pull-to-refresh body {
    overscroll-behavior-y: none;
}

body {
    min-height: 100vh;
    margin: 0;
    padding: 18px 12px;
    color: var(--lcd-ink);
    background:
        radial-gradient(circle at 50% -20%, #eef0e5 0, transparent 44%),
        var(--body);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }
button, select { font: inherit; }
button { color: inherit; }

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

.device-shell {
    width: min(100%, 980px);
    margin: 0 auto;
    padding: 18px;
    border: 1px solid var(--shell-edge);
    border-radius: 28px 28px 52px 28px;
    background: var(--shell);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.65);
}

.device-header,
.section-heading,
.game-link {
    display: flex;
    align-items: center;
}

.device-header { justify-content: space-between; margin-bottom: 16px; }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #3e473d;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-decoration: none;
}

.brand-mark {
    padding: 5px 7px;
    border-radius: 5px;
    color: #e9ecdf;
    background: var(--key);
    box-shadow: inset 0 -2px 0 var(--key-edge);
    letter-spacing: .04em;
}

.power-light {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #e76543;
    box-shadow: 0 0 0 4px rgba(231,101,67,.14), 0 0 12px rgba(231,101,67,.28);
}

.lcd-panel {
    position: relative;
    overflow: hidden;
    padding: 24px 19px;
    border: 7px solid #4c5449;
    border-radius: 11px;
    background: var(--lcd);
    box-shadow: inset 0 0 0 2px #899474, inset 0 8px 25px rgba(62,76,55,.11);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.lcd-panel::after {
    position: absolute;
    inset: 0;
    content: "";
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 3px,
        rgba(45,57,42,.035) 4px
    );
}

.lcd-kicker,
.lcd-help {
    margin: 0;
    font-size: 10px;
    letter-spacing: .08em;
    opacity: .65;
}

.lcd-panel h1 {
    margin: 8px 0 10px;
    font-size: clamp(27px, 8vw, 48px);
    line-height: 1;
    letter-spacing: -.06em;
}

.lcd-version {
    margin: 4px 0 0;
    font: 800 10px/1.2 ui-monospace, monospace;
    letter-spacing: .04em;
    opacity: .65;
}

.lcd-result-title {
    margin: 14px 0 6px;
    font-size: 16px;
}

.lcd-result-help {
    margin: 0;
    font-size: 11px;
    line-height: 1.55;
    opacity: .7;
}

.lcd-panel.is-warn .lcd-result-title { color: var(--accent); }

.game-section { margin-top: 22px; }
.section-heading { justify-content: space-between; margin-bottom: 10px; }
.section-heading h2 { margin: 0; font-size: 15px; }
.section-heading span { font: 700 9px/1 ui-monospace, monospace; opacity: .52; }
.game-grid { display: grid; gap: 10px; }
.action-list,
.save-grid { display: grid; gap: 10px; }

.game-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.45);
}

.game-link {
    min-height: 76px;
    gap: 12px;
    padding: 12px;
    text-decoration: none;
    transition: transform .16s ease, background-color .16s ease;
}

.save-action,
.version-main {
    width: 100%;
    border: 0;
    text-align: left;
    cursor: pointer;
}

.save-action {
    position: relative;
    background: var(--paper);
}

.game-key {
    display: grid;
    place-items: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    color: #dbe1c3;
    background: var(--key);
    box-shadow: inset 0 -4px 0 var(--key-edge), 0 3px 7px rgba(37,45,35,.18);
    font: 800 13px/1 ui-monospace, monospace;
}

.game-copy { min-width: 0; }
.game-copy strong, .game-copy small { display: block; }
.game-copy strong { font-size: 15px; }
.game-copy small { margin-top: 5px; font-size: 11px; opacity: .62; }
.game-arrow { margin-left: auto; font-size: 25px; opacity: .6; }

.settings-key {
    border: 0;
    color: #edf0e5;
    background: var(--key);
    box-shadow: inset 0 -3px 0 var(--key-edge);
    cursor: pointer;
}

.settings-key {
    flex: 0 0 42px;
    height: 42px;
    border-radius: 8px;
}

.device-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-top: 22px;
    color: #50594e;
}

.device-footer span { font: 800 9px/1 ui-monospace, monospace; letter-spacing: .08em; }
.device-footer p { margin: 0; font-size: 10px; opacity: .62; text-align: right; }

.utility-shell { max-width: 760px; }

.version-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    overflow: hidden;
}

.version-main { background: transparent; }
.version-main:disabled { cursor: wait; opacity: .7; }
.detail-key {
    width: 42px;
    height: 42px;
    margin-right: 8px;
    border-radius: 8px;
    font: 800 15px/1 ui-monospace, monospace;
}

.version-detail {
    grid-column: 1 / -1;
    padding: 13px 15px 15px;
    border-top: 1px dashed rgba(46,56,43,.27);
    background: rgba(197,208,155,.48);
    font-size: 12px;
    line-height: 1.65;
}

.loading-card {
    padding: 22px;
    border: 1px dashed rgba(48,59,46,.25);
    border-radius: 12px;
    background: var(--paper);
    font-size: 12px;
    text-align: center;
    opacity: .65;
}

.utility-footer { min-height: 36px; }

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

.dialog-overlay {
    position: fixed;
    z-index: 20;
    inset: 0;
    padding: 14px;
    background: rgba(25,31,24,.6);
    backdrop-filter: blur(3px);
}

.dialog-overlay:not([hidden]) {
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.dialog-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 9px; margin-top: 14px; }

.device-button {
    padding: 12px 10px;
    border-radius: 8px;
    color: #eef0e7;
    background: var(--key);
    box-shadow: inset 0 -4px 0 var(--key-edge);
    font-size: 12px;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
}

.dialog-open { overflow: hidden; }
.noscript-note { width: min(100%, 980px); margin: 12px auto 0; font-size: 12px; text-align: center; }

.game-link:hover { background: rgba(255,255,255,.2); }
.game-link:active, .device-button:active, .settings-key:active { transform: translateY(2px); }

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

@media (min-width: 760px) {
    body { padding: 38px 24px; }
    .device-shell { padding: 28px; }
    .lcd-panel { padding: 32px 28px; }
    .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .save-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
    .save-action {
        align-items: flex-start;
        flex-direction: column;
        min-height: 142px;
    }
    .save-action .game-arrow {
        position: absolute;
        align-self: flex-end;
    }
    .dialog-overlay:not([hidden]) { align-items: center; }
    .about-overlay:target { align-items: center; }
}

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

/* backup.html：还原区目标槽选择与还原按钮 */
.slot-label { margin: 14px 0 8px; font-size: 11px; font-weight: 800; letter-spacing: .04em; opacity: .65; }
.slot-picker { display: flex; gap: 8px; }
.slot-chip {
    flex: 1;
    padding: 10px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.45);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: transform .16s ease, background-color .16s ease;
}
.slot-chip.is-active {
    color: #eef0e7;
    background: var(--key);
    border-color: var(--key-edge);
    box-shadow: inset 0 -3px 0 var(--key-edge);
}
.slot-chip:active { transform: translateY(2px); }

/* 备份页游戏选择器：游戏名较长，允许换行 */
#game-picker { flex-wrap: wrap; }
#game-picker .game-chip { flex: 1 1 30%; font-size: 11px; }
.restore-btn {
    width: 100%;
    margin-top: 12px;
    padding: 13px;
    border: 0;
    border-radius: 8px;
    color: #eef0e7;
    background: var(--key);
    box-shadow: inset 0 -4px 0 var(--key-edge);
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: transform .16s ease;
}
.restore-btn:active { transform: translateY(2px); }
.restore-btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* 游戏页：游戏画面内嵌 LCD 屏幕 */
.game-title { margin-bottom: 10px; }
.game-title h1 { margin: 0; font-size: 15px; }

.lcd-panel-screen { padding: 10px; }
.lcd-panel-screen canvas {
    display: block;
    width: 100%;
    height: auto;
    background: var(--lcd);
    image-rendering: pixelated;
}
.game-load-error {
    margin: 10px 0 0;
    padding: 10px 12px;
    border: 1px solid rgba(132, 49, 38, .35);
    border-radius: 8px;
    color: #6c2d25;
    background: rgba(232, 132, 111, .2);
    font-size: 12px;
    font-weight: 700;
}

.key-map {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}
.key-map-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.45);
    font-size: 12px;
}
.key-chip {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    min-width: 32px;
    height: 28px;
    padding: 0 8px;
    border-radius: 7px;
    color: #dbe1c3;
    background: var(--key);
    box-shadow: inset 0 -3px 0 var(--key-edge);
    font: 800 11px/1 ui-monospace, monospace;
    white-space: nowrap;
}
.key-map-item span:last-child { opacity: .65; }

/* 首页「关于本站」弹层：纯 CSS :target 开关，保持首页零脚本 */
.about-overlay {
    position: fixed;
    z-index: 20;
    inset: 0;
    padding: 14px;
    display: none;
    background: rgba(25, 31, 24, .6);
    backdrop-filter: blur(3px);
}

.about-overlay:target {
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.about-dialog {
    width: min(100%, 620px);
    max-height: calc(100vh - 28px);
    padding: 18px;
    border: 1px solid var(--shell-edge);
    border-radius: 24px 24px 38px 24px;
    background: var(--shell);
    box-shadow: 0 26px 80px rgba(20, 25, 19, .42), inset 0 1px 0 rgba(255, 255, 255, .65);
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
}

.about-display {
    padding: 19px 18px 17px;
    border-width: 5px;
}

.about-display h2 {
    margin: 5px 0 7px;
    font: 800 20px/1.15 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.about-body {
    margin-top: 14px;
    padding: 14px 16px 15px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45);
    font-size: 13px;
    line-height: 1.7;
}

.about-body p {
    margin: 0 0 10px;
}

.about-body p:last-child {
    margin: 0;
}

.about-body ul {
    margin: 0 0 12px;
    padding-left: 18px;
}

.about-body li {
    margin: 5px 0;
}

.about-actions {
    margin-top: 14px;
}

.about-actions .device-button {
    display: block;
    width: 100%;
    border: 0;
}

.footer-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: right;
}
