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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #111;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #fff;
    /* Prevent pull-to-refresh and overscroll */
    overscroll-behavior: none;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

canvas {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    touch-action: none;
}

body.playing canvas {
    cursor: none;
}

/* Overlays */
.overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.hidden {
    display: none !important;
}

/* Menu */
.menu-container {
    text-align: center;
    max-width: 700px;
    padding: 40px 20px;
    width: 100%;
}

.menu-container h1 {
    font-size: clamp(1.6rem, 5vw, 3rem);
    margin-bottom: 10px;
    text-shadow: 0 0 30px rgba(100, 180, 255, 0.5);
}

.subtitle {
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    color: #aaa;
    margin-bottom: 30px;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (max-width: 500px) {
    .level-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

.level-btn {
    background: linear-gradient(135deg, #1a3a5c, #0d2137);
    border: 2px solid #2a6090;
    border-radius: 12px;
    padding: 20px 16px;
    color: #fff;
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    -webkit-tap-highlight-color: transparent;
}

.level-btn:hover {
    background: linear-gradient(135deg, #254d73, #153050);
    border-color: #4a9edd;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(74, 158, 221, 0.3);
}

.level-btn:active {
    transform: translateY(0);
    background: linear-gradient(135deg, #2a5a8c, #1a4060);
}

.level-btn .icon {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
}

.level-btn .name {
    font-weight: 600;
}

.level-btn .desc {
    font-size: clamp(0.7rem, 2vw, 0.8rem);
    color: #8ab4d8;
}

.level-btn.locked {
    opacity: 0.45;
    cursor: default;
    border-color: #1a3050;
}

.level-btn.locked:hover {
    transform: none;
    box-shadow: none;
    background: linear-gradient(135deg, #1a3a5c, #0d2137);
}

.level-btn.locked .desc {
    color: #5a7a9a;
    font-style: italic;
}

.btn-clear-progress {
    margin-top: 20px;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.4);
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: clamp(0.75rem, 2vw, 0.85rem);
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn-clear-progress:hover {
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.3);
}

/* HUD */
.hud {
    position: fixed;
    top: 0; left: 0; right: 0;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    z-index: 50;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
    pointer-events: none;
    padding-top: max(12px, env(safe-area-inset-top));
}

.progress-container {
    flex: 1;
    max-width: 400px;
    height: 32px;
    background: rgba(0, 20, 40, 0.6);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(100, 180, 255, 0.3);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(180deg, #4fc3f7 0%, #0288d1 40%, #01579b 100%);
    border-radius: 14px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.wave {
    position: absolute;
    top: -8px;
    right: -12px;
    width: 24px;
    height: 100%;
    background: radial-gradient(ellipse at left, rgba(255,255,255,0.3) 0%, transparent 70%);
    animation: waveMove 1.5s ease-in-out infinite;
}

.wave2 {
    top: -4px;
    right: -8px;
    width: 16px;
    opacity: 0.5;
    animation-delay: 0.4s;
}

@keyframes waveMove {
    0%, 100% { transform: translateY(-2px); }
    50% { transform: translateY(2px); }
}

.bubble {
    position: absolute;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8), rgba(255,255,255,0.1));
    border-radius: 50%;
    animation: bubbleRise 2s ease-in infinite;
}

.bubble1 {
    width: 6px; height: 6px;
    right: 20%; bottom: 0;
    animation-delay: 0s;
    animation-duration: 1.8s;
}
.bubble2 {
    width: 4px; height: 4px;
    right: 40%; bottom: 0;
    animation-delay: 0.6s;
    animation-duration: 2.2s;
}
.bubble3 {
    width: 5px; height: 5px;
    right: 60%; bottom: 0;
    animation-delay: 1.2s;
    animation-duration: 2s;
}

@keyframes bubbleRise {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0;
    }
    20% { opacity: 0.8; }
    100% {
        transform: translateY(-28px) scale(0.5);
        opacity: 0;
    }
}

.progress-text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.85rem;
    font-weight: 700;
    text-shadow: 0 1px 4px rgba(0,0,0,0.9), 0 0 8px rgba(0, 100, 200, 0.3);
    letter-spacing: 0.5px;
}

.btn-back {
    pointer-events: all;
    margin-left: auto;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 8px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-back:hover {
    background: rgba(255,255,255,0.2);
}

/* Complete screen */
.complete-container {
    text-align: center;
    padding: 20px;
}

.complete-container h1 {
    font-size: clamp(1.8rem, 5vw, 3rem);
    margin-bottom: 16px;
    animation: pulse 1.5s ease-in-out infinite;
}

.complete-container p {
    font-size: clamp(1rem, 3vw, 1.3rem);
    color: #aaa;
    margin-bottom: 30px;
}

.btn-menu {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border: none;
    border-radius: 10px;
    padding: 14px 32px;
    color: #fff;
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    font-weight: 600;
    cursor: pointer;
    margin: 6px 8px;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

.btn-menu:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
}

.btn-menu:active {
    transform: translateY(0);
}

.btn-share {
    background: linear-gradient(135deg, #0288d1, #01579b);
}

.btn-share:hover {
    box-shadow: 0 6px 20px rgba(2, 136, 209, 0.4);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Loading screen */
.loading-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loading-text {
    font-size: clamp(1rem, 3vw, 1.3rem);
    color: #8ab4d8;
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Pressure Gauge */
.gauge {
    width: clamp(160px, 40vw, 220px);
    aspect-ratio: 2 / 1.2;
}

.gauge-body {
    width: 100%;
    height: 0;
    padding-bottom: 60%;
    position: relative;
    border-radius: 999px 999px 0 0;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 3px solid #2a4a6b;
    border-bottom: none;
    overflow: hidden;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5), 0 4px 20px rgba(0, 0, 0, 0.4);
}

.gauge-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: conic-gradient(
        from 0.75turn,
        #22c55e 0%,
        #eab308 15%,
        #ef4444 30%,
        transparent 30%
    );
    transform-origin: bottom center;
    opacity: 0.25;
    border-radius: 999px 999px 0 0;
}

.gauge-cover {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 70%;
    background: linear-gradient(135deg, #1a1a2e, #0d1525);
    border-radius: 999px 999px 0 0;
    z-index: 2;
}

/* Needle */
.gauge-needle {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 3px;
    height: 90%;
    background: linear-gradient(to top, #ef4444, #ff6b6b);
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(-90deg);
    animation: needleSweep 1.8s ease-in-out infinite;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
    z-index: 3;
}

.gauge-center {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    background: radial-gradient(circle, #9ca3af, #4b5563);
    border-radius: 50%;
    z-index: 4;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
}

@keyframes needleSweep {
    0% { transform: translateX(-50%) rotate(-90deg); }
    60% { transform: translateX(-50%) rotate(70deg); }
    70% { transform: translateX(-50%) rotate(60deg); }
    85% { transform: translateX(-50%) rotate(80deg); }
    100% { transform: translateX(-50%) rotate(75deg); }
}

/* Tick marks */
.gauge-ticks {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translateX(-50%);
    z-index: 1;
}

.tick {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 2px;
    height: 12%;
    background: rgba(255, 255, 255, 0.5);
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(var(--angle));
}

/* Labels */
.gauge-label-min,
.gauge-label-max {
    position: absolute;
    bottom: 4px;
    font-size: clamp(0.55rem, 1.5vw, 0.7rem);
    color: rgba(255, 255, 255, 0.5);
    z-index: 5;
    font-weight: 600;
}

.gauge-label-min { left: 10%; }
.gauge-label-max { right: 10%; }

.gauge-label-unit {
    position: absolute;
    bottom: 28%;
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(0.7rem, 2vw, 0.9rem);
    color: rgba(255, 255, 255, 0.4);
    font-weight: 700;
    letter-spacing: 2px;
    z-index: 5;
}
