/* Cosmic Tarot Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0a0a23 0%, #1a1a3a 50%, #2a1a5a 100%);
    background-attachment: fixed;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    color: #ffffff;
}

/* Animated Cosmic Background */
.cosmic-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.stars, .twinkling {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.stars {
    background: transparent url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><radialGradient id="star"><stop offset="0%" stop-color="%23fff" stop-opacity="1"/><stop offset="100%" stop-color="%23fff" stop-opacity="0"/></radialGradient></defs><circle cx="20" cy="20" r="1" fill="url(%23star)"/><circle cx="60" cy="5" r="1" fill="url(%23star)"/><circle cx="90" cy="25" r="1" fill="url(%23star)"/><circle cx="30" cy="70" r="1" fill="url(%23star)"/><circle cx="80" cy="80" r="1" fill="url(%23star)"/></svg>') repeat;
    background-size: 200px 200px;
    animation: stars-move 120s linear infinite;
}

.twinkling {
    background: transparent url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><radialGradient id="twinkle"><stop offset="0%" stop-color="%23fff" stop-opacity="1"/><stop offset="100%" stop-color="%23fff" stop-opacity="0"/></radialGradient></defs><circle cx="15" cy="35" r="0.5" fill="url(%23twinkle)"/><circle cx="75" cy="15" r="0.8" fill="url(%23twinkle)"/><circle cx="45" cy="85" r="0.6" fill="url(%23twinkle)"/><circle cx="85" cy="60" r="0.4" fill="url(%23twinkle)"/></svg>') repeat;
    background-size: 300px 300px;
    animation: twinkling 100s linear infinite;
}

@keyframes stars-move {
    from { transform: translateY(0px); }
    to { transform: translateY(-2000px); }
}

@keyframes twinkling {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20px 30px, #ffffff, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, #ffffff, transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.6), transparent),
        radial-gradient(2px 2px at 160px 30px, #ffffff, transparent);
    background-repeat: repeat;
    background-size: 200px 100px;
    animation: twinkle 4s linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
    padding: 30px 20px;
}

.back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #DDA0DD;
    text-decoration: none;
    font-size: 1.1em;
    transition: all 0.3s ease;
    padding: 10px 15px;
    border-radius: 20px;
    background: rgba(221, 160, 221, 0.1);
    backdrop-filter: blur(10px);
}

.back-btn:hover {
    background: rgba(221, 160, 221, 0.2);
    transform: translateX(-5px);
}

.header h1 {
    font-size: 3.5em;
    color: #fff;
    text-shadow: 2px 2px 10px rgba(147, 112, 219, 0.5);
    margin-bottom: 15px;
    background: linear-gradient(45deg, #9370DB, #DDA0DD, #E6E6FA, #FFD700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: mysticalGlow 3s ease-in-out infinite alternate;
}

.subtitle {
    font-size: 1.3em;
    color: #DDA0DD;
    font-style: italic;
    text-shadow: 1px 1px 5px rgba(147, 112, 219, 0.3);
    margin-bottom: 20px;
}

@keyframes mysticalGlow {
    from { 
        text-shadow: 0 0 20px rgba(147, 112, 219, 0.5), 0 0 40px rgba(221, 160, 221, 0.3); 
    }
    to { 
        text-shadow: 0 0 30px rgba(147, 112, 219, 0.8), 0 0 60px rgba(221, 160, 221, 0.6); 
    }
}



.nav-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5), 0 0 20px rgba(138, 43, 226, 0.6);
}

.admin-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5), 0 0 20px rgba(139, 69, 19, 0.6);
}

.tarot-intro {
    text-align: center;
    margin-bottom: 40px;
    background: rgba(13, 13, 30, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.mystical-text {
    font-size: 1.2em;
    line-height: 1.6;
    color: #E6E6FA;
    text-shadow: 0 0 10px rgba(230, 230, 250, 0.3);
}

.reading-selection {
    margin-bottom: 40px;
}

.reading-selection h2 {
    text-align: center;
    font-size: 2em;
    margin-bottom: 30px;
    color: #DDA0DD;
    text-shadow: 0 0 15px rgba(221, 160, 221, 0.5);
}

.reading-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.reading-btn {
    background: rgba(13, 13, 30, 0.9);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(147, 112, 219, 0.3);
    border-radius: 20px;
    padding: 30px;
    cursor: pointer;
    transition: all 0.4s ease;
    text-align: center;
    color: #ffffff;
    font-size: 1em;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.reading-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(147, 112, 219, 0.2), transparent);
    transition: left 0.5s ease;
}

.reading-btn:hover::before {
    left: 100%;
}

.reading-btn:hover {
    border-color: #9370DB;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4), 0 0 30px rgba(147, 112, 219, 0.4);
    transform: translateY(-5px) scale(1.02);
}

.reading-icon {
    display: block;
    font-size: 3em;
    margin-bottom: 15px;
    filter: drop-shadow(0 0 10px rgba(147, 112, 219, 0.5));
}

.reading-title {
    display: block;
    font-size: 1.4em;
    font-weight: bold;
    margin-bottom: 10px;
    color: #DDA0DD;
}

.reading-desc {
    display: block;
    color: #B8B8D4;
    font-style: italic;
}

.card-area {
    text-align: center;
}

.reading-header {
    margin-bottom: 40px;
    background: rgba(13, 13, 30, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 25px;
}

.reading-header h3 {
    font-size: 2em;
    color: #DDA0DD;
    margin-bottom: 10px;
    text-shadow: 0 0 15px rgba(221, 160, 221, 0.5);
}

.reading-header p {
    font-size: 1.1em;
    color: #E6E6FA;
}

.card-deck {
    margin-bottom: 40px;
}

.deck-card {
    width: 200px;
    height: 300px;
    margin: 0 auto;
    cursor: pointer;
    perspective: 1000px;
    transition: transform 0.3s ease;
}

.deck-card:hover {
    transform: scale(1.05) rotateY(5deg);
}

.card-back {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a3a, #2a1a5a, #3a1a7a);
    border: 3px solid #9370DB;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4), 0 0 20px rgba(147, 112, 219, 0.3);
    position: relative;
    overflow: hidden;
}

.card-pattern {
    position: absolute;
    inset: 10px;
    background: repeating-conic-gradient(from 0deg, #9370DB 0deg 45deg, #DDA0DD 45deg 90deg);
    opacity: 0.2;
    border-radius: 10px;
}

.card-text {
    font-size: 1.2em;
    font-weight: bold;
    color: #E6E6FA;
    z-index: 1;
    text-shadow: 0 0 10px rgba(230, 230, 250, 0.5);
}

.drawn-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.tarot-card {
    background: rgba(13, 13, 30, 0.95);
    backdrop-filter: blur(15px);
    border: 2px solid rgba(147, 112, 219, 0.4);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4), 0 0 25px rgba(147, 112, 219, 0.2);
    transition: all 0.4s ease;
    animation: cardAppear 0.8s ease forwards;
    opacity: 0;
    transform: translateY(50px) rotateX(45deg);
}

@keyframes cardAppear {
    to {
        opacity: 1;
        transform: translateY(0) rotateX(0);
    }
}

.tarot-card:hover {
    transform: translateY(-10px) scale(1.03);
    border-color: #9370DB;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(147, 112, 219, 0.4);
}

.card-position {
    font-size: 0.9em;
    color: #FFD700;
    font-weight: bold;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.card-content.reversed {
    filter: hue-rotate(180deg) brightness(0.8);
}

.card-name {
    font-size: 1.5em;
    font-weight: bold;
    color: #DDA0DD;
    margin-bottom: 8px;
    text-shadow: 0 0 15px rgba(221, 160, 221, 0.5);
}

.card-suit {
    font-size: 1em;
    color: #9370DB;
    margin-bottom: 15px;
    font-style: italic;
}

.card-meaning {
    text-align: left;
    margin-bottom: 15px;
}

.card-meaning h4 {
    color: #E6E6FA;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.card-meaning p {
    color: #B8B8D4;
    line-height: 1.5;
    font-size: 0.95em;
}

.card-arcana {
    font-size: 0.85em;
    color: #9370DB;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
}

.reading-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
}

.control-btn {
    padding: 15px 30px;
    background: linear-gradient(45deg, #4a148c, #6a1b9a, #8e24aa);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4), 0 0 10px rgba(138, 43, 226, 0.3);
}

.control-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5), 0 0 20px rgba(138, 43, 226, 0.6);
    background: linear-gradient(45deg, #6a1b9a, #8e24aa, #ab47bc);
}

.loading {
    text-align: center;
    background: rgba(13, 13, 30, 0.9);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 40px;
    margin: 40px auto;
    max-width: 400px;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(147, 112, 219, 0.3);
    border-left: 4px solid #9370DB;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: #DDA0DD;
    font-style: italic;
    font-size: 1.1em;
}

.error-message {
    background: rgba(214, 52, 71, 0.2);
    color: #ff6b6b;
    border: 1px solid rgba(214, 52, 71, 0.4);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    margin: 20px auto;
    max-width: 500px;
    backdrop-filter: blur(10px);
}

/* Sparkle effect */
.sparkle {
    position: fixed;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, #FFD700, transparent);
    border-radius: 50%;
    pointer-events: none;
    animation: sparkleEffect 1s ease-out forwards;
    z-index: 3;
}

@keyframes sparkleEffect {
    0% {
        opacity: 1;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0);
    }
}

/* iOS Safari background fix */
@supports (-webkit-touch-callout: none) {
    body {
        background-attachment: scroll;
        background-size: 100% 100%;
        background-repeat: no-repeat;
    }
    
    body::before {
        position: absolute;
        background-attachment: scroll;
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .header h1 {
        font-size: 2em;
    }
    
    .header-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .nav-btn, .admin-btn {
        width: 100%;
        justify-content: center;
    }
    
    .reading-options {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .reading-btn {
        padding: 25px 20px;
    }
    
    .drawn-cards {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .reading-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .control-btn {
        width: 100%;
        max-width: 250px;
    }
}