@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    font-family: 'Press Start 2P', cursive;
    color: #fff;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    /* Retro look */
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: transparent;
    overflow: hidden;
}

#ui-layer::before,
#ui-layer::after {
    content: none;
}

#ui-layer.start-mode {
    background:
        radial-gradient(120% 120% at 30% 25%, rgba(40, 60, 120, 0.3), transparent 65%),
        radial-gradient(120% 120% at 70% 70%, rgba(20, 90, 160, 0.26), transparent 62%),
        linear-gradient(180deg, #04060d 0%, #05070f 35%, #050812 100%);
}

#ui-layer.start-mode::before,
#ui-layer.start-mode::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
}

#ui-layer.start-mode::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Crect width='220' height='220' fill='none'/%3E%3Ccircle cx='12' cy='30' r='1' fill='%23ffffff' opacity='0.45'/%3E%3Ccircle cx='40' cy='110' r='1.2' fill='%23d8e7ff' opacity='0.5'/%3E%3Ccircle cx='120' cy='18' r='0.9' fill='%23ffffff' opacity='0.4'/%3E%3Ccircle cx='210' cy='46' r='1.1' fill='%23ffffff' opacity='0.45'/%3E%3Ccircle cx='150' cy='96' r='1' fill='%23ffffff' opacity='0.5'/%3E%3Ccircle cx='70' cy='80' r='0.8' fill='%23ffffff' opacity='0.42'/%3E%3Ccircle cx='24' cy='170' r='1' fill='%23ffffff' opacity='0.45'/%3E%3Ccircle cx='140' cy='190' r='0.9' fill='%23ffffff' opacity='0.45'/%3E%3Ccircle cx='200' cy='170' r='1.1' fill='%23d8e7ff' opacity='0.52'/%3E%3Ccircle cx='95' cy='205' r='1' fill='%23ffffff' opacity='0.5'/%3E%3Ccircle cx='180' cy='130' r='0.9' fill='%23ffffff' opacity='0.4'/%3E%3Ccircle cx='60' cy='140' r='1' fill='%23ffffff' opacity='0.45'/%3E%3Ccircle cx='18' cy='120' r='0.9' fill='%23ffffff' opacity='0.45'/%3E%3C/svg%3E");
    background-size: 220px 220px;
    opacity: 0.5;
    animation: starDrift 38s linear infinite;
}

#ui-layer.start-mode::after {
    background:
        radial-gradient(60% 50% at 25% 40%, rgba(60, 80, 140, 0.25), transparent 70%),
        radial-gradient(55% 45% at 75% 60%, rgba(30, 70, 120, 0.22), transparent 70%),
        radial-gradient(45% 40% at 50% 50%, rgba(120, 150, 200, 0.12), transparent 70%);
    mix-blend-mode: screen;
    opacity: 0.65;
    animation: nebulaShift 24s ease-in-out infinite alternate;
}

#ui-layer.playing {
    background: transparent;
}

#ui-layer.playing::before,
#ui-layer.playing::after {
    content: none;
}

.hidden {
    display: none !important;
}

#loading {
    font-size: 24px;
    color: #0f0;
}

#start-screen {
    text-align: center;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Crect width='240' height='240' fill='none'/%3E%3Ccircle cx='22' cy='34' r='1' fill='%23ffffff' opacity='0.55'/%3E%3Ccircle cx='120' cy='16' r='0.8' fill='%23b8d8ff' opacity='0.55'/%3E%3Ccircle cx='210' cy='48' r='0.9' fill='%23ffffff' opacity='0.55'/%3E%3Ccircle cx='60' cy='88' r='0.8' fill='%23d0e4ff' opacity='0.65'/%3E%3Ccircle cx='188' cy='92' r='1.1' fill='%23ffffff' opacity='0.6'/%3E%3Ccircle cx='30' cy='150' r='0.9' fill='%23ffffff' opacity='0.55'/%3E%3Ccircle cx='140' cy='170' r='1.2' fill='%23ffffff' opacity='0.65'/%3E%3Ccircle cx='220' cy='182' r='0.8' fill='%23b8d8ff' opacity='0.55'/%3E%3Ccircle cx='92' cy='200' r='0.9' fill='%23ffffff' opacity='0.55'/%3E%3Ccircle cx='45' cy='210' r='1.2' fill='%23ffffff' opacity='0.55'/%3E%3Ccircle cx='176' cy='132' r='1.1' fill='%23ffffff' opacity='0.6'/%3E%3Ccircle cx='118' cy='118' r='0.7' fill='%23ffffff' opacity='0.5'/%3E%3Ccircle cx='12' cy='110' r='1.3' fill='%23ffffff' opacity='0.6'/%3E%3Ccircle cx='232' cy='108' r='1' fill='%23ffffff' opacity='0.55'/%3E%3Ccircle cx='156' cy='54' r='0.9' fill='%23ffffff' opacity='0.55'/%3E%3Ccircle cx='80' cy='32' r='0.9' fill='%23ffffff' opacity='0.55'/%3E%3Ccircle cx='204' cy='224' r='1.1' fill='%23ffffff' opacity='0.6'/%3E%3Ccircle cx='132' cy='214' r='0.8' fill='%23ffffff' opacity='0.55'/%3E%3C/svg%3E"),
        linear-gradient(145deg, rgba(8, 12, 26, 0.95), rgba(10, 20, 40, 0.92));
    background-size: 240px 240px, cover;
    background-repeat: repeat, no-repeat;
    background-position: center center, center center;
    padding: 32px 42px 46px;
    border: 2px solid #4df5ff;
    box-shadow: 0 0 35px rgba(0, 255, 255, 0.35), 0 20px 60px rgba(0, 0, 0, 0.55);
    pointer-events: auto;
    /* Enable clicking on start screen */
    backdrop-filter: blur(8px);
    position: relative;
    overflow: hidden;
}

#start-screen > :not(.version-tag) {
    position: relative;
    z-index: 2;
}

.start-orbs {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.cosmic-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(18px);
    mix-blend-mode: screen;
    opacity: 0.3;
    animation: orbFloat 18s ease-in-out infinite alternate;
}

.orb-a {
    width: 220px;
    height: 220px;
    top: -40px;
    left: -60px;
    background: radial-gradient(circle at 30% 30%, rgba(90, 120, 180, 0.4), rgba(20, 28, 60, 0.16));
}

.orb-b {
    width: 280px;
    height: 280px;
    bottom: -80px;
    right: -40px;
    background: radial-gradient(circle at 60% 60%, rgba(120, 170, 230, 0.36), rgba(18, 50, 110, 0.18));
    animation-duration: 18s;
}

.orb-c {
    width: 200px;
    height: 200px;
    top: 40%;
    left: 42%;
    background: radial-gradient(circle at 40% 40%, rgba(170, 190, 220, 0.3), rgba(30, 40, 70, 0.16));
    animation-duration: 20s;
}

#start-screen::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    pointer-events: none;
    background:
        radial-gradient(120% 120% at 20% 30%, rgba(50, 70, 120, 0.26), transparent 62%),
        radial-gradient(120% 120% at 78% 65%, rgba(40, 120, 180, 0.22), transparent 62%),
        radial-gradient(140% 140% at 50% 48%, rgba(80, 110, 160, 0.16), transparent 70%),
        linear-gradient(180deg, rgba(5, 8, 18, 0.9), rgba(5, 10, 22, 0.85));
}

#start-screen::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 12% 20%, rgba(255, 255, 255, 0.5), transparent),
        radial-gradient(1px 1px at 32% 78%, rgba(141, 210, 255, 0.45), transparent),
        radial-gradient(1px 1px at 72% 35%, rgba(220, 230, 255, 0.5), transparent),
        radial-gradient(1px 1px at 86% 88%, rgba(255, 255, 240, 0.55), transparent),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(0deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 280px 280px, 280px 280px, 280px 280px, 280px 280px, 26px 26px, 26px 26px;
    mix-blend-mode: screen;
}

#hud {
    pointer-events: none;
}

h1 {
    font-size: 36px;
    color: #8cfbff;
    text-shadow: 0 0 18px rgba(140, 251, 255, 0.7), 4px 4px #ff0080;
    margin-bottom: 8px;
    line-height: 1.5;
}

p {
    font-size: 16px;
    color: #e5f9ff;
    margin: 10px 0;
}

h2 {
    font-size: 18px;
    color: #ff9df2;
    margin: 0;
    letter-spacing: 2px;
    text-shadow: 0 0 12px rgba(255, 157, 242, 0.7);
}

p {
    font-family: 'Press Start 2P', cursive;
}

.blink {
    animation: blinker 1s linear infinite;
}

.title-glow {
    padding: 12px 18px;
    border: 1px solid rgba(0, 255, 255, 0.4);
    box-shadow: inset 0 0 20px rgba(0, 255, 255, 0.2);
    margin-bottom: 12px;
    background: linear-gradient(120deg, rgba(0, 200, 255, 0.15), rgba(255, 0, 150, 0.15));
}

.start-badges {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 10px 0 6px;
}

.badge {
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: #c8f6ff;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 1px;
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.12);
}

.badge-primary { border-color: #00f5ff; color: #00f5ff; }
.badge-secondary { border-color: #ff7af6; color: #ffb7ff; }
.badge-accent { border-color: #ffe066; color: #ffe8aa; }

.tagline {
    font-size: 14px;
    color: #e5f9ff;
    margin: 12px 0 18px;
    line-height: 1.5;
}

.version-tag {
    position: absolute;
    bottom: 14px;
    left: 16px;
    font-size: 12px;
    letter-spacing: 1px;
    color: #c8f6ff;
    text-shadow: 0 0 10px rgba(200, 246, 255, 0.6);
    opacity: 0.9;
    pointer-events: none;
}

#start-button {
    font-family: 'Press Start 2P', cursive;
    font-size: 15px;
    padding: 16px 30px;
    background: linear-gradient(120deg, #00f5ff 0%, #ff00b3 50%, #ffe066 100%);
    color: #0a0a0a;
    border: 1px solid #ffffff;
    box-shadow: 0 0 18px rgba(0, 245, 255, 0.6), 0 12px 28px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    margin: 12px 0;
    text-transform: uppercase;
}

#start-button:active {
    transform: translateY(2px);
    box-shadow: 0 0 10px rgba(0, 245, 255, 0.4);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: #bfe8ff;
    margin: 10px 0 4px;
    text-transform: uppercase;
}

.hint {
    margin-top: 10px;
}

@keyframes blinker {
    50% {
        opacity: 0;
    }
}

@keyframes orbFloat {
    0% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(8px, -6px, 0) scale(1.04); }
    100% { transform: translate3d(-10px, 12px, 0) scale(1.08); }
}

@keyframes starDrift {
    from { transform: translate3d(0, 0, 0); }
    to { transform: translate3d(-160px, -140px, 0); }
}

@keyframes nebulaShift {
    0% { transform: translate3d(-5%, -3%, 0) scale(1); }
    50% { transform: translate3d(4%, 5%, 0) scale(1.05); }
    100% { transform: translate3d(-3%, 4%, 0) scale(1.08); }
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    justify-content: space-between;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
}

#level-progress-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 300px;
}

#level-progress-label {
    font-size: 11px;
    margin-bottom: 6px;
    color: #9ff8ff;
    letter-spacing: 1px;
    text-shadow: 0 0 10px rgba(159, 248, 255, 0.6);
}

#level-progress-bar {
    width: 100%;
    height: 14px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.05), transparent 45%), linear-gradient(90deg, rgba(12, 20, 40, 0.9), rgba(8, 12, 24, 0.95));
    border-radius: 12px;
    box-shadow: inset 0 0 14px rgba(0, 255, 255, 0.2), 0 0 10px rgba(0, 255, 255, 0.12);
    overflow: hidden;
}

#level-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #6ef7ff 0%, #7cf0d6 45%, #f7ff9a 100%);
    box-shadow: 0 0 14px rgba(111, 247, 255, 0.45);
    transition: width 0.25s ease-out;
}

.hud-bottom {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: auto;
}

#health-bar {
    width: auto;
    min-width: 220px;
    height: 18px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: linear-gradient(120deg, rgba(12, 28, 20, 0.9), rgba(8, 16, 10, 0.95));
    border-radius: 14px;
    box-shadow: inset 0 0 14px rgba(0, 255, 128, 0.25), 0 0 14px rgba(0, 255, 128, 0.16);
    overflow: hidden;
}

#health-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #5afc8f 0%, #3efca2 50%, #c8ffd6 100%);
    box-shadow: 0 0 14px rgba(90, 252, 143, 0.55);
    transition: width 0.25s ease-out;
}

#boss-bar {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    min-width: 280px;
}

#boss-label {
    font-size: 11px;
    color: #ffc0e0;
    text-shadow: 0 0 10px rgba(255, 192, 224, 0.7);
    text-align: right;
    letter-spacing: 1px;
}

#boss-bar-track {
    width: 280px;
    height: 14px;
    border: 1px solid rgba(255, 70, 140, 0.65);
    background: linear-gradient(90deg, rgba(45, 6, 26, 0.9), rgba(24, 3, 16, 0.9));
    box-shadow: inset 0 0 16px rgba(255, 70, 140, 0.35), 0 0 18px rgba(255, 70, 140, 0.22);
    border-radius: 12px;
    overflow: hidden;
}

#boss-bar-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ff3e6b 0%, #ff9f43 50%, #ffe28a 100%);
    box-shadow: 0 0 16px rgba(255, 62, 107, 0.45);
    transition: width 0.2s ease-out;
}

#boss-shield-track {
    width: 200px;
    height: 10px;
    border: 1px solid rgba(120, 210, 255, 0.7);
    background: linear-gradient(90deg, rgba(10, 30, 50, 0.9), rgba(6, 16, 30, 0.9));
    box-shadow: inset 0 0 12px rgba(120, 210, 255, 0.35), 0 0 12px rgba(120, 210, 255, 0.18);
    border-radius: 10px;
    overflow: hidden;
}

#boss-shield-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #64d8ff 0%, #8ff7ff 50%, #d7f9ff 100%);
    box-shadow: 0 0 12px rgba(100, 216, 255, 0.45);
    transition: width 0.2s ease-out;
}

.boss-bars {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.boss-bar {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    min-width: 220px;
}

#boss-bar-track-2 {
    width: 240px;
    height: 14px;
    border: 1px solid rgba(120, 200, 255, 0.7);
    background: linear-gradient(90deg, rgba(10, 30, 50, 0.9), rgba(6, 16, 30, 0.9));
    box-shadow: inset 0 0 16px rgba(120, 200, 255, 0.35), 0 0 18px rgba(120, 200, 255, 0.22);
    border-radius: 12px;
    overflow: hidden;
}

#boss-bar-fill-2 {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #5ac8ff 0%, #64f1d4 50%, #c5f3ff 100%);
    box-shadow: 0 0 16px rgba(90, 200, 255, 0.4);
    transition: width 0.2s ease-out;
}

#boss-label-2 {
    font-size: 11px;
    color: #a4e0ff;
    text-shadow: 0 0 10px rgba(164, 224, 255, 0.7);
    text-align: right;
    letter-spacing: 1px;
}

#message-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: radial-gradient(90% 90% at 50% 40%, rgba(12, 24, 48, 0.75), rgba(4, 6, 12, 0.7));
    backdrop-filter: blur(8px);
    z-index: 10;
}

#message-overlay.hidden {
    display: none !important;
}

.message-frame {
    width: min(520px, 92vw);
    background:
        linear-gradient(140deg, rgba(0, 20, 40, 0.9), rgba(12, 12, 32, 0.92)),
        radial-gradient(120% 140% at 20% 20%, rgba(80, 150, 255, 0.18), transparent 60%),
        radial-gradient(120% 140% at 80% 60%, rgba(255, 90, 180, 0.14), transparent 60%);
    border: 2px solid rgba(0, 255, 255, 0.35);
    box-shadow: 0 0 25px rgba(0, 200, 255, 0.2), 0 20px 50px rgba(0, 0, 0, 0.55);
    padding: 18px 18px 16px;
    position: relative;
    overflow: hidden;
}

.message-frame::after {
    content: '';
    position: absolute;
    inset: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    pointer-events: none;
}

.message-header {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    letter-spacing: 1px;
    color: #9eefff;
    text-transform: uppercase;
    margin-bottom: 10px;
    gap: 8px;
}

/* Safety: hide legacy pulse indicator if any markup remains */
.message-header .message-pulse {
    display: none !important;
}

.message-kicker {
    color: #9eefff;
}

.message-title {
    font-size: 18px;
    color: #8cfbff;
    text-shadow: 0 0 14px rgba(140, 251, 255, 0.6);
    margin-bottom: 12px;
    text-align: center;
}

.message-body {
    font-size: 13px;
    line-height: 1.6;
    color: #d8f5ff;
    text-align: center;
    white-space: pre-line;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 12px;
    box-shadow: inset 0 0 14px rgba(0, 255, 255, 0.06);
}

.message-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 18px;
}

.message-actions button {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    padding: 12px 18px;
    text-transform: uppercase;
    border: 1px solid #ffffff;
    cursor: pointer;
    box-shadow: 0 0 12px rgba(0, 245, 255, 0.4), 0 8px 18px rgba(0, 0, 0, 0.45);
    background: linear-gradient(110deg, #00f5ff 0%, #ff00b3 65%, #ffe066 100%);
    color: #0a0a0a;
}

.message-actions button:active {
    transform: translateY(1px);
}

.message-actions .ghost {
    background: rgba(255, 255, 255, 0.07);
    color: #d8f5ff;
    border-color: rgba(255, 255, 255, 0.35);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.08);
}

#message-overlay[data-tone="victory"] .message-title {
    color: #7af7d3;
    text-shadow: 0 0 16px rgba(122, 247, 211, 0.7);
}

#message-overlay[data-tone="victory"] .message-frame {
    border-color: rgba(122, 247, 211, 0.6);
    box-shadow: 0 0 30px rgba(122, 247, 211, 0.32), 0 20px 50px rgba(0, 0, 0, 0.55);
}

#message-overlay[data-tone="alert"] .message-title {
    color: #ff9db8;
    text-shadow: 0 0 16px rgba(255, 157, 184, 0.7);
}

#message-overlay[data-tone="alert"] .message-frame {
    border-color: rgba(255, 100, 140, 0.55);
    box-shadow: 0 0 28px rgba(255, 100, 140, 0.28), 0 20px 50px rgba(0, 0, 0, 0.55);
}
