/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #000;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Main speed image - fullscreen with cover fit */
.speed-image {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    object-position: center;
    transition: opacity 0.5s ease-in-out;
    z-index: 1;
}

.speed-image.fade-out {
    opacity: 0;
}

/* Speed overlay - top right corner */
.speed-overlay {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 15px 20px;
    border-radius: 12px;
    z-index: 100;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 120px;
    text-align: center;
}

.speed-overlay.hidden {
    display: none;
}

.speed-value {
    font-size: 32px;
    line-height: 1.2;
    margin-bottom: 5px;
    letter-spacing: -0.5px;
}

.speed-status {
    font-size: 11px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* Error message container */
.error-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.error-message.hidden {
    display: none;
}

.error-content {
    text-align: center;
    color: #fff;
    max-width: 400px;
}

.error-content h2 {
    font-size: 24px;
    margin-bottom: 15px;
    font-weight: 700;
}

.error-content p {
    font-size: 16px;
    margin-bottom: 25px;
    opacity: 0.9;
    line-height: 1.5;
}

.retry-button {
    background: #fff;
    color: #667eea;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.retry-button:active {
    transform: scale(0.95);
}

/* Loading indicator */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 150;
    color: #fff;
}

.loading-indicator.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-indicator p {
    font-size: 16px;
    opacity: 0.8;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Prevent pull-to-refresh and overscroll on mobile */
body {
    overscroll-behavior: none;
}

/* Wake lock button - bottom center floating */
.wake-lock-button {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 14px 24px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    min-height: 44px;
    min-width: 44px;
    white-space: nowrap;
    touch-action: manipulation;
}

.wake-lock-button:active {
    transform: translateX(-50%) scale(0.95);
}

.wake-lock-button.active {
    background: rgba(76, 175, 80, 0.85);
    border-color: rgba(76, 175, 80, 1);
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.4);
}

.wake-lock-button.hidden {
    display: none;
}

/* iOS Safari address bar handling */
@supports (-webkit-touch-callout: none) {
    .speed-image,
    .error-message,
    .loading-indicator {
        height: -webkit-fill-available;
        min-height: 100vh;
    }
}

/* Landscape mode adjustments */
@media screen and (orientation: landscape) {
    .speed-overlay {
        top: 15px;
        right: 15px;
        padding: 12px 18px;
    }
    
    .speed-value {
        font-size: 28px;
    }
    
    .speed-status {
        font-size: 10px;
    }
    
    .wake-lock-button {
        bottom: 20px;
        padding: 12px 20px;
        font-size: 13px;
    }
}

/* Small screens adjustments */
@media screen and (max-width: 360px) {
    .speed-overlay {
        top: 15px;
        right: 15px;
        padding: 10px 15px;
    }
    
    .speed-value {
        font-size: 24px;
    }
    
    .speed-status {
        font-size: 9px;
    }
    
    .wake-lock-button {
        bottom: 20px;
        padding: 12px 18px;
        font-size: 12px;
    }
}
