:root {
    --bg: #030911;
    --panel: rgba(7, 20, 32, 0.88);
    --ink: #edf9ff;
    --muted: #8fa8b7;
    --cyan: #58e6ff;
    --orange: #ffb454;
    --red: #ff705f;
    --line: rgba(105, 214, 255, 0.2);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 70% 8%, rgba(20, 134, 175, 0.2), transparent 30rem),
        linear-gradient(180deg, #040b13, #02070c);
    color: var(--ink);
    font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    content: "";
    background-image:
        linear-gradient(rgba(110, 220, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(110, 220, 255, 0.035) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    font: inherit;
}

.game-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    min-height: 76px;
    align-items: center;
    padding: 12px clamp(16px, 3vw, 36px);
    border-bottom: 1px solid var(--line);
    background: rgba(3, 10, 17, 0.88);
    backdrop-filter: blur(18px);
    grid-template-columns: 1fr auto 1fr;
}

.back-link {
    display: inline-flex;
    width: max-content;
    align-items: center;
    gap: 8px;
    color: #acc4d1;
    font-size: 13px;
    text-decoration: none;
}

.back-link:hover {
    color: var(--cyan);
}

.game-brand {
    display: grid;
    justify-items: center;
    line-height: 1.25;
}

.game-brand strong {
    font-size: 15px;
    letter-spacing: 0.08em;
}

.game-brand span,
.section-code,
.overlay-kicker {
    color: #7292a4;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 9px;
    letter-spacing: 0.14em;
}

.game-status {
    display: inline-flex;
    justify-self: end;
    align-items: center;
    gap: 7px;
    color: #99b2c0;
    font-size: 11px;
}

.game-status i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8dffb0;
    box-shadow: 0 0 10px #8dffb0;
}

.game-layout {
    width: min(calc(100% - 28px), 1240px);
    margin: 0 auto;
    padding: 26px 0 42px;
}

.game-stage {
    display: grid;
    place-items: center;
}

.game-frame {
    position: relative;
    width: 100%;
    overflow: hidden;
    border: 1px solid rgba(96, 218, 248, 0.28);
    border-radius: 14px;
    background: #06111c;
    box-shadow:
        0 35px 100px rgba(0, 0, 0, 0.52),
        0 0 80px rgba(62, 194, 235, 0.08);
}

#game-canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 2;
    outline: none;
    touch-action: none;
}

.game-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-content: center;
    justify-items: center;
    padding: 24px;
    background: rgba(1, 7, 12, 0.82);
    text-align: center;
    backdrop-filter: blur(8px);
}

.game-overlay[hidden] {
    display: none;
}

.game-overlay h1 {
    margin: 12px 0 8px;
    font-size: clamp(34px, 5vw, 62px);
    letter-spacing: -0.04em;
}

.game-overlay p {
    max-width: 570px;
    margin: 0;
    color: #a9c0cc;
    line-height: 1.8;
}

.overlay-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 26px;
}

.overlay-actions button {
    min-width: 140px;
    padding: 13px 20px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--cyan);
    color: #031019;
    font-weight: 700;
    cursor: pointer;
}

.overlay-actions button + button {
    background: rgba(255, 255, 255, 0.045);
    color: var(--ink);
}

.game-help {
    display: grid;
    gap: 26px;
    margin-top: 18px;
    padding: 22px 24px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.9fr);
}

.game-help h2 {
    margin: 7px 0 8px;
    font-size: 25px;
}

.game-help p {
    max-width: 680px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.8;
}

.key-guide {
    display: grid;
    align-content: center;
    gap: 9px 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.key-guide span {
    color: #a9c0cc;
    font-size: 11px;
    white-space: nowrap;
}

kbd {
    display: inline-grid;
    min-width: 22px;
    height: 22px;
    margin-right: 3px;
    place-items: center;
    border: 1px solid rgba(105, 214, 255, 0.28);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.035);
    color: var(--cyan);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 9px;
}

.touch-controls {
    display: none;
    justify-content: space-between;
    gap: 16px;
    margin-top: 14px;
    user-select: none;
}

.touch-group {
    display: grid;
    gap: 7px;
    grid-template-columns: repeat(2, 58px);
}

.touch-group button {
    width: 58px;
    height: 52px;
    border: 1px solid rgba(105, 214, 255, 0.25);
    border-radius: 10px;
    background: rgba(8, 26, 40, 0.9);
    color: var(--ink);
    font-size: 20px;
    touch-action: none;
}

.touch-group button.is-active {
    border-color: var(--cyan);
    background: rgba(88, 230, 255, 0.2);
    color: var(--cyan);
}

.touch-actions {
    grid-template-columns: repeat(4, 52px);
}

.touch-actions button {
    width: 52px;
    height: 41px;
    color: #b9d0db;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 13px;
}

.game-note {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 4px 0;
    color: #698493;
    font-size: 11px;
}

.game-note a {
    color: var(--cyan);
    text-decoration: none;
}

.community-rating-dialog {
    width: min(92vw, 520px);
    padding: 0;
    border: 1px solid rgba(255, 180, 84, 0.36);
    border-radius: 18px;
    background: #06121d;
    color: var(--ink);
    box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7);
}

.community-rating-dialog::backdrop {
    background: rgba(0, 5, 10, 0.86);
    backdrop-filter: blur(8px);
}

.rating-dialog-inner {
    position: relative;
    padding: 36px;
    background:
        radial-gradient(circle at 50% 0, rgba(255, 180, 84, 0.12), transparent 19rem),
        linear-gradient(180deg, #071724, #040c14);
    text-align: center;
}

.rating-dialog-inner h2 {
    margin: 13px 0 0;
    font-size: clamp(28px, 5vw, 40px);
}

.rating-dialog-inner > p {
    margin: 10px auto 0;
    max-width: 390px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.8;
}

.rating-dialog-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: transparent;
    color: #a7bec9;
    cursor: pointer;
}

.rating-stars {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 24px;
}

.rating-stars button {
    padding: 0;
    border: 0;
    background: transparent;
    color: #405360;
    cursor: pointer;
    font-size: 44px;
    line-height: 1;
    transition: color 0.15s ease, transform 0.15s ease;
}

.rating-stars button:hover,
.rating-stars button:focus-visible,
.rating-stars button.is-filled {
    color: var(--orange);
    transform: translateY(-1px);
}

.rating-feedback {
    min-height: 20px;
    color: #7eefa5;
}

.rating-feedback.is-error {
    color: #ff8f7c;
}

@media (max-width: 820px) {
    .game-header {
        grid-template-columns: 1fr auto;
    }

    .game-brand {
        display: none;
    }

    .game-layout {
        width: min(calc(100% - 16px), 1240px);
        padding-top: 10px;
    }

    .game-frame {
        border-radius: 9px;
    }

    .game-help {
        grid-template-columns: 1fr;
        padding: 18px;
    }

    .game-help p {
        font-size: 12px;
    }

    .touch-controls {
        display: flex;
    }

    .key-guide {
        display: none;
    }
}

@media (max-width: 560px) {
    .game-status {
        display: none;
    }

    .game-header {
        min-height: 58px;
        padding: 8px 12px;
    }

    .game-stage {
        margin-inline: -8px;
    }

    .game-frame {
        border-right: 0;
        border-left: 0;
        border-radius: 0;
    }

    .game-help {
        margin-top: 10px;
    }

    .game-help h2 {
        font-size: 20px;
    }

    .touch-controls {
        align-items: end;
        gap: 9px;
    }

    .touch-group {
        gap: 5px;
        grid-template-columns: repeat(2, 48px);
    }

    .touch-group button {
        width: 48px;
        height: 45px;
    }

    .touch-actions {
        grid-template-columns: repeat(4, 43px);
    }

    .touch-actions button {
        width: 43px;
        height: 36px;
        font-size: 11px;
    }

    .game-note {
        display: grid;
    }
}

@media (hover: none) and (pointer: coarse) {
    .touch-controls {
        display: flex;
    }

    .key-guide {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation: none !important;
        transition: none !important;
    }
}
