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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: 'Courier New', monospace;
    color: #fff;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

#gameCanvas {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    touch-action: none;
}

.screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    pointer-events: none;
}

.screen-overlay.active {
    display: flex;
    pointer-events: auto;
}

.screen-panel {
    background: rgba(5, 5, 20, 0.92);
    border: 2px solid rgba(0, 255, 255, 0.3);
    border-radius: 8px;
    padding: 30px 40px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 0 40px rgba(0, 255, 255, 0.1), inset 0 0 30px rgba(0, 0, 0, 0.5);
}

.game-title {
    font-size: clamp(28px, 6vw, 56px);
    font-weight: bold;
    color: #0ff;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.5), 0 0 40px rgba(0, 255, 255, 0.2);
    margin-bottom: 5px;
    letter-spacing: 4px;
}

.game-subtitle {
    font-size: clamp(10px, 2vw, 16px);
    color: #f80;
    letter-spacing: 6px;
    margin-bottom: 25px;
    text-shadow: 0 0 10px rgba(255, 136, 0, 0.4);
}

.menu-best-score {
    font-size: clamp(11px, 1.8vw, 15px);
    color: #ff0;
    margin-bottom: 20px;
    text-shadow: 0 0 8px rgba(255, 255, 0, 0.3);
}

.btn {
    display: block;
    width: 100%;
    max-width: 260px;
    margin: 8px auto;
    padding: 12px 20px;
    background: rgba(0, 255, 255, 0.08);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 4px;
    color: #0ff;
    font-family: 'Courier New', monospace;
    font-size: clamp(13px, 2vw, 16px);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 2px;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover, .btn:focus {
    background: rgba(0, 255, 255, 0.15);
    border-color: #0ff;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
    transform: scale(1.02);
}

.btn:active {
    background: rgba(0, 255, 255, 0.25);
    transform: scale(0.98);
}

.btn-primary {
    background: rgba(0, 255, 255, 0.15);
    border-color: #0ff;
    font-size: clamp(15px, 2.5vw, 20px);
    padding: 14px 24px;
}

.btn-primary:hover, .btn-primary:focus {
    background: rgba(0, 255, 255, 0.3);
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.3);
}

.btn-danger {
    border-color: rgba(255, 50, 50, 0.4);
    color: #f55;
}

.btn-danger:hover, .btn-danger:focus {
    background: rgba(255, 50, 50, 0.15);
    border-color: #f55;
}

.howto-content {
    text-align: left;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 10px;
    font-size: clamp(11px, 1.5vw, 14px);
    line-height: 1.6;
}

.howto-content::-webkit-scrollbar {
    width: 4px;
}

.howto-content::-webkit-scrollbar-thumb {
    background: #0ff3;
    border-radius: 2px;
}

.howto-content h3 {
    color: #0ff;
    margin: 15px 0 8px 0;
    font-size: clamp(13px, 1.8vw, 16px);
}

.howto-content h3:first-child {
    margin-top: 0;
}

.howto-content .control-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.howto-content .control-key {
    color: #ff0;
    font-weight: bold;
}

.howto-content .control-desc {
    color: #ccc;
}

.howto-content .note {
    color: #f80;
    font-style: italic;
    margin-top: 10px;
    font-size: clamp(10px, 1.4vw, 13px);
}

.go-score {
    font-size: clamp(28px, 6vw, 48px);
    color: #ff0;
    font-weight: bold;
    text-shadow: 0 0 20px rgba(255, 255, 0, 0.3);
    margin: 10px 0;
}

.go-label {
    font-size: clamp(10px, 1.5vw, 13px);
    color: #888;
    letter-spacing: 2px;
}

.go-value {
    font-size: clamp(16px, 3vw, 22px);
    color: #fff;
    margin: 5px 0 12px 0;
}

.go-new-record {
    color: #f0f;
    font-size: clamp(14px, 2.5vw, 20px);
    font-weight: bold;
    text-shadow: 0 0 15px rgba(255, 0, 255, 0.5);
    animation: pulse 0.8s ease-in-out infinite alternate;
    margin: 10px 0;
}

@keyframes pulse {
    from { opacity: 0.7; transform: scale(1); }
    to { opacity: 1; transform: scale(1.05); }
}

.countdown-text {
    font-size: 80px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 30px #0ff;
}

.section-title {
    color: #0ff;
    font-size: clamp(16px, 3vw, 22px);
    margin-bottom: 15px;
}

.touch-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: none;
    padding: 10px 15px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    pointer-events: none;
}

.touch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.touch-btn {
    pointer-events: auto;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid rgba(0, 255, 255, 0.4);
    background: rgba(0, 20, 30, 0.7);
    color: #0ff;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.1s;
}

.touch-btn.pressed {
    background: rgba(0, 255, 255, 0.3);
    border-color: #0ff;
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.4);
}

.touch-btn-large {
    width: 70px;
    height: 70px;
    font-size: 12px;
}

.touch-btn-special {
    border-color: rgba(255, 0, 255, 0.4);
    color: #f0f;
    width: 65px;
    height: 65px;
}

.touch-btn-special.pressed {
    background: rgba(255, 0, 255, 0.3);
    border-color: #f0f;
    box-shadow: 0 0 12px rgba(255, 0, 255, 0.4);
}

.touch-dpad {
    display: flex;
    gap: 8px;
}

.touch-actions {
    display: flex;
    gap: 8px;
}

@media (max-width: 768px) {
    .screen-panel {
        padding: 20px 25px;
    }

    .touch-btn {
        width: 55px;
        height: 55px;
        font-size: 10px;
    }

    .touch-btn-large {
        width: 62px;
        height: 62px;
    }

    .touch-btn-special {
        width: 58px;
        height: 58px;
    }
}

@media (max-height: 500px) {
    .touch-controls {
        padding: 5px 10px;
    }

    .touch-btn {
        width: 48px;
        height: 48px;
        font-size: 9px;
    }

    .touch-btn-large {
        width: 52px;
        height: 52px;
    }

    .touch-row {
        margin-bottom: 4px;
    }
}

@media (min-width: 769px) and (min-height: 500px) {
    .touch-controls .touch-row:first-child {
        display: none;
    }
}

.hidden {
    display: none !important;
}

button:focus-visible {
    outline: 2px solid #0ff;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition-duration: 0s !important;
    }
}
