/******************/
/*** ANIMATIONS ***/
/******************/

@keyframes blink {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }

    100% {
        opacity: 0.2;
    }
}

@keyframes radar-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0% {
        opacity: 0.2;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        opacity: 0.2;
    }
}

/*****************/
/*** HTML TAGS ***/
/*****************/

body {
    margin: 0;
    overflow: hidden;
    background-color: #010103;
    touch-action: none;
    font-family: 'Courier New', Courier, monospace;
    cursor: crosshair;
}

body.keyboard-mode {
    cursor: none;
}

canvas {
    display: block;
}

/*********************/
/*** STYLE CLASSES ***/
/*********************/

.start-btn {
    background: rgba(0, 255, 255, 0.1);
    color: #0ff;
    border: 2px solid #0ff;
    padding: 15px 50px;
    font-size: 1.5em;
    font-family: inherit;
    cursor: pointer;
    position: absolute;
    bottom: 5vh;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 0 15px #0ff;
    transition: all 0.5s;
}

.start-btn:hover {
    background: #0ff;
    color: black;
    font-weight: bold;
    box-shadow: 0 0 40px #0ff;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    align-items: flex-start;
    color: #0ff;
    font-weight: bold;
    text-shadow: 0 0 10px #0ff;
    font-size: 18px;
    mix-blend-mode: screen;
}

.radar-wrapper {
    position: relative;
    width: 280px;
    height: 280px;
    transition: transform 0.5s ease-in-out;
}

.radar-wrapper.touch-mode {
    transform: scale(0.5);
    transform-origin: top left;
}

.stats-overlay {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    z-index: 10;
    text-shadow: 1px 1px 2px #000, 0 0 10px #0ff;
}

.ship-icon {
    width: 16px;
    height: 16px;
    background-color: #0ff;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    box-shadow: 0 0 5px #0ff;
    transition: opacity 0.5s;
}

.ship-icon.lost {
    opacity: 0.2;
    background-color: #555;
    box-shadow: none;
}

.radar-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    padding-right: 10px;
}

.key {
    color: #ff9900;
    font-weight: bold;
}

.alert {
    color: #ff0055;
    font-weight: bold;
}

.upgrade {
    color: #00ffff;
    font-weight: bold;
    text-shadow: 0 0 5px #00ffff;
}


/********************/
/*** ID SELECTORS ***/
/********************/

#fade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    z-index: 49;
    pointer-events: none;
    transition: background 3s ease-in;
    /* Seconds fade to black */
}

#info-led {
    color: #0ff;
    font-family: 'Courier New', Courier, monospace;
    font-size: 2.2em;
    font-weight: bold;
    opacity: 0.7;
    overflow: hidden;
    text-align: center;
    text-shadow: 0 0 5px #00ff00, 0 0 10px #00ff00, 0 0 20px #00ff00;
    white-space: pre-wrap;
    width: 80%;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    z-index: 20;
}

#radar-container {
    width: 280px;
    height: 280px;
    border: 1px solid #005555;
    border-radius: 50%;
    background: rgba(0, 5, 10, 0.9);
    position: relative;
    opacity: 0.9;
    overflow: hidden;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
    pointer-events: auto;
}

#radar-canvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

#radar-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent 0deg, rgba(0, 255, 255, 0.15) 40deg, transparent 40deg);
    animation: radar-spin 3s linear infinite;
    pointer-events: none;
}

#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    z-index: 50;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#intro-backdrop,
#gameover-backdrop,
#victory-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    z-index: -1;
    pointer-events: none;
    border: 0;
    /* Ensure no borders are visible from the masks */
    /* Soften edges with a high-diffusion radial mask */
    -webkit-mask-image: radial-gradient(circle at center, white 30%, rgba(255, 255, 255, 0.8) 50%, transparent 85%);
    mask-image: radial-gradient(circle at center, white 30%, rgba(255, 255, 255, 0.8) 50%, transparent 85%);
}

#intro-backdrop {
    background-image: url('img/intro.png');
    opacity: 0.95;
    transition: opacity 3s ease-in-out;
}

#gameover-backdrop {
    background-image: url('img/gameover.png');
    opacity: 0;
    transition: opacity 3s ease-in-out;
}

#victory-backdrop {
    background-image: url('img/victory.png');
    opacity: 0;
    transition: opacity 3s ease-in-out;
}

/* State management */
#start-screen.game-over #intro-backdrop {
    opacity: 0;
}

#start-screen.game-over #gameover-backdrop {
    opacity: 0.95;
}

#start-screen.victory #intro-backdrop {
    opacity: 0;
}

#start-screen.victory #victory-backdrop {
    opacity: 0.95;
}

#start-screen.fade-out #gameover-backdrop,
#start-screen.fade-out #victory-backdrop {
    opacity: 0.05;
    transition: opacity 20s ease-in-out;
}

#title {
    color: white;
    font-size: 3.5em;
    font-weight: bold;
    letter-spacing: 5px;
    margin-top: 5vh;
    opacity: 0.8;
    position: absolute;
    text-align: center;
    text-shadow: 0 0 20px #0ff, 0 0 40px #0ff;
    top: 0;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#yt-link {
    position: absolute;
    bottom: 1.5vh;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 80, 80, 0.55);
    font-size: 0.7em;
    font-family: 'Courier New', Courier, monospace;
    text-decoration: none;
    letter-spacing: 1px;
    white-space: nowrap;
    transition: color 0.3s, text-shadow 0.3s;
    pointer-events: auto;
    z-index: 10;
}

#yt-link:hover {
    color: #ff4444;
    text-shadow: 0 0 8px #ff4444, 0 0 18px #ff2222;
}