:root {
    color-scheme: dark;
    --bg: #0a0f1c;
    --panel: rgba(18, 26, 43, 0.92);
    --panel-edge: rgba(171, 189, 224, 0.16);
    --text: #f4f7ff;
    --muted: #93a0b9;
    --green: #63f5a6;
    --green-dark: #18a965;
    --danger: #ff5964;
    --wall: #2b3854;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    min-height: 100svh;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 18% 10%, rgba(69, 95, 167, 0.22), transparent 32rem),
        radial-gradient(circle at 84% 78%, rgba(30, 184, 113, 0.12), transparent 30rem),
        var(--bg);
    color: var(--text);
    font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button {
    border: 0;
    font: inherit;
}

button:focus-visible {
    outline: 3px solid rgba(99, 245, 166, 0.55);
    outline-offset: 3px;
}

.page {
    width: min(100% - 32px, 1040px);
    min-height: 100vh;
    min-height: 100svh;
    margin: 0 auto;
    display: grid;
    place-items: center;
    padding: 32px 0;
}

.menu {
    width: min(100%, 680px);
    padding: clamp(32px, 7vw, 72px);
    position: relative;
    overflow: hidden;
    text-align: left;
    background: linear-gradient(145deg, rgba(30, 42, 67, 0.94), rgba(14, 21, 36, 0.96));
    border: 1px solid var(--panel-edge);
    border-radius: 28px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.42);
}

.menu::after {
    content: "";
    width: 230px;
    aspect-ratio: 1;
    position: absolute;
    right: -80px;
    bottom: -100px;
    border: 26px solid rgba(99, 245, 166, 0.07);
    border-radius: 50%;
}

.eyebrow {
    margin-bottom: 18px;
    color: var(--green);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

h1 {
    max-width: 9em;
    font-size: clamp(42px, 8vw, 72px);
    line-height: 1.02;
    letter-spacing: -0.055em;
}

.intro {
    max-width: 34em;
    margin: 22px 0 32px;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.8;
}

.primary-button,
.secondary-button,
.icon-button {
    cursor: pointer;
    transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-button {
    min-width: 154px;
    padding: 14px 24px;
    border-radius: 999px;
    background: var(--green);
    color: #07160f;
    font-weight: 850;
    box-shadow: 0 12px 32px rgba(49, 224, 137, 0.22);
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover {
    transform: translateY(-2px);
}

.game-screen {
    width: min(100%, 760px);
}

.is-hidden {
    display: none !important;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 18px;
}

.game-title {
    font-size: clamp(27px, 5vw, 40px);
    letter-spacing: -0.04em;
}

.game-subtitle {
    margin-top: 7px;
    color: var(--muted);
    font-size: 13px;
}

.stats {
    display: flex;
    gap: 8px;
}

.stat {
    min-width: 88px;
    padding: 10px 14px;
    background: rgba(24, 35, 56, 0.8);
    border: 1px solid var(--panel-edge);
    border-radius: 14px;
    text-align: left;
}

.stat-label {
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 0.12em;
}

.stat-value {
    font-size: 22px;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.game-card {
    padding: clamp(12px, 2.5vw, 20px);
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 24px;
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.38);
}

.arena-shell {
    width: min(100%, 520px);
    margin: 0 auto;
    padding: clamp(8px, 1.8vw, 12px);
    position: relative;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 35%),
        #202b43;
    border: 2px solid #465572;
    border-radius: 15px;
    box-shadow:
        0 0 0 1px #070b12,
        0 16px 30px rgba(0, 0, 0, 0.3),
        inset 0 0 0 2px rgba(255, 255, 255, 0.04);
}

.arena-shell::before {
    content: "实体边界 / 撞墙结束";
    position: absolute;
    z-index: 3;
    top: -10px;
    left: 20px;
    padding: 3px 9px;
    background: #28354f;
    border: 1px solid #52617c;
    border-radius: 5px;
    color: #aebbd2;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.13em;
}

.arena-shell.is-hit {
    animation: wall-hit 380ms ease-out;
}

@keyframes wall-hit {
    0%, 100% { transform: translateX(0); border-color: #465572; }
    18% { transform: translateX(-7px); border-color: var(--danger); }
    38% { transform: translateX(6px); }
    58% { transform: translateX(-3px); }
    78% { transform: translateX(2px); }
}

.canvas-wrap {
    position: relative;
    overflow: hidden;
    border: 2px solid #080c14;
    border-radius: 7px;
    background: #0d1422;
    box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.5);
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    touch-action: none;
}

.game-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(6, 10, 18, 0.78);
    backdrop-filter: blur(5px);
    text-align: center;
}

.overlay-panel {
    width: min(100%, 290px);
    padding: 24px;
    background: rgba(20, 29, 47, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}

.overlay-kicker {
    color: var(--danger);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.16em;
}

.overlay-title {
    margin: 8px 0 6px;
    font-size: 28px;
}

.overlay-copy {
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.status-row {
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 4px 0;
}

.status {
    color: #c0cada;
    font-size: 13px;
}

.status::before {
    content: "";
    width: 7px;
    height: 7px;
    display: inline-block;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 10px var(--green);
    vertical-align: 1px;
}

.status.is-paused::before {
    background: #ffc857;
    box-shadow: 0 0 10px #ffc857;
}

.status.is-over::before {
    background: var(--danger);
    box-shadow: 0 0 10px var(--danger);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
}

.secondary-button,
.icon-button {
    padding: 11px 17px;
    background: #202c44;
    border: 1px solid #3b4964;
    border-radius: 11px;
    color: #e9effc;
    font-size: 13px;
    font-weight: 700;
}

.secondary-button:hover,
.icon-button:hover {
    background: #293751;
    border-color: #566580;
}

.touch-pad {
    display: none;
    width: 164px;
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(2, 48px);
    justify-content: center;
    gap: 7px;
    margin: 18px auto 0;
}

.direction-button {
    cursor: pointer;
    background: #202c44;
    border: 1px solid #44526d;
    border-radius: 12px;
    color: var(--text);
    font-size: 20px;
    touch-action: manipulation;
}

.direction-button:active {
    transform: translateY(1px);
    background: #34435f;
}

.direction-up { grid-column: 2; }
.direction-left { grid-column: 1; grid-row: 2; }
.direction-down { grid-column: 2; grid-row: 2; }
.direction-right { grid-column: 3; grid-row: 2; }

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

@media (max-width: 620px) {
    .page {
        width: min(100% - 20px, 1040px);
        padding: 18px 0;
    }

    .game-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
    }

    .stats {
        width: 100%;
    }

    .stat {
        flex: 1;
    }

    .status-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .shortcut {
        display: none;
    }
}

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

/* 简洁主题：保留清晰边界，移除霓虹、金属与科技装饰。 */
:root {
    color-scheme: light;
    --bg: #dff3ff;
    --panel: #ffffff;
    --panel-edge: #d8d7d0;
    --text: #20231f;
    --muted: #73786f;
    --green: #367a4d;
    --green-dark: #265c39;
    --danger: #d95545;
    --wall: #3f463f;
}

body {
    background:
        linear-gradient(180deg, #d8f1ff 0%, #eaf8ff 52%, #dff3ff 100%);
    color: var(--text);
}

button:focus-visible {
    outline-color: rgba(54, 122, 77, 0.4);
}

.page {
    width: min(100% - 32px, 880px);
}

.menu {
    width: min(100%, 590px);
    padding: clamp(36px, 7vw, 64px);
    overflow: visible;
    background: var(--panel);
    border-color: var(--panel-edge);
    border-radius: 18px;
    box-shadow: 0 14px 40px rgba(30, 33, 28, 0.08);
    text-align: center;
}

.menu::after,
.arena-shell::before {
    display: none;
}

.eyebrow {
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: none;
}

.menu > .eyebrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 12px 6px;
    border: 1px solid #efdadd;
    border-radius: 999px;
    background: #fff4f5;
    color: #78696c;
    font-family: ui-rounded, "Hiragino Maru Gothic ProN", "YouYuan", "幼圆", "Microsoft YaHei UI", sans-serif;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.18em;
    line-height: 1;
}

h1 {
    max-width: none;
    font-size: clamp(40px, 7vw, 58px);
    line-height: 1.08;
    letter-spacing: -0.045em;
}

.intro {
    max-width: 30em;
    margin: 20px auto 30px;
    color: var(--muted);
    line-height: 1.75;
}

.menu > .intro {
    text-decoration-line: line-through;
    text-decoration-color: rgba(103, 106, 99, 0.72);
    text-decoration-thickness: 1px;
    text-decoration-skip-ink: none;
}

.primary-button,
.secondary-button,
.icon-button {
    transition: background 140ms ease, border-color 140ms ease;
}

.primary-button {
    min-width: 136px;
    padding: 13px 22px;
    border-radius: 10px;
    background: var(--green);
    color: #ffffff;
    font-weight: 700;
    box-shadow: none;
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover {
    transform: none;
}

.primary-button:hover {
    background: var(--green-dark);
}

.game-screen {
    width: min(100%, 680px);
}

.game-title {
    font-size: clamp(28px, 5vw, 36px);
    letter-spacing: -0.035em;
}

.game-subtitle {
    color: var(--muted);
}

.stat {
    min-width: 82px;
    background: transparent;
    border-color: var(--panel-edge);
    border-radius: 9px;
}

.stat-label {
    color: var(--muted);
    font-weight: 650;
    letter-spacing: 0.08em;
}

.game-card {
    padding: clamp(12px, 2.5vw, 18px);
    background: var(--panel);
    border-color: var(--panel-edge);
    border-radius: 16px;
    box-shadow: 0 12px 34px rgba(30, 33, 28, 0.08);
}

.arena-shell {
    padding: 8px;
    background: #d9d8d1;
    border: 1px solid #b9b9b1;
    border-radius: 9px;
    box-shadow: none;
}

@keyframes wall-hit {
    0%, 100% { transform: translateX(0); border-color: #b9b9b1; }
    22% { transform: translateX(-5px); border-color: var(--danger); }
    45% { transform: translateX(4px); }
    68% { transform: translateX(-2px); }
}

.canvas-wrap {
    border: 0;
    border-radius: 4px;
    background: #f7f7f2;
    box-shadow: none;
}

.ready-start-button {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
    min-width: 150px;
    transform: translate(-50%, -50%);
    box-shadow: 0 10px 28px rgba(30, 33, 28, 0.14);
}

.ready-start-button:hover {
    transform: translate(-50%, -50%);
}

.ready-start-button[hidden] {
    display: none;
}

.game-overlay {
    background: rgba(247, 247, 242, 0.86);
    backdrop-filter: blur(3px);
}

.overlay-panel {
    background: #ffffff;
    border-color: var(--panel-edge);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(30, 33, 28, 0.12);
}

.overlay-kicker {
    color: var(--danger);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.overlay-copy,
.status {
    color: var(--muted);
}

.status::before {
    background: var(--green);
    box-shadow: none;
}

.status.is-paused::before {
    background: #d49b32;
    box-shadow: none;
}

.status.is-over::before {
    background: var(--danger);
    box-shadow: none;
}

.secondary-button,
.icon-button,
.direction-button {
    background: #ffffff;
    border-color: #c9c9c1;
    color: var(--text);
    border-radius: 9px;
}

.secondary-button:hover,
.icon-button:hover {
    background: #f7f7f2;
    border-color: #a9aaa1;
}

.direction-button:active {
    background: #e9e9e2;
}

.menu {
    width: min(100%, 760px);
}

.site-choices {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 32px;
}

.choice-card {
    min-height: 190px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 22px;
    border: 1px solid #d8d7d0;
    border-radius: 13px;
    color: var(--text);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease;
}

.choice-card:hover {
    border-color: #9d9f96;
}

.choice-card:focus-visible {
    outline: 3px solid rgba(54, 122, 77, 0.3);
    outline-offset: 3px;
}

.blog-choice {
    background: #f4f7fa;
}

.snake-choice {
    background: #f4f7f1;
}

.choice-number {
    margin-bottom: 30px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.choice-title {
    margin-bottom: 7px;
    font-size: 25px;
    font-weight: 750;
    letter-spacing: -0.03em;
}

.choice-copy {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.blog-choice .choice-copy {
    text-decoration-line: line-through;
    text-decoration-color: currentColor;
    text-decoration-thickness: 1px;
    text-decoration-skip-ink: none;
}

.choice-whisper {
    margin-top: 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    opacity: 0.48;
}

.choice-action {
    margin-top: auto;
    padding-top: 18px;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
}

.game-screen {
    width: min(100%, 940px);
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 520px) 240px;
    justify-content: center;
    align-items: start;
    gap: 22px;
}

.play-column {
    min-width: 0;
}

.settings-panel {
    min-height: 100%;
    padding-left: 22px;
    border-left: 1px solid var(--panel-edge);
}

.settings-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.settings-title {
    font-size: 17px;
    letter-spacing: -0.02em;
}

.settings-state {
    flex: 0 0 auto;
    padding: 4px 7px;
    border-radius: 6px;
    background: #efeee9;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.settings-panel.is-unlocked .settings-state {
    background: #e6f0e8;
    color: var(--green-dark);
}

.settings-intro,
.settings-note,
.setting-help {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
}

.settings-fieldset {
    margin-top: 20px;
    min-width: 0;
    padding: 14px 13px 16px;
    border: 1px solid #dfdfd8;
    border-radius: 10px;
    background: #fbfaf7;
    transition: opacity 140ms ease;
}

.difficulty-title {
    padding: 0 7px;
    color: var(--text);
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0.02em;
}

.settings-fieldset:disabled {
    opacity: 0.45;
}

.setting-block + .setting-block {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #ecebe6;
}

.setting-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 11px;
}

.setting-label,
.toggle-title {
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}

.speed-output {
    color: var(--green-dark);
    font-size: 13px;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

.speed-slider {
    width: 100%;
    height: 22px;
    display: block;
    margin: 0;
    cursor: pointer;
    accent-color: var(--green);
}

.speed-slider:disabled {
    cursor: not-allowed;
}

.speed-marks {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
    color: #8a8e86;
    font-size: 9px;
    font-variant-numeric: tabular-nums;
}

.toggle-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.toggle-copy {
    display: grid;
    gap: 4px;
}

.toggle-control {
    position: relative;
    display: inline-flex;
}

.toggle-input {
    width: 42px;
    height: 24px;
    position: absolute;
    inset: 0;
    z-index: 1;
    cursor: pointer;
    opacity: 0;
}

.toggle-track {
    width: 42px;
    height: 24px;
    position: relative;
    display: block;
    border-radius: 999px;
    background: #c9cbc5;
    transition: background 140ms ease;
}

.toggle-track::after {
    content: "";
    width: 18px;
    height: 18px;
    position: absolute;
    top: 3px;
    left: 3px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(30, 33, 28, 0.2);
    transition: transform 140ms ease;
}

.toggle-input:checked + .toggle-track {
    background: var(--green);
}

.toggle-input:checked + .toggle-track::after {
    transform: translateX(18px);
}

.toggle-input:focus-visible + .toggle-track {
    outline: 3px solid rgba(54, 122, 77, 0.3);
    outline-offset: 2px;
}

.current-speed,
.recent-key {
    margin-top: 22px;
    padding: 12px;
    border: 1px solid #e1e0da;
    border-radius: 9px;
    background: #f8f7f3;
}

.recent-key {
    margin-top: 12px;
}

.current-speed span,
.recent-key span {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 10px;
}

.current-speed strong,
.recent-key output {
    display: block;
    min-height: 24px;
    font-size: 18px;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

.recent-key output {
    overflow-wrap: anywhere;
    font-family: ui-monospace, "Cascadia Mono", "Microsoft YaHei UI", monospace;
}

.settings-note {
    margin-top: 13px;
}

@media (max-width: 820px) {
    .game-layout {
        grid-template-columns: minmax(0, 520px);
    }

    .settings-panel {
        min-height: auto;
        padding: 20px 0 0;
        border-top: 1px solid var(--panel-edge);
        border-left: 0;
    }
}

@media (max-width: 560px) {
    .site-choices {
        grid-template-columns: 1fr;
    }

    .choice-card {
        min-height: 160px;
    }

    .choice-number {
        margin-bottom: 20px;
    }
}