:root {
    --glass-bg: rgba(255, 255, 255, 0.12);
    --glass-border: rgba(255, 255, 255, 0.25);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --accent: rgba(120, 200, 255, 0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100vh;
    min-height: -webkit-fill-available;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 25%, #0f3460 50%, #1a1a2e 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    overflow-x: hidden;
    padding-bottom: max(140px, env(safe-area-inset-bottom));
    position: relative;
    -webkit-overflow-scrolling: touch;
}

body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(circle at 20% 20%, rgba(120, 200, 255, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(180, 120, 255, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(100, 220, 200, 0.08) 0%, transparent 50%);
    animation: floatBg 20s ease-in-out infinite;
    z-index: 0;
    pointer-events: none;
}

@keyframes floatBg {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(2%, 2%) rotate(1deg); }
    66% { transform: translate(-1%, 1%) rotate(-1deg); }
}

header {
    padding: max(2rem, env(safe-area-inset-top)) 1.5rem 1.5rem;
    text-align: center;
    background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 100%);
    position: relative;
    z-index: 10;
}

h1 {
    font-size: clamp(1.8rem, 5vw, 2.2rem);
    font-weight: 600;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, rgba(200, 230, 255, 0.9) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 2px 20px rgba(120, 200, 255, 0.3);
}

.current-time {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-top: 0.5rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}

.current-date {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
    font-weight: 400;
}

.location-selector {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-top: 1rem;
    position: relative;
    background: rgba(10, 10, 15, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 5px;
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.location-glass-indicator {
    position: absolute;
    height: calc(100% - 10px);
    top: 5px;
    background: linear-gradient(135deg, rgba(120, 200, 255, 0.25), rgba(180, 120, 255, 0.18));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 
        0 4px 20px rgba(120, 200, 255, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.35),
        inset 0 -1px 0 rgba(255, 255, 255, 0.1);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    left: 5px;
    width: 80px;
    transform: translateX(0);
    will-change: transform, width;
}

.location-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 100px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.3s ease;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    z-index: 1;
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
}

.location-btn.active {
    color: var(--text-primary);
}

.location-btn:active {
    opacity: 0.8;
}

main {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

@media (min-width: 768px) {
    main {
        flex-direction: row;
        padding: 2rem;
        gap: 2rem;
    }
}

.prayer-times-container {
    flex: 2;
    border-radius: 20px;
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.month-selector {
    display: flex;
    overflow-x: auto;
    gap: 0;
    padding: 5px;
    margin-bottom: 1rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    position: relative;
    background: rgba(10, 10, 15, 0.5);
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.month-selector::-webkit-scrollbar {
    display: none;
}

.month-glass-indicator {
    position: absolute;
    height: calc(100% - 10px);
    top: 5px;
    background: linear-gradient(135deg, rgba(120, 200, 255, 0.25), rgba(180, 120, 255, 0.18));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 
        0 4px 20px rgba(120, 200, 255, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.35),
        inset 0 -1px 0 rgba(255, 255, 255, 0.1);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    left: 5px;
    width: 50px;
    z-index: 0;
    transform: translateX(0);
    will-change: transform, width;
}

.month-tab {
    padding: 0.5rem 0.9rem;
    border-radius: 100px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.3s ease;
    scroll-snap-align: center;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.month-tab.active {
    color: var(--text-primary);
}

.prayer-times {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (max-width: 480px) {
    .prayer-times {
        grid-template-columns: 1fr;
    }
}

.prayer-card {
    padding: 1.25rem;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    -webkit-touch-callout: none;
}

.prayer-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
}

.prayer-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(120, 200, 255, 0.15);
    border-color: rgba(120, 200, 255, 0.3);
}

.prayer-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.prayer-time {
    font-size: 2rem;
    font-weight: 600;
    background: linear-gradient(135deg, #ffffff 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

@media (min-width: 768px) {
    .prayer-time {
        font-size: 2.2rem;
    }
}

@media (max-width: 390px) {
    .prayer-time {
        font-size: 1.75rem;
    }
}

/* Slide animation classes */
.prayer-time.slide-out-left {
    animation: slideOutLeft 0.3s ease forwards;
}

.prayer-time.slide-in-right {
    animation: slideInRight 0.3s ease forwards;
}

.prayer-time.slide-out-right {
    animation: slideOutRight 0.3s ease forwards;
}

.prayer-time.slide-in-left {
    animation: slideInLeft 0.3s ease forwards;
}

@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-30px);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.music-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.start-prayer-btn {
    width: 100%;
    padding: 2rem 1.5rem;
    border-radius: 24px;
    background: linear-gradient(135deg, rgba(120, 200, 255, 0.15) 0%, rgba(180, 120, 255, 0.12) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    -webkit-touch-callout: none;
    user-select: none;
    box-shadow: 
        0 8px 32px rgba(120, 200, 255, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.start-prayer-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(120, 200, 255, 0.2) 0%, rgba(180, 120, 255, 0.15) 50%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.start-prayer-btn:active {
    transform: scale(0.98);
}

@media (hover: hover) {
    .start-prayer-btn:hover {
        transform: translateY(-4px);
        border-color: rgba(120, 200, 255, 0.4);
        box-shadow: 
            0 12px 40px rgba(120, 200, 255, 0.25),
            inset 0 1px 0 rgba(255, 255, 255, 0.25);
    }

    .start-prayer-btn:hover::before {
        opacity: 1;
    }
}

.prayer-icon {
    font-size: 3rem;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(120, 200, 255, 0.3) 0%, rgba(180, 120, 255, 0.2) 100%);
    border-radius: 20px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 4px 16px rgba(120, 200, 255, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.prayer-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    text-align: left;
    position: relative;
    z-index: 1;
}

.prayer-label {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.prayer-time-label {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.player-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.875rem 1rem;
    padding-bottom: calc(0.875rem + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(20, 20, 40, 0.95) 0%, rgba(15, 15, 30, 0.98) 100%);
    backdrop-filter: blur(60px) saturate(200%);
    -webkit-backdrop-filter: blur(60px) saturate(200%);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 -10px 40px rgba(0, 0, 0, 0.3),
        0 -1px 0 rgba(255, 255, 255, 0.1) inset;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 100;
}

.player-container.visible {
    transform: translateY(0);
}

.player-content {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    max-width: 900px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .player-content {
        flex-direction: row;
        align-items: center;
    }
}

.player-info {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

@media (min-width: 768px) {
    .player-info {
        flex: 1;
    }
}

.player-cover {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, rgba(120, 200, 255, 0.35) 0%, rgba(180, 120, 255, 0.25) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    box-shadow: 
        0 4px 12px rgba(120, 200, 255, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.player-details {
    overflow: hidden;
}

.player-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.player-artist {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .player-controls {
        flex: 1;
    }
}

.player-btn {
    width: 42px;
    height: 42px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.player-btn:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.08);
}

@media (hover: hover) {
    .player-btn:hover {
        background: rgba(255, 255, 255, 0.18);
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }
}

.player-btn.play-pause {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
    background: linear-gradient(135deg, rgba(120, 200, 255, 0.5) 0%, rgba(180, 120, 255, 0.4) 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    box-shadow: 
        0 6px 24px rgba(120, 200, 255, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.player-btn.play-pause:active {
    transform: scale(0.94);
}

@media (hover: hover) {
    .player-btn.play-pause:hover {
        box-shadow: 
            0 8px 32px rgba(120, 200, 255, 0.4),
            0 4px 12px rgba(0, 0, 0, 0.25),
            inset 0 1px 0 rgba(255, 255, 255, 0.25);
        transform: scale(1.05);
    }
}

.player-progress {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

@media (min-width: 768px) {
    .player-progress {
        flex: 2;
    }
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 100px;
    cursor: pointer;
    position: relative;
    overflow: visible;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(120, 200, 255, 0.9), rgba(180, 120, 255, 0.8));
    border-radius: 100px;
    width: 0%;
    transition: width 0.1s linear;
    box-shadow: 0 0 12px rgba(120, 200, 255, 0.6);
}

.progress-fill::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, rgba(120, 200, 255, 1), rgba(180, 120, 255, 0.9));
    border-radius: 50%;
    box-shadow: 
        0 2px 8px rgba(120, 200, 255, 0.5),
        0 0 0 2px rgba(255, 255, 255, 0.3);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.progress-bar:active .progress-fill::after {
    opacity: 1;
}

.time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 38px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.close-player {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.close-player:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.08);
}

@media (hover: hover) {
    .close-player:hover {
        background: rgba(255, 255, 255, 0.2);
        color: var(--text-primary);
        transform: scale(1.05);
    }
}

@media (min-width: 768px) {
    .close-player {
        position: static;
        margin-left: 1rem;
    }
}

audio {
    display: none;
}

/* iOS specific optimizations */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }
}

@media (max-width: 768px) {
    body {
        padding-bottom: max(140px, calc(120px + env(safe-area-inset-bottom)));
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    .current-time {
        font-size: 1.1rem;
    }
    
    .current-date {
        font-size: 0.9rem;
    }
    
    .prayer-times {
        gap: 0.75rem;
    }
    
    .music-container {
        gap: 0.75rem;
    }
    
    .player-container {
        padding: 0.75rem 0.875rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    }
    
    .player-content {
        gap: 0.75rem;
    }
}

/* iPhone SE and smaller */
@media (max-width: 375px) {
    main {
        padding: 0.75rem;
    }
    
    .prayer-times-container {
        padding: 1rem;
    }
    
    .prayer-card {
        padding: 1rem;
    }
    
    .prayer-name {
        font-size: 0.8rem;
    }
}

html {
    scroll-behavior: smooth;
}

::selection {
    background: rgba(120, 200, 255, 0.3);
}

button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
