* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

:root {
    --primary-color: #0a0a1a;
    --text-color: #fff;
    --accent-color: #0ff;
    --button-color: #0066cc;
    --button-hover: #0088ff;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
}

body {
    background-color: var(--primary-color);
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
}

.game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    overflow: hidden;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.game-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(18px, 5vw, 26px);
    font-family: 'Poppins', sans-serif;
    font-weight: 300;
    width: 80%;
    max-width: 450px;
    text-align: center;
    color: var(--text-color);
    text-shadow: 0 0 15px var(--accent-color), 0 0 30px rgba(0, 255, 255, 0.5);
    opacity: 0;
    transition: opacity 0.5s ease;
    padding: 20px 30px;
    border-radius: 25px;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 255, 255, 0.2);
    letter-spacing: 1px;
    pointer-events: none;
}

.game-message.visible {
    opacity: 1;
   pointer-events: auto;
}

.restart-button {
    position: absolute;
    bottom: max(40px, calc(40px + env(safe-area-inset-bottom)));
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 50px;
    background: linear-gradient(145deg, var(--button-color), #004fa3);
    color: var(--text-color);
    border: none;
    border-radius: 50px;
    font-size: 18px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    cursor: pointer;
    pointer-events: auto;
    display: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 102, 204, 0.4);
    text-transform: uppercase;
    letter-spacing: 2px;
     -webkit-appearance: none; /* Remove iOS default styling */
    -moz-appearance: none;
    appearance: none;
    -webkit-touch-callout: none; /* Disable callout on long press */
    touch-action: manipulation; /* Enable fast tap on mobile */
}

.restart-button:hover {
    background: linear-gradient(145deg, var(--button-hover), #0066cc);
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 136, 255, 0.6);
}

.restart-button:active,
.restart-button:focus {
    outline: none;
    transform: translateX(-50%) scale(0.95);
    background: linear-gradient(145deg, var(--button-hover), #0066cc);
}

.mobile-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.touch-area {
    width: 100%;
    height: 100%;
    pointer-events: auto;
}

/* Force hardware acceleration */
.game-container,
canvas {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Load fonts before game starts */
@font-face {
    font-family: 'Orbitron';
    font-display: swap;
    src: local('Orbitron'), url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');
}

@font-face {
    font-family: 'Poppins';
    font-display: swap;
    src: local('Poppins'), url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap');
}