body {
    background-color: #111;
    color: #fff;
    font-family: 'Press Start 2P', 'Courier New', Courier, monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    /* Prevent scrolling on mobile */
    touch-action: none;
}

#game-container {
    position: relative;
    border: 4px solid #444;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

canvas {
    display: block;
    background-color: #000;
    height: 90vh;
    width: auto;
    aspect-ratio: 2/3;
    image-rendering: pixelated;
}

#ui-layer {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    font-size: 15px;
    /* Adjusted for pixel font */
    font-weight: bold;
    text-shadow: 2px 2px 0 #000;
    z-index: 10;
}

#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 30;
    text-align: center;
}

.title {
    font-size: 1.1em;
    color: #ff00ff;
    text-shadow: 4px 4px 0 #00ffff;
    margin-bottom: 70px;
}

.high-scores {
    margin-bottom: 10px;
    width: 80%;
}

.high-scores h2 {
    font-size: 16px;
    color: #ffff00;
    margin-bottom: 30px;
}

.score-entry {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin: 10px 0;
}

.score-1 {
    color: #ff0000;
}

.score-2 {
    color: #00ff00;
}

.score-3 {
    color: #00ffff;
}

.score-4 {
    color: #ff00ff;
}

.score-5 {
    color: #ffffff;
}

.score-6 {
    color: #ffaa00;
}

.score-7 {
    color: #ff88ff;
}

.score-8 {
    color: #88ffff;
}

.score-9 {
    color: #88ff88;
}

.score-10 {
    color: #cccccc;
}

.blink {
    animation: blink 1s infinite;
    font-size: 12px;
    color: #fff;
    width: 70%;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

#game-over {
    position: absolute;
    top: 1%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    background: rgba(0, 0, 0, 0.95);
    padding: 30px 20px;
    border: 4px solid #fff;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
    z-index: 20;
    min-width: 300px;
}

#game-over h1 {
    font-size: 28px;
    color: #ff0000;
    text-shadow: 3px 3px 0 #000;
    margin: 0 0 20px 0;
}

#final-score {
    font-size: 16px;
    color: #ffff00;
    margin: 20px 0;
}

#name-entry {
    margin: 30px 0;
}

#name-entry p {
    font-size: 12px;
    margin: 10px 0;
}

#player-name {
    font-family: 'Press Start 2P', 'Courier New', Courier, monospace;
    font-size: 24px;
    width: 200px;
    padding: 10px;
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    border: 3px solid #00ffff;
    color: #fff;
    text-transform: uppercase;
    outline: none;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.5), inset 0 0 10px rgba(0, 255, 255, 0.2);
    transition: all 0.3s ease;
}

#player-name:focus {
    border-color: #ff00ff;
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.8), inset 0 0 15px rgba(255, 0, 255, 0.3);
}

.submit-btn {
    font-family: 'Press Start 2P', 'Courier New', Courier, monospace;
    font-size: 16px;
    margin-top: 20px;
    padding: 15px 30px;
    background: rgba(0, 255, 0, 0.2);
    border: 3px solid #00ff00;
    color: #00ff00;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.5);
}

.submit-btn:hover,
.submit-btn:active {
    background: rgba(0, 255, 0, 0.4);
    box-shadow: 0 0 25px rgba(0, 255, 0, 0.8);
    transform: scale(1.05);
}

.share-btn {
    font-family: 'Press Start 2P', 'Courier New', Courier, monospace;
    font-size: 12px;
    margin-top: 20px;
    padding: 12px 20px;
    background: rgba(37, 211, 102, 0.2);
    border: 3px solid #25D366;
    color: #25D366;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(37, 211, 102, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.share-btn:hover,
.share-btn:active {
    background: rgba(37, 211, 102, 0.4);
    box-shadow: 0 0 25px rgba(37, 211, 102, 0.8);
    transform: scale(1.05);
}

.share-icon {
    font-size: 16px;
}

#restart-msg {
    font-size: 10px;
    color: #aaa;
    margin-top: 20px;
}

.hidden {
    display: none !important;
}

/* Adjust canvas for mobile */
@media (hover: none) and (pointer: coarse),
(max-width: 768px) {
    body {
        align-items: flex-start;
        padding: 0;
        height: 100svh;
        /* Match viewport height exactly */
    }

    canvas {
        width: 100%;
        height: 100%;
        aspect-ratio: unset;
        border: 2px solid #444;
        box-sizing: border-box;
    }

    #game-container {
        border: none;
        box-shadow: none;
        width: 100%;
        height: 100%;
        /* Fill the body */
        display: flex;
        justify-content: center;
        align-items: flex-start;
        /* Ensure content starts at top */
        background: #000;
        padding: 0;
        /* Add padding for safe areas (e.g. iPhone home bar) */
        padding-bottom: env(safe-area-inset-bottom);
    }

    .title {
        font-size: 24px;
    }
}

#start-bg-ship {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 330px;
    height: 330px;
    opacity: 0.4;
    z-index: -1;
    pointer-events: none;
    image-rendering: pixelated;
}