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

/* Disable text selection on interactive elements */
.title,
.subtitle,
.welcome-card,
.question-card h3,
.answer-btn,
.result-card h2,
.result-card p,
.result-traits,
.btn,
.back-link,
.question-counter,
.shire-decoration,
.dashboard-link,
.footer {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

body {
    font-family: 'Lora', serif;
    line-height: 1.6;
    color: #2c3e50;
    background: linear-gradient(135deg, #2d5016 0%, #4a7c2c 50%, #6b9d3e 100%);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(139, 69, 19, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 215, 0, 0.2) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(34, 139, 34, 0.25) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
    animation: shireGlow 8s ease-in-out infinite;
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 15% 25%, rgba(255, 223, 0, 0.6), transparent),
        radial-gradient(1px 1px at 85% 75%, rgba(139, 69, 19, 0.5), transparent),
        radial-gradient(2px 2px at 45% 55%, rgba(34, 139, 34, 0.6), transparent),
        radial-gradient(1px 1px at 70% 30%, rgba(255, 215, 0, 0.4), transparent),
        radial-gradient(1px 1px at 30% 80%, rgba(107, 142, 35, 0.5), transparent);
    background-size: 250% 250%;
    pointer-events: none;
    z-index: -1;
    animation: fireflies 5s ease-in-out infinite;
}

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

@keyframes fireflies {
    0%, 100% { background-position: 0% 0%; opacity: 0.8; }
    50% { background-position: 100% 100%; opacity: 1; }
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Hero section */
.hero {
    text-align: center;
    padding: 40px 0;
    background: rgba(45, 80, 22, 0.7);
    border-radius: 20px;
    backdrop-filter: blur(15px);
    margin-bottom: 30px;
    border: 2px solid rgba(139, 69, 19, 0.5);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 50px rgba(255, 215, 0, 0.15), inset 0 0 30px rgba(139, 69, 19, 0.1);
}

.hero-content {
    position: relative;
}

.back-link {
    display: inline-block;
    color: rgba(255, 223, 0, 0.9);
    text-decoration: none;
    font-size: 1rem;
    margin-bottom: 20px;
    padding: 8px 16px;
    border-radius: 20px;
    background: rgba(139, 69, 19, 0.3);
    transition: all 0.3s ease;
    border: 1px solid rgba(139, 69, 19, 0.5);
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.back-link:focus {
    outline: none;
}

.back-link:active {
    outline: none;
}

.back-link:hover {
    background: rgba(139, 69, 19, 0.5);
    transform: translateX(-5px);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.title {
    font-family: 'Cinzel', serif;
    font-size: 3rem;
    font-weight: 600;
    background: linear-gradient(135deg, #ffdf00, #8b4513, #6b8e23);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shireGradient 4s ease infinite;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.4));
}

@keyframes shireGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.subtitle {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.shire-decoration {
    font-size: 2rem;
    margin-top: 20px;
    animation: sway 3s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(107, 142, 35, 0.6));
}

@keyframes sway {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

/* Screen management */
.screen {
    display: none;
    animation: fadeIn 0.5s ease-in;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Welcome screen */
.welcome-card {
    background: rgba(60, 40, 20, 0.85);
    backdrop-filter: blur(10px);
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 30px rgba(139, 69, 19, 0.2);
    border: 2px solid rgba(139, 69, 19, 0.5);
}

.welcome-card h2 {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    color: #ffdf00;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5), 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.welcome-card p {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.9);
}

/* Quiz screen */
.quiz-container {
    background: rgba(60, 40, 20, 0.85);
    backdrop-filter: blur(10px);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 30px rgba(139, 69, 19, 0.2);
    border: 2px solid rgba(139, 69, 19, 0.5);
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8b4513, #6b8e23, #ffdf00);
    background-size: 200% 100%;
    border-radius: 5px;
    transition: width 0.3s ease;
    width: 0%;
    animation: progressShimmer 2s linear infinite;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.question-counter {
    text-align: center;
    font-size: 0.9rem;
    color: rgba(255, 223, 0, 0.9);
    margin-bottom: 30px;
    font-weight: 600;
}

.question-card h3 {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: #ffdf00;
    margin-bottom: 25px;
    text-align: center;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.4), 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.answers {
    display: grid;
    gap: 15px;
}

.answer-btn {
    background: rgba(80, 50, 25, 0.6);
    backdrop-filter: blur(5px);
    border: 2px solid rgba(139, 69, 19, 0.4);
    padding: 15px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    position: relative;
    overflow: hidden;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.answer-btn:focus {
    outline: none;
}

.answer-btn:active {
    outline: none;
}

.answer-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.2), rgba(107, 142, 35, 0.2), transparent);
    transition: left 0.5s ease;
}

.answer-btn:hover {
    border-color: #8b4513;
    background: rgba(100, 60, 30, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(139, 69, 19, 0.5), 0 0 20px rgba(255, 215, 0, 0.2);
}

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

.answer-btn.selected {
    border-color: #8b4513;
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.5), rgba(107, 142, 35, 0.5));
    color: #fff;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4), inset 0 0 20px rgba(139, 69, 19, 0.3);
}

/* Result screen */
.result-card {
    background: rgba(60, 40, 20, 0.85);
    backdrop-filter: blur(10px);
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 30px rgba(139, 69, 19, 0.2);
    border: 2px solid rgba(139, 69, 19, 0.5);
}

.result-image {
    margin-bottom: 20px;
}

.result-image img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 4px solid #8b4513;
    object-fit: cover;
    box-shadow: 0 0 30px rgba(139, 69, 19, 0.6), 0 0 50px rgba(255, 215, 0, 0.3);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    0% { 
        box-shadow: 0 0 20px rgba(139, 69, 19, 0.6), 0 0 30px rgba(255, 215, 0, 0.3);
        transform: scale(1);
    }
    100% { 
        box-shadow: 0 0 40px rgba(139, 69, 19, 0.8), 0 0 60px rgba(255, 215, 0, 0.5);
        transform: scale(1.02);
    }
}

.result-card h2 {
    font-family: 'Cinzel', serif;
    font-size: 2.2rem;
    color: #ffdf00;
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5), 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.result-card p {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 25px;
    line-height: 1.7;
}

.result-traits {
    background: rgba(80, 50, 25, 0.5);
    backdrop-filter: blur(5px);
    padding: 20px;
    border-radius: 10px;
    margin: 25px 0;
    text-align: left;
    border: 2px solid rgba(139, 69, 19, 0.4);
    box-shadow: inset 0 0 20px rgba(139, 69, 19, 0.2);
}

.result-traits h4 {
    font-family: 'Cinzel', serif;
    color: #ffdf00;
    margin-bottom: 10px;
    text-align: center;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.result-traits ul {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
}

.result-traits li {
    padding: 5px 0;
    color: rgba(255, 255, 255, 0.85);
}

.result-traits li:before {
    content: "🌿 ";
    margin-right: 8px;
    filter: drop-shadow(0 0 5px rgba(107, 142, 35, 0.6));
}

.result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    position: relative;
    overflow: hidden;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:focus {
    outline: none;
}

.btn:active {
    outline: none;
}

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

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

.btn-primary {
    background: linear-gradient(135deg, #8b4513, #6b8e23, #ffdf00);
    background-size: 200% 200%;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    animation: buttonGradient 3s ease infinite;
    box-shadow: 0 4px 15px rgba(139, 69, 19, 0.4);
}

@keyframes buttonGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 69, 19, 0.6), 0 0 30px rgba(255, 215, 0, 0.3);
}

.btn-secondary {
    background: rgba(80, 50, 25, 0.6);
    backdrop-filter: blur(5px);
    color: #ffdf00;
    border: 2px solid #8b4513;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #8b4513, #6b8e23);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(139, 69, 19, 0.5);
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

.dashboard-link {
    display: inline-block;
    margin-top: 10px;
    padding: 10px 25px;
    background: linear-gradient(135deg, #ffdf00, #8b4513);
    color: #2c3e50;
    text-decoration: none;
    border-radius: 20px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 69, 19, 0.4);
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.dashboard-link:focus {
    outline: none;
}

.dashboard-link:active {
    outline: none;
}

.dashboard-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 69, 19, 0.6);
    background: linear-gradient(135deg, #8b4513, #ffdf00);
}

.dashboard-link:visited {
    color: #2c3e50;
}

.dashboard-link:active {
    transform: translateY(0);
}

/* Share confirmation popup */
.share-confirmation {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: linear-gradient(135deg, #6b8e23, #8b4513);
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 215, 0, 0.3);
    border: 2px solid rgba(139, 69, 19, 0.6);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
}

.share-confirmation.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.share-confirmation-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.share-check {
    font-size: 1.5rem;
    font-weight: bold;
    background: #ffdf00;
    color: #2d5016;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: checkPop 0.3s ease;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

@keyframes checkPop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.share-confirmation-content p {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .title {
        font-size: 2.2rem;
    }
    
    .welcome-card,
    .quiz-container,
    .result-card {
        padding: 25px;
    }
    
    .result-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 250px;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .welcome-card,
    .quiz-container,
    .result-card {
        padding: 20px;
    }
}