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

body {
    background-color: #000000;
    color: #ffffff;
    font-family: 'Times New Roman', Times, serif;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100vw;
    padding: 10px;
    gap: 5px;
}

.game-header {
    text-align: center;
    width: 100%;
}

.title {
    font-size: clamp(20px, 5vw, 32px);
    font-weight: bold;
    letter-spacing: 2px;
    color: #ffffff;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.score-display {
    display: flex;
    gap: 20px;
    font-size: clamp(14px, 3vw, 18px);
    color: #cccccc;
    justify-content: center;
    flex-wrap: wrap;
}

#score {
    color: #ff4444;
}

#highscore {
    color: #ffaa00;
}

#canvas-container {
    position: relative;
    border: 3px solid #666666;
    background: #000000;
    width: min(90vw, 90vh, 500px);
    height: min(90vw, 90vh, 500px);
    max-width: 600px;
    max-height: 600px;
}

canvas {
    background-color: #111111;
    display: block;
    image-rendering: pixelated;
    width: 100%;
    height: 100%;
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

#overlay-title {
    color: #ff4444;
    font-size: clamp(18px, 4vw, 28px);
    margin-bottom: 8px;
}

#overlay-subtitle {
    color: #999999;
    margin-bottom: 15px;
    max-width: 300px;
    font-size: clamp(12px, 2.5vw, 16px);
}

button {
    background: #000000;
    color: #ffffff;
    border: 2px solid #ffffff;
    padding: clamp(8px, 2vw, 10px) clamp(20px, 5vw, 30px);
    font-family: 'Times New Roman', Times, serif;
    font-size: clamp(14px, 3vw, 18px);
    cursor: pointer;
    text-transform: uppercase;
    touch-action: manipulation;
}

button:hover {
    background: #ffffff;
    color: #000000;
}

button:active {
    background: #ffffff;
    color: #000000;
}

.mobile-controls {
    display: none;
    width: 100%;
    max-width: 300px;
    margin-top: 5px;
}

.control-row {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin: 3px 0;
}

.ctrl-btn {
    width: 50px;
    height: 50px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: #1a1a1a;
    border: 2px solid #444444;
    color: #ffffff;
}

.ctrl-btn:active {
    background: #333333;
    border-color: #ffffff;
}

.controls-hint {
    margin-top: 3px;
    color: #666666;
    font-size: clamp(10px, 2vw, 14px);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.desktop-hint {
    display: inline;
}

.mobile-hint {
    display: none;
}

#pause-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.menu-content {
    text-align: center;
    max-width: 350px;
    width: 100%;
    padding: 20px;
    border: 2px solid #666666;
    background: #000000;
}

.menu-content h2 {
    font-size: clamp(20px, 5vw, 28px);
    margin-bottom: 15px;
    color: #ffffff;
}

.rules {
    text-align: left;
    margin-bottom: 20px;
    color: #cccccc;
    font-size: clamp(12px, 2.5vw, 16px);
    line-height: 1.5;
}

.rules p {
    margin-bottom: 6px;
}

.hidden {
    display: none !important;
}

@media (max-width: 768px) {
    .mobile-controls {
        display: block;
    }
    
    .desktop-hint {
        display: none;
    }
    
    .mobile-hint {
        display: inline;
    }
    
    .game-wrapper {
        padding: 5px;
        gap: 3px;
    }
    
    #canvas-container {
        width: min(95vw, 85vh, 400px);
        height: min(95vw, 85vh, 400px);
    }
}

@media (max-width: 400px) {
    #canvas-container {
        width: 95vw;
        height: 95vw;
        max-width: 350px;
        max-height: 350px;
    }
    
    .ctrl-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    
    .menu-content {
        padding: 15px;
    }
}