/* --- FONT DEFINITIONS --- */
:root {
    --font-primary: 'Montserrat', sans-serif;
    --font-secondary: 'Orbitron', sans-serif;
    --font-mono: 'Roboto Mono', monospace;
    --font-script: 'Pacifico', cursive;
    --font-display: 'Lobster', cursive;
}

/* --- THEME DEFINITIONS --- */

/* Helper for glow amounts */
:root {
    --moderate-glow-amount: 6px; /* Increased from 3px for more pop */
    --strong-glow-amount: 12px; /* For hover effects or more intense elements */
    --accent-glow-property: text-shadow;
}

/* 1. NEON ELECTRIC (Default - Blue/Cyan - Ramped up glow) */
html.theme-neon-electric {
    --bg-primary: #0a192f;
    --bg-secondary: #172a45;
    --bg-tertiary: #0f213a;
    --text-primary: #64ffda;
    --text-secondary: #ccd6f6;
    --text-muted: #8892b0;
    --accent-glow-color: var(--text-primary);
    --accent-glow: 0 0 var(--moderate-glow-amount) var(--accent-glow-color), 0 0 calc(var(--moderate-glow-amount) * 1.5) var(--accent-glow-color);
    --slider-thumb: var(--text-primary);
    --slider-track: #303C55;
    --border-color: #64ffda33;
    --button-bg: transparent;
    --button-text: var(--text-primary);
    --button-border: 1px solid var(--text-primary);
    --button-hover-bg: #64ffda1a;
    --button-hover-text: var(--text-primary);
    --leader-card-overlay: rgba(23, 42, 69, 0.85);
    --font-titles: var(--font-secondary);
}

/* 2. NEON PULSE (Pink - Ramped up glow) */
html.theme-neon-pulse {
    --bg-primary: #1a001a;
    --bg-secondary: #2c002c;
    --bg-tertiary: #3f003f;
    --text-primary: #ff00ff;
    --text-secondary: #f0e6f0;
    --text-muted: #a894a8;
    --accent-glow-color: var(--text-primary);
    --accent-glow: 0 0 var(--moderate-glow-amount) var(--accent-glow-color), 0 0 calc(var(--moderate-glow-amount) * 1.5) var(--accent-glow-color);
    --slider-thumb: var(--text-primary);
    --slider-track: #593359;
    --border-color: #ff00ff33;
    --button-bg: transparent;
    --button-text: var(--text-primary);
    --button-border: 1px solid var(--text-primary);
    --button-hover-bg: #ff00ff1a;
    --button-hover-text: var(--text-primary);
    --leader-card-overlay: rgba(44, 0, 44, 0.85);
    --font-titles: var(--font-secondary);
}


/* 3. NEON CRIMSON (Red/Magenta - Ramped up glow) */
html.theme-neon-crimson {
    --bg-primary: #200000;
    --bg-secondary: #300000;
    --bg-tertiary: #400a0a;
    --text-primary: #ff4757;
    --text-secondary: #f5f6fa;
    --text-muted: #a4b0be;
    --accent-glow-color: var(--text-primary);
    --accent-glow: 0 0 var(--moderate-glow-amount) var(--accent-glow-color), 0 0 calc(var(--moderate-glow-amount) * 1.5) var(--accent-glow-color);
    --slider-thumb: var(--text-primary);
    --slider-track: #573333;
    --border-color: #ff475733;
    --button-bg: transparent;
    --button-text: var(--text-primary);
    --button-border: 1px solid var(--text-primary);
    --button-hover-bg: #ff47571a;
    --button-hover-text: var(--text-primary);
    --leader-card-overlay: rgba(48, 0, 0, 0.85);
    --font-titles: var(--font-secondary);
}
/* 4. NEON VIRIDIS (Green - Ramped up glow) */
html.theme-neon-viridis {
    --bg-primary: #011607;
    --bg-secondary: #022c0d;
    --bg-tertiary: #033f14;
    --text-primary: #39ff14;
    --text-secondary: #e0f0e0;
    --text-muted: #708f70;
    --accent-glow-color: var(--text-primary);
    --accent-glow: 0 0 var(--moderate-glow-amount) var(--accent-glow-color), 0 0 calc(var(--moderate-glow-amount) * 1.5) var(--accent-glow-color);
    --slider-thumb: var(--text-primary);
    --slider-track: #1f4c2a;
    --border-color: #39ff1433;
    --button-bg: transparent;
    --button-text: var(--text-primary);
    --button-border: 1px solid var(--text-primary);
    --button-hover-bg: #39ff141a;
    --button-hover-text: var(--text-primary);
    --leader-card-overlay: rgba(2, 44, 13, 0.85);
    --font-titles: var(--font-secondary);
}

/* 5. BUBBLEGUM POP (Neon Candy Pink! - Ramped up glow, distinct from Neon Pulse) */
html.theme-bubblegum-pop {
    --bg-primary: #2c001e;
    --bg-secondary: #44002a;
    --bg-tertiary: #5a0035;
    --text-primary: #ff69b4;
    --text-secondary: #ffe0f0;
    --text-muted: #ffaad5;
    --accent-alt: #00e0e0;
    --accent-glow-color: var(--text-primary);
    --accent-glow: 0 0 var(--moderate-glow-amount) var(--accent-glow-color), 0 0 calc(var(--moderate-glow-amount) * 1.5) var(--accent-glow-color);
    --slider-thumb: var(--text-primary);
    --slider-track: #77335f;
    --border-color: #ff69b440;
    --button-bg: var(--text-primary);
    --button-text: var(--bg-primary);
    --button-border: 1px solid var(--text-primary);
    --button-hover-bg: #ff8cc6;
    --button-hover-text: var(--bg-primary);
    --leader-card-overlay: rgba(68, 0, 42, 0.85);
    --font-titles: var(--font-script);
}
html.theme-bubblegum-pop .points-tracker span,
html.theme-bubblegum-pop #modal-country-total-score,
html.theme-bubblegum-pop .slider-value {
    color: var(--accent-alt);
    text-shadow: 0 0 var(--moderate-glow-amount) var(--accent-alt);
}
html.theme-bubblegum-pop header h1 {
    font-family: var(--font-display);
    font-size: 3rem;
}


/* 6. DISCO FEVER (Glitter & Gold - "Campy" Vibe) */
html.theme-disco-fever {
    --bg-primary: #111;
    --bg-secondary: #222;
    --bg-tertiary: #333;
    --text-primary: #ffd700;
    --text-secondary: #f0f0f0;
    --text-muted: #aaa;
    --accent-alt: #ff00ff;
    --accent-glow: 0 0 3px #fff, 0 0 6px #fff, 0 0 9px var(--text-primary); /* Enhanced Sparkle */
    --accent-glow-property: box-shadow;
    --slider-thumb: var(--text-primary);
    --slider-track: #444;
    --border-color: #ffd70070;
    --button-bg: var(--text-primary);
    --button-text: #111;
    --button-border: 1px solid var(--text-primary);
    --button-hover-bg: var(--accent-alt);
    --button-hover-text: #fff;
    --leader-card-overlay: linear-gradient(45deg, rgba(0,0,0,0.7), rgba(50,0,50,0.8));
    --font-titles: var(--font-display);
}
html.theme-disco-fever header {
    box-shadow: 0 2px 10px var(--accent-alt);
}
html.theme-disco-fever .action-button {
    text-transform: uppercase;
    letter-spacing: 1px;
}
html.theme-disco-fever #modal-country-name {
    color: var(--accent-alt);
    text-shadow: 0 0 7px var(--accent-alt);
}

/* 7. INTERSTELLAR BALLAD (Cosmic Eurovision Vibe - Ramped up glow) */
html.theme-interstellar-ballad {
    --bg-primary: #0c011f;
    --bg-secondary: #1d0f36;
    --bg-tertiary: #2f1d4d;
    --text-primary: #9d72ff;
    --text-secondary: #e6dcf7;
    --text-muted: #a092b8;
    --accent-alt: #00f5d4;
    --accent-glow: 0 0 var(--moderate-glow-amount) var(--accent-alt), 0 0 calc(var(--moderate-glow-amount) * 1.5) var(--accent-alt); /* Star-like twinkle */
    --accent-glow-property: text-shadow;
    --slider-thumb: var(--text-primary);
    --slider-track: #4a3b68;
    --border-color: #9d72ff50;
    --button-bg: transparent;
    --button-text: var(--text-primary);
    --button-border: 1px solid var(--text-primary);
    --button-hover-bg: #9d72ff20;
    --button-hover-text: var(--text-primary);
    --leader-card-overlay: rgba(29, 15, 54, 0.88);
    --font-titles: var(--font-secondary);
}
html.theme-interstellar-ballad .points-tracker span,
html.theme-interstellar-ballad #modal-country-total-score,
html.theme-interstellar-ballad .slider-value,
html.theme-interstellar-ballad .category-icon {
    color: var(--accent-alt);
    text-shadow: var(--accent-glow);
}

/* 8. FOLKLORE FIRE (Renamed - Vibrant & Earthy Eurovision Vibe) */
html.theme-folklore-fire {
    --bg-primary: #3d2c22;
    --bg-secondary: #5c4335;
    --bg-tertiary: #7a5b4a;
    --text-primary: #ff8c00;
    --text-secondary: #f5e9e0;
    --text-muted: #b8a49a;
    --accent-alt: #40e0d0;
    --accent-gold: #daa520;
    --accent-glow: none;
    --slider-thumb: var(--text-primary);
    --slider-track: #8c7365;
    --border-color: #ff8c0060;
    --button-bg: var(--text-primary);
    --button-text: #3d2c22;
    --button-border: 1px solid var(--text-primary);
    --button-hover-bg: #e67e00;
    --button-hover-text: #3d2c22;
    --leader-card-overlay: rgba(92, 67, 53, 0.8);
    --font-titles: var(--font-primary);
}
html.theme-folklore-fire h2 {
    font-family: var(--font-display);
    color: var(--accent-gold);
    border-bottom-color: var(--accent-gold);
}
html.theme-folklore-fire #modal-country-name {
    color: var(--accent-gold);
}
html.theme-folklore-fire .category-icon {
    color: var(--accent-alt);
}

/* 9. MIDNIGHT GOLD */
html.theme-midnight-gold {
    --bg-primary: #0c1427;
    --bg-secondary: #1c2941;
    --bg-tertiary: #2d3d5a;
    --text-primary: #ffd700;
    --text-secondary: #e0e6f1;
    --text-muted: #90a0b7;
    --accent-glow: none;
    --slider-thumb: #ffd700;
    --slider-track: #4b5a78;
    --border-color: #ffd70050;
    --button-bg: #ffd700;
    --button-text: #0c1427;
    --button-border: 1px solid #ffd700;
    --button-hover-bg: #e6c300;
    --button-hover-text: #0c1427;
    --leader-card-overlay: rgba(28, 41, 65, 0.8);
    --font-titles: var(--font-primary);
}
/* 10. ARCTIC AURORA */
html.theme-arctic-aurora {
    --bg-primary: #011627;
    --bg-secondary: #0b2538;
    --bg-tertiary: #13364f;
    --text-primary: #7f5af0;
    --text-secondary: #d8deeb;
    --text-muted: #8c9bb1;
    --accent-alt: #2cb67d;
    --accent-glow: none;
    --slider-thumb: #7f5af0;
    --slider-track: #2e4d64;
    --border-color: #7f5af040;
    --button-bg: #7f5af0;
    --button-text: #d8deeb;
    --button-border: 1px solid #7f5af0;
    --button-hover-bg: #6b44d6;
    --button-hover-text: #d8deeb;
    --leader-card-overlay: rgba(11, 37, 56, 0.85);
    --font-titles: var(--font-primary);
}
html.theme-arctic-aurora .action-button.reset-button {
    background-color: var(--accent-alt);
    border-color: var(--accent-alt);
    color: var(--bg-primary);
}
html.theme-arctic-aurora .action-button.reset-button:hover {
    background-color: #239566;
}
/* 11. SOLARIZED DARK */
html.theme-solarized-dark {
    --bg-primary: #002b36;
    --bg-secondary: #073642;
    --bg-tertiary: #001f27;
    --text-primary: #268bd2;
    --text-secondary: #839496;
    --text-muted: #586e75;
    --accent-yellow: #b58900;
    --accent-orange: #cb4b16;
    --accent-red: #dc322f;
    --accent-magenta: #d33682;
    --accent-violet: #6c71c4;
    --accent-cyan: #2aa198;
    --accent-green: #859900;
    --accent-glow: none;
    --slider-thumb: var(--accent-cyan);
    --slider-track: #003f4f;
    --border-color: #073642;
    --button-bg: var(--accent-blue, var(--text-primary)); /* Fallback for accent-blue */
    --button-text: var(--bg-primary);
    --button-border: 1px solid var(--accent-blue, var(--text-primary));
    --button-hover-bg: #1e7cb9;
    --button-hover-text: var(--bg-primary);
    --leader-card-overlay: rgba(0, 43, 54, 0.8);
    --font-titles: var(--font-mono);
}
html.theme-solarized-dark .points-tracker span,
html.theme-solarized-dark #modal-country-total-score,
html.theme-solarized-dark .slider-value {
    color: var(--accent-yellow);
}
html.theme-solarized-dark .action-button.reset-button {
    background-color: var(--accent-red);
    border-color: var(--accent-red);
    color: var(--bg-primary); /* Ensure contrast for text on red button */
}
/* 12. MONOKAI PRO */
html.theme-monokai-pro {
    --bg-primary: #2D2A2E;
    --bg-secondary: #3E3A3F;
    --bg-tertiary: #221F22;
    --text-primary: #FF6188;
    --text-secondary: #FCFCFA;
    --text-muted: #727072;
    --accent-orange: #FC9867;
    --accent-yellow: #FFD866;
    --accent-green: #A9DC76;
    --accent-blue: #78DCE8;
    --accent-purple: #AB9DF2;
    --accent-glow: none;
    --slider-thumb: var(--accent-yellow);
    --slider-track: #4a464b;
    --border-color: #4a464b;
    --button-bg: var(--accent-blue);
    --button-text: var(--bg-primary);
    --button-border: 1px solid var(--accent-blue);
    --button-hover-bg: #61cddc;
    --button-hover-text: var(--bg-primary);
    --leader-card-overlay: rgba(45, 42, 46, 0.8);
    --font-titles: var(--font-mono);
}
html.theme-monokai-pro .points-tracker span,
html.theme-monokai-pro #modal-country-total-score,
html.theme-monokai-pro .slider-value {
    color: var(--accent-green);
}
html.theme-monokai-pro .action-button.reset-button {
    background-color: var(--accent-orange);
    border-color: var(--accent-orange);
    color: var(--bg-primary);
}
/* 13. CLASSIC ENHANCED DARK */
html.theme-classic-enhanced {
    --bg-primary: #1e1e2f;
    --bg-secondary: #27293d;
    --bg-tertiary: #161625;
    --text-primary: #82aaff;
    --text-secondary: #c3c7d9;
    --text-muted: #696d8a;
    --accent-alt: #c792ea;
    --accent-success: #c3e88d;
    --accent-warning: #ffcb6b;
    --accent-danger: #f07178;
    --accent-glow: none;
    --slider-thumb: var(--text-primary);
    --slider-track: #3a3c53;
    --border-color: #3a3c53;
    --button-bg: var(--text-primary);
    --button-text: var(--bg-primary);
    --button-border: 1px solid var(--text-primary);
    --button-hover-bg: #6f93e8;
    --button-hover-text: var(--bg-primary);
    --leader-card-overlay: rgba(39, 41, 61, 0.8);
    --font-titles: var(--font-primary);
}
html.theme-classic-enhanced #modal-country-name {
    color: var(--accent-alt);
}
html.theme-classic-enhanced .points-tracker span,
html.theme-classic-enhanced #modal-country-total-score,
html.theme-classic-enhanced .slider-value {
    color: var(--accent-success);
}
html.theme-classic-enhanced .action-button.reset-button {
    background-color: var(--accent-danger);
    border-color: var(--accent-danger);
    color: var(--bg-primary);
}
html.theme-classic-enhanced #allocation-message.warning {
    color: var(--accent-warning);
}


/* --- DEFAULT THEME APPLICATION (Fallback) --- */
:root:not([class*="theme-"]) {
    --bg-primary: #0a192f;
    --bg-secondary: #172a45;
    --bg-tertiary: #0f213a;
    --text-primary: #64ffda;
    --text-secondary: #ccd6f6;
    --text-muted: #8892b0;
    --accent-glow-color: var(--text-primary);
    --accent-glow: 0 0 var(--moderate-glow-amount) var(--accent-glow-color), 0 0 calc(var(--moderate-glow-amount) * 1.5) var(--accent-glow-color);
    --slider-thumb: var(--text-primary);
    --slider-track: #303C55;
    --border-color: #64ffda33;
    --button-bg: transparent;
    --button-text: var(--text-primary);
    --button-border: 1px solid var(--text-primary);
    --button-hover-bg: #64ffda1a;
    --button-hover-text: var(--text-primary);
    --leader-card-overlay: rgba(23, 42, 69, 0.85);
    --font-titles: var(--font-secondary);
}


/* --- GENERAL STYLES (Using theme variables) --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.2s ease-out, color 0.2s ease-out, border-color 0.2s ease-out, box-shadow 0.2s ease-out;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.theme-switcher-container {
    background-color: var(--bg-tertiary, #000);
    padding: 0.5rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color, #333);
}
.theme-switcher-container label {
    margin-right: 0.5rem;
    color: var(--text-muted, #ccc);
    font-size: 0.9rem;
}
#theme-select {
    background-color: var(--bg-secondary, #111);
    color: var(--text-secondary, #eee);
    border: 1px solid var(--border-color, #444);
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    font-family: var(--font-primary);
}


header {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 1.5rem 2rem;
    text-align: center;
    border-bottom: 2px solid var(--text-primary);
    box-shadow: var(--accent-glow-property, text-shadow) var(--accent-glow, none);
}

header h1 {
    margin-bottom: 0.5rem;
    font-family: var(--font-titles, var(--font-secondary));
    font-weight: 700;
    font-size: 2.8rem;
    box-shadow: var(--accent-glow-property, text-shadow) var(--accent-glow, none);
}

.points-tracker p {
    font-size: 1.1rem;
    display: inline-block;
    margin: 0 1rem;
    color: var(--text-secondary);
}
.points-tracker span {
    color: var(--text-primary);
    font-weight: bold;
}

main {
    flex-grow: 1;
    padding: 2rem;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

section {
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

h2 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    font-family: var(--font-titles, var(--font-secondary));
    box-shadow: var(--accent-glow-property, text-shadow) var(--accent-glow, none);
}

.select-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 400px;
}

#country-dropdown {
    width: 100%;
    padding: 0.8rem 1rem;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    appearance: none;
    cursor: pointer;
    font-family: var(--font-primary);
}
#country-dropdown:focus {
    outline: none;
    border-color: var(--text-primary);
    box-shadow: 0 0 var(--moderate-glow-amount) var(--text-primary);
}

.select-wrapper::after {
    content: '▼';
    font-size: 1rem;
    color: var(--text-primary);
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.message {
    margin-top: 1rem;
    font-style: italic;
    color: var(--text-muted);
}

#allocation-message.warning {
    color: var(--text-primary);
    font-weight: bold;
    box-shadow: var(--accent-glow-property, text-shadow) var(--accent-glow, none);
}

#leaders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.leader-card {
    background-color: var(--bg-tertiary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--text-primary);
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    aspect-ratio: 4 / 3;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.leader-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--leader-card-overlay);
    z-index: 1;
}

.leader-card h4,
.leader-card p {
    position: relative;
    z-index: 2;
    color: var(--text-secondary);
    text-align: center;
}

.leader-card h4 {
    font-size: clamp(1rem, 4vw, 1.1rem);
    font-family: var(--font-titles, var(--font-secondary));
    margin-bottom: 0.3rem;
    word-break: break-word;
    color: var(--text-primary);
    box-shadow: var(--accent-glow-property, text-shadow) var(--accent-glow, none);
}

.leader-card p {
    font-size: clamp(0.8rem, 3vw, 0.9rem);
}
.leader-card .winner-name {
    font-weight: bold;
    color: var(--text-primary);
}
.leader-card .score-display {
    color: var(--text-secondary);
}

.country-list-table-container {
    margin-top: 1rem;
    overflow-x: auto;
}

.country-list-table {
    width: 100%;
    border-collapse: collapse;
}

.country-list-table th, .country-list-table td {
    border: 1px solid var(--border-color);
    padding: 0.6rem 0.8rem;
    text-align: left;
}

.country-list-table th {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-titles, var(--font-primary));
}

.country-list-table td {
    background-color: transparent;
    font-size: 0.95rem;
}
.country-list-table tr:nth-child(even) td {
    background-color: rgba(0,0,0,0.05);
}

.country-list-table .country-cell {
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.country-list-table .country-cell:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.country-list-table .country-cell img {
    width: 24px;
    height: auto;
    margin-right: 10px;
    border-radius: 2px;
    border: 1px solid var(--border-color);
}

.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.75); animation: fadeIn 0.3s ease-out; }
.modal-content { background-color: var(--bg-secondary); margin: 5% auto; padding: 25px; border: 1px solid var(--border-color); border-top: 3px solid var(--text-primary); border-radius: 10px; width: 90%; max-width: 700px; /* Increased max-width for video */ box-shadow: 0 5px 20px rgba(0,0,0,0.4); position: relative; animation: slideIn 0.3s ease-out; }
.close-button { color: var(--text-muted); position: absolute; top: 15px; right: 20px; font-size: 28px; font-weight: bold; cursor: pointer; box-shadow: none;}
.close-button:hover, .close-button:focus { color: var(--text-primary); box-shadow: var(--accent-glow-property, text-shadow) var(--accent-glow, none); }
.modal-points-tracker { background-color: var(--bg-tertiary); padding: 0.75rem 1rem; border-radius: 5px; margin-bottom: 1rem; text-align: center; border: 1px solid var(--border-color);}
.modal-points-tracker p { font-size: 0.9rem; color: var(--text-secondary); margin: 0.2rem 0; }
.modal-points-tracker span { font-weight: bold; color: var(--text-primary); }

.modal-header {
    display: flex;
    align-items: center; /* Vertically align items */
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    flex-wrap: wrap; /* Allow wrapping if space is tight */
}

.modal-country-flag {
    width: 60px; /* Or your preferred size */
    height: auto;
    margin-right: 15px;
    border-radius: 4px;
    border: 1px solid var(--text-muted);
    align-self: flex-start; /* Align flag to the top if content wraps */
}

.modal-header > div { /* This is the div holding country name, song, order */
    flex-grow: 1; /* Allow text block to take available space */
    min-width: 200px; /* Prevent text block from becoming too small */
    margin-right: 15px; /* Space between text and video */
}

#modal-video-preview-container {
    width: 200px; /* Desired width for the video preview */
    height: 113px; /* Corresponding height for 16:9 aspect ratio */
    background-color: #000; /* Optional: Placeholder background */
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden; /* Ensures iframe corners are rounded if container has border-radius */
    flex-shrink: 0; /* Prevent video from shrinking if text is long */
}

#modal-video-preview-container iframe {
    width: 100%;
    height: 100%;
    display: block; /* Remove extra space below iframe */
}


#modal-country-name { font-size: 1.8rem; color: var(--text-primary); font-family: var(--font-titles, var(--font-secondary)); box-shadow: var(--accent-glow-property, text-shadow) var(--accent-glow, none);}
#modal-song-info, #modal-running-order { font-size: 0.9rem; color: var(--text-muted); }
.slider-group { margin-bottom: 1.5rem; }
.slider-group label { display: block; margin-bottom: 0.5rem; font-weight: bold; font-size: 1.1rem; color: var(--text-secondary); }
.slider-group label .category-icon { margin-right: 8px; font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; color: var(--text-primary); box-shadow: var(--accent-glow-property, text-shadow) var(--accent-glow, none);}
.slider-group .category-description { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; font-weight: normal; }
.slider-container { display: flex; align-items: center; } /* Added for slider alignment */

input[type="range"] { flex-grow: 1; -webkit-appearance: none; appearance: none; width: 100%; height: 10px; background: var(--slider-track); outline: none; border-radius: 5px; cursor: pointer; border: 1px solid var(--border-color); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; background: var(--slider-thumb); border-radius: 50%; cursor: pointer; border: 2px solid var(--bg-secondary); box-shadow: 0 0 var(--moderate-glow-amount) var(--slider-thumb); }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; background: var(--slider-thumb); border-radius: 50%; cursor: pointer; border: 2px solid var(--bg-secondary); box-shadow: 0 0 var(--moderate-glow-amount) var(--slider-thumb); }
.slider-value { min-width: 30px; text-align: right; font-weight: bold; color: var(--text-primary); font-size: 1.1rem; box-shadow: var(--accent-glow-property, text-shadow) var(--accent-glow, none); margin-left: 10px; } /* Added margin-left */
#modal-country-total-score { font-weight: bold; color: var(--text-primary); box-shadow: var(--accent-glow-property, text-shadow) var(--accent-glow, none);}

.action-button {
    background-color: var(--button-bg);
    color: var(--button-text);
    padding: 0.8rem 1.5rem;
    border: var(--button-border, 1px solid transparent);
    border-radius: 5px;
    font-size: 1rem;
    font-family: var(--font-titles, var(--font-secondary));
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: block;
    margin: 1rem auto;
    text-shadow: none;
}
.action-button:hover {
    background-color: var(--button-hover-bg);
    color: var(--button-hover-text, var(--button-text));
    box-shadow: 0 0 var(--strong-glow-amount) var(--text-primary);
    border-color: var(--text-primary);
}
.action-button.reset-button {
    background-color: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
    margin-top: 2rem;
}
.action-button.reset-button:hover {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: 0 0 var(--strong-glow-amount) var(--text-primary);
    border-color: var(--text-primary);
}


#final-scoreboard-table-container { margin-top: 1rem; overflow-x: auto; }
#final-scoreboard { width: 100%; border-collapse: collapse; margin-top: 1rem; }
#final-scoreboard th, #final-scoreboard td { border: 1px solid var(--border-color); padding: 0.8rem; text-align: left; }
#final-scoreboard th { background-color: var(--bg-tertiary); color: var(--text-primary); font-family: var(--font-titles, var(--font-primary)); }
#final-scoreboard td { background-color: transparent; }
#final-scoreboard tr:nth-child(even) td { background-color: rgba(0,0,0,0.05); }
.country-cell-final { display: flex; align-items: center; }
.country-cell-final img { width: 24px; height: auto; margin-right: 8px; border: 1px solid var(--border-color); }

footer {
    text-align: center;
    padding: 1.5rem;
    background-color: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

@media (max-width: 768px) {
    header h1 { font-size: 2.2rem; }
    main { padding: 1rem; }
    .modal-content { max-width: 95%; } /* Adjust for smaller screens */
    .modal-header { flex-direction: column; align-items: flex-start; } /* Stack header items */
    .modal-header > div { margin-right: 0; margin-bottom: 10px; width: 100%;} /* Text block full width */
    #modal-video-preview-container { margin-left: 0; margin-top: 10px; width: 100%; height: auto; aspect-ratio: 16 / 9;} /* Video full width, maintain aspect ratio */

    .theme-switcher-container { text-align: center; padding: 0.75rem; }
    .theme-switcher-container label { display: block; margin-bottom: 0.3rem;}
    #leaders-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

@media (max-width: 480px) {
    header h1 { font-size: 1.8rem; }
    #leaders-grid { grid-template-columns: 1fr; }
    .country-list-table th:first-child, .country-list-table td:first-child { width: auto; }
    .country-list-table th:last-child, .country-list-table td:last-child { width: auto; text-align: left; }
    .modal-content { margin: 2% auto; width: 96%; padding: 15px;}
    #modal-country-name { font-size: 1.5rem;}
    .slider-group label {font-size: 1rem;}
    .action-button { padding: 0.7rem 1.2rem; font-size: 0.9rem;}
}

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