:root {
    --bg-color-top: #0284c7;
    --bg-color-bottom: #0f172a;
    --pipe-color: #1e293b;
    --pipe-glow: #38bdf8;
    --player-color: #0ea5e9;
    --player-glow: #7dd3fc;
    --dev-color: #22d3ee;
    --test-color: #fbbf24;
    --prod-color: #f472b6;
    --ui-text: #f8fafc;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: linear-gradient(to bottom, var(--bg-color-top), var(--bg-color-bottom));
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

svg {
    width: 100%;
    height: 100%;
    cursor: none;
    will-change: contents;
}

#ui-layer {
    position: absolute;
    top: 20px;
    left: 20px;
    pointer-events: none;
    color: var(--ui-text);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.status-chip {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    padding: 8px 16px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.status-chip.active {
    border-color: var(--pipe-glow);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
}

.hint-overlay {
    position: absolute;
    bottom: 40px;
    width: 100%;
    text-align: center;
    color: rgba(248, 250, 252, 0.5);
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}


@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

.target-node {
    animation: pulse 2s infinite ease-in-out;
}

#victory-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(20px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: #4ade80;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#victory-overlay h1 {
    font-size: clamp(2rem, 10vw, 5rem);
    margin: 0 20px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 900;
    text-shadow:
        0 0 10px #4ade80,
        0 0 20px #4ade80,
        0 0 40px #22c55e,
        0 0 80px #16a34a;
    animation: neonPulse 2s infinite ease-in-out;
}

@keyframes neonPulse {

    0%,
    100% {
        opacity: 1;
        text-shadow: 0 0 10px #4ade80, 0 0 20px #4ade80, 0 0 40px #22c55e;
    }

    50% {
        opacity: 0.8;
        text-shadow: 0 0 5px #4ade80, 0 0 10px #4ade80, 0 0 20px #22c55e;
    }
}

#victory-overlay p {
    font-size: clamp(1rem, 4vw, 1.2rem);
    color: rgba(74, 222, 128, 0.6);
    margin-top: 20px;
    padding: 0 20px;
}

#victory-overlay .restart-hint {
    margin-top: 40px;
    font-size: 0.9rem;
    opacity: 0.8;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    animation: pulse 1.5s infinite;
}

#score-display {
    font-size: 2rem;
    margin-top: 20px;
    color: #fbbf24;
    font-family: monospace;
    text-shadow: 0 0 10px #fbbf24;
    display: none;
}

/* DORA Metrics Panel */
#dora-metrics {
    display: flex;
    gap: 16px;
    margin-top: 28px;
    flex-wrap: wrap;
    justify-content: center;
}

.dora-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(74, 222, 128, 0.2);
    border-radius: 14px;
    padding: 16px 22px;
    min-width: 130px;
    text-align: center;
    backdrop-filter: blur(8px);
}

.dora-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(74, 222, 128, 0.55);
    margin-bottom: 8px;
}

.dora-value {
    font-size: 1.9rem;
    font-weight: 900;
    font-family: monospace;
    color: #4ade80;
    text-shadow: 0 0 12px rgba(74, 222, 128, 0.5);
    line-height: 1;
}

.dora-unit {
    font-size: 1rem;
    font-weight: 600;
    opacity: 0.7;
    margin-left: 2px;
}

.dora-sub {
    font-size: 0.65rem;
    color: rgba(74, 222, 128, 0.4);
    margin-top: 6px;
    letter-spacing: 0.05em;
}

/* Underwater Visual Elements */
@keyframes floatUp {
    0% {
        transform: translateY(110vh) scale(1);
        opacity: 0;
    }

    10% {
        opacity: 0.3;
    }

    90% {
        opacity: 0.4;
    }

    100% {
        transform: translateY(-10vh) scale(1.5);
        opacity: 0;
    }
}

@keyframes sway {

    0%,
    100% {
        transform: translateX(-10px);
    }

    50% {
        transform: translateX(10px);
    }
}

.bubble {
    position: absolute;
    bottom: -50px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(186, 230, 253, 0.8), rgba(125, 211, 252, 0.15) 60%, rgba(125, 211, 252, 0) 100%);
    border: 1px solid rgba(125, 211, 252, 0.4);
    pointer-events: none;
    z-index: 1;
    animation: floatUp 8s infinite linear;
}

.bubble-container {
    animation: sway 4s infinite ease-in-out alternate;
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

/* Hazard Popover */
@keyframes hazardSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, calc(-50% - 20px)) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes hazardFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        pointer-events: none;
    }
}

@keyframes jellyFloat {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-6px);
    }
}

#hazard-popover {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 900;
    background: rgba(15, 5, 30, 0.88);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(244, 114, 182, 0.5);
    border-radius: 20px;
    padding: 36px 48px;
    text-align: center;
    min-width: 280px;
    box-shadow:
        0 0 30px rgba(244, 114, 182, 0.25),
        0 8px 40px rgba(0, 0, 0, 0.6);
}

#hazard-popover.visible {
    display: block;
    animation: hazardSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#hazard-popover.hiding {
    display: block;
    animation: hazardFadeOut 0.4s ease-out forwards;
}

#hazard-popover-icon {
    font-size: 3rem;
    line-height: 1;
    filter: hue-rotate(130deg) saturate(150%);
    animation: jellyFloat 2s infinite ease-in-out;
    margin-bottom: 12px;
}

#hazard-popover-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(244, 114, 182, 0.7);
    margin-bottom: 10px;
}

#hazard-popover-name {
    font-size: 1.35rem;
    font-weight: 800;
    color: #f9a8d4;
    text-shadow:
        0 0 10px #f472b6,
        0 0 24px #ec4899;
    margin-bottom: 14px;
    line-height: 1.3;
}

#hazard-popover-hint {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(244, 114, 182, 0.45);
}

/* ─── Mobile performance overrides ───────────────────────────────────
   backdrop-filter: blur() forces a GPU compositing layer per element and is
   repainted on every frame on iOS Safari. When JS detects a touch device it
   adds .reduce-effects to <body>; here we swap blur for solid backgrounds
   that look almost identical but are an order of magnitude cheaper to render.
   Desktop browsers never receive .reduce-effects so they keep full visuals.
   ─────────────────────────────────────────────────────────────────────────── */
.reduce-effects .status-chip {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(10, 18, 38, 0.92);
}

.reduce-effects #victory-overlay {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(10, 18, 38, 0.96);
}

.reduce-effects .dora-card {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(255, 255, 255, 0.06);
}

.reduce-effects #hazard-popover {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(15, 5, 30, 0.95);
}