/* Mobile-first base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    min-height: 100dvh; /* account for mobile browser chrome */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 1rem;
    padding-bottom: calc(env(safe-area-inset-bottom) + 120px); /* leave room for fixed CTA */
}

.container {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    text-align: center;
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.subtitle {
    font-size: 0.875rem;
    color: #a8b2c1;
    margin-bottom: 2rem;
}

.compass-container {
    position: relative;
    width: 90vw;
    max-width: 350px;
    height: 90vw;
    max-height: 350px;
    margin: 0 auto 2rem;
}

.compass {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, #2d3561 0%, #1a1a2e 70%);
    border: 4px solid #4a5568;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5),
                inset 0 0 30px rgba(0, 0, 0, 0.3);
    position: relative;
    transition: transform 0.1s ease-out;
}

.compass-rose {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.direction-marker {
    position: absolute;
    width: 2px;
    height: 15%;
    background: #fff;
    left: 50%;
    transform: translateX(-50%);
    transform-origin: bottom center;
}

.direction-marker.north {
    background: #ef4444;
    width: 3px;
    height: 20%;
    top: 5%;
}

.direction-marker.south {
    background: #3b82f6;
    top: 5%;
    height: 10%;
}

.direction-marker.east,
.direction-marker.west {
    height: 12%;
    top: 5%;
}

.direction-label {
    position: absolute;
    font-size: 1.25rem;
    font-weight: bold;
    color: #fff;
    left: 50%;
    transform: translateX(-50%);
}

.direction-label.north {
    top: 8%;
    color: #ef4444;
    font-size: 1.5rem;
}

.direction-label.south {
    bottom: 8%;
    color: #3b82f6;
}

.direction-label.east {
    right: 8%;
    left: auto;
    transform: translateY(-50%);
    top: 50%;
}

.direction-label.west {
    left: 8%;
    transform: translateY(-50%);
    top: 50%;
}

.degree-marks {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.degree-mark {
    position: absolute;
    width: 1px;
    height: 6%;
    background: rgba(255, 255, 255, 0.3);
    left: 50%;
    top: 2%;
    transform-origin: 50% calc(45vw - 2%);
}

@media (min-width: 768px) {
    .degree-mark {
        transform-origin: 50% calc(200px - 2%);
    }
}

@media (min-width: 1024px) {
    .degree-mark {
        transform-origin: 50% calc(225px - 2%);
    }
}

.needle {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 40% solid #ef4444;
    left: 50%;
    top: 10%;
    transform: translateX(-50%);
    z-index: 10;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.qibla-pointer {
    position: absolute;
    width: 2px;
    height: 38%;
    background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
    top: 12%;
    left: 50%;
    transform: translateX(-50%) rotate(0deg);
    transform-origin: bottom center;
    border-radius: 999px;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.6);
    opacity: 0.85;
}

.center-dot {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 11;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.heading-display {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.heading-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #3b82f6;
    margin-bottom: 0.25rem;
}

.heading-direction {
    font-size: 1rem;
    color: #a8b2c1;
}

.qibla-display {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 1rem;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.qibla-heading {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fbbf24;
    margin-bottom: 0.2rem;
}

.qibla-delta {
    font-size: 0.95rem;
    color: #e5e7eb;
}

.status {
    font-size: 0.875rem;
    color: #a8b2c1;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.5rem;
    margin-top: 1rem;
}

.error {
    color: #ef4444;
}

.button {
    background: #2563eb;
    color: #fff;
    border: none;
    padding: 1rem 1.25rem;
    font-size: 1.125rem;
    font-weight: 600;
    border-radius: 0.75rem;
    cursor: pointer;
    margin-top: 1rem;
    transition: background 0.2s, transform 0.05s ease-in-out;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    min-height: 48px;
}

.button:hover { background: #1d4ed8; }

.button:active {
    transform: scale(0.98);
}

/* Make the start button an easy-to-tap fixed CTA */
#startButton {
    position: fixed;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom) + 16px);
    transform: translateX(-50%);
    width: calc(100vw - 2rem);
    max-width: 560px;
    z-index: 1000;
    box-shadow: 0 12px 28px rgba(0,0,0,0.35);
}

#startButton:disabled {
    opacity: 0.7;
}

#startButton:focus-visible {
    outline: 3px solid #93c5fd;
    outline-offset: 2px;
}

/* Tablet and larger screens */
@media (min-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .compass-container {
        max-width: 400px;
        max-height: 400px;
    }

    .heading-value {
        font-size: 3rem;
    }

    .heading-direction {
        font-size: 1.125rem;
    }
}

/* Desktop and larger screens */
@media (min-width: 1024px) {
    h1 {
        font-size: 2.5rem;
    }

    .compass-container {
        max-width: 450px;
        max-height: 450px;
    }
}
