:root {
    --bg-dark: #07050f;
    --primary-glow: #00f3ff;
    --accent-glow: #ff0055;
    --green-neon: #39ff14;
    --red-neon: #ff073a;
    --yellow-neon: #ffeb3b;
    --text-light: #f5f4fc;
    --text-muted: #8d87b3;
    --panel-bg: rgba(15, 11, 28, 0.65);
    --panel-border: rgba(255, 255, 255, 0.08);
    --panel-glow: rgba(0, 243, 255, 0.15);
    --font-primary: 'Outfit', sans-serif;
    --font-numeric: 'Orbitron', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-drag: none;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: var(--font-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* Full Screen Container */
#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Canvas Styling */
#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
}

/* Glass Panel Styling Base */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    box-shadow: 
        0 12px 40px 0 rgba(0, 0, 0, 0.6), 
        inset 0 1px 1px rgba(255, 255, 255, 0.1),
        0 0 20px var(--panel-glow);
    padding: 2rem;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Heads-Up Display */
#hud {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 900px;
    z-index: 10;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: auto;
}

.hud-item {
    display: flex;
    flex-direction: column;
}

.hud-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 2px;
    font-weight: 600;
}

.hud-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-glow);
    text-shadow: 0 0 8px rgba(0, 243, 255, 0.5);
}

.numeric-font {
    font-family: var(--font-numeric);
    letter-spacing: 1px;
}

/* HUD Center - Apple Health */
.center-hud {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.apple-health-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 16px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.apple-icon {
    font-size: 1.4rem;
    filter: drop-shadow(0 0 6px rgba(255, 0, 85, 0.8));
    animation: breathing 2s infinite ease-in-out;
}

.health-bar-bg {
    width: 140px;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.5);
}

#health-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--accent-glow) 0%, var(--green-neon) 100%);
    border-radius: 5px;
    box-shadow: 0 0 8px rgba(57, 255, 20, 0.5);
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
}

#health-pct {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--green-neon);
    min-width: 45px;
    text-align: right;
}

.right-hud {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 24px;
}

.hud-sub-item {
    display: flex;
    flex-direction: column;
}

.hud-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hud-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--primary-glow);
    color: var(--primary-glow);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.3);
    transform: scale(1.05);
}

.hud-btn:active {
    transform: scale(0.95);
}

/* Screen Overlays */
.screen-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(5, 3, 10, 0.4);
    opacity: 1;
    transition: opacity 0.4s ease, visibility 0.4s;
}

.screen-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.content-box {
    width: 90%;
    max-width: 520px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.8rem;
    animation: zoomIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.content-box.small-box {
    max-width: 380px;
}

/* Typography & Titles */
.glow-text {
    text-shadow: 0 0 15px rgba(0, 243, 255, 0.5);
}

.game-title {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: 4px;
    background: linear-gradient(135deg, #fff 30%, var(--primary-glow) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 2px;
}

.accent-color {
    background: linear-gradient(135deg, var(--accent-glow) 0%, #ff5287 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(255, 0, 85, 0.4));
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Instructions */
.instructions {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 14px;
    padding: 1.2rem;
    width: 100%;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.instructions h3 {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 6px;
}

.instructions ul {
    list-style: none;
}

.instructions li {
    font-size: 0.9rem;
    color: #cdc9e3;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.instructions li:last-child {
    margin-bottom: 0;
}

.key-icon {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 32px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: bold;
    padding: 0 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* High Score Board */
.high-score-board {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--yellow-neon);
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 235, 59, 0.1);
    padding: 8px 18px;
    border-radius: 50px;
    border: 1px solid rgba(255, 235, 59, 0.2);
}

.trophy {
    font-size: 1.2rem;
    animation: wiggle 2s infinite ease-in-out;
}

/* Buttons */
.btn {
    border: none;
    outline: none;
    border-radius: 12px;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-primary);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    letter-spacing: 1px;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-glow) 0%, #00bcff 100%);
    color: #030a14;
    box-shadow: 0 4px 15px rgba(0, 243, 255, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 243, 255, 0.55);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--text-muted);
    transform: translateY(-2px);
}

.btn-secondary:active {
    transform: translateY(1px);
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.btn-group-row {
    display: flex;
    gap: 12px;
    width: 100%;
}

/* Stats Layout */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
}

.stat-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-light);
}

.error-text {
    background: linear-gradient(135deg, var(--red-neon) 0%, #ff4d6a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(255, 7, 58, 0.4));
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 2px;
}

.gameover-desc {
    font-size: 1rem;
    color: var(--text-muted);
}

.badge {
    background: linear-gradient(135deg, var(--yellow-neon) 0%, #ffb300 100%);
    color: #0b0700;
    font-weight: 800;
    font-size: 0.85rem;
    padding: 6px 16px;
    border-radius: 20px;
    letter-spacing: 1px;
    box-shadow: 0 0 15px rgba(255, 235, 59, 0.4);
    animation: heartbeat 1.5s infinite ease-in-out;
}

/* Animations */
@keyframes breathing {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 4px rgba(255, 0, 85, 0.6)); }
    50% { transform: scale(1.1); filter: drop-shadow(0 0 12px rgba(255, 0, 85, 1)); }
}

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

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.pulse-btn {
    animation: buttonPulse 2s infinite;
}

@keyframes buttonPulse {
    0% {
        box-shadow: 0 4px 15px rgba(0, 243, 255, 0.35);
    }
    50% {
        box-shadow: 0 8px 25px rgba(0, 243, 255, 0.7), 0 0 15px rgba(0, 243, 255, 0.4);
    }
    100% {
        box-shadow: 0 4px 15px rgba(0, 243, 255, 0.35);
    }
}

/* Screen shake class for apple damage */
.shake-element {
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translate(0, 0); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-4px, -2px); }
    20%, 40%, 60%, 80% { transform: translate(4px, 2px); }
}

/* Responsive Scaling tweaks */
@media (max-width: 480px) {
    .game-title {
        font-size: 2.6rem;
    }
    .error-text {
        font-size: 2.2rem;
    }
    .hud-value {
        font-size: 1.1rem;
    }
    #hud {
        padding: 10px 16px;
        top: 12px;
    }
    .apple-health-container {
        padding: 4px 10px;
        gap: 6px;
    }
    .health-bar-bg {
        width: 80px;
    }
    #health-pct {
        font-size: 0.8rem;
        min-width: 32px;
    }
    .btn-group-row {
        flex-direction: column;
    }
    .right-hud {
        gap: 12px;
    }
}
