@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;700&display=swap');

:root {
    --bg-color: #0a0a12;
    --bg-gradient-top: #05253d;
    --bg-gradient-bottom: #0a0a25;
    --text-color: #ffffff;
    --accent-color: #00c8ff;
    --danger-color: #ff3c5a;
    --success-color: #40ffbc;
    --panel-color: #121222;
    --depth-color: #00c8ff;
    --obstacle-color: #ff3c5a;
    --phase-color: #00bfff;
    --phase-alt-color: #8a2be2;
    --background-color: #222;
    --shaft-color: #0a1a2f;
    --elevator-color: #555;
    --leviathan-color: #7209b7;
    --brake-color: #ff6600;
    --submarine-color: #345995;
    --submarine-window: #89CFF0;
    --submarine-detail: #1A2930;
    --bubble-color: #89CFF0;
    --water-overlay: rgba(10, 50, 90, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto Mono', monospace;
    background: linear-gradient(to bottom, var(--bg-gradient-top), var(--bg-gradient-bottom));
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: background-color 0.5s;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            0deg,
            var(--water-overlay),
            transparent 200px
        );
    pointer-events: none;
    z-index: -1;
    animation: waterShimmer 15s linear infinite;
}

@keyframes waterShimmer {
    0% { background-position: 0 0; }
    100% { background-position: 0 200px; }
}

body.braking {
    background-color: #220e00;
}

body.phasing {
    background-color: #001429;
}

.game-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: calc(100vh - 190px);
    min-height: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    border: 2px solid var(--accent-color);
    border-radius: 5px;
    background-color: rgba(5, 20, 40, 0.4);
    overflow: hidden;
    box-shadow: 0 0 15px rgba(0, 200, 255, 0.4);
}

.welcome-screen, .game-screen, .results-screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.game-screen {
    padding: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
}

h1 {
    font-size: 2.2rem;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(0, 200, 255, 0.8);
    text-align: center;
    color: var(--accent-color);
    font-weight: 700;
}

h2 {
    font-size: 1.8rem;
    margin-bottom: 15px;
    color: var(--accent-color);
}

h3 {
    font-size: 1.4rem;
    margin-bottom: 15px;
    color: var(--text-color);
    font-weight: 400;
}

p {
    margin-bottom: 15px;
    text-align: center;
    max-width: 400px;
}

.input-container {
    margin: 15px 0;
    width: 100%;
    max-width: 300px;
}

input[type="text"] {
    width: 100%;
    padding: 10px;
    font-family: 'Roboto Mono', monospace;
    background-color: var(--panel-color);
    color: var(--text-color);
    border: 1px solid var(--accent-color);
    border-radius: 3px;
    margin-bottom: 15px;
    text-align: center;
    font-size: 1rem;
}

input[type="text"]:focus {
    outline: none;
    box-shadow: 0 0 10px rgba(0, 200, 255, 0.5);
}

button {
    padding: 10px 20px;
    font-family: 'Roboto Mono', monospace;
    background-color: var(--accent-color);
    color: var(--bg-color);
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
}


#startButton {
    width: 100%;
    display: block;
}

button:hover {
    box-shadow: 0 0 10px rgba(0, 200, 255, 0.8);
}

.hidden {
    display: none !important;
}

.stats {
    width: 100%;
    padding: 10px;
    background-color: var(--panel-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--accent-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.depth-display {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
}

#playerNameDisplay {
    font-size: 0.7rem;
    color: var(--text-color);
    margin-bottom: 2px;
    font-weight: bold;
}

.depth-value {
    display: flex;
    align-items: baseline;
    font-size: 1.2rem;
    color: var(--depth-color);
}

.depth-value span:first-child {
    font-weight: bold;
    font-size: 1.4rem;
}

.depth-value span:last-child {
    font-size: 0.9rem;
    margin-left: 2px;
}

#currentDepth {
    font-weight: bold;
    color: var(--depth-color);
    transition: color 0.2s;
}

.personal-best-display {
    display: flex;
    align-items: baseline;
    font-size: 1rem;
    color: var(--success-color);
    margin: 0 10px;
    padding: 3px 8px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    border: 1px solid var(--success-color);
    text-shadow: 0 0 5px rgba(64, 255, 188, 0.7);
}

.personal-best-display span:first-child {
    font-weight: bold;
    margin-right: 5px;
}

.personal-best-display span:last-child {
    font-size: 0.8rem;
    margin-left: 2px;
}

#personalBestValue {
    font-weight: bold;
}

.player-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.elevator-shaft {
    flex-grow: 1;
    width: 100%;
    position: relative;
    overflow: hidden;
    background-color: var(--shaft-color);
    transition: background-color 0.3s, box-shadow 0.3s;
    background-image: 
        linear-gradient(0deg, 
            rgba(5, 30, 60, 0.6) 0%, 
            rgba(10, 40, 70, 0.2) 20%, 
            rgba(15, 50, 80, 0.1) 50%, 
            rgba(10, 40, 70, 0.2) 80%, 
            rgba(5, 30, 60, 0.6) 100%);
    cursor: none;
    padding-top: 25px;
}

.elevator-shaft::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        ellipse at center,
        rgba(0, 150, 255, 0.05) 0%,
        rgba(0, 0, 0, 0) 70%
    );
    pointer-events: none;
}

.elevator-shaft.braking {
    background-color: #2a1500;
    box-shadow: inset 0 0 20px rgba(255, 102, 0, 0.4);
    background-image: 
        linear-gradient(0deg, 
            rgba(42, 21, 0, 0.6) 0%, 
            rgba(42, 21, 0, 0.2) 20%, 
            rgba(42, 21, 0, 0) 50%, 
            rgba(42, 21, 0, 0.2) 80%, 
            rgba(42, 21, 0, 0.6) 100%);
}

.elevator-shaft::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200"><filter id="f"><feTurbulence type="fractalNoise" baseFrequency="0.03" numOctaves="2" seed="1" /><feDisplacementMap in="SourceGraphic" scale="20" /></filter><rect width="100%" height="100%" fill="rgba(0,120,255,0.05)" filter="url(%23f)" /></svg>');
    background-size: 100% 100%;
    pointer-events: none;
    opacity: 0.15;
    animation: caustics 20s linear infinite;
}

@keyframes caustics {
    0% {
        background-position: 0% 0%;
        opacity: 0.15;
    }
    25% {
        opacity: 0.12;
    }
    50% {
        background-position: 20% 80%;
        opacity: 0.18;
    }
    75% {
        opacity: 0.13;
    }
    100% {
        background-position: 0% 0%;
        opacity: 0.15;
    }
}

.elevator {
    position: absolute;
    width: 40px;
    height: 70px;
    background-color: var(--submarine-color);
    border: 2px solid #2d4b80;
    border-radius: 10px;
    left: 50%;
    top: 25%;
    transform: translate(-50%, -50%) rotate(0deg);
    transition: transform 0.1s ease-out, box-shadow 0.3s, border-color 0.3s;
    box-shadow: 0 0 10px rgba(52, 89, 149, 0.6);
    z-index: 2;
    background-image: linear-gradient(
        to bottom,
        rgba(52, 89, 149, 1) 0%,
        rgba(45, 75, 128, 0.9) 50%,
        rgba(52, 89, 149, 1) 100%
    );
}

.elevator::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: var(--submarine-window);
    border: 2px solid var(--submarine-detail);
    border-radius: 50%;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 8px rgba(137, 207, 240, 0.6) inset;
    transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
    animation: viewportPulse 4s ease-in-out infinite;
}

.elevator::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 10px;
    background-color: var(--submarine-detail);
    border-top-left-radius: 2px;
    border-top-right-radius: 2px;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    transition: background-color 0.3s;
}

.elevator.phasing {
    box-shadow: 0 0 15px rgba(0, 191, 255, 0.7);
    background-color: rgba(0, 191, 255, 0.7);
    border-color: #8a2be2;
    animation: phaseEffect 0.3s infinite alternate;
}

.elevator.phasing::before, .elevator.phasing::after {
    border-color: #8a2be2;
    animation: viewportPulse 0.5s infinite alternate;
}

@keyframes viewportPulse {
    0% { box-shadow: 0 0 5px rgba(137, 207, 240, 0.5) inset; }
    100% { box-shadow: 0 0 15px rgba(0, 191, 255, 0.8) inset; }
}

@keyframes phaseEffect {
    0% {
        opacity: 0.7;
        transform: translate(-50%, -50%) rotate(var(--current-rotation, 0deg)) scale(0.95);
        box-shadow: 0 0 15px rgba(0, 150, 255, 0.6);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(var(--current-rotation, 0deg)) scale(1.05);
        box-shadow: 0 0 25px rgba(138, 43, 226, 0.8);
    }
}

.elevator.phasing .trail {
    position: absolute;
    width: 60px;
    height: 120px;
    left: 50%;
    bottom: -120px;
    transform: translateX(-50%);
    background: linear-gradient(to top, 
        rgba(138, 43, 226, 0) 0%,
        rgba(138, 43, 226, 0.2) 30%,
        rgba(0, 191, 255, 0.4) 60%,
        rgba(0, 191, 255, 0.2) 90%,
        rgba(0, 191, 255, 0.1) 100%
    );
    animation: phaseTrail 0.8s infinite;
    box-shadow: 0 0 15px rgba(0, 150, 255, 0.4);
    border-radius: 50% 50% 0 0 / 20% 20% 0 0;
}

@keyframes phaseTrail {
    0% { 
        height: 120px; 
        opacity: 0.7; 
        transform: translateX(-50%) scaleX(1);
    }
    50% {
        transform: translateX(-50%) scaleX(1.1);
    }
    100% { 
        height: 200px; 
        opacity: 0; 
        transform: translateX(-50%) scaleX(0.9);
    }
}

.elevator.normalizing-speed {
    animation: normalizingPulse 0.5s infinite alternate;
}

.elevator.braking {
    background-color: var(--brake-color);
    border-color: #ff3300;
    box-shadow: 0 0 15px rgba(255, 102, 0, 0.5);
}

.elevator.phasing {
    box-shadow: 0 0 15px rgba(0, 191, 255, 0.7);
    background-color: rgba(0, 191, 255, 0.7);
    border-color: #8a2be2;
    animation: phaseEffect 0.3s infinite alternate;
}

.elevator.phasing::before, .elevator.phasing::after {
    border-color: #8a2be2;
}

@keyframes normalizingPulse {
    0% {
        box-shadow: 0 0 5px rgba(52, 89, 149, 0.5);
    }
    100% {
        box-shadow: 0 0 15px rgba(64, 255, 188, 0.6);
    }
}

.elevator-shaft.phasing {
    background-color: #001a3a;
    box-shadow: inset 0 0 40px rgba(0, 191, 255, 0.35);
    background-image: 
        linear-gradient(0deg, 
            rgba(0, 30, 70, 0.7) 0%, 
            rgba(0, 20, 55, 0.3) 20%, 
            rgba(0, 10, 41, 0.1) 50%, 
            rgba(0, 20, 55, 0.3) 80%, 
            rgba(0, 30, 70, 0.7) 100%);
    border-color: #8a2be2;
    backdrop-filter: blur(2px);
}

.obstacle {
    position: absolute;
    height: 15px;
    background-color: var(--obstacle-color);
    box-shadow: 0 0 12px rgba(255, 60, 90, 0.6);
    border-radius: 0;
    z-index: 1;
    background-image: linear-gradient(
        to bottom,
        rgba(255, 60, 90, 0.9) 0%,
        rgba(255, 30, 70, 0.7) 50%,
        rgba(255, 60, 90, 0.9) 100%
    );
    border-top: 1px solid rgba(255, 100, 120, 0.8);
    border-bottom: 1px solid rgba(200, 30, 60, 0.8);
}

.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background-color: rgba(137, 207, 240, 0.4);
    border-radius: 50%;
    animation: float 10s linear infinite;
    box-shadow: 0 0 2px rgba(0, 191, 255, 0.3);
}

@keyframes float {
    0% { 
        transform: translateY(0) translateX(0); 
    }
    25% {
        transform: translateY(-25vh) translateX(5px);
    }
    50% {
        transform: translateY(-50vh) translateX(-5px);
    }
    75% {
        transform: translateY(-75vh) translateX(5px);
    }
    100% { 
        transform: translateY(-100vh) translateX(0); 
    }
}

.leaderboard {
    margin-top: 20px;
    width: 100%;
    max-width: 350px;
    background-color: var(--panel-color);
    border: 1px solid var(--accent-color);
    border-radius: 5px;
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    position: relative;
    z-index: 5;
}

#leaderboardList {
    list-style: none;
    position: relative;
    touch-action: pan-y;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(0, 200, 255, 0.2);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.leaderboard-entry:hover {
    background-color: rgba(0, 200, 255, 0.1);
}

.leaderboard-entry:last-child {
    border-bottom: none;
}

.leaderboard-rank {
    font-weight: bold;
    color: var(--accent-color);
    min-width: 30px;
    margin-right: 10px;
}

.leaderboard-name {
    flex-grow: 1;
    text-overflow: ellipsis;
}

.leaderboard-depth {
    font-weight: bold;
    color: var(--depth-color);
    min-width: 75px;
    text-align: right;
}

.leaderboard-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-color);
    font-style: italic;
    opacity: 0.7;
}

#finalDepth {
    font-size: 2rem;
    font-weight: bold;
    color: var(--depth-color);
    margin: 10px 0;
    text-shadow: 0 0 10px rgba(0, 200, 255, 0.7);
}

.results-screen h2 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(0, 200, 255, 0.7);
    text-align: center;
}

.results-screen p {
    margin-bottom: 5px;
}

.results-screen h3 {
    font-size: 1.5rem;
    margin: 20px 0 10px;
    color: var(--accent-color);
    text-align: center;
}

.results-screen {
    position: relative;
    background: radial-gradient(
        circle at center,
        rgba(0, 10, 41, 0.9) 0%,
        rgba(10, 10, 18, 0.95) 70%
    );
}

.results-screen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, transparent 50%, rgba(0, 191, 255, 0.1) 100%);
    z-index: -1;
}

.leaderboard h3 {
    position: relative;
    font-size: 1.3rem;
    margin-bottom: 15px;
    padding-bottom: 8px;
    text-align: center;
    border-bottom: 1px solid var(--accent-color);
}

.leaderboard h3::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 25%;
    width: 50%;
    height: 2px;
    background-color: var(--accent-color);
    box-shadow: 0 0 5px rgba(0, 200, 255, 0.7);
}

.debug-box {
    position: absolute;
    border: 1px solid yellow;
    pointer-events: none;
    z-index: 100;
}

.debug-elevator {
    border-color: cyan;
}

.debug-gap {
    border-color: green;
}

.game-header {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background-color: rgba(18, 18, 44, 0.9);
    border-bottom: 1px solid var(--accent-color);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 5;
    margin-bottom: 0;
}

.brake-power-container {
    display: flex;
    flex-direction: column;
    min-width: 120px;
}

.brake-power-container span {
    font-size: 0.65rem;
    text-transform: uppercase;
    margin-bottom: 2px;
    font-weight: bold;
    color: var(--phase-color);
}

.brake-power-bar-background {
    height: 8px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid var(--phase-color);
}

.brake-power-bar {
    height: 100%;
    width: 100%;
    background-color: var(--phase-color);
    border-radius: 3px;
    transition: width 0.1s, background-color 0.3s;
}

.welcome-screen {
    animation: fadeIn 0.5s ease-out;
}

.version-display {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    font-family: 'Roboto Mono', monospace;
}

.offline-notice {
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.7rem;
    color: rgba(255, 60, 60, 0.8);
    font-family: 'Roboto Mono', monospace;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 0, 0, 0.5);
}

.banned-notice {
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.9rem;
    color: #ff0000;
    font-family: 'Roboto Mono', monospace;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.8);
    background-color: rgba(0, 0, 0, 0.7);
    padding: 8px 0;
    border-top: 1px solid #ff0000;
    border-bottom: 1px solid #ff0000;
    animation: banPulse 1.2s infinite alternate;
    z-index: 100;
}

@keyframes banPulse {
    0% {
        background-color: rgba(0, 0, 0, 0.7);
        color: #ff0000;
        transform: scale(0.98);
    }
    100% {
        background-color: rgba(60, 0, 0, 0.8);
        color: #ff6666;
        transform: scale(1.02);
    }
}

.results-screen {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes glow {
    0% {
        box-shadow: 0 0 5px rgba(0, 191, 255, 0.5);
    }
    100% {
        box-shadow: 0 0 15px rgba(0, 191, 255, 0.8);
    }
}

.leaderboard-entry:nth-child(1) .leaderboard-depth {
    color: gold;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

.leaderboard-entry:nth-child(2) .leaderboard-depth {
    color: silver;
    text-shadow: 0 0 5px rgba(192, 192, 192, 0.5);
}

.leaderboard-entry:nth-child(3) .leaderboard-depth {
    color: #cd7f32;
    text-shadow: 0 0 5px rgba(205, 127, 50, 0.5);
}

.leviathan-distance-container {
    display: flex;
    flex-direction: column;
    min-width: 120px;
}

.leviathan-distance-container span {
    font-size: 0.65rem;
    text-transform: uppercase;
    margin-bottom: 2px;
    font-weight: bold;
    color: var(--leviathan-color);
}

.leviathan-distance-container.fullwidth {
    width: 100%;
    padding: 2px 12px 8px;
    background-color: rgba(10, 10, 18, 0.85);
    border-bottom: 1px solid rgba(114, 9, 183, 0.4);
    margin: 0 0 5px 0;
    position: relative;
    z-index: 10;
}

.leviathan-distance-container.fullwidth span {
    font-size: 0.8rem;
    text-align: center;
    margin: 0 auto 4px;
    text-shadow: 0 0 5px rgba(114, 9, 183, 0.7);
}

.leviathan-distance-bar-background {
    height: 8px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid var(--leviathan-color);
}

.leviathan-distance-container.fullwidth .leviathan-distance-bar-background {
    height: 10px;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(114, 9, 183, 0.3);
}

.leviathan-distance-bar {
    height: 100%;
    width: 100%;
    background-color: var(--leviathan-color);
    border-radius: 3px;
    transition: width 0.1s, background-color 0.3s;
}

.leviathan {
    position: absolute;
    width: 120px;
    height: 150px;
    top: -15%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(114, 9, 183, 0.7);
    border-radius: 10px 10px 40px 40px;
    border: 2px solid rgba(114, 9, 183, 1);
    box-shadow: 0 0 20px rgba(114, 9, 183, 0.7);
    z-index: 3;
    transition: top 0.8s cubic-bezier(0.17, 0.67, 0.35, 1.2), box-shadow 0.3s, border-color 0.3s, transform 0.5s;
    background-image: linear-gradient(
        to bottom,
        rgba(114, 9, 183, 0.9) 0%,
        rgba(90, 7, 150, 0.7) 50%,
        rgba(114, 9, 183, 0.9) 100%
    );
}

.leviathan::before,
.leviathan::after {
    content: '';
    position: absolute;
    background-color: rgba(114, 9, 183, 0.7);
    border: 2px solid rgba(114, 9, 183, 1);
    box-shadow: 0 0 15px rgba(114, 9, 183, 0.5);
    border-radius: 5px 5px 30px 30px;
    transition: transform 0.5s ease-out;
    background-image: linear-gradient(
        to bottom,
        rgba(114, 9, 183, 0.9) 0%,
        rgba(90, 7, 150, 0.7) 50%,
        rgba(114, 9, 183, 0.9) 100%
    );
}

.leviathan::before {
    width: 25px;
    height: 100px;
    left: -15px;
    bottom: -80px;
    transform-origin: top center;
    animation: sideTentacleWave 3s ease-in-out infinite;
}

.leviathan::after {
    width: 25px;
    height: 100px;
    right: -15px;
    bottom: -80px;
    transform-origin: top center;
    animation: sideTentacleWave 3s ease-in-out infinite reverse;
}

.leviathan .middle-tentacle {
    position: absolute;
    width: 30px;
    height: 150px;
    bottom: -130px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(114, 9, 183, 0.7);
    border: 2px solid rgba(114, 9, 183, 1);
    box-shadow: 0 0 10px rgba(114, 9, 183, 0.4);
    border-radius: 5px 5px 30px 30px;
    transform-origin: top center;
    animation: middleTentacleWave 4s ease-in-out infinite;
}

@keyframes sideTentacleWave {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(-15deg); }
}

@keyframes middleTentacleWave {
    0%, 100% { transform: translateX(-50%) rotate(0deg); }
    50% { transform: translateX(-50%) rotate(15deg); }
}

.leviathan.approaching {
    box-shadow: 0 0 20px rgba(255, 102, 0, 0.7);
    border-color: rgba(255, 102, 0, 1);
    animation: approachPulse 1s infinite alternate;
}

.leviathan.close {
    box-shadow: 0 0 25px rgba(255, 60, 90, 0.8);
    border-color: rgba(255, 60, 90, 1);
    animation: closePulse 0.5s infinite alternate;
    transform: translateX(-50%) scale(1.1);
}

@keyframes approachPulse {
    0% { background-color: rgba(114, 9, 183, 0.7); }
    100% { background-color: rgba(255, 102, 0, 0.7); }
}

@keyframes closePulse {
    0% { 
        background-color: rgba(114, 9, 183, 0.7);
        box-shadow: 0 0 25px rgba(255, 60, 90, 0.6);
    }
    100% { 
        background-color: rgba(255, 60, 90, 0.7);
        box-shadow: 0 0 40px rgba(255, 60, 90, 0.9);
    }
}

.leviathan.close::before {
    animation: sideTentacleWaveFast 1s ease-in-out infinite;
}

.leviathan.close::after {
    animation: sideTentacleWaveFast 1s ease-in-out infinite reverse;
}

.leviathan.close .middle-tentacle {
    animation: middleTentacleWaveFast 1.5s ease-in-out infinite;
}

@keyframes sideTentacleWaveFast {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(-30deg); }
}

@keyframes tentacleWaveFast {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(35deg); }
}

@keyframes middleTentacleWaveFast {
    0%, 100% { transform: translateX(-50%) rotate(0deg); }
    50% { transform: translateX(-50%) rotate(30deg); }
}

.elevator-shaft.collision {
    animation: collisionFlash 0.3s;
}

@keyframes collisionFlash {
    0%, 100% { background-color: var(--shaft-color); }
    50% { background-color: rgba(255, 60, 90, 0.3); }
}

.leviathan.escaping {
    box-shadow: 0 0 20px rgba(64, 255, 188, 0.7);
    border-color: rgba(64, 255, 188, 1);
    animation: escapingPulse 1s infinite alternate;
}

@keyframes escapingPulse {
    0% { background-color: rgba(114, 9, 183, 0.7); }
    100% { background-color: rgba(64, 255, 188, 0.7); }
}

.elevator-shaft.escaping {
    background-color: rgba(0, 30, 20, 0.7);
    box-shadow: inset 0 0 30px rgba(64, 255, 188, 0.3);
    background-image: 
        linear-gradient(0deg, 
            rgba(0, 30, 20, 0.6) 0%, 
            rgba(0, 30, 20, 0.2) 20%, 
            rgba(0, 30, 20, 0) 50%, 
            rgba(0, 30, 20, 0.2) 80%, 
            rgba(0, 30, 20, 0.6) 100%);
    border-color: rgba(64, 255, 188, 0.5);
}

.leviathan-distance-bar.escaping {
    background-color: var(--success-color);
    box-shadow: 0 0 10px rgba(64, 255, 188, 0.7);
    animation: escapingBar 1s infinite alternate;
}

@keyframes escapingBar {
    0% {
        background-color: var(--success-color);
        box-shadow: 0 0 5px rgba(64, 255, 188, 0.5);
    }
    100% {
        background-color: var(--phase-alt-color);
        box-shadow: 0 0 10px rgba(138, 43, 226, 0.7);
    }
}

.elevator .propulsion-trail {
    position: absolute;
    width: 20px;
    height: 25px;
    left: 50%;
    bottom: -20px;
    transform: translateX(-50%) rotate(var(--current-rotation, 0deg));
    background: radial-gradient(
        ellipse at top, 
        rgba(0, 191, 255, 0.6) 0%, 
        rgba(0, 191, 255, 0.4) 40%, 
        rgba(0, 191, 255, 0) 80%
    );
    opacity: 0.6;
    transition: height 0.3s, opacity 0.3s, background 0.3s;
}

.elevator.moving .propulsion-trail {
    height: 35px;
    opacity: 0.7;
}

.elevator.phasing .propulsion-trail {
    height: 50px;
    opacity: 1;
    background: radial-gradient(
        ellipse at top, 
        rgba(138, 43, 226, 0.7) 0%, 
        rgba(0, 191, 255, 0.7) 30%, 
        rgba(0, 191, 255, 0.3) 70%
    );
    animation: propulsionPulse 0.5s infinite alternate;
}

@keyframes propulsionPulse {
    0% {
        height: 50px;
        opacity: 0.8;
    }
    100% {
        height: 60px;
        opacity: 1;
    }
}

.elevator.phasing + .bubble-particle {
    background-color: rgba(138, 43, 226, 0.8);
    box-shadow: 0 0 8px rgba(138, 43, 226, 0.6);
}

.elevator.phasing,
.elevator.phasing::before,
.elevator.phasing::after {
    background-color: rgba(0, 191, 255, 0.7);
    border-color: #8a2be2;
    box-shadow: 0 0 15px rgba(0, 191, 255, 0.7);
}

.bubble-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    background-color: rgba(137, 207, 240, 0.8);
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(0, 191, 255, 0.6);
    animation: bubbleFloat 2s ease-out forwards;
}

@keyframes bubbleFloat {
    0% {
        transform: translateY(0) translateX(0) scale(1);
        opacity: 0.8;
    }
    50% {
        transform: translateY(-50px) translateX(calc(var(--float-x, 5px) * 0.5)) scale(0.8);
        opacity: 0.9;
    }
    100% {
        transform: translateY(-100px) translateX(var(--float-x, 10px)) scale(0.5);
        opacity: 0;
    }
}

.results-screen p {
    margin-bottom: 5px;
}

.personal-best-message {
    color: var(--success-color);
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    margin-top: 10px;
    animation: pulseBest 1.5s infinite alternate;
    text-shadow: 0 0 10px rgba(64, 255, 188, 0.7);
}

@keyframes pulseBest {
    0% {
        opacity: 0.7;
        transform: scale(0.98);
    }
    100% {
        opacity: 1;
        transform: scale(1.02);
    }
}

/* Mobile device detection */
.mobile-only {
    display: none;
}

@media (max-width: 768px), (pointer: coarse) {
    .pc-only {
        display: none;
    }
    
    .mobile-only {
        display: inline-block;
    }
    
    /* Improve scrolling on mobile devices */
    .leaderboard {
        -webkit-overflow-scrolling: touch;
        overflow-y: scroll; /* Force scrolling on mobile */
        overflow-x: hidden;
        touch-action: pan-y; /* Explicitly allow vertical scrolling */
        max-height: 350px; /* Slightly smaller to fit better on mobile */
        position: relative;
        z-index: 10; /* Ensure it's above other elements */
    }
    
    #leaderboardList {
        position: relative;
        touch-action: pan-y;
        overflow-y: visible;
        padding-bottom: 10px; /* Add some padding at bottom for scrolling */
    }
    
    /* Make leaderboard entries easier to tap/scroll on mobile */
    .leaderboard-entry {
        padding: 12px 12px; /* Larger touch target */
        min-height: 36px;
    }
    
    /* Ensure the click-to-restart hint is easily visible */
    #clickToRestartHint {
        margin-top: 25px !important;
        padding: 10px;
        background-color: rgba(0, 0, 0, 0.2);
        border-radius: 5px;
    }
}

/* Add styling for the fullwidth container when the leviathan is in different states */
.leviathan-distance-container.fullwidth .leviathan-distance-bar.escaping {
    box-shadow: 0 0 12px rgba(64, 255, 188, 0.8);
}

/* Styles for approaching/close states */
.leviathan-distance-container.fullwidth.approaching {
    border-bottom-color: var(--brake-color);
}

.leviathan-distance-container.fullwidth.approaching span {
    color: var(--brake-color);
    text-shadow: 0 0 5px rgba(255, 102, 0, 0.7);
}

.leviathan-distance-container.fullwidth.close {
    border-bottom-color: var(--danger-color);
    animation: leviathanPulse 0.5s infinite alternate;
}

.leviathan-distance-container.fullwidth.close span {
    color: var(--danger-color);
    text-shadow: 0 0 5px rgba(255, 60, 90, 0.7);
    animation: leviathanTextPulse 0.5s infinite alternate;
}

@keyframes leviathanPulse {
    0% {
        background-color: rgba(10, 10, 18, 0.85);
    }
    100% {
        background-color: rgba(40, 10, 18, 0.85);
    }
}

@keyframes leviathanTextPulse {
    0% {
        opacity: 0.8;
    }
    100% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* Styles for escaping state */
.leviathan-distance-container.fullwidth.escaping {
    border-bottom-color: var(--success-color);
}

.leviathan-distance-container.fullwidth.escaping span {
    color: var(--success-color);
    text-shadow: 0 0 5px rgba(64, 255, 188, 0.7);
} 