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

body {
    background: #0F0E17;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Press Start 2P', monospace;
    color: #F0E6D3;
    user-select: none;
    -webkit-user-select: none;
}

#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    z-index: 10;
    align-items: center;
    justify-content: center;
}

.screen.active {
    display: flex;
}

.screen-content {
    text-align: center;
    max-width: min(700px, 90vw);
    padding: clamp(16px, 3vw, 40px);
}

/* Titles */
.pixel-title {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(20px, 4vw, 42px);
    color: #2ECC40;
    letter-spacing: clamp(3px, 0.6vw, 8px);
    margin-bottom: clamp(12px, 2vw, 24px);
}

.title-glow {
    text-shadow:
        0 0 10px rgba(46, 204, 64, 0.6),
        0 0 30px rgba(46, 204, 64, 0.3),
        0 0 60px rgba(46, 204, 64, 0.15);
}

.title-red {
    color: #FF4136;
    text-shadow:
        0 0 10px rgba(255, 65, 54, 0.6),
        0 0 30px rgba(255, 65, 54, 0.3);
}

.subtitle {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(8px, 1.2vw, 13px);
    color: #8B8B9E;
    margin-bottom: clamp(20px, 4vw, 50px);
    line-height: 1.8;
}

/* Menu */
.menu {
    margin: clamp(16px, 3vw, 36px) 0;
}

.menu-item {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(10px, 1.4vw, 16px);
    padding: clamp(8px, 1vw, 14px) clamp(16px, 2vw, 28px);
    margin: clamp(4px, 0.6vw, 8px) 0;
    cursor: pointer;
    color: #8B8B9E;
    transition: color 0.15s, transform 0.1s;
    position: relative;
}

.menu-item.selected {
    color: #2ECC40;
    text-shadow: 0 0 8px rgba(46, 204, 64, 0.4);
}

.menu-item.selected::before {
    content: '\25B6';
    position: absolute;
    left: 0;
    animation: blink-arrow 0.8s infinite;
}

@keyframes blink-arrow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Stats */
.stats {
    margin: clamp(16px, 3vw, 36px) 0;
    font-size: clamp(9px, 1.2vw, 14px);
    line-height: 2.2;
}

.stats p {
    color: #F0E6D3;
}

.stats span {
    color: #FFD700;
}

/* 备案信息栏 */
#beianBar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 0 8px;
    z-index: 20;
    pointer-events: none;
}

#beianBar a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(6px, 0.75vw, 9px);
    color: #3A3A4E;
    text-decoration: none;
    pointer-events: auto;
    transition: color 0.2s;
    letter-spacing: 0.5px;
}

#beianBar a:hover {
    color: #5A5A7E;
}

.beian-sep {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(6px, 0.75vw, 9px);
    color: #2A2A3E;
    margin: 0 8px;
}

#beianBar img {
    width: clamp(12px, 1.2vw, 16px);
    height: clamp(12px, 1.2vw, 16px);
    image-rendering: pixelated;
    opacity: 0.5;
    transition: opacity 0.2s;
}

#beianBar a:hover img {
    opacity: 0.8;
}

/* Footer hints */
.footer-hint {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(7px, 0.9vw, 11px);
    color: #5A5A6E;
    margin-top: clamp(20px, 3vw, 40px);
    line-height: 1.8;
}

/* Blink text */
.blink-text {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(9px, 1.2vw, 14px);
    color: #FFD700;
    animation: blink-text 1s infinite;
}

@keyframes blink-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

/* HUD */
#gameScreen {
    pointer-events: none;
    z-index: 5;
}

#gameScreen.active {
    display: block;
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(6px, 1vw, 12px) clamp(10px, 1.5vw, 24px);
    background: linear-gradient(180deg, rgba(15, 14, 23, 0.95) 0%, rgba(15, 14, 23, 0) 100%);
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(8px, 1.1vw, 13px);
    z-index: 6;
}

#hudLeft, #hudRight {
    display: flex;
    gap: clamp(10px, 1.5vw, 24px);
    align-items: center;
}

#hudLives .heart {
    color: #FF4136;
    margin-right: 2px;
}

#hudLives .heart.empty {
    color: #3D3025;
}

#hudLevel { color: #8B8B9E; }
#hudScore { color: #FFD700; font-size: clamp(9px, 1.3vw, 15px); }
#hudTimer { color: #00D4AA; }

#gameHudBottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(6px, 1vw, 12px) clamp(10px, 1.5vw, 24px);
    background: linear-gradient(0deg, rgba(15, 14, 23, 0.95) 0%, rgba(15, 14, 23, 0) 100%);
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(7px, 1vw, 12px);
    z-index: 6;
}

#hudPoints { color: #8B8B9E; }
#hudBuffer { color: #FFD700; font-size: clamp(8px, 1.1vw, 13px); min-width: 80px; text-align: right; }

/* Game Command Hints */
#gameHints {
    position: absolute;
    bottom: clamp(32px, 4.5vh, 50px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: clamp(8px, 1.5vw, 20px);
    align-items: center;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(6px, 0.75vw, 9px);
    color: #8B8B9E;
    white-space: nowrap;
    z-index: 7;
    pointer-events: none;
    padding: clamp(4px, 0.5vw, 6px) clamp(8px, 1.2vw, 16px);
    background: rgba(15, 14, 23, 0.75);
    border: 1px solid rgba(92, 74, 50, 0.3);
    border-radius: 4px;
}

#gameHints .hint-group {
    display: flex;
    align-items: center;
    gap: clamp(3px, 0.4vw, 5px);
}

#gameHints .hint-sep {
    color: #3D3025;
    margin: 0 clamp(2px, 0.3vw, 4px);
}

#gameHints kbd {
    color: #7B6B4F;
    border-color: #5C4A32;
    background: rgba(26, 24, 37, 0.8);
    font-size: clamp(6px, 0.75vw, 9px);
    padding: 1px clamp(3px, 0.3vw, 5px);
}

/* Level Select Grid */
.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: clamp(6px, 1vw, 14px);
    margin: clamp(16px, 3vw, 36px) auto;
    max-width: min(400px, 70vw);
}

.level-cell {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(10px, 1.4vw, 16px);
    padding: clamp(8px, 1.2vw, 18px);
    text-align: center;
    background: rgba(91, 91, 110, 0.15);
    border: 2px solid #3D3025;
    color: #5A5A6E;
    cursor: pointer;
    transition: all 0.15s;
}

.level-cell.unlocked {
    color: #F0E6D3;
    border-color: #5C4A32;
}

.level-cell.selected {
    border-color: #2ECC40;
    color: #2ECC40;
    background: rgba(46, 204, 64, 0.1);
    box-shadow: 0 0 10px rgba(46, 204, 64, 0.3);
}

.level-cell.completed::after {
    content: ' \2713';
    color: #2ECC40;
    font-size: clamp(7px, 0.9vw, 11px);
}

/* Help Screen */
.help-content {
    text-align: left;
    max-width: min(720px, 92vw);
    max-height: 88vh;
    overflow-y: auto;
    padding: clamp(14px, 2.5vw, 30px) clamp(12px, 2vw, 24px);
}

.help-content::-webkit-scrollbar {
    width: 6px;
}
.help-content::-webkit-scrollbar-track {
    background: rgba(91, 91, 110, 0.1);
}
.help-content::-webkit-scrollbar-thumb {
    background: #5C4A32;
    border-radius: 3px;
}

.help-content h2 {
    text-align: center;
    margin-bottom: clamp(14px, 2vw, 28px);
}

.help-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(10px, 1.5vw, 20px);
    margin-bottom: clamp(12px, 1.5vw, 22px);
}

.help-section h3 {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(7px, 0.95vw, 12px);
    color: #FFD700;
    margin-bottom: clamp(6px, 0.8vw, 12px);
    padding-bottom: clamp(4px, 0.5vw, 8px);
    border-bottom: 1px solid #3D3025;
}

.help-row {
    font-size: clamp(7px, 0.85vw, 11px);
    color: #8B8B9E;
    margin-bottom: clamp(3px, 0.4vw, 6px);
    line-height: 1.7;
    display: flex;
    align-items: flex-start;
    gap: clamp(4px, 0.5vw, 8px);
    flex-wrap: wrap;
}

.help-row .help-desc {
    color: #A0A0B8;
}

kbd {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(7px, 0.85vw, 11px);
    background: #1A1825;
    border: 1px solid #5C4A32;
    border-radius: 3px;
    padding: clamp(2px, 0.3vw, 4px) clamp(4px, 0.5vw, 7px);
    color: #2ECC40;
    display: inline-block;
}

.help-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(5px, 0.7vw, 10px);
    font-size: clamp(7px, 0.85vw, 11px);
    color: #8B8B9E;
    padding: clamp(8px, 1.2vw, 16px);
    background: rgba(91, 91, 110, 0.08);
    border: 1px solid #3D3025;
    margin-bottom: clamp(10px, 1.2vw, 16px);
}

.help-rules {
    font-size: clamp(7px, 0.85vw, 11px);
    color: #8B8B9E;
    margin-bottom: clamp(10px, 1.2vw, 18px);
    line-height: 1.9;
    padding: clamp(8px, 1.2vw, 16px);
    background: rgba(91, 91, 110, 0.05);
    border: 1px solid #3D3025;
}

.help-tips {
    font-size: clamp(7px, 0.85vw, 11px);
    color: #FFD700;
    margin-bottom: clamp(10px, 1.2vw, 18px);
    line-height: 1.9;
    padding: clamp(8px, 1.2vw, 16px);
    background: rgba(255, 215, 0, 0.03);
    border: 1px solid rgba(255, 215, 0, 0.15);
}

.help-tips p,
.help-rules p {
    margin-bottom: clamp(2px, 0.3vw, 5px);
}

.help-divider {
    border: none;
    border-top: 1px solid #3D3025;
    margin: clamp(10px, 1.2vw, 16px) 0;
}

.legend-wall {
    display: inline-block;
    width: clamp(10px, 1.2vw, 16px);
    height: clamp(10px, 1.2vw, 16px);
    background: #5C4A32;
    border: 1px solid #7B6B4F;
    vertical-align: middle;
    margin-right: 4px;
}

.legend-tilde {
    display: inline-block;
    color: #00D4AA;
    font-weight: bold;
    margin-right: 4px;
    width: clamp(10px, 1.2vw, 16px);
    text-align: center;
}

.legend-text {
    display: inline-block;
    color: #F0E6D3;
    margin-right: 4px;
    width: clamp(10px, 1.2vw, 16px);
    text-align: center;
}

.legend-ghost {
    display: inline-block;
    width: clamp(10px, 1.2vw, 16px);
    height: clamp(10px, 1.2vw, 16px);
    background: #FF4136;
    border-radius: 50% 50% 0 0;
    vertical-align: middle;
    margin-right: 4px;
}

/* Death overlay */
#deathOverlay {
    background: rgba(255, 65, 54, 0.15);
    z-index: 8;
    animation: death-flash 0.5s ease-out;
}

@keyframes death-flash {
    0% { background: rgba(255, 65, 54, 0.4); }
    100% { background: rgba(255, 65, 54, 0.15); }
}

.death-text {
    animation: death-pop 0.3s ease-out;
}

@keyframes death-pop {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* Responsive: small screens stack help grid to single column */
@media (max-width: 600px) {
    .help-grid { grid-template-columns: 1fr; }
    .help-legend { grid-template-columns: 1fr; }
}
