* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a1a2e;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e94560;
    z-index: 100;
    transition: opacity 0.5s ease;
}

#loading.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Explosion Flash Effect */
#explosionFlash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 200, 100, 0.9) 0%, rgba(255, 100, 50, 0.7) 50%, rgba(255, 50, 0, 0) 100%);
    pointer-events: none;
    opacity: 0;
    z-index: 55;
}

#explosionFlash.active {
    animation: explosionFlash 0.4s ease-out forwards;
}

@keyframes explosionFlash {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
    }

    100% {
        opacity: 0;
        transform: scale(1.5);
    }
}

#loading p {
    margin-top: 20px;
    font-size: 1.2rem;
    letter-spacing: 2px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(233, 69, 96, 0.2);
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Start Menu */
#startMenu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
    gap: 4rem;
    justify-content: flex-end;
    /* Align elements to right */
    padding-right: 10%;
    align-items: center;
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.95) 0%, rgba(22, 33, 62, 0.95) 100%);
    z-index: 50;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

#startMenu .menu-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

#startMenu.hidden {
    opacity: 0;
    transform: scale(1.1);
    pointer-events: none;
}

#startMenu .title {
    font-size: 4rem;
    color: #fff;
    text-shadow: 0 0 20px rgba(233, 69, 96, 0.8), 0 0 40px rgba(233, 69, 96, 0.4);
    margin-bottom: 1rem;
    animation: pulse 2s ease-in-out infinite;
}

.title-logo {
    height: 1em;
    width: auto;
    vertical-align: middle;
    margin-right: 0.2em;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

#startMenu .subtitle {
    font-size: 1.4rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 3rem;
}

#startMenu #playBtn {
    padding: 1.2rem 4rem;
    font-size: 1.8rem;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #e94560 0%, #c73e54 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 0 30px rgba(233, 69, 96, 0.5), 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#startMenu #playBtn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 50px rgba(233, 69, 96, 0.8), 0 15px 40px rgba(0, 0, 0, 0.4);
}

#startMenu #playBtn:active {
    transform: scale(0.95);
}

#startMenu .hint {
    margin-top: 2rem;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 3px;
    text-transform: uppercase;
}

/* Volume Controls */
.volume-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

#muteBtn {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

#muteBtn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

#volumeSlider {
    width: 150px;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    outline: none;
}

#volumeSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #e94560;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
}

#volumeSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #e94560;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
}

.highscore {
    margin-top: 1rem;
    font-size: 1.2rem;
    color: #ffd700;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* HUD */
#hud {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 40;
    color: #fff;
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    display: flex;
    gap: 2rem;
    align-items: center;
}

.hud-top {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Health Bar */
.health-bar-container {
    width: 150px;
    height: 16px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    overflow: hidden;
}

.health-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #e94560 0%, #ff6b6b 100%);
    border-radius: 6px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
}

#hudMuteBtn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    filter: drop-shadow(0 0 5px rgba(233, 69, 96, 0.5));
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

#hudMuteBtn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.1);
}

#hud.hidden {
    opacity: 0;
    pointer-events: none;
}

#hud .stat span {
    color: #e94560;
}

/* Notification */
.notification {
    position: fixed;
    top: 80px;
    right: 20px;
    /* Slide in from right */
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 1rem 1.5rem;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 50;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(233, 69, 96, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    transform: translateX(0);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s;
}

.notification.hidden {
    transform: translateX(120%);
    /* Slide out to right */
    opacity: 0;
    pointer-events: none;
}

.notification .icon {
    font-size: 1.5rem;
}

.notification .meta {
    display: flex;
    flex-direction: column;
}

#npTitle {
    font-weight: bold;
    color: #e94560;
    font-size: 1rem;
}

#npArtist {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

/* Game Over Menu (reuses Start Menu styles) */
#gameOverMenu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(26, 26, 46, 0.9);
    z-index: 60;
    transition: opacity 0.3s ease;
}

#gameOverMenu.hidden {
    opacity: 0;
    pointer-events: none;
}

#gameOverMenu .title {
    font-size: 4rem;
    color: #e94560;
    margin-bottom: 1rem;
    text-transform: uppercase;
}

#gameOverMenu .subtitle {
    font-size: 2rem;
    color: #fff;
    margin-bottom: 3rem;
}

#restartBtn {
    padding: 1rem 3rem;
    font-size: 1.5rem;
    background: #fff;
    color: #1a1a2e;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s ease;
}

#restartBtn:hover {
    transform: scale(1.1);
}

.secondary-btn {
    margin-top: 1rem;
    padding: 0.8rem 2rem;
    font-size: 1.2rem;
    background: transparent;
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
    transform: scale(1.05);
}

/* Highscore Table */
.highscore-container {
    margin-top: 1.5rem;
    width: 300px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    padding: 1rem;
    backdrop-filter: blur(5px);
}

.highscore-container h3 {
    text-align: center;
    color: #e94560;
    margin-bottom: 0.8rem;
    text-transform: uppercase;
    font-size: 1.1rem;
    letter-spacing: 1px;
}

#highscoreTable {
    width: 100%;
    border-collapse: collapse;
    color: #fff;
    font-size: 0.95rem;
}

#highscoreTable td {
    padding: 6px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#highscoreTable tr:last-child td {
    border-bottom: none;
}

.rank-1 {
    color: #ffd700;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

.rank-2 {
    color: #c0c0c0;
    font-weight: bold;
}

.rank-3 {
    color: #cd7f32;
    font-weight: bold;
}

/* Name Input */
#highscoreInput {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    animation: fadeIn 0.5s ease;
    vertical-align: top;
}

#highscoreInput.hidden {
    display: none;
}

/* Trophy and Input side by side wrapper */
#gameOverRow {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
}

#gameOverRow .trophy-display {
    flex-shrink: 0;
}

.new-record {
    color: #ffd700;
    font-size: 1.4rem;
    font-weight: bold;
    animation: pulse 1s infinite;
}

#playerName {
    padding: 0.8rem 1rem;
    font-size: 1.2rem;
    border: 2px solid #e94560;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    text-align: center;
    outline: none;
    width: 200px;
}

#playerName:focus {
    box-shadow: 0 0 15px rgba(233, 69, 96, 0.5);
}

#saveScoreBtn {
    padding: 0.8rem 2rem;
    font-size: 1.1rem;
    background: #e94560;
    color: #fff;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s;
}

#saveScoreBtn:hover {
    transform: scale(1.05);
}

#gameOverButtons {
    display: flex;
    flex-direction: column;
    align-items: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Start Banner */
#startBanner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #1a1a2e;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    z-index: 200;
    transition: opacity 0.5s ease;
}

#startBanner.hidden {
    opacity: 0;
    pointer-events: none;
}

#startBanner .title {
    font-size: 5rem;
    color: #fff;
    text-shadow: 0 0 20px rgba(233, 69, 96, 0.8), 0 0 40px rgba(233, 69, 96, 0.4);
    margin-bottom: 2rem;
    animation: float 3s ease-in-out infinite;
}

#bannerStartBtn {
    padding: 1.5rem 5rem;
    font-size: 2rem;
    font-weight: bold;
    color: #e94560;
    background: transparent;
    border: 3px solid #e94560;
    border-radius: 5px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 4px;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.2);
}

#bannerStartBtn:hover {
    background: #e94560;
    color: #fff;
    box-shadow: 0 0 40px rgba(233, 69, 96, 0.6);
    transform: scale(1.05);
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

/* Ensure pulse animation is available */
.pulse-btn {
    animation: pulse 2s infinite;
}

/* Character images */
.banner-character {
    max-width: 350px;
    max-height: 350px;
    width: auto;
    height: auto;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5));
}

.menu-character {
    position: absolute;
    max-width: 400px;
    max-height: 400px;
    width: auto;
    height: auto;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
    animation: characterBounce 2s ease-in-out infinite;
    z-index: -1;
    /* Behind menu elements */
    opacity: 0.9;
}

.menu-char-left {
    left: 5%;
    bottom: 5%;
}

.menu-char-right {
    right: 5%;
    bottom: 10%;
    transform: scaleX(-1);
}

@keyframes characterBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

/* Mobile responsive for characters */
@media (max-width: 768px) {
    .banner-character {
        max-width: 200px;
        max-height: 200px;
    }

    .menu-character {
        max-width: 150px;
        max-height: 150px;
        opacity: 0.5;
    }

    .menu-char-left {
        left: 2%;
        bottom: 5%;
    }
}

/* Trophy Cut Notification */
.trophy-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 3rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 40px rgba(255, 215, 0, 0.4), 2px 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: none;
}

.trophy-notification.show {
    animation: trophyPop 1.5s ease-out forwards;
}

@keyframes trophyPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }

    15% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }

    30% {
        transform: translate(-50%, -50%) scale(1);
    }

    70% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8) translateY(-30px);
    }
}

/* Trophy Display on Game Over */
.trophy-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 1.5rem 0;
    padding: 1rem 2rem;
    background: rgba(255, 215, 0, 0.1);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 12px;
}

.trophy-title {
    color: #ffd700;
    font-size: 1.3rem;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    margin-bottom: 0.5rem;
}

.trophy-heads {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    justify-content: center;
}

.trophy-head {
    font-size: 2rem;
    animation: trophyBounce 0.5s ease-out;
    animation-fill-mode: both;
}

.trophy-head:nth-child(1) {
    animation-delay: 0.1s;
}

.trophy-head:nth-child(2) {
    animation-delay: 0.2s;
}

.trophy-head:nth-child(3) {
    animation-delay: 0.3s;
}

.trophy-head:nth-child(4) {
    animation-delay: 0.4s;
}

.trophy-head:nth-child(5) {
    animation-delay: 0.5s;
}

.trophy-head:nth-child(6) {
    animation-delay: 0.6s;
}

.trophy-head:nth-child(7) {
    animation-delay: 0.7s;
}

.trophy-head:nth-child(8) {
    animation-delay: 0.8s;
}

.trophy-head:nth-child(9) {
    animation-delay: 0.9s;
}

.trophy-head:nth-child(10) {
    animation-delay: 1.0s;
}

.trophy-more {
    color: #ffd700;
    font-size: 1.5rem;
    font-weight: bold;
    margin-left: 0.5rem;
}

.trophy-bonus {
    color: #4ade80;
    font-size: 1.1rem;
    font-weight: bold;
    margin-top: 0.5rem;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}

#trophyCanvas {
    border-radius: 50%;
    margin: 1rem 0;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6), 0 0 60px rgba(255, 215, 0, 0.3);
    border: 3px solid #ffd700;
    background: radial-gradient(circle, rgba(26, 26, 46, 1) 0%, rgba(16, 16, 32, 1) 100%);
}

.trophy-count {
    color: #fff;
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

@keyframes trophyBounce {
    0% {
        opacity: 0;
        transform: scale(0) translateY(-20px);
    }

    50% {
        transform: scale(1.3) translateY(0);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}