@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
    --font-main: 'Outfit', sans-serif;
    --color-bg: #121212;
    --color-text: #ffffff;
    --color-primary: #0d6efd;
    --color-secondary: #6c757d;
    --transition-speed: 0.5s;
    --radius-main: 24px;
}

html, body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-main);
    overflow: hidden; /* Prevent global scrollbar */
    margin: 0;
    width: 100%;
    height: 100%;
}

body {
    transition: background 1s ease;
    display: flex;
    flex-direction: column;
}

/* --- Dynamic Themes --- */
/* Default / Lobby */
body.theme-default {
    background: linear-gradient(135deg, #1A1A2E 0%, #16213E 50%, #0F3460 100%);
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
}

/* History / Sepia / Mythology */
body.theme-history {
    background: linear-gradient(135deg, #2C241B 0%, #4E342E 50%, #5D4037 100%);
}

/* Science / Tech / Space / Astrology / Cars - Cold Blue/Cyan */
body.theme-science, body.theme-technology, body.theme-space, body.theme-cars, body.theme-astrology {
    background: linear-gradient(135deg, #001f3f 0%, #003366 50%, #004080 100%);
}

/* Nature / Animals / Geography / Food / Decor - Green */
body.theme-nature, body.theme-animals, body.theme-food, body.theme-geography, body.theme-decor {
    background: linear-gradient(135deg, #1B2E1A 0%, #2E4E2E 50%, #345D34 100%);
}

/* Pop Culture / Music / Movies / Art / Literature / Identity - Purple/Pink */
body.theme-pop-culture, body.theme-music, body.theme-movies, body.theme-art, body.theme-fashion, body.theme-literature, body.theme-beauty, body.theme-relationships, body.theme-celebrities {
    background: linear-gradient(135deg, #2E1A2E 0%, #4A235A 50%, #6C3483 100%);
}

/* Sports / Start / Gaming / Fitness - Energetic Orange/Red */
body.theme-sports, body.theme-start, body.theme-gaming, body.theme-fitness, body.theme-healthy {
    background: linear-gradient(135deg, #3E1A1A 0%, #6E2C2C 50%, #943126 100%);
}

/* Latvia - Maroon/White */
body.theme-latvia {
    background: linear-gradient(135deg, #7D2027 0%, #A4282E 50%, #7D2027 100%);
}

/* Mind / Philosophy / Psychology / Riddles - Deep Indigo */
body.theme-mind {
    background: linear-gradient(135deg, #1A237E 0%, #311B92 50%, #4527A0 100%);
}

@keyframes gradientShift {
	0% { background-position: 0% 50%; }
	50% { background-position: 100% 50%; }
	100% { background-position: 0% 50%; }
}

/* --- Typography --- */
h1.title {
    font-weight: 800;
    font-style: italic;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 2vh;
    font-size: clamp(2.5rem, 6vmin, 4rem);
}

h2, h3, h4 {
    font-weight: 600;
}

.h-custom {
    height: 60px !important;
    font-size: 1.5rem !important;
}
button.h-custom {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* --- Layout Utilities --- */
.full-screen {
    flex: 1; /* Take remaining space */
    width: 100%;
    overflow: hidden; /* Prevent scrollbars on full screens like Lobby */
    /* Remove fixed height: 100vh to avoid overflow with top bar */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-main);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    padding: 2rem;
}

/* --- Components --- */
.btn-custom { 
    padding: 1rem 2.5rem; 
    font-size: 1.3rem; 
    margin: 0; /* Removed 0.5rem to fix w-100 overflow */
    border-radius: var(--radius-main); 
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

.btn-join {
    background: linear-gradient(45deg, #11998e, #38ef7d);
    color: white;
    box-shadow: 0 4px 15px rgba(56, 239, 125, 0.4);
    height: 60px; /* Enforce same height for join button */
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-theme-player {
    background: linear-gradient(45deg, #11998e, #38ef7d);
    color: white;
    box-shadow: 0 4px 15px rgba(56, 239, 125, 0.4);
    /* Allow height to grow with content */
    display: block; /* Default to block for text wrapping, or flex if needed but separate from fixed height */
}

#category-screen {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 2vh;
    box-sizing: border-box;
}

#category-grid {
    flex: 1;
    overflow: visible; /* Allow selected cards to scale beyond grid */
    padding: 1vmin; /* Padding to accommodate scaled cards */
    margin-top: 1vh;
}

.btn-join:hover, .btn-theme-player:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(56, 239, 125, 0.6);
    color: white;
}

.btn-host, .btn-theme-host {
    background: linear-gradient(45deg, #FF416C, #FF4B2B);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 65, 108, 0.4);
}

.btn-host:hover, .btn-theme-host:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 65, 108, 0.6);
    color: white;
}

.btn-theme-danger {
    background: linear-gradient(45deg, #FF512F, #DD2476);
    color: white;
    box-shadow: 0 4px 15px rgba(221, 36, 118, 0.4);
}

.btn-theme-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(221, 36, 118, 0.6);
    color: white;
}

.btn-terminate {
    background: rgba(0, 0, 0, 0.3);
    color: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 9999;
    opacity: 0.6;
}
.btn-terminate:hover {
    background: rgba(255, 75, 75, 0.3);
    border-color: rgba(255, 75, 75, 0.5);
    color: #ff6b6b;
    opacity: 1;
}


#game-code {
    font-size: clamp(3rem, 10vmin, 6rem);
    font-weight: 800;
    letter-spacing: 0.5rem;
    color: white;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    line-height: 1;
    margin-bottom: 1vh;
}
#qr-code img {
    margin: 0 auto;
    object-fit: contain;
    max-height: 35vh;
    width: auto !important;
}

/* --- Grid (Categories) --- */
.masonry-grid { 
    display: grid; 
    grid-template-columns: repeat(6, 1fr); /* 6 cols x 5 rows approx for 25 items */
    grid-auto-rows: 1fr;
    gap: 2vmin; 
    width: 100%; 
    height: 100%;
    max-width: 1600px; /* Wider for TV */
    margin: 0 auto; 
}
.category-card { 
    margin-bottom: 0; /* Handled by gap */
    cursor: pointer; 
    transition: transform 0.2s, background-color 0.2s; 
    background: rgba(255,255,255,0.05); 
    border: 1px solid rgba(255,255,255,0.1); 
    border-radius: var(--radius-main); 
    padding: 0.5rem; 
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}
.category-card h3 {
    margin: 0;
    font-size: clamp(0.9rem, 1.8vmin, 1.6rem);
    line-height: 1.2;
}
.category-card.selected { background: var(--color-primary); border-color: var(--color-primary); transform: scale(1.05); z-index: 1; }
.category-card:hover { border-color: #fff; background: rgba(255,255,255,0.1); }
@media (max-width: 768px) { 
    .masonry-grid { 
        grid-template-columns: repeat(2, 1fr); 
        overflow-y: auto; /* Allow scroll on mobile */
        display: block; /* Fallback to block/masonry for mobile? Or just simple grid */
        display: grid;
    } 
    #category-grid { overflow-y: auto; }
}

/* --- Mobile Specific --- */
.team-score-display {
    color: #FFD700;
}
input.form-control {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius-main) !important;
}
input.form-control::placeholder {
    color: rgba(255,255,255,0.5);
}

/* Input Group Styling */
.input-group > .form-control {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}
.input-group > .btn {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-top-right-radius: var(--radius-main) !important;
    border-bottom-right-radius: var(--radius-main) !important;
    margin: 0;
    /* Ensure border aligns with input */
    border: 1px solid rgba(255,255,255,0.2); 
    border-left: none; /* Merge visual */
    background: rgba(255,255,255,0.1); /* Match input bg */
    color: white;
}
.input-group > .btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
}

/* Preset Buttons (for host settings) */
.btn-preset {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px !important;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}
.btn-preset:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    color: white;
    transform: scale(1.05);
}
.btn-preset:active {
    background: rgba(255, 255, 255, 0.3);
}
.preset-group {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* Language toggle active state */
.btn-check:checked + .btn-preset {
    background: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
    color: white !important;
}
.btn-check:checked + .btn-preset:hover {
    background: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
    color: white !important;
    transform: scale(1.05);
}
.btn-preset:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    color: white !important;
    transform: scale(1.05);
}

/* Fixed bottom controls for game screen */
#game-screen {
    position: relative;
}
#controls-area, #leaderboard-controls, #lobby-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    padding: 2vh 0;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

/* Ensure content is not covered by fixed bottom controls */
#game-scrollable, #players-list-container, .scroll-area {
    padding-bottom: 120px !important; 
}

/* Adjust Leaderboard scroll area */
#leaderboard-screen > div.flex-grow-1 {
    padding-bottom: 120px !important;
}

/* --- TV / Host Specific --- */
.text-tv-question {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.2;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.6);
    transition: font-size 0.3s ease;
}

.text-tv-question-long {
    font-size: 2.2rem !important;
}

.text-tv-answer {
    font-size: 2.5rem;
    font-weight: 600;
    transition: font-size 0.3s ease;
}

.text-tv-answer-long {
    font-size: 1.6rem !important;
}

.card-answer {
    transition: all 0.3s ease;
    border: 2px solid rgba(255,255,255,0.1);
    background: rgba(0, 0, 0, 0.4); /* Darker semi-transparent background */
    backdrop-filter: blur(5px);
}

.card-answer.bg-success {
    background: #198754 !important; /* Bootstrap Success Color */
    border-color: #fff;
    transform: scale(1.02);
    box-shadow: 0 0 20px rgba(25, 135, 84, 0.5);
}

/* --- Advanced Styling --- */
.btn-glass {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-main) !important;
    transition: all 0.3s ease;
}
.btn-glass:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 10px 40px 0 rgba(0, 0, 0, 0.5);
    color: white;
}
.btn-glass:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Stylish Timer */
.timer-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-main);
    padding: 5px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
    overflow: hidden;
}

.progress-bar-stylish {
    height: 100%;
    border-radius: var(--radius-main);
    background: linear-gradient(90deg, #00C9FF 0%, #92FE9D 100%);
    box-shadow: 0 0 15px rgba(146, 254, 157, 0.6);
    transition: width 0.1s linear, background 0.3s ease;
}

/* Stylish Badges */
.badge-glass {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: var(--radius-main);
    font-size: 1.5rem;
    padding: 1rem 2rem !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: inline-block;
    margin: 0.5rem;
}

/* Fix mobile horizontal scroll */
.full-screen {
    overflow-x: hidden;
    width: 100%;
}

/* Glass Table */
.glass-table {
    width: 100%;
    border-collapse: collapse;
    color: white;
}
.glass-table th, .glass-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}
.glass-table th {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 1.2rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}
.glass-table tr:last-child td {
    border-bottom: none;
}

/* Glass Card - Replaces Bootstrap Card */
.glass-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-main);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    padding: 0; /* Let children handle padding or header/body divs */
    overflow: hidden;
}

/* TV Mode End Screen Adjustments */
#end-screen .glass-table th, 
#end-screen .glass-table td {
    font-size: clamp(1rem, 2.5vmin, 2rem) !important;
    padding: 1vmin 1.5vmin;
}
#end-screen .glass-card-header .text-white {
    font-size: clamp(1.2rem, 3vmin, 2rem) !important;
}
#end-screen .glass-card-body h5 {
    font-size: clamp(1.5rem, 4vmin, 2.5rem) !important;
    font-weight: 700;
}
#end-screen .glass-card-body p {
    font-size: clamp(1.2rem, 3vmin, 1.8rem) !important;
}
#end-screen .badge {
    font-size: clamp(1rem, 2vmin, 1.5rem) !important;
    padding: 0.5em 0.8em !important;
}
.big-font {
    font-size: clamp(1.5rem, 4vmin, 3rem) !important;
}
.glass-card-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 600;
}
.glass-card-body {
    padding: 1.5rem;
}

