:root {
    --bg-dark: #1a202c;
    --bg-medium: #2d3748;
    --bg-light: #4a5568;
    --text-light: #edf2f7;
    --text-medium: #a0aec0;
    --primary-color: #667eea; /* Indigo */
    --primary-hover: #5a67d8;
    --secondary-color: #4a5568; /* Darker slate */
    --secondary-hover: #3b4250;
    --danger-color: #e53e3e; /* Red */
    --danger-hover: #c53030;
    --success-color: #48bb78; /* Green */
    --warning-color: #fb7185; /* Rose */
    --info-color: #818cf8; /* Light Indigo for room ID */
    --accent-purple: #9f7aea;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    line-height: 1.6;
    background-image: linear-gradient(to bottom right, #1a202c, #2d3748);
    background-attachment: fixed; /* Keep background fixed during scroll */
}

.container {
    background-color: var(--bg-medium);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4); /* Stronger, softer shadow */
    width: 100%;
    /* --- Adjusted max-width for Laptop UI --- */
    max-width: 700px; /* Set a more contained max-width */
    /* -------------------------------- */
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.08); /* Subtle border */
    position: relative;
    overflow: hidden;
}

h1 {
    font-size: 3.5rem;
    color: var(--primary-color);
    margin-bottom: 30px;
    font-weight: 700;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    letter-spacing: 1.5px;
}

h2 {
    font-size: 2.5rem;
    color: var(--accent-purple);
    margin-bottom: 25px;
    font-weight: 600;
}

h3 {
    font-size: 1.8rem;
    color: var(--text-medium);
    margin-bottom: 20px;
    font-weight: 500;
}

.input-group {
    margin-bottom: 25px;
    text-align: left;
}

.label {
    display: block;
    font-size: 1.1rem;
    color: var(--text-medium);
    margin-bottom: 10px;
}

.input-field {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--bg-light);
    border-radius: 10px;
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-size: 1.1rem;
    box-sizing: border-box;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.5);
}

.btn {
    padding: 14px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: inline-block;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease-in-out, height 0.3s ease-in-out;
    z-index: -1;
}

.btn:hover:before {
    width: 200%;
    height: 200%;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-primary {
    background: linear-gradient(45deg, var(--primary-color), #7f9cf5);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(45deg, #5a67d8, #6b82f5);
}

.btn-secondary {
    background: linear-gradient(45deg, var(--secondary-color), #5a67d8);
    color: var(--text-light);
}

.btn-secondary:hover {
    background: linear-gradient(45deg, #3b4250, #4a5568);
}

.btn-danger {
    background: linear-gradient(45deg, var(--danger-color), #f687b3);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(45deg, #c53030, #e53e3e);
}

/* Custom utility classes replacing some Tailwind equivalents */
.w-full { width: 100%; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mb-10 { margin-bottom: 2.5rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.p-6 { padding: 1.5rem; }
.rounded-lg { border-radius: 0.5rem; }
.space-y-2 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.5rem; }
.space-y-3 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.75rem; }
.space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: 1rem; }

.text-center { text-align: center; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.text-5xl { font-size: 3rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

/* Colors mapped to variables */
.text-rose-500 { color: var(--danger-color); }
.text-teal-600 { color: #0d9488; }
.text-slate-700 { color: #334155; }
.text-slate-400 { color: #94a3b8; }
.text-indigo-400 { color: var(--info-color); }
.text-purple-400 { color: var(--accent-purple); }
.text-teal-400 { color: #2dd4bf; }
.text-rose-400 { color: var(--warning-color); }

.bg-slate-700 { background-color: #334155; }


.card {
    background-color: var(--bg-light);
    padding: 2.5rem; /* Increased padding for better spacing */
    border-radius: 12px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.hidden {
    display: none;
}

.screen {
    animation: fadeIn 0.6s ease-out;
}

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

.divider {
    border-top: 1px dashed var(--bg-light);
    margin: 35px 0;
    text-align: center;
    line-height: 0.1em;
}

.divider::before {
    content: "OR";
    background: var(--bg-medium);
    padding: 0 15px;
    color: var(--text-medium);
    font-size: 1rem;
    font-weight: 500;
}

ul {
    list-style: none;
    padding: 0;
}

/* Error Banner */
.error-banner {
    background-color: var(--danger-color);
    color: white;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: slideInTop 0.4s ease-out;
}

/* Notification Banner */
.notification-banner {
    background-color: #38bdf8; /* Sky Blue */
    color: white;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: slideInTop 0.4s ease-out;
}

@keyframes slideInTop {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Specific styles for Lobby */
#player-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#player-list li {
    background-color: var(--bg-dark);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Game Screen Styles */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 0 10px;
    /* --- Timer Display Fix --- */
    flex-wrap: nowrap; /* Prevent wrapping of elements */
    /* ------------------------- */
}

#question-text {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

#timer {
    /* --- Timer Display Fix --- */
    white-space: nowrap; /* Prevent text from wrapping */
    min-width: 80px; /* Ensure enough space for 3-digit timer */
    /* ------------------------- */
}

.options-grid {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Ensures good width on larger screens */
}

.options-grid-item {
    padding: 18px 20px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 10px;
    text-align: center;
    font-size: 1.15rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 2px solid transparent;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.options-grid-item:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.option-button.selected {
    background-color: var(--secondary-color);
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.6);
}

.option-button.correct {
    background-color: var(--success-color);
    border: 2px solid #38a169;
    box-shadow: 0 0 0 3px rgba(72, 187, 120, 0.6);
}

.option-button.incorrect {
    background-color: var(--danger-color);
    border: 2px solid #c53030;
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.6);
}

.options-grid-item:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: var(--bg-light);
    color: var(--text-medium);
    box-shadow: none;
}

.scoreboard {
    display: flex;
    justify-content: space-around;
    gap: 25px;
    margin-top: 30px;
}

.scoreboard-card {
    flex: 1;
    background-color: var(--bg-dark);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
}

.scoreboard-card .player-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 10px;
}

.scoreboard-card .player-score {
    font-size: 2rem;
    font-weight: bold;
    color: var(--success-color);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.scoreboard-card .player-status {
    font-size: 1rem;
    margin-top: 8px;
    font-style: italic;
    color: var(--text-medium);
}

/* Game Over Screen */
#finalScoresList {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#finalScoresList li {
    background-color: var(--bg-dark);
    padding: 15px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2rem;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.05);
}


/* --- Responsive Adjustments --- */

@media (max-width: 992px) { /* Adjust for larger tablets and smaller laptops */
    .container {
        max-width: 600px; /* Further reduction */
        padding: 35px;
    }
    h1 { font-size: 3rem; }
    h2 { font-size: 2.2rem; }
    h3 { font-size: 1.6rem; }
    .btn { font-size: 1.1rem; padding: 12px 25px; }
    .options-grid { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
    .scoreboard-card .player-name { font-size: 1.2rem; }
    .scoreboard-card .player-score { font-size: 1.8rem; }
    #timer { font-size: 2.5rem; /* Adjust font size for timer on smaller screens */ }
}

@media (max-width: 768px) { /* Standard tablet portrait */
    .container {
        padding: 25px;
        border-radius: 14px;
    }

    h1 {
        font-size: 2.5rem;
        margin-bottom: 20px;
    }

    h2 {
        font-size: 1.8rem;
        margin-bottom: 20px;
    }

    h3 {
        font-size: 1.4rem;
        margin-bottom: 15px;
    }

    .label, .input-field, .btn, .options-grid-item {
        font-size: 1rem;
        padding: 12px;
    }

    .options-grid {
        grid-template-columns: 1fr; /* Stack options on small screens */
        gap: 12px;
    }

    .scoreboard {
        flex-direction: column; /* Stack scoreboard cards */
        gap: 15px;
    }

    .scoreboard-card {
        padding: 15px;
    }

    .scoreboard-card .player-name {
        font-size: 1.1rem;
    }

    .scoreboard-card .player-score {
        font-size: 1.4rem;
    }

    .game-header {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    #timer { font-size: 2rem; } /* Further adjust font size for timer */
}

@media (max-width: 480px) { /* Mobile phones */
    body {
        padding: 15px;
    }

    .container {
        padding: 20px;
        border-radius: 12px;
    }

    h1 {
        font-size: 2rem;
        margin-bottom: 15px;
    }

    h2 {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }

    h3 {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.95rem;
        border-radius: 8px;
    }

    .input-field {
        padding: 10px;
        border-radius: 8px;
    }

    .error-banner, .notification-banner {
        padding: 10px;
        font-size: 0.85rem;
    }

    .options-grid-item {
        padding: 12px;
        font-size: 0.95rem;
    }

    .scoreboard-card .player-name {
        font-size: 1rem;
    }

    .scoreboard-card .player-score {
        font-size: 1.2rem;
    }
    #timer { font-size: 1.5rem; } /* Smallest font size for timer on mobile */
}