/**
 * Playful Design System v2 for In-or-Out
 * Complete redesign with proper contrast and cohesive candy theme
 */

/* Import playful fonts - including weight 900 for bold room codes! */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700;800;900&family=Quicksand:wght@400;500;600;700;800;900&display=swap');

/* Root color variables - Enhanced Candy Theme with Better Contrast */
:root {
    /* Primary Colors */
    --color-in: #4ECDC4;      /* Soft teal */
    --color-out: #FF6B9D;     /* Bubblegum pink */
    --primary: #FFC75F;       /* Warm sunny yellow */
    
    /* Background gradient - slightly darker for better contrast */
    --bg-start: #FFD89B;      /* Warmer yellow */
    --bg-middle: #F5A09E;     /* Deeper peach */
    --bg-end: #ED6EA0;        /* Richer pink */
    --bg-accent: #8B7FD8;     /* Deeper purple */
    
    /* Dark colors for contrast */
    --dark-purple: #4A3C7D;   /* Dark purple for text */
    --dark-pink: #C2185B;     /* Dark pink for accents */
    --dark-teal: #00796B;     /* Dark teal for buttons */
    
    /* Container backgrounds - better contrast */
    --container-bg: rgba(255, 255, 255, 0.85);
    --container-border: rgba(255, 255, 255, 0.95);
    --container-shadow: rgba(74, 60, 125, 0.25);
    
    /* Text colors */
    --text-primary: #4A3C7D;   /* Dark purple for main text */
    --text-secondary: #6B5B95;  /* Medium purple */
    --text-light: #FFFFFF;      /* White for dark backgrounds */
    
    /* Button colors */
    --btn-primary-bg: #FFC75F;
    --btn-primary-text: #4A3C7D;
    --btn-hover-shadow: rgba(255, 199, 95, 0.6);
}

/* Enhanced gradient background */
body {
    background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-middle) 35%, var(--bg-end) 65%, var(--bg-accent) 100%) !important;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

/* Remove any existing background pseudo-elements */
body::before {
    display: none !important;
}

/* Enhanced floating bubbles */
.bubble {
    position: fixed;
    border-radius: 50%;
    opacity: 0;
    animation: floatBubble var(--duration) infinite ease-in;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.9), rgba(255,255,255,0.4));
    box-shadow: 
        0 0 20px rgba(255,255,255,0.6),
        inset 0 0 20px rgba(255,255,255,0.2);
    backdrop-filter: blur(2px);
}

@keyframes floatBubble {
    0% { 
        transform: translateY(100vh) translateX(0) scale(0);
        opacity: 0;
    }
    10% { 
        opacity: 0.8;
    }
    50% {
        transform: translateY(50vh) translateX(var(--wobble)) scale(1);
        opacity: 0.6;
    }
    100% { 
        transform: translateY(-100vh) translateX(calc(var(--wobble) * -1)) scale(0.8);
        opacity: 0;
    }
}

/* Bubble instances */
.bubble:nth-child(1) { width: 60px; height: 60px; left: 10%; --duration: 15s; --wobble: 40px; animation-delay: 0s; }
.bubble:nth-child(2) { width: 40px; height: 40px; left: 25%; --duration: 18s; --wobble: -50px; animation-delay: 3s; }
.bubble:nth-child(3) { width: 50px; height: 50px; left: 50%; --duration: 20s; --wobble: 30px; animation-delay: 5s; }
.bubble:nth-child(4) { width: 45px; height: 45px; left: 70%; --duration: 16s; --wobble: -40px; animation-delay: 2s; }
.bubble:nth-child(5) { width: 70px; height: 70px; left: 85%; --duration: 22s; --wobble: 35px; animation-delay: 4s; }

/* Logo styling with better contrast */
h1 {
    font-family: 'Fredoka', 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 4.5em;
    color: var(--text-light);
    text-shadow: 
        3px 3px 0px var(--dark-purple),
        6px 6px 20px rgba(0,0,0,0.3);
    animation: wobble 4s ease-in-out infinite;
    letter-spacing: -2px;
    margin: 20px 0;
    text-align: center;
}

@keyframes wobble {
    0%, 100% { transform: rotate(-2deg) scale(1); }
    25% { transform: rotate(2deg) scale(1.02); }
    50% { transform: rotate(-1deg) scale(1); }
    75% { transform: rotate(1deg) scale(0.98); }
}

/* Logo colors with strong shadows */
h1 span.turquoise {
    color: var(--color-in) !important;
    text-shadow: 
        2px 2px 0px var(--dark-teal),
        4px 4px 0px rgba(0,0,0,0.2),
        6px 6px 20px rgba(0,0,0,0.3);
}

h1 span.magenta {
    color: var(--color-out) !important;
    text-shadow: 
        2px 2px 0px var(--dark-pink),
        4px 4px 0px rgba(0,0,0,0.2),
        6px 6px 20px rgba(0,0,0,0.3);
}

/* Enhanced container styling with better contrast - ALLE GAME CONTAINER */
#gameMode, .game-container,
#singleSetup, #multiSetup, #multiChoice, #lobby, #game,
#singlePlayerCollection, #singleRoleReveal, #singleRoleDisplay, 
#singleQuestions, #singleSummary, #singleVoting, #singleResults,
#multiRoleDisplay {
    background: var(--container-bg) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 2px solid var(--container-border) !important;
    border-radius: 25px !important;
    box-shadow: 
        0 10px 25px var(--container-shadow),
        0 4px 10px rgba(0,0,0,0.1),
        inset 0 1px 0 rgba(255,255,255,0.9) !important;
    padding: 25px !important;
    position: relative;
    overflow: hidden;
    color: var(--text-primary) !important;
    max-width: 500px;
    margin: 20px auto;
}

/* Text styling for better readability */
h2 {
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 2rem;  /* Define h2 size */
    color: var(--text-primary) !important;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
    margin-bottom: 20px;
}

h3 {
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 1.5rem;  /* Define h3 size */
    color: var(--text-primary) !important;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
    margin-bottom: 20px;
}

p, .description-text, label {
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    color: var(--text-primary) !important;
    line-height: 1.6;
    text-shadow: 0 1px 2px rgba(255,255,255,0.5);
}

/* Enhanced button design */
button {
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    background: linear-gradient(135deg, var(--btn-primary-bg) 0%, #FFB700 100%) !important;
    color: var(--text-primary) !important;
    border: 2px solid rgba(255,255,255,0.9) !important;
    border-radius: 20px;
    padding: 14px 28px;
    font-size: 1.05em;
    box-shadow: 
        0 6px 20px rgba(255, 199, 95, 0.3),
        0 3px 8px rgba(0,0,0,0.1),
        inset 0 2px 4px rgba(255,255,255,0.8);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
    max-width: 320px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    display: block !important;
    overflow: hidden;
    text-transform: none;
    letter-spacing: 0.3px;
}

/* Exclude round/close buttons from max-width restriction */
button.overlay-close,
button.sound-toggle,
button.tutorial-trigger,
button.stats-button,
button[style*="border-radius: 50%"],
button[style*="width: 30px"],
button[style*="width: 40px"],
button[style*="width: 50px"],
button[style*="width: 60px"] {
    max-width: none !important;
    margin: 0 !important;
    display: inline-flex !important;
}

button:hover {
    transform: translateY(-4px) scale(1.05) rotate(-1deg);
    box-shadow: 
        0 12px 35px var(--btn-hover-shadow),
        0 6px 15px rgba(0,0,0,0.15),
        inset 0 2px 4px rgba(255,255,255,0.9);
}

/* PROPER ROOM CODE STYLING WITH HIGH SPECIFICITY */
/* Base room code display class */
.room-code-display {
    font-family: 'Fredoka', 'Arial Black', 'Impact', sans-serif !important;
    font-weight: 900 !important;
    text-align: center !important;
    display: block !important;
    transition: all 0.3s ease !important;
    text-transform: uppercase !important;  /* Make it even bolder looking */
}

/* Old large room code rules removed - using single-frame class instead */

/* Force room code to be MASSIVE compared to title */
#lobby h2 {
    font-size: 1.8rem !important;  /* Make title smaller */
    font-weight: 600 !important;
}

/* Old override rules removed - using single-frame class instead */

/* Joined room code for non-host players */
.room-code-display.room-code-joined,
#joinedRoomCode.room-code-joined,
#nonHostControls .room-code-display.room-code-joined {
    font-size: 3.5rem !important;
    color: #FFD60A !important;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%) !important;
    padding: 1.5rem 2rem !important;
    border-radius: 15px !important;
    display: block !important;
    min-width: 280px !important;
    width: auto !important;
    max-width: 90% !important;
    text-align: center !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3) !important;
    border: 3px solid rgba(255, 214, 10, 0.8) !important;
    box-shadow: 
        0 8px 25px rgba(255, 214, 10, 0.4),
        0 4px 15px rgba(0,0,0,0.15),
        inset 0 2px 4px rgba(255,255,255,0.9) !important;
    letter-spacing: 0.5rem !important;
    animation: roomCodePulse 3s ease-in-out infinite !important;
    margin: 0.5rem 0 !important;
}


/* EXTRA HIGHLIGHT für Room-Code Text - macht ihn NOCH prominenter */
/* Room code ::before removed - no duplicate text needed */

/* SINGLE FRAME ROOM CODE - Wie vom User gewünscht */
.room-code-single-frame {
    /* Einzelner, eleganter Rahmen */
    border: 4px solid var(--color-in) !important;
    border-radius: 25px !important;
    
    /* Genug Innenabstand für den großen Text */
    padding: 2rem 3.5rem !important;
    
    /* Begrenzte Breite mit gutem Abstand zum Container-Rand */
    max-width: 85% !important;
    width: auto !important;
    
    /* Zentriert mit Außenabstand */
    margin: 1.5rem auto !important;
    
    /* Schöner Hintergrund */
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(10px) !important;
    
    /* Subtiler Schatten */
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.15) !important;
    
    /* Text bleibt groß aber passt in den Container */
    font-size: 3.5rem !important;
    font-weight: 900 !important;
    color: var(--color-primary) !important;
    text-align: center !important;
    
    /* Verhindert Overflow */
    overflow: hidden !important;
    word-break: break-word !important;
}

/* Mobile Anpassung */
@media (max-width: 480px) {
    .room-code-single-frame {
        font-size: 2.5rem !important;
        padding: 1.5rem 2.5rem !important;
        max-width: 90% !important;
    }
}

/* Lobby specific room code container */
#lobby > div:nth-child(2) {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 2px solid var(--bg-accent) !important;  /* Purple border */
    border-radius: 20px !important;
    padding: 15px !important;
    margin: 15px auto !important;
    box-shadow: 0 4px 15px rgba(139, 127, 216, 0.15) !important;
}

#lobby > div:nth-child(2) > div:first-child {
    color: var(--text-primary) !important;
    font-size: 0.85em !important;
    font-weight: 600 !important;
}

#lobby > div:nth-child(2) > div:last-child {
    color: var(--text-secondary) !important;
    font-size: 0.75em !important;
    opacity: 1 !important;
}

/* Enhanced form inputs */
input[type="text"], input[type="number"], select {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 2px solid var(--bg-accent) !important;  /* Purple border */
    border-radius: 15px;
    padding: 12px 20px;
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    color: var(--text-primary) !important;
    font-size: 1em;
    transition: all 0.3s ease;
    box-shadow: 
        0 3px 8px rgba(139, 127, 216, 0.15),
        inset 0 1px 3px rgba(0,0,0,0.05);
    width: 100%;
    box-sizing: border-box;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
}

input[type="text"]:focus, input[type="number"]:focus, select:focus {
    outline: none;
    border-color: var(--color-out) !important;
    background: rgba(255, 255, 255, 1) !important;
    transform: scale(1.02);
    box-shadow: 
        0 6px 20px rgba(255, 107, 157, 0.3),
        inset 0 1px 3px rgba(0,0,0,0.05);
}

/* Dropdown styling */
select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234A3C7D' 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 15px center;
    background-size: 20px;
    padding-right: 50px;
}

/* Redesigned bottom control buttons */
.sound-controls {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
}

.sound-toggle, .tutorial-trigger, .stats-button {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    border: none !important;
    color: var(--text-light) !important;
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease;
    position: fixed !important;
    bottom: 20px;
    padding: 0 !important;
}

/* Sound button - teal theme */
.sound-toggle {
    background: rgba(78, 205, 196, 0.9) !important;
    left: 20px;
    box-shadow: 
        0 3px 10px rgba(78, 205, 196, 0.4),
        0 2px 5px rgba(0,0,0,0.1) !important;
}

.sound-toggle:hover {
    transform: scale(1.1);
    background: rgba(78, 205, 196, 1) !important;
    box-shadow: 
        0 4px 15px rgba(78, 205, 196, 0.5),
        0 2px 8px rgba(0,0,0,0.15) !important;
}

/* Tutorial button - purple theme */
.tutorial-trigger {
    background: rgba(139, 127, 216, 0.9) !important;
    left: 70px;
    box-shadow: 
        0 3px 10px rgba(139, 127, 216, 0.4),
        0 2px 5px rgba(0,0,0,0.1) !important;
}

.tutorial-trigger:hover {
    transform: scale(1.1);
    background: rgba(139, 127, 216, 1) !important;
    box-shadow: 
        0 4px 15px rgba(139, 127, 216, 0.5),
        0 2px 8px rgba(0,0,0,0.15) !important;
}

/* Stats button - pink theme */
.stats-button {
    background: rgba(255, 107, 157, 0.9) !important;
    bottom: 20px;
    right: 20px;
    left: auto;
    box-shadow: 
        0 3px 10px rgba(255, 107, 157, 0.4),
        0 2px 5px rgba(0,0,0,0.1) !important;
}

.stats-button:hover {
    transform: scale(1.1);
    background: rgba(255, 107, 157, 1) !important;
    box-shadow: 
        0 4px 15px rgba(255, 107, 157, 0.5),
        0 2px 8px rgba(0,0,0,0.15) !important;
}

/* Icon styling for control buttons */
.sound-toggle svg, .tutorial-trigger svg, .stats-button svg {
    width: 20px !important;
    height: 20px !important;
    stroke-width: 2 !important;
}

/* ULTIMATE ANTI-DISTORTION: Control Buttons - KEINE Container-Verzerrung möglich */
button.sound-toggle, 
button.tutorial-trigger, 
button.stats-button,
.sound-controls button,
div.sound-toggle,
div.tutorial-trigger,
div.stats-button {
    /* SIZE - ABSOLUT FEST */
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    
    /* SHAPE - PERFEKT RUND */
    border-radius: 50% !important;
    aspect-ratio: 1 !important;
    
    /* SPACING - NULL */
    padding: 0 !important;
    margin: 0 !important;
    
    /* FLEX CONTROL - KEINE Verzerrung */
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    flex-basis: auto !important;
    
    /* ANTI-DISTORTION - Verhindert Container-Einflüsse */
    box-sizing: border-box !important;
    overflow: visible !important;
    white-space: nowrap !important;
    
    /* LAYOUT RESET */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    
    /* POSITION CONTROL */
    position: fixed !important;
    z-index: 9999 !important;
}

/* Player avatars/tags */
.player-tag, ul#playerList li {
    background: linear-gradient(135deg, var(--color-in) 0%, #7DD3C0 100%) !important;
    color: var(--text-light) !important;
    padding: 8px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 8px;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 0.75em;
    min-width: 60px;
    width: 60px;
    height: 60px;
    text-align: center;
    box-shadow: 
        0 4px 15px rgba(78, 205, 196, 0.3),
        inset 0 2px 4px rgba(255,255,255,0.3);
    animation: bounceIn 0.5s ease-out;
    border: 2px solid rgba(255,255,255,0.5);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}

/* Hover effect to show it's interactive */
ul#playerList li:hover {
    transform: scale(1.1);
    box-shadow: 
        0 6px 20px rgba(78, 205, 196, 0.4),
        inset 0 2px 4px rgba(255,255,255,0.4);
    z-index: 10;
}

/* Tooltip styling for full name display */
ul#playerList li[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 6px 12px;
    background: rgba(74, 60, 125, 0.95);
    color: white;
    border-radius: 8px;
    font-size: 0.85em;
    white-space: nowrap;
    pointer-events: none;
    animation: fadeIn 0.2s ease;
}

ul#playerList li[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 2px;
    border: 6px solid transparent;
    border-top-color: rgba(74, 60, 125, 0.95);
    pointer-events: none;
    animation: fadeIn 0.2s ease;
}

/* Position relative for tooltip */
ul#playerList li {
    position: relative;
}

/* Error messages - friendly style */
.error, #singleSetupError, #multiSetupError, #multiChoiceError {
    background: linear-gradient(135deg, #FFB6B6 0%, var(--accent-orange) 100%) !important;
    color: var(--text-primary) !important;
    padding: 16px 28px;
    border-radius: 20px;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    box-shadow: 
        0 6px 20px rgba(243, 129, 129, 0.3),
        inset 0 2px 4px rgba(255,255,255,0.5);
    animation: shake 0.5s ease-in-out;
    border: 3px solid rgba(255,255,255,0.8);
    margin: 15px 0;
}

/* Mode selection buttons enhancement */
.mode-button {
    background: var(--container-bg) !important;
    border: 4px solid var(--color-out) !important;  /* Pink border instead of yellow */
    color: var(--text-primary) !important;
    font-size: 1.3em;
    padding: 25px 35px;
    margin: 20px auto;
    animation: floatButton 3s ease-in-out infinite;
    animation-delay: var(--delay);
    text-shadow: none;
    max-width: 90%;
    box-shadow: 
        0 6px 20px rgba(255, 107, 157, 0.2),
        0 3px 10px rgba(0,0,0,0.1);
    display: flex !important;
    align-items: center !important;
    gap: 25px !important;  /* Größerer Abstand zwischen Icon und Text */
    text-align: left !important;
}

.mode-button:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%) !important;
    border-color: var(--bg-accent) !important;  /* Purple on hover */
    transform: translateY(-8px) scale(1.08) rotate(-2deg);
    box-shadow: 
        0 10px 30px rgba(139, 127, 216, 0.3),
        0 5px 15px rgba(0,0,0,0.15);
}

/* 🎨 ULTRA-GROẞE SPIELMODUS-ICONS - 4X GRÖẞER! */
.mode-button .icon-3d {
    width: 120px !important;  /* 4X größer als vorher (von ~30px) */
    height: 120px !important;
    min-width: 120px !important;
    min-height: 120px !important;
    flex-shrink: 0 !important;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2)) !important;
    transition: all 0.3s ease !important;
}

.mode-button:hover .icon-3d {
    transform: scale(1.1) rotate(5deg) !important;
    filter: drop-shadow(0 6px 12px rgba(139, 127, 216, 0.4)) !important;
}

/* Text-Content neben den großen Icons */
.mode-button .text-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mode-button .text-content small {
    opacity: 0.8;
    font-size: 0.85em;
    font-weight: 500;
}

/* 📱 MOBILE RESPONSIVE für große Icons */
@media (max-width: 768px) {
    .mode-button .icon-3d {
        width: 80px !important;  /* Etwas kleiner auf Mobile, aber immer noch groß */
        height: 80px !important;
        min-width: 80px !important;
        min-height: 80px !important;
    }
    
    .mode-button {
        gap: 20px !important;
        padding: 20px 25px !important;
        font-size: 1.1em !important;
    }
    
    .mode-button .text-content {
        gap: 6px;
    }
}

/* 🎭 HERO-ICON STYLING - Gleicher attraktiver Stil */
.hero-icon {
    width: 100px !important;  /* Groß und prominent */
    height: 100px !important;
    min-width: 100px !important;
    min-height: 100px !important;
    margin-right: 20px !important;
    vertical-align: middle !important;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2)) !important;
    transition: all 0.3s ease !important;
    flex-shrink: 0 !important;
}

.hero-icon:hover {
    transform: scale(1.05) rotate(2deg) !important;
    filter: drop-shadow(0 6px 12px rgba(139, 127, 216, 0.4)) !important;
}

/* Hero Description Layout */
.hero-description {
    display: flex !important;
    align-items: center !important;
    gap: 20px !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    font-size: 1.3em !important;
    font-weight: 700 !important;
    text-align: center !important;
}

/* Game Mode Container */
#gameMode {
    position: relative !important;
}

/* Mini Language Flags */
.language-flags-mini {
    position: absolute !important;
    top: 15px !important;
    right: 15px !important;
    display: flex !important;
    gap: 8px !important;
    z-index: 10 !important;
}

.language-flag-mini {
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border: 2px solid rgba(255, 255, 255, 0.95) !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    overflow: hidden !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.language-flag-mini img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

.language-flag-mini:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 4px 16px rgba(139, 127, 216, 0.3) !important;
}

.language-flag-mini.selected {
    border-color: #8B7FD8 !important;
    box-shadow: 0 0 0 3px rgba(139, 127, 216, 0.3) !important;
}

/* Mobile Responsive für Hero Icon */
@media (max-width: 768px) {
    .hero-icon {
        width: 70px !important;
        height: 70px !important;
        min-width: 70px !important;
        min-height: 70px !important;
        margin-right: 15px !important;
    }
    
    .hero-description {
        font-size: 1.15em !important;
        gap: 15px !important;
    }
    
    /* Mini flags on mobile */
    .language-flags-mini {
        top: 10px !important;
        right: 10px !important;
        gap: 6px !important;
    }
    
    .language-flag-mini {
        width: 32px !important;
        height: 32px !important;
    }
}

/* Fix any remaining contrast issues */
#multiRoleDisplay h2, #singleRoleDisplay h2,
#summaryContent h2, #votingContent h2,
#resultsContent h2 {
    color: var(--text-primary) !important;
}

/* Ensure all text is readable */
.game-info, .question-display, .voting-breakdown {
    background: rgba(255, 255, 255, 0.9) !important;
    color: var(--text-primary) !important;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* Mobile responsiveness */
@media (max-width: 600px) {
    h1 { 
        font-size: 2.8em; 
        margin: 15px 0;
    }
    
    #gameMode, .game-container,
    #singleSetup, #multiSetup, #multiChoice, #lobby, #game,
    #singlePlayerCollection, #singleRoleReveal, #singleRoleDisplay, 
    #singleQuestions, #singleSummary, #singleVoting, #singleResults,
    #multiRoleDisplay {
        padding: 20px 15px !important;
        margin: 10px !important;
        border-radius: 20px !important;
    }
    
    .sound-toggle, .tutorial-trigger, .stats-button {
        width: 36px !important;
        height: 36px !important;
        bottom: 15px;
    }
    
    .sound-toggle { left: 15px; }
    .tutorial-trigger { left: 60px; }
    .stats-button { right: 15px; }
    
    .sound-toggle svg, .tutorial-trigger svg, .stats-button svg {
        width: 18px !important;
        height: 18px !important;
    }
    
    /* MOBILE ANTI-DISTORTION: Control Buttons - KEINE Container-Verzerrung */
    button.sound-toggle, 
    button.tutorial-trigger, 
    button.stats-button,
    .sound-controls button,
    div.sound-toggle,
    div.tutorial-trigger,
    div.stats-button {
        /* MOBILE SIZE - ABSOLUT FEST */
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        max-width: 36px !important;
        min-height: 36px !important;
        max-height: 36px !important;
        
        /* MOBILE SHAPE - PERFEKT RUND */
        border-radius: 50% !important;
        aspect-ratio: 1 !important;
        
        /* MOBILE ANTI-DISTORTION */
        box-sizing: border-box !important;
        overflow: visible !important;
        position: fixed !important;
        z-index: 9999 !important;
        
        /* MOBILE LAYOUT */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
        flex-grow: 0 !important;
    }
    
    button {
        font-size: 0.95em;
        padding: 12px 24px;
    }
    
    input[type="text"], input[type="number"], select {
        padding: 10px 16px;
        font-size: 0.95em;
    }
    
    /* Mobile room code adjustments */
    .room-code-display.room-code-large,
    #roomCodeDisplay.room-code-large {
        font-size: 4rem !important;
        padding: 1.5rem 2rem !important;
        letter-spacing: 0.5rem !important;
    }
    
    .room-code-display.room-code-joined,
    #joinedRoomCode.room-code-joined {
        font-size: 2.5rem !important;
        padding: 1rem 1.2rem !important;
        letter-spacing: 0.3rem !important;
        min-width: 200px !important;
    }
    
    /* Overlay-Menü Mobile Anpassung */
    .overlay-menu-content {
        min-width: 280px !important;
        max-width: 95vw !important;
        padding: 25px !important;
    }
}

/* Animations */
@keyframes floatButton {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

@keyframes bounceIn {
    0% { transform: scale(0) rotate(180deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px) rotate(-1deg); }
    75% { transform: translateX(10px) rotate(1deg); }
}

@keyframes shakeError {
    0%, 100% { transform: translateX(0) scale(1); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px) scale(1.02); }
    20%, 40%, 60%, 80% { transform: translateX(5px) scale(1.02); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 6px 20px rgba(255, 199, 95, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 8px 30px rgba(255, 199, 95, 0.6); }
}

/* SPEZIELLE ROOM-CODE ANIMATION - ULTRA PROMINENT */
@keyframes roomCodePulse {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 
            0 8px 25px rgba(255, 107, 157, 0.4),
            0 4px 15px rgba(0,0,0,0.15),
            inset 0 2px 4px rgba(255,255,255,0.9);
        border-color: rgba(255, 107, 157, 0.6);
    }
    50% { 
        transform: scale(1.03);  /* Sanfte Vergrößerung */
        box-shadow: 
            0 12px 35px rgba(255, 107, 157, 0.6),
            0 6px 20px rgba(0,0,0,0.2),
            inset 0 3px 6px rgba(255,255,255,1);
        border-color: rgba(255, 107, 157, 0.8);
    }
}

@keyframes fadeIn {
    0% { opacity: 0; transform: translateX(-50%) translateY(5px); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* KOMPAKTE OVERLAY-BUTTONS FÜR SPRACHE & KATEGORIE */
.settings-buttons-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin: 20px 0;
}

.setting-button-container {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.setting-button {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    padding: 15px 20px !important;
    border-radius: 15px !important;
    background: linear-gradient(135deg, var(--bg-accent) 0%, #9B7BE8 100%) !important;
    border: 2px solid rgba(255,255,255,0.3) !important;
    color: var(--text-light) !important;
    font-family: 'Quicksand', sans-serif !important;
    font-weight: 600 !important;
    font-size: 0.95em !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
    box-shadow: 
        0 4px 15px rgba(139, 127, 216, 0.3),
        inset 0 2px 4px rgba(255,255,255,0.2) !important;
}

.setting-button:hover {
    transform: translateY(-2px) scale(1.02) !important;
    background: linear-gradient(135deg, #A29BFE 0%, #B8A9E8 100%) !important;
    box-shadow: 
        0 6px 20px rgba(139, 127, 216, 0.4),
        inset 0 2px 4px rgba(255,255,255,0.3) !important;
}

.setting-icon {
    width: 20px !important;
    height: 20px !important;
    flex-shrink: 0 !important;
}

.dropdown-arrow {
    width: 16px !important;
    height: 16px !important;
    flex-shrink: 0 !important;
    transition: transform 0.3s ease !important;
}

.setting-button.active .dropdown-arrow {
    transform: rotate(180deg) !important;
}

/* CONTAINER-FILLING OVERLAY-MENÜ (füllt den Container-Rahmen aus) */
.overlay-menu {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: linear-gradient(135deg, rgba(255, 192, 203, 0.4) 0%, rgba(255, 182, 193, 0.5) 50%, rgba(221, 160, 221, 0.4) 100%) !important;
    backdrop-filter: blur(15px) !important;
    border-radius: 25px !important;
    z-index: 99999 !important;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 30px !important;
    box-sizing: border-box !important;
}

/* Das eigentliche Overlay-Menü in der Mitte */
.overlay-menu-content {
    background: var(--container-bg) !important;
    backdrop-filter: blur(20px) saturate(180%);
    border: 2px solid var(--container-border) !important;
    border-radius: 20px !important;
    padding: 35px 30px !important;
    min-width: 300px !important;
    max-width: 85% !important;
    width: auto !important;
    max-height: 75% !important;
    overflow-y: auto;
    box-shadow: 
        0 20px 50px rgba(139, 127, 216, 0.15),
        0 10px 25px rgba(255, 192, 203, 0.3),
        inset 0 1px 0 rgba(255,255,255,0.9) !important;
    transform: scale(0.85) translateY(30px);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Overlay-Titel */
.overlay-title {
    color: var(--text-primary) !important;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.4em;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

/* ULTIMATE FIX: Close Button - KEINE Container-Verzerrung möglich */
.overlay-close {
    /* POSITION & SIZE - ABSOLUT FEST */
    position: absolute !important;
    top: 15px !important;
    right: 15px !important;
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    
    /* SHAPE - PERFEKT RUND */
    border-radius: 50% !important;
    aspect-ratio: 1 !important;
    
    /* BACKGROUND & BORDER - KEINE Vererbung */
    background: rgba(255, 107, 157, 0.9) !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    
    /* TEXT & CONTENT - ZENTRIERT */
    color: white !important;
    font-size: 16px !important;
    font-weight: bold !important;
    line-height: 1 !important;
    text-align: center !important;
    
    /* LAYOUT - FLEX PERFEKT ZENTRIERT */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    
    /* SPACING - NULL PADDING/MARGIN */
    padding: 0 !important;
    margin: 0 !important;
    
    /* INTERACTION */
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    
    /* ANTI-DISTORTION - Verhindert Container-Einflüsse */
    transform: none !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    white-space: nowrap !important;
    
    /* Z-INDEX - Immer oben */
    z-index: 99999 !important;
    
    /* FONT RESET - Keine Vererbung */
    font-family: system-ui, -apple-system, sans-serif !important;
}

.overlay-close:hover {
    background: rgba(255, 107, 157, 1) !important;
    transform: scale(1.1) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.overlay-close:active {
    transform: scale(0.95) !important;
}

.overlay-menu.active {
    opacity: 1;
    visibility: visible;
}

.overlay-menu.active .overlay-menu-content {
    transform: scale(1) translateY(0);
}

.overlay-option {
    padding: 18px 25px !important;
    color: var(--text-primary) !important;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700 !important;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 15px !important;
    margin: 12px 0 !important;
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.4) !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    font-size: 1.1em !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
}

.overlay-option:hover {
    background: var(--bg-accent) !important;
    color: var(--text-light) !important;
    transform: translateY(-3px) scale(1.03) !important;
    border-color: var(--accent-orange) !important;
    box-shadow: 0 8px 25px rgba(139, 127, 216, 0.4) !important;
}

.overlay-option.selected {
    background: var(--color-out) !important;
    color: var(--text-light) !important;
    border-color: rgba(255,255,255,0.7);
}

.overlay-option span {
    font-size: 0.95em;
}

/* Mobile Anpassungen */
@media (max-width: 600px) {
    .settings-buttons-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .setting-button-container {
        min-width: unset;
    }
    
    .setting-button {
        padding: 12px 16px !important;
        font-size: 0.9em !important;
    }
}

/* 🚨 ULTIMATE ANTI-DISTORTION SYSTEM 🚨 */
/* Verhindert ALLE Container-basierten Verzerrungen */

/* 1. ALLGEMEINE ANTI-DISTORTION für wichtige UI Elemente */
.overlay-close,
.sound-toggle,
.tutorial-trigger,
.stats-button,
button[class*="close"],
button[class*="x"],
[role="button"][class*="close"] {
    /* ISOLATION - Keine Container-Vererbung */
    isolation: isolate !important;
    contain: layout style !important;
    
    /* SHAPE PROTECTION - Verhindert Oval-Verzerrung */
    aspect-ratio: 1 !important;
    border-radius: 50% !important;
    
    /* SIZE LOCK - Verhindert Größenverzerrung */
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    flex-basis: auto !important;
    
    /* TRANSFORM RESET - Verhindert Verzerrung durch Transform */
    transform-origin: center !important;
    will-change: transform !important;
    
    /* FONT ISOLATION - Verhindert Font-Vererbung */
    font-synthesis: none !important;
}

/* 2. CONTAINER TRANSFORM ISOLATION */
/* Verhindert, dass Parent-Container die Buttons verzerren */
.overlay-menu-content,
.settings-buttons-row,
.game-container {
    /* TRANSFORM CONTAINMENT */
    contain: layout style !important;
    
    /* FLEX RESET für Child-Elemente */
    *:not(.overlay-close):not(.sound-toggle):not(.tutorial-trigger):not(.stats-button) {
        transform-origin: center !important;
    }
}

/* 3. UNIVERSAL BUTTON SHAPE PROTECTION */
/* Schützt ALLE runden Buttons vor Verzerrung */
button[style*="border-radius: 50%"],
button[class*="round"],
.round-button,
[class*="circular"] {
    aspect-ratio: 1 !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    isolation: isolate !important;
}

/* 4. SVG ICON PROTECTION */
/* Verhindert SVG-Icon Verzerrung */
.overlay-close svg,
.sound-toggle svg,
.tutorial-trigger svg,
.stats-button svg,
button svg {
    /* SVG SHAPE LOCK */
    width: auto !important;
    height: auto !important;
    max-width: 20px !important;
    max-height: 20px !important;
    
    /* SVG POSITION LOCK */
    position: relative !important;
    flex-shrink: 0 !important;
    
    /* SVG TRANSFORM PROTECTION */
    transform: none !important;
    transform-origin: center !important;
}

/* 5. CRITICAL ELEMENT Z-INDEX PROTECTION */
/* Stellt sicher, dass kritische Elemente immer sichtbar sind */
.overlay-close {
    z-index: 99999 !important;
}

.sound-toggle,
.tutorial-trigger,
.stats-button {
    z-index: 9999 !important;
}

/* 6. MOBILE PROTECTION ENHANCEMENT */
@media (max-width: 600px) {
    .overlay-close,
    .sound-toggle,
    .tutorial-trigger,
    .stats-button {
        /* MOBILE SPECIFIC PROTECTION */
        contain: layout style size !important;
        isolation: isolate !important;
        
        /* MOBILE TOUCH TARGET */
        min-width: 36px !important;
        min-height: 36px !important;
    }
}

/* 7. FORCE ASPECT RATIO FOR ALL CIRCULAR ELEMENTS */
/* Verhindert Container-Verzerrung durch erzwungenes Aspect Ratio */
.overlay-close,
.sound-toggle,
.tutorial-trigger,
.stats-button,
button[class*="round"],
[class*="circular"] {
    /* CSS ASPECT RATIO ENFORCEMENT */
    aspect-ratio: 1 / 1 !important;
    
    /* BACKUP: Manual Width/Height Lock */
    min-width: var(--btn-size, 30px) !important;
    min-height: var(--btn-size, 30px) !important;
    max-width: var(--btn-size, 30px) !important;
    max-height: var(--btn-size, 30px) !important;
    
    /* SHAPE ENFORCEMENT */
    border-radius: 50% !important;
    
    /* LAYOUT RESET */
    box-sizing: border-box !important;
    overflow: hidden !important;
    
    /* CONTENT CENTERING */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    
    /* NO PADDING/MARGIN INHERITANCE */
    padding: 0 !important;
    margin: 0 !important;
}

/* 8. FINAL OVERRIDE: CSS CUSTOM PROPERTIES for Button Sizes */
.overlay-close {
    --btn-size: 30px;
}

.sound-toggle,
.tutorial-trigger,
.stats-button {
    --btn-size: 40px;
}

@media (max-width: 600px) {
    .sound-toggle,
    .tutorial-trigger,
    .stats-button {
        --btn-size: 36px;
    }
}