/* Modern TV Quiz Theme */
:root {
    --bg-gradient: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    --card-bg: rgba(22, 33, 62, 0.95);
    --text-main: #ffffff;
    --text-muted: #a0a0a0;
    --primary: #4facfe;
    --primary-dark: #00f260; /* Grün für Richtig */
    --accent: #ff0055;
    --highlight: #ffd700; /* Gelb für Auswahl */
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --font-stack: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    font-family: var(--font-stack);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Container als "Karte" */
.app-container {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
    position: relative;
}

@media (min-width: 500px) {
    .app-container {
        min-height: auto;
        border-radius: 24px;
        border: var(--glass-border);
        margin: 20px;
        min-height: 80vh;
    }
}

/* Utility Classes */
.hidden { display: none !important; }

h1 {
    font-size: 2.5rem;
    text-align: center;
    margin: 10px 0 20px;
    background: -webkit-linear-gradient(var(--primary-dark), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 900;
    letter-spacing: -1px;
}

h2 {
    font-size: 1.5rem;
    text-align: center;
    color: var(--text-main);
    font-weight: 600;
    margin-bottom: 20px;
}

p {
    text-align: center;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Header & Stats */
header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

#game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
}

/* Quit Button Styling */
#btn-quit {
    width: auto;
    padding: 5px 10px;
    margin: 0;
    font-size: 0.8rem;
    background: rgba(255, 0, 0, 0.2);
    color: #ff5555;
    border: 1px solid rgba(255, 0, 0, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

#btn-quit.btn-confirm-quit {
    background: #ff5555;
    color: white;
    font-weight: bold;
    animation: shake 0.3s;
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

/* SCOREBOARD DYNAMIC STYLING */
#scoreboard {
    display: flex;
    gap: 10px;
    width: 100%;
}

/* Layout für wenige Spieler: Zentriert, wrapped */
#scoreboard.grid-layout {
    justify-content: center;
    flex-wrap: wrap;
}

/* Layout für viele Spieler: Linksbündig, horizontal scrollbar */
#scoreboard.scroll-layout {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 8px; /* Platz für Scrollbar */
    mask-image: linear-gradient(to right, black 85%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
}

/* Custom Scrollbar */
#scoreboard.scroll-layout::-webkit-scrollbar {
    height: 4px;
}
#scoreboard.scroll-layout::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

.player-score {
    background: rgba(0,0,0,0.3);
    padding: 8px 12px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.05);
    min-width: 70px; /* Einheitliche Breite */
    flex: 0 0 auto; /* Nicht schrumpfen */
    transition: border-color 0.3s;
}

.player-score.me {
    border-color: var(--primary);
    background: rgba(79, 172, 254, 0.1);
}

.player-score span {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

.player-score strong {
    font-size: 1.2rem;
    color: var(--highlight);
    display: block;
}

/* Inputs & Forms */
.form-group { margin-bottom: 20px; }

input[type="text"], input[type="number"] {
    width: 100%;
    padding: 16px;
    background: rgba(0,0,0,0.4);
    border: 1px solid #444;
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    text-align: center;
    box-sizing: border-box;
    transition: border-color 0.3s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Buttons */
button {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(1); }

.btn-primary {
    background: linear-gradient(90deg, var(--primary), #2980b9);
    color: white;
    box-shadow: 0 4px 15px rgba(41, 128, 185, 0.4);
}

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: white;
}

.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.separator {
    text-align: center;
    margin: 15px 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Leaderboard */
#leaderboard-container {
    margin-top: 20px;
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    padding: 15px;
    max-height: 200px;
    overflow-y: auto;
}
.leaderboard-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.9rem;
}
.leaderboard-item:last-child { border-bottom: none; }
.leaderboard-rank { color: var(--highlight); font-weight: bold; margin-right: 10px; }
.leaderboard-score { font-weight: bold; }

/* Waiting Room */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 30px;
}

@keyframes spin { to { transform: rotate(360deg); } }

#lobby-code {
    font-size: 2.5rem;
    letter-spacing: 5px;
    color: var(--primary);
    display: block;
    margin-top: 10px;
}

/* Game Area */
#timer-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    margin: 20px 0;
    overflow: hidden;
}

#timer-fill {
    height: 100%;
    background: var(--primary-dark);
    width: 0%;
    transition: width 1s linear;
}

#timer-text {
    font-size: 4rem;
    font-weight: 800;
    text-align: center;
    margin: 10px 0 30px;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 20px rgba(255,255,255,0.2);
}

.btn-action {
    background: var(--primary-dark);
    color: #000;
    font-size: 1.3rem;
    box-shadow: 0 0 20px rgba(0, 242, 96, 0.3);
}

.answers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-top: auto;
}

.btn-answer {
    aspect-ratio: 1;
    background: rgba(255,255,255,0.1);
    font-size: 2.5rem;
    border: 2px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.btn-answer:hover {
    background: rgba(255,255,255,0.2);
}

/* GELB HINTERLEGT BEI AUSWAHL */
.btn-answer.selected {
    background: var(--highlight) !important;
    color: #000 !important;
    border-color: white;
    box-shadow: 0 0 30px var(--highlight);
    opacity: 1 !important;
}

/* GRÜN HINTERLEGT BEI AUFLÖSUNG */
.btn-answer.correct-reveal {
    background: var(--primary-dark) !important;
    color: #000 !important;
    border-color: white;
    box-shadow: 0 0 30px var(--primary-dark);
}

/* CONFIRM STATE FOR RESOLUTION */
.btn-answer.confirm-state {
    background: var(--primary) !important;
    font-size: 1rem;
    color: white !important;
}

/* Betting Slider */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    margin: 30px 0;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 30px;
    width: 30px;
    border-radius: 50%;
    background: var(--primary);
    margin-top: -12px;
    box-shadow: 0 0 10px var(--primary);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.bet-display {
    font-size: 3rem;
    text-align: center;
    color: var(--highlight);
    font-weight: bold;
    margin-bottom: 20px;
}

/* Resolution */
.resolution-options {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.resolution-options button {
    font-size: 1.5rem;
    padding: 15px 0;
}

/* Finished */
#winner-display {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--highlight);
    text-align: center;
    margin: 40px 0;
    line-height: 1.4;
    white-space: pre-wrap; /* Zeilenumbrüche erhalten */
}