/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: manipulation; /* Prevent default touch behaviors */
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #87CEEB; /* Sky blue background */
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overscroll-behavior: none;
}

/* Game Container */
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Canvas */
#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, #87CEEB 0%, #4A90E2 100%);
}

/* UI Elements */
.ui-element {
    position: absolute;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    padding: 10px 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Score Display */
#score-display {
    top: 20px;
    left: 20px;
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Magnet Meter */
#magnet-meter {
    top: 20px;
    right: 20px;
    width: 150px;
}

.meter-label {
    font-size: 14px;
    margin-bottom: 5px;
    text-align: center;
}

.meter-bar {
    width: 100%;
    height: 10px;
    background: #ddd;
    border-radius: 5px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    width: 75%;
    background: linear-gradient(to right, #4ECDC4, #C0C0C0);
    border-radius: 5px;
    transition: width 0.3s ease;
}

/* Collection Counter */
#collection-counter {
    bottom: 20px;
    left: 20px;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Menus */
.menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.menu-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.menu h1 {
    color: #4A90E2;
    margin-bottom: 20px;
    font-size: 28px;
}

.menu h2 {
    color: #4A90E2;
    margin-bottom: 20px;
}

.menu p {
    margin: 10px 0;
    color: #666;
}

.menu-button {
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    border: none;
    border-radius: 8px;
    background: #4A90E2;
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.menu-button:hover {
    background: #3a7bc8;
    transform: translateY(-2px);
}

.menu-button.secondary {
    background: #f0f0f0;
    color: #666;
}

.menu-button.secondary:hover {
    background: #e0e0e0;
}

.hidden {
    display: none !important;
}

/* Permission Prompt */
.prompt {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.prompt-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    max-width: 90%;
    width: 400px;
}

.prompt h3 {
    color: #4A90E2;
    margin-bottom: 15px;
}

.prompt p {
    margin: 15px 0;
    color: #666;
    line-height: 1.5;
}

/* Tutorial Overlay */
.tutorial {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 150;
}

.tutorial-step {
    background: white;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    max-width: 90%;
    width: 400px;
    display: none;
}

.tutorial-step.active {
    display: block;
}

.tutorial h3 {
    color: #4A90E2;
    margin-bottom: 15px;
}

.tutorial p {
    margin: 15px 0;
    color: #666;
    font-size: 18px;
}

.tutorial-image {
    font-size: 48px;
    margin: 20px 0;
}

/* Loading Screen */
#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #87CEEB;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 300;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive Adjustments */
@media (max-width: 480px) {
    .menu-content, .prompt-content, .tutorial-step {
        padding: 20px 15px;
    }
    
    .menu h1 {
        font-size: 24px;
    }
    
    #score-display {
        top: 10px;
        left: 10px;
        font-size: 20px;
        padding: 8px 12px;
    }
    
    #magnet-meter {
        top: 10px;
        right: 10px;
        width: 120px;
    }
    
    #collection-counter {
        bottom: 10px;
        left: 10px;
        font-size: 16px;
        padding: 8px 12px;
    }
}