/* Cosmic Dice 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: 1000px;
    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: #FFD23F;
    text-decoration: none;
    font-size: 1.1em;
    transition: all 0.3s ease;
    padding: 10px 15px;
    border-radius: 20px;
    background: rgba(255, 210, 63, 0.1);
    backdrop-filter: blur(10px);
}

.back-btn:hover {
    background: rgba(255, 210, 63, 0.2);
    transform: translateX(-5px);
}

.header h1 {
    font-size: 3.5em;
    color: #fff;
    text-shadow: 2px 2px 10px rgba(255, 107, 53, 0.5);
    margin-bottom: 15px;
    background: linear-gradient(45deg, #FF6B35, #F7931E, #FFD23F, #06FFA5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: diceGlow 3s ease-in-out infinite alternate;
}

.subtitle {
    font-size: 1.3em;
    color: #FFD23F;
    font-style: italic;
    text-shadow: 1px 1px 5px rgba(255, 107, 53, 0.3);
    margin-bottom: 20px;
}

@keyframes diceGlow {
    from { 
        text-shadow: 0 0 20px rgba(255, 107, 53, 0.5), 0 0 40px rgba(247, 147, 30, 0.3); 
    }
    to { 
        text-shadow: 0 0 30px rgba(255, 107, 53, 0.8), 0 0 60px rgba(247, 147, 30, 0.6); 
    }
}



.dice-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);
}

.question-section {
    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);
}

.question-section h2 {
    text-align: center;
    font-size: 1.8em;
    margin-bottom: 20px;
    color: #FFD23F;
    text-shadow: 0 0 15px rgba(255, 210, 63, 0.5);
}

.question-input-container {
    position: relative;
}

#userQuestion {
    width: 100%;
    min-height: 100px;
    padding: 15px;
    border: 2px solid rgba(255, 210, 63, 0.3);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    color: #ffffff;
    font-size: 1.1em;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

#userQuestion::placeholder {
    color: #B8B8D4;
    font-style: italic;
}

#userQuestion:focus {
    outline: none;
    border-color: #FFD23F;
    box-shadow: 0 0 15px rgba(255, 210, 63, 0.3);
}

.question-counter {
    text-align: right;
    margin-top: 8px;
    color: #B8B8D4;
    font-size: 0.9em;
}

.dice-arena {
    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: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.dice-arena h2 {
    font-size: 2em;
    margin-bottom: 30px;
    color: #FF6B35;
    text-shadow: 0 0 15px rgba(255, 107, 53, 0.5);
}

.dice-options {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.dice-option-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #ffffff;
    text-align: center;
    min-width: 150px;
    backdrop-filter: blur(5px);
}

.dice-option-btn.active {
    border-color: #FF6B35;
    background: rgba(255, 107, 53, 0.2);
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.3);
}

.dice-option-btn:hover {
    transform: translateY(-3px);
    border-color: #FF6B35;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.option-icon {
    display: block;
    font-size: 2em;
    margin-bottom: 10px;
}

.option-title {
    display: block;
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 5px;
    color: #FF6B35;
}

.option-desc {
    display: block;
    font-size: 0.9em;
    color: #B8B8D4;
}

.dice-container {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin: 50px 0;
    perspective: 1000px;
    min-height: 120px;
    align-items: center;
    flex-wrap: wrap;
}

.dice {
    width: 100px;
    height: 100px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s;
    margin: 20px;
}

.dice.rolling {
    animation: rollAnimation 1s ease-in-out;
}

@keyframes rollAnimation {
    0% { transform: rotateX(0) rotateY(0) rotateZ(0); }
    25% { transform: rotateX(90deg) rotateY(180deg) rotateZ(45deg) scale(1.1); }
    50% { transform: rotateX(180deg) rotateY(360deg) rotateZ(90deg) scale(1.2); }
    75% { transform: rotateX(270deg) rotateY(540deg) rotateZ(135deg) scale(1.1); }
    100% { transform: rotateX(360deg) rotateY(720deg) rotateZ(180deg) scale(1); }
}

.face {
    width: 100px;
    height: 100px;
    position: absolute;
    background: linear-gradient(135deg, #FF6B35, #F7931E, #FFD23F);
    border: 3px solid #FFD23F;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    font-weight: bold;
    color: #1a1a3a;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.2), 0 0 15px rgba(255, 107, 53, 0.4);
    line-height: 1;
}

.face.front { transform: translateZ(50px); }
.face.back { transform: rotateY(180deg) translateZ(50px); }
.face.right { transform: rotateY(90deg) translateZ(50px); }
.face.left { transform: rotateY(-90deg) translateZ(50px); }
.face.top { transform: rotateX(90deg) translateZ(50px); }
.face.bottom { transform: rotateX(-90deg) translateZ(50px); }

.roll-btn {
    padding: 20px 40px;
    background: linear-gradient(45deg, #FF6B35, #F7931E, #FFD23F);
    color: #1a1a3a;
    border: none;
    border-radius: 25px;
    font-size: 1.3em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4), 0 0 20px rgba(255, 107, 53, 0.3);
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.roll-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 107, 53, 0.6);
}

.roll-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.results-section {
    background: rgba(13, 13, 30, 0.9);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 107, 53, 0.3);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 40px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4), 0 0 25px rgba(255, 107, 53, 0.2);
    animation: resultsAppear 1s ease-out;
}

@keyframes resultsAppear {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.results-section h2 {
    text-align: center;
    font-size: 2.2em;
    margin-bottom: 30px;
    color: #FFD23F;
    text-shadow: 0 0 20px rgba(255, 210, 63, 0.6);
}

.dice-result {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 107, 53, 0.1);
    border-radius: 15px;
    border: 1px solid rgba(255, 107, 53, 0.3);
}

.result-numbers {
    font-size: 2.5em;
    font-weight: bold;
    color: #FF6B35;
    margin-bottom: 10px;
    text-shadow: 0 0 15px rgba(255, 107, 53, 0.6);
}

.result-total {
    font-size: 1.5em;
    color: #FFD23F;
    text-shadow: 0 0 10px rgba(255, 210, 63, 0.5);
}

.cosmic-interpretation,
.numerology-insight,
.action-guidance {
    margin-bottom: 25px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    border-left: 4px solid #FF6B35;
}

.cosmic-interpretation h3,
.numerology-insight h3,
.action-guidance h3 {
    color: #FFD23F;
    font-size: 1.3em;
    margin-bottom: 10px;
    text-shadow: 0 0 10px rgba(255, 210, 63, 0.4);
}

.interpretation-text,
.numerology-text,
.guidance-text {
    color: #E6E6FA;
    line-height: 1.6;
    font-size: 1.1em;
}

.result-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
    flex-wrap: wrap;
}

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

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

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

.cosmic-spinner {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 30px;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top-color: #FF6B35;
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
}

.spinner-ring:nth-child(2) {
    width: 70%;
    height: 70%;
    top: 15%;
    left: 15%;
    border-top-color: #F7931E;
    animation-duration: 1.2s;
    animation-direction: reverse;
}

.spinner-ring:nth-child(3) {
    width: 40%;
    height: 40%;
    top: 30%;
    left: 30%;
    border-top-color: #FFD23F;
    animation-duration: 0.9s;
}

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

.loading p {
    color: #FFD23F;
    font-style: italic;
    font-size: 1.1em;
    text-shadow: 0 0 10px rgba(255, 210, 63, 0.4);
}

/* 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;
    }
    
    .dice-options {
        flex-direction: column;
        align-items: center;
    }
    
    .dice-option-btn {
        width: 100%;
        max-width: 250px;
    }
    
    .dice-container {
        gap: 20px;
    }
    
    .dice {
        width: 80px;
        height: 80px;
        margin: 10px;
    }
    
    .face {
        width: 80px;
        height: 80px;
        font-size: 1em;
    }
    
    .face.front { transform: translateZ(40px); }
    .face.back { transform: rotateY(180deg) translateZ(40px); }
    .face.right { transform: rotateY(90deg) translateZ(40px); }
    .face.left { transform: rotateY(-90deg) translateZ(40px); }
    .face.top { transform: rotateX(90deg) translateZ(40px); }
    .face.bottom { transform: rotateX(-90deg) translateZ(40px); }
    
    .result-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .control-btn {
        width: 100%;
        max-width: 200px;
    }
}