/* Deep Ocean - Pixel Art Abyssal Interface */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

* {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Deep Ocean Palette */
:root {
    --abyss-deep: #020a14;
    --abyss-mid: #0a1f33;
    --abyss-top: #0f3247;
    --surface: #1a2942;
    --surface-edge: #050d1a;
    --bio-cyan: #4fd9e8;
    --bio-cyan-dim: rgba(79, 217, 232, 0.5);
    --bio-cyan-glow: rgba(79, 217, 232, 0.8);
    --text-light: #d4e8f0;
    --danger: #ff4466;
}

body {
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
    background: var(--abyss-deep);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
    color: var(--text-light);
}

/* Scene Container - Abyssal Gradient */
.scene-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background:
        radial-gradient(ellipse at top, var(--abyss-top) 0%, var(--abyss-mid) 40%, var(--abyss-deep) 100%);
    overflow: hidden;
    cursor: default;
}

/* Currents - Slow Drifting Soft Glows (no hard edges in the abyss) */
.ocean-current {
    position: absolute;
    left: -20%;
    width: 140%;
    height: 180px;
    background: radial-gradient(
        ellipse at center,
        rgba(79, 217, 232, 0.10) 0%,
        rgba(79, 217, 232, 0.05) 25%,
        rgba(79, 217, 232, 0.02) 50%,
        transparent 75%
    );
    filter: blur(20px);
    pointer-events: none;
    z-index: 2;
    animation: currentDrift 24s infinite linear;
}

.ocean-current:nth-of-type(2n) {
    height: 140px;
    animation-duration: 32s;
    animation-direction: reverse;
    opacity: 0.7;
}

.ocean-current:nth-of-type(3n) {
    height: 220px;
    animation-duration: 40s;
    opacity: 0.5;
}

@keyframes currentDrift {
    0%   { transform: translateX(0); }
    100% { transform: translateX(15%); }
}

/* Marine Snow - Tiny Drifting Particles */
.marine-snow {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--text-light);
    border-radius: 50%;
    opacity: 0.5;
    pointer-events: none;
    z-index: 3;
    animation: snowFall 18s infinite linear;
    box-shadow: 0 0 3px rgba(212, 232, 240, 0.6);
}

@keyframes snowFall {
    0%   { transform: translate(0, -10vh); opacity: 0; }
    10%  { opacity: 0.5; }
    90%  { opacity: 0.4; }
    100% { transform: translate(20px, 110vh); opacity: 0; }
}

/* Plankton - Pulsing Bioluminescent Dots */
.plankton {
    position: absolute;
    width: var(--size, 70px);
    height: var(--size, 70px);
    background: radial-gradient(
        circle at center,
        rgba(79, 217, 232, 0.35) 0%,
        rgba(79, 217, 232, 0.12) 40%,
        transparent 70%
    );
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    animation: planktonPulse 4s infinite ease-in-out;
}

.plankton::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30%;
    height: 30%;
    background: var(--bio-cyan);
    border-radius: 50%;
    opacity: 0.6;
    box-shadow: 0 0 10px var(--bio-cyan-glow);
}

@keyframes planktonPulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50%      { transform: scale(1.08); opacity: 1; }
}

.plankton:hover {
    transform: scale(1.15);
}

.plankton:hover::before {
    opacity: 1;
    box-shadow: 0 0 20px var(--bio-cyan-glow), 0 0 40px var(--bio-cyan-dim);
}

.plankton.active::before {
    opacity: 1;
    box-shadow: 0 0 25px var(--bio-cyan-glow), 0 0 50px var(--bio-cyan);
    animation: planktonActivePulse 2s infinite;
}

@keyframes planktonActivePulse {
    0%, 100% { box-shadow: 0 0 25px var(--bio-cyan-glow), 0 0 50px var(--bio-cyan); }
    50%      { box-shadow: 0 0 35px var(--bio-cyan-glow), 0 0 70px var(--bio-cyan); }
}

/* Deep-Sea Creatures (shared base) */
.deep-creature {
    position: absolute;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 15;
}

/* Anglerfish - Dark Silhouette + Bright Lure */
.deep-creature.anglerfish {
    width: 56px;
    height: 32px;
    background: var(--abyss-deep);
    border-radius: 50% 30% 30% 50% / 60% 50% 50% 60%;
    box-shadow:
        inset -4px 0 0 rgba(0, 0, 0, 0.4),
        0 2px 0 rgba(0, 0, 0, 0.5);
    animation: anglerfishHover 6s infinite ease-in-out;
}

.deep-creature.anglerfish::before {
    /* The lure */
    content: '';
    position: absolute;
    top: 4px;
    left: -10px;
    width: 6px;
    height: 6px;
    background: var(--bio-cyan);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--bio-cyan-glow), 0 0 24px var(--bio-cyan-dim);
    animation: lurePulse 2.5s infinite ease-in-out;
}

.deep-creature.anglerfish::after {
    /* The connecting filament from head to lure */
    content: '';
    position: absolute;
    top: 8px;
    left: -4px;
    width: 8px;
    height: 1px;
    background: rgba(79, 217, 232, 0.3);
}

@keyframes anglerfishHover {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(-3px, -2px); }
}

@keyframes lurePulse {
    0%, 100% { opacity: 0.7; box-shadow: 0 0 8px var(--bio-cyan-glow), 0 0 16px var(--bio-cyan-dim); }
    50%      { opacity: 1; box-shadow: 0 0 16px var(--bio-cyan-glow), 0 0 32px var(--bio-cyan); }
}

.deep-creature.anglerfish:hover::before {
    opacity: 1;
    box-shadow: 0 0 24px var(--bio-cyan-glow), 0 0 48px var(--bio-cyan);
    animation-duration: 1s;
}

/* Vampire Squid - Webbed Cape Silhouette + Glowing Arm Tips */
.deep-creature.vampire-squid {
    width: 48px;
    height: 56px;
    background: var(--abyss-deep);
    border-radius: 50% 50% 20% 20% / 60% 60% 40% 40%;
    box-shadow:
        inset 0 -8px 0 rgba(0, 0, 0, 0.5),
        0 2px 0 rgba(0, 0, 0, 0.5);
    animation: squidDrift 8s infinite ease-in-out;
}

.deep-creature.vampire-squid::before {
    /* Webbed cape tendrils */
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 16px;
    background:
        radial-gradient(circle at 10% 0%, var(--abyss-deep) 5px, transparent 6px),
        radial-gradient(circle at 30% 0%, var(--abyss-deep) 5px, transparent 6px),
        radial-gradient(circle at 50% 0%, var(--abyss-deep) 5px, transparent 6px),
        radial-gradient(circle at 70% 0%, var(--abyss-deep) 5px, transparent 6px),
        radial-gradient(circle at 90% 0%, var(--abyss-deep) 5px, transparent 6px);
}

.deep-creature.vampire-squid::after {
    /* Bioluminescent arm tips */
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 4px;
    background:
        radial-gradient(circle at 10% 50%, var(--bio-cyan) 1.5px, transparent 2px),
        radial-gradient(circle at 30% 50%, var(--bio-cyan) 1.5px, transparent 2px),
        radial-gradient(circle at 50% 50%, var(--bio-cyan) 1.5px, transparent 2px),
        radial-gradient(circle at 70% 50%, var(--bio-cyan) 1.5px, transparent 2px),
        radial-gradient(circle at 90% 50%, var(--bio-cyan) 1.5px, transparent 2px);
    filter: drop-shadow(0 0 4px var(--bio-cyan-glow));
    animation: squidGlow 3s infinite ease-in-out;
}

@keyframes squidDrift {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33%      { transform: translate(2px, -4px) rotate(-2deg); }
    66%      { transform: translate(-2px, 2px) rotate(2deg); }
}

@keyframes squidGlow {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; }
}

.deep-creature.vampire-squid:hover::after {
    opacity: 1;
    filter: drop-shadow(0 0 8px var(--bio-cyan-glow)) drop-shadow(0 0 16px var(--bio-cyan));
}

/* Radio Element */
.radio-element {
    position: absolute;
    width: 100px;
    height: 80px;
    background: var(--surface);
    border: 3px solid var(--surface-edge);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 20;
    box-shadow:
        0 4px 0 rgba(0, 0, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.05);
    animation: radioIdle 6s infinite ease-in-out;
}

.radio-element::before {
    content: '';
    position: absolute;
    top: 50%;
    left: calc(50% + 3px);
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 12px 0 12px 20px;
    border-color: transparent transparent transparent var(--bio-cyan);
    filter: drop-shadow(0 0 10px var(--bio-cyan-glow));
    transition: all 0.3s ease;
}

.radio-element::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    height: 15px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 2px;
}

.radio-element.playing::before {
    content: '';
    left: 50%;
    width: 6px;
    height: 22px;
    border-style: solid;
    border-width: 0 6px 0 6px;
    border-color: transparent var(--bio-cyan) transparent var(--bio-cyan);
    filter: drop-shadow(0 0 10px var(--bio-cyan-glow));
}

.radio-element.playing {
    animation: radioPlaying 2s infinite ease-in-out;
    border-color: var(--bio-cyan);
}

@keyframes radioIdle {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50%      { transform: translate(-50%, -50%) scale(1.02); }
}

@keyframes radioPlaying {
    0%, 100% {
        box-shadow:
            0 4px 0 rgba(0, 0, 0, 0.4),
            inset 0 2px 0 rgba(255, 255, 255, 0.05),
            0 0 20px var(--bio-cyan-dim);
    }
    50% {
        box-shadow:
            0 4px 0 rgba(0, 0, 0, 0.4),
            inset 0 2px 0 rgba(255, 255, 255, 0.05),
            0 0 30px var(--bio-cyan-glow);
    }
}

.radio-element:hover {
    transform: translate(-50%, -50%) scale(1.05);
    border-color: var(--bio-cyan);
    box-shadow:
        0 4px 0 rgba(0, 0, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.05),
        0 0 20px var(--bio-cyan-dim);
}

.radio-element:active {
    transform: translate(-50%, -50%) scale(0.95);
    box-shadow:
        0 2px 0 rgba(0, 0, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.05);
}

/* Pixel Art Text */
.pixel-text {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-light);
    text-shadow:
        2px 2px 0 var(--abyss-deep),
        0 0 10px rgba(212, 232, 240, 0.3);
    image-rendering: pixelated;
}

/* Song Display */
.song-display {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background: rgba(10, 31, 51, 0.92);
    border: 2px solid var(--bio-cyan);
    border-radius: 4px;
    z-index: 30;
    min-width: 200px;
    max-width: 80%;
    text-align: center;
    box-shadow:
        0 0 0 1px var(--abyss-deep),
        0 4px 0 rgba(0, 0, 0, 0.4),
        0 0 15px var(--bio-cyan-dim);
    transition: all 0.3s ease;
    user-select: none;
}

.song-display:hover {
    transform: translateX(-50%) translateY(-5px);
    box-shadow:
        0 0 0 1px var(--abyss-deep),
        0 6px 0 rgba(0, 0, 0, 0.4),
        0 0 25px var(--bio-cyan-glow);
}

.song-display:active {
    transform: translateX(-50%) translateY(-3px);
}

.song-display.generating {
    animation: generatingPulse 2s infinite;
}

@keyframes generatingPulse {
    0%, 100% {
        box-shadow:
            0 0 0 1px var(--abyss-deep),
            0 4px 0 rgba(0, 0, 0, 0.4),
            0 0 15px var(--bio-cyan-dim);
    }
    50% {
        box-shadow:
            0 0 0 1px var(--abyss-deep),
            0 4px 0 rgba(0, 0, 0, 0.4),
            0 0 25px var(--bio-cyan-glow);
    }
}

.song-display .pixel-text {
    font-size: 12px;
    line-height: 1.4;
    word-wrap: break-word;
    display: block;
}

/* Startup Overlay */
.startup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 10, 20, 0.96);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease-out;
}

.startup-message {
    text-align: center;
    padding: 30px 40px;
    background: rgba(10, 31, 51, 0.92);
    border: 3px solid var(--bio-cyan);
    border-radius: 8px;
    box-shadow:
        0 0 0 2px var(--abyss-deep),
        0 8px 0 rgba(0, 0, 0, 0.5),
        0 0 30px var(--bio-cyan-glow);
}

.startup-message .pixel-text {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--bio-cyan);
    text-shadow:
        2px 2px 0 var(--abyss-deep),
        0 0 15px var(--bio-cyan-glow);
}

.startup-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    font-size: 24px;
    color: var(--bio-cyan);
}

.startup-dots span {
    animation: startupDotPulse 1.4s infinite;
    animation-delay: calc(var(--dot-index, 0) * 0.2s);
}

.startup-dots span:nth-child(1) { --dot-index: 0; }
.startup-dots span:nth-child(2) { --dot-index: 1; }
.startup-dots span:nth-child(3) { --dot-index: 2; }

@keyframes startupDotPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50%      { opacity: 1; transform: scale(1.2); }
}

/* Status Indicator */
.status-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 6px 12px;
    background: rgba(10, 31, 51, 0.85);
    border: 2px solid var(--bio-cyan);
    border-radius: 4px;
    z-index: 30;
    box-shadow:
        0 0 0 1px var(--abyss-deep),
        0 2px 0 rgba(0, 0, 0, 0.4);
}

.status-indicator.online {
    border-color: var(--bio-cyan);
    animation: statusPulse 2s infinite;
}

.status-indicator.offline {
    border-color: var(--danger);
}

@keyframes statusPulse {
    0%, 100% {
        box-shadow:
            0 0 0 1px var(--abyss-deep),
            0 2px 0 rgba(0, 0, 0, 0.4),
            0 0 10px var(--bio-cyan-dim);
    }
    50% {
        box-shadow:
            0 0 0 1px var(--abyss-deep),
            0 2px 0 rgba(0, 0, 0, 0.4),
            0 0 20px var(--bio-cyan-glow);
    }
}

/* Ripple Effect on Click */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: var(--bio-cyan-dim);
    transform: scale(0);
    animation: rippleEffect 0.6s ease-out;
    pointer-events: none;
    z-index: 100;
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .deep-creature {
        display: none;
    }

    .plankton {
        --size: 50px;
    }

    .radio-element {
        width: 100px;
        height: 80px;
    }

    .song-display {
        bottom: max(100px, env(safe-area-inset-bottom) + 85px);
        padding: 10px 16px;
        min-width: 150px;
        max-width: 90%;
    }

    .pixel-text {
        font-size: 12px;
    }

    .status-indicator {
        top: max(15px, env(safe-area-inset-top) + 10px);
        right: 15px;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
