/* ============================================
   BUTTONBASS MUSIC TRIVIA - POLISHED THEME
   A vibrant, music-inspired design
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Space+Mono:wght@400;700&display=swap');

/* CSS Variables for Theme Consistency */
:root {
    --bg-dark: #0a0a0f;
    --bg-card: #12121a;
    --bg-card-hover: #1a1a25;
    --accent-primary: #00e5ff;
    --accent-secondary: #ff00e5;
    --accent-tertiary: #ffcc00;
    --gradient-primary: linear-gradient(135deg, #00e5ff 0%, #ff00e5 100%);
    --gradient-secondary: linear-gradient(135deg, #ff00e5 0%, #ffcc00 100%);
    --gradient-success: linear-gradient(135deg, #00ff88 0%, #00e5ff 100%);
    --gradient-error: linear-gradient(135deg, #ff3366 0%, #ff00e5 100%);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    --border-glow: 0 0 20px rgba(0, 229, 255, 0.3);
    --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --font-display: 'Outfit', sans-serif;
    --font-mono: 'Space Mono', monospace;
}

/* Global Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-display);
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Animated Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(0, 229, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(255, 0, 229, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(255, 204, 0, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
    animation: bgPulse 15s ease-in-out infinite;
}

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

/* Noise Texture Overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: -1;
}

.hidden {
    display: none !important;
}

/* Banner Container */
#banner-container {
    width: 90%;
    max-width: 800px;
    margin: 40px auto 30px;
    text-align: center;
    animation: slideDown 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.banner-image {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 10px 40px rgba(0, 229, 255, 0.3));
    transition: transform 0.4s ease, filter 0.4s ease;
}

.banner-image:hover {
    transform: scale(1.02);
    filter: drop-shadow(0 15px 50px rgba(255, 0, 229, 0.4));
}

/* Game Container */
#game-container {
    width: 90%;
    max-width: 800px;
    margin: 0 auto 60px;
    padding: 20px;
}

/* Form Wrapper */
.form-wrapper {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 40px 30px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--card-shadow);
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.2s backwards;
    position: relative;
    overflow: hidden;
}

.form-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
}

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

/* Form Groups */
.form-group {
    margin-bottom: 28px;
    width: 100%;
}

.form-group label {
    display: block;
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 0.95em;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-align: left;
}

/* Input & Select Styling */
input[type="text"],
select {
    width: 100%;
    padding: 16px 20px;
    font-size: 1.1em;
    font-family: var(--font-display);
    font-weight: 500;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    transition: all 0.3s ease;
    outline: none;
}

input[type="text"]:focus,
select:focus {
    border-color: var(--accent-primary);
    background: rgba(0, 229, 255, 0.05);
    box-shadow: 0 0 0 4px rgba(0, 229, 255, 0.1);
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2300e5ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 50px;
}

select option {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 12px;
}

/* Emoji Picker */
.emoji-picker-container {
    position: relative;
}

.open-picker-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 16px 20px;
    font-size: 1.1em;
    font-family: var(--font-display);
    font-weight: 600;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.open-picker-btn:hover {
    border-color: var(--accent-secondary);
    background: rgba(255, 0, 229, 0.05);
}

.chosen-emoji {
    font-size: 1.4em;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.emoji-grid {
    display: none;
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    max-height: 250px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px;
    z-index: 1000;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

.emoji-grid.show {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

.emoji-grid span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 1.5em;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.emoji-grid span:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.2);
}

/* Custom Scrollbar for Emoji Grid */
.emoji-grid::-webkit-scrollbar {
    width: 8px;
}

.emoji-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.emoji-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.emoji-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Submit Button */
.submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 18px 32px;
    font-size: 1.15em;
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--bg-dark);
    background: var(--gradient-primary);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 229, 255, 0.3);
}

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

.submit-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 229, 255, 0.4);
}

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

.submit-btn:active {
    transform: translateY(-1px);
}

/* Question Container */
#question-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Question Box */
.question-box {
    background: var(--bg-card);
    padding: 32px 28px;
    border-radius: 20px;
    margin-bottom: 28px;
    font-size: 1.35em;
    font-weight: 600;
    line-height: 1.5;
    color: var(--text-primary);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
}

.question-box::before {
    content: '♪';
    position: absolute;
    top: -20px;
    right: -20px;
    font-size: 120px;
    opacity: 0.03;
    transform: rotate(15deg);
}

.question-box::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-secondary);
}

/* Answers Container */
.answers-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 30px;
}

/* Answer Choice */
.answer-choice {
    background: var(--bg-card);
    padding: 20px 24px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 500;
    color: var(--text-primary);
    border: 2px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.answer-choice::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.answer-choice:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 229, 255, 0.15);
}

.answer-choice:hover::before {
    opacity: 1;
}

.answer-choice.correct {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.15) 0%, rgba(0, 229, 255, 0.15) 100%) !important;
    border-color: #00ff88 !important;
    animation: correctPulse 0.5s ease;
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.answer-choice.incorrect {
    background: linear-gradient(135deg, rgba(255, 51, 102, 0.15) 0%, rgba(255, 0, 229, 0.15) 100%) !important;
    border-color: #ff3366 !important;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.answer-choice.disabled {
    pointer-events: none;
    opacity: 0.6;
}

/* Progress Container */
#progress-container {
    width: 100%;
    max-width: 600px;
    margin: 30px auto;
    animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.1s backwards;
}

#progress-bar {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}

#progress-fill {
    height: 100%;
    width: 0%;
    background: var(--gradient-primary);
    border-radius: 20px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

#progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

#progress-text,
#score-text {
    font-size: 0.95em;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 12px 0 0;
    text-align: center;
    font-family: var(--font-mono);
    letter-spacing: 1px;
}

#score-text {
    color: var(--accent-tertiary);
}

/* Feedback Message */
#feedback-message {
    font-size: 1.3em;
    font-weight: 700;
    margin: 24px 0;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 3px;
    animation: feedbackPop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Leaderboard Container */
.leaderboard-container {
    width: 100%;
    max-width: 800px;
    margin: 40px auto;
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.leaderboard-container h3 {
    font-size: 1.1em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin: 40px 0 20px;
    color: var(--text-secondary);
    text-align: center;
    position: relative;
}

.leaderboard-container h3::before,
.leaderboard-container h3::after {
    content: '—';
    margin: 0 16px;
    opacity: 0.3;
}

/* Leaderboard */
.leaderboard {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--card-shadow);
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-radius: 14px;
    margin: 4px 0;
    background: transparent;
    transition: all 0.3s ease;
}

.leaderboard-entry:hover {
    background: rgba(255, 255, 255, 0.03);
}

.leaderboard-entry.top-score {
    background: linear-gradient(135deg, rgba(255, 204, 0, 0.1) 0%, rgba(255, 0, 229, 0.05) 100%);
    border: 1px solid rgba(255, 204, 0, 0.3);
}

.leaderboard-entry.top-score .leaderboard-rank {
    color: var(--accent-tertiary);
    text-shadow: 0 0 20px rgba(255, 204, 0, 0.5);
}

.leaderboard-rank {
    font-size: 1.4em;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--text-muted);
    width: 50px;
    text-align: center;
    flex-shrink: 0;
}

.leaderboard-name {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-primary);
}

.leaderboard-icon {
    font-size: 1.4em;
    flex-shrink: 0;
}

.leaderboard-score {
    font-size: 1.2em;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent-primary);
    padding: 8px 16px;
    background: rgba(0, 229, 255, 0.1);
    border-radius: 10px;
}

.leaderboard-entry.current-user {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.15) 0%, rgba(255, 0, 229, 0.15) 100%);
    border: 2px solid var(--accent-primary);
    animation: currentUserGlow 2s infinite;
}

@keyframes currentUserGlow {
    0%, 100% { 
        box-shadow: 0 0 20px rgba(0, 229, 255, 0.3); 
    }
    50% { 
        box-shadow: 0 0 30px rgba(255, 0, 229, 0.4); 
    }
}

/* Final Screen Container */
.final-screen-container {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 50px 40px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--card-shadow);
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.final-screen-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-success);
}

.final-screen-container h2 {
    font-size: 2em;
    font-weight: 800;
    margin-bottom: 16px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.final-screen-container p {
    font-size: 1.3em;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.final-button-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 36px;
}

/* Congratulations Message */
.congratulations-message {
    font-size: 1.6em;
    font-weight: 800;
    text-align: center;
    padding: 24px;
    margin: 20px 0;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: congratsPulse 1.5s ease-in-out infinite;
}

@keyframes congratsPulse {
    0%, 100% { 
        transform: scale(1); 
        filter: brightness(1);
    }
    50% { 
        transform: scale(1.03); 
        filter: brightness(1.2);
    }
}

/* Confetti */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 9999;
}

.confetti-piece {
    position: absolute;
    top: -20px;
    width: 12px;
    height: 12px;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(1080deg) scale(0.5);
        opacity: 0;
    }
}

/* Button Container (High Scores Page) */
.button-container {
    width: 90%;
    max-width: 800px;
    margin: 30px auto;
    display: flex;
    gap: 16px;
}

.button-container .submit-btn {
    flex: 1;
}

/* Mobile Responsive */
@media (max-width: 640px) {
    #banner-container {
        margin: 24px auto 20px;
    }

    .form-wrapper {
        padding: 30px 20px;
        border-radius: 20px;
    }

    .form-group label {
        font-size: 0.85em;
    }

    input[type="text"],
    select,
    .open-picker-btn {
        padding: 14px 16px;
        font-size: 1em;
    }

    .submit-btn {
        padding: 16px 24px;
        font-size: 1em;
    }

    .question-box {
        padding: 24px 20px;
        font-size: 1.15em;
        border-radius: 16px;
    }

    .answers-container {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .answer-choice {
        padding: 18px 20px;
        font-size: 1em;
    }

    .final-screen-container {
        padding: 36px 24px;
    }

    .final-screen-container h2 {
        font-size: 1.5em;
    }

    .leaderboard-entry {
        padding: 14px 16px;
    }

    .leaderboard-rank {
        font-size: 1.2em;
        width: 40px;
    }

    .leaderboard-name {
        font-size: 1em;
    }

    .leaderboard-score {
        font-size: 1em;
        padding: 6px 12px;
    }

    .button-container {
        flex-direction: column;
    }
}

/* Tablet Responsive */
@media (min-width: 641px) and (max-width: 900px) {
    .question-box {
        font-size: 1.25em;
    }

    .answer-choice {
        padding: 18px 22px;
    }
}

/* Selection Color */
::selection {
    background: var(--accent-primary);
    color: var(--bg-dark);
}

/* Focus Visible for Accessibility */
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 3px;
}
