:root {
    /* Colors */
    --bg-dark: #0f0f13;
    /* Deep elegant gradient */
    --bg-gradient: radial-gradient(circle at 50% -20%, #2a2a35 0%, #0f0f13 100%);

    --glass-bg: rgba(20, 20, 25, 0.85);
    --glass-border: rgba(255, 215, 0, 0.15);
    /* Subtle Gold Border */
    --glass-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);

    --primary: #ffd700;
    /* Gold */
    --primary-hover: #ffed4a;
    --secondary: #a8a8b3;
    --danger: #ff4757;
    --success: #2ed573;

    --text-main: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);

    /* Spacing */
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-dark);
    /* Subtle Gold/Blue ambient light */
    background-image:
        radial-gradient(at 0% 0%, rgba(255, 215, 0, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(100, 100, 255, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    /* Allow content to grow beyond viewport */
    overflow-y: auto;
    /* Enable vertical scroll */
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Texture Overlay */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Subtle geometric pattern */
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    z-index: -1;
}

h1,
h2,
h3 {
    font-family: 'Playfair Display', serif;
}

/* Background Effects */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: var(--bg-gradient);
}

.glass-overlay {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.05) 0%, transparent 40%);
    animation: rotate 60s linear infinite;
    z-index: -1;
    pointer-events: none;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Container */
.game-container {
    width: 100%;
    max-width: 900px;
    /* Widened from 480px for horizontal layout */
    height: 100vh;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    padding: 20px;
    margin: 0 auto;
}

@media (min-width: 600px) {
    .game-container {
        height: 90vh;
    }
}

/* Choices */
.choices-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* 2 columns */
    gap: 15px;
    margin-top: 20px;
}

/* Ensure choices don't get too tall */
.choice-btn {
    padding: 12px 16px;
    color: var(--primary);
}

/* Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.branding {
    display: flex;
    align-items: center;
    gap: 10px;
}

.branding h1 {
    font-size: 1.5rem;
    color: var(--primary);
}

.logo-icon {
    color: var(--primary);
    width: 24px;
    height: 24px;
}

.score-display {
    text-align: right;
}

.score-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-value {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Game Card */
.game-card {
    flex: 1;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow-y: auto;
    /* Allow scrolling if content is tall */
    overflow-x: hidden;
}

.view-section {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease;
    position: relative;
    /* Context for absolute visuals */
    z-index: 2;
}

.view-section.hidden {
    display: none;
    opacity: 0;
}

/* Decorations */
.avg-decoration {
    position: absolute;
    width: 250px;
    opacity: 0.15;
    pointer-events: none;
    filter: sepia(0.5) contrast(1.2);
    z-index: -1;
    mix-blend-mode: luminosity;
}

.avg-decoration.left {
    bottom: -50px;
    left: -50px;
    transform: rotate(15deg);
}

.avg-decoration.right {
    top: 50px;
    right: -80px;
    width: 300px;
    transform: rotate(-10deg);
}

/* Start View Specifics */
#start-view {
    justify-content: center;
    align-items: center;
    text-align: center;
}

#start-view h2 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    margin-top: 60px;
}

#start-view .subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    max-width: 600px;
}

.round-info {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.round-pill {
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    letter-spacing: 1px;
    color: var(--text-muted);
}

/* Visualizer Bars */
.visualizer-bars {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    height: 60px;
    margin-top: 20px;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.playing .visualizer-bars {
    opacity: 1;
}

.visualizer-bar {
    width: 4px;
    background: var(--primary);
    border-radius: 2px;
    height: 4px;
    transition: height 0.1s ease;
}

.playing .visualizer-bar {
    animation: visualize 0.8s ease-in-out infinite;
}

@keyframes visualize {
    0% {
        height: 4px;
        opacity: 0.5;
    }

    50% {
        height: 100%;
        opacity: 1;
    }

    100% {
        height: 4px;
        opacity: 0.5;
    }
}

/* Stagger animations */
.visualizer-bar:nth-child(odd) {
    animation-duration: 0.6s;
}

.visualizer-bar:nth-child(2n) {
    animation-duration: 0.9s;
}

.visualizer-bar:nth-child(3n) {
    animation-duration: 0.7s;
}

.visualizer-bar:nth-child(4n) {
    animation-duration: 1.1s;
}

/* Audio Visualizer Area */
.visualizer-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 20px;
}

.visualizer-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.1);
}

.visualizer-circle:active {
    transform: scale(0.95);
}

.visualizer-circle:hover {
    border-color: var(--primary);
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.3);
}

.play-icon {
    width: 40px;
    height: 40px;
    fill: var(--text-main);
    stroke: none;
}

/* Time Controls */
.timer-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.time-text {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    color: var(--primary);
}

.add-time-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.add-time-btn:hover:not(:disabled) {
    border-color: var(--text-main);
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.add-time-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.add-time-btn svg {
    width: 14px;
    height: 14px;
}

/* Round Selector */
.round-selector {
    display: flex;
    justify-content: center;
    gap: 15px;
    background: transparent;
    padding: 0;
    width: 100%;
    margin: 10px 0;
}

.round-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    font-size: 1rem;
    position: relative;
    overflow: hidden;
}

.round-btn:hover {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

.round-btn.active {
    background: #00a8ff !important;
    color: white !important;
    font-weight: 700;
    border: 1px solid #00a8ff !important;
    box-shadow: 0 4px 15px rgba(0, 168, 255, 0.4);
}

/* Choices */
.choices-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    /* Subtle border */
    color: var(--text-main);
    padding: 16px;
    border-radius: var(--radius-md);
    text-align: left;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    /* Regular weight needed if using Outfit? or 300 lighter */
    transition: all 0.25s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.choice-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
}

.choice-btn.correct {
    background: rgba(46, 213, 115, 0.2);
    border-color: var(--success);
    color: var(--success);
}

.choice-btn.wrong {
    background: rgba(255, 71, 87, 0.2);
    border-color: var(--danger);
    color: var(--danger);
}

.choice-composer {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
}

.choice-title {
    opacity: 0.7;
    font-size: 0.85rem;
}

/* Feedback */
.feedback-message {
    height: 30px;
    text-align: center;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.feedback-message.correct {
    color: var(--success);
}

.feedback-message.wrong {
    color: var(--danger);
}

/* Buttons */
.primary-btn {
    background: var(--primary);
    color: rgb(20, 20, 20);
    border: none;
    padding: 16px 32px;
    border-radius: var(--radius-lg);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    width: 100%;
    margin-top: 20px;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* Animations */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Leaderboard */
.leaderboard-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 10px 0;
    text-align: center;
}

.leaderboard-container h3 {
    color: var(--primary);
    font-size: 1rem;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#high-scores-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.highscore-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.95rem;
}

.highscore-item:last-child {
    border-bottom: none;
}

.highscore-item .rank {
    font-weight: bold;
    color: var(--primary);
    width: 24px;
}

.highscore-item .name {
    flex: 1;
    text-align: left;
}

.highscore-item .score {
    font-weight: 700;
}

.empty-score {
    opacity: 0.6;
    font-style: italic;
    font-size: 0.9rem;
}

/* New High Score Input */
#highscore-input-container {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.highscore-alert {
    color: var(--primary);
    font-weight: bold;
    font-size: 1.2rem;
    animation: pulse 1s infinite;
}

#player-name-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 12px;
    border-radius: var(--radius-sm);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
}

#player-name-input:focus {
    outline: none;
    border-color: var(--primary);
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

/* Composer Showcase */
.composer-showcase {
    margin: 30px 0;
    width: 100%;
}

.composer-showcase h3 {
    font-size: 1rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 20px;
}

.showcase-grid {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    max-width: 850px;
    /* Increased to fit 9 items per row (18 total) */
    margin: 0 auto;
}

.showcase-item {
    width: 65px;
    /* Slightly smaller to fit 8 comfortably */
    height: 65px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 215, 0, 0.3);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.showcase-item:hover {
    transform: scale(1.2);
    border-color: var(--primary);
    z-index: 10;
    box-shadow: 0 8px 20px rgba(255, 215, 0, 0.3);
}

.showcase-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Zoom in to crop painted frames and focus on face */
    transform: scale(1.4);
    object-position: center 15%;
    /* Focus slightly higher on facial features */
    transition: transform 0.3s ease;
}

.showcase-item:hover img {
    /* Maintain zoom on hover (container scales, image stays zoomed relative to container) */
    transform: scale(1.4);
}

/* Specific Adjustments for smaller portraits */
.showcase-item[title="F. Mendelssohn"] img {
    /* Mendelssohn stays at 1.7 */
    transform: scale(1.7);
    object-position: center 25%;
}

.showcase-item[title="G. Verdi"] img {
    /* Verdi zoomed to match Wagner/Mendelssohn consistency */
    transform: scale(1.7);
    object-position: center 20%;
}

.showcase-item[title="G. Verdi"]:hover img {
    transform: scale(1.7);
}

.showcase-item[title="P.I. Tchaikovsky"] img {
    /* Reduce zoom to fit full head */
    transform: scale(1.25);
    object-position: center 10%;
}

.showcase-item[title="P.I. Tchaikovsky"]:hover img {
    transform: scale(1.25);
}