@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700;800&family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-primary: #fafaf8;
    --bg-secondary: #f0ede8;
    --bg-card: #ffffff;
    --accent: #c8956c;
    --accent-hover: #b07d58;
    --gold: #d4a03c;
    --silver: #a0a0a0;
    --bronze: #cd7f32;
    --text: #2c3e50;
    --text-muted: #6b7b8d;
    --primary: #1a3c5e;
    --success: #27ae60;
    --error: #e74c3c;
    --radius: 16px;
    --font-heading: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(200, 149, 108, 0.07) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(26, 60, 94, 0.04) 0%, transparent 50%);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

.container {
    max-width: 560px;
    margin: 0 auto;
    padding: 1.2rem;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Screens */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    flex: 1;
    animation: fadeIn 0.4s ease;
}

.screen.active {
    display: flex;
}

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

/* Header / Logo */
.logo {
    text-align: center;
    margin: 2.5rem 0 1.5rem;
}

.logo h1 {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.logo p {
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.visit-link {
    display: inline-block;
    margin-top: 0.8rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.04em;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: var(--transition);
}

.visit-link:hover {
    border-bottom-color: var(--accent);
}

/* Forms */
.form-group {
    width: 100%;
    margin-bottom: 1.1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

input, select {
    width: 100%;
    padding: 0.9rem 1.1rem;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(200, 149, 108, 0.12);
}

input::placeholder {
    color: var(--text-muted);
}

select option {
    background: var(--bg-card);
    color: var(--text);
}

/* Custom select dropdown */
.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    width: 100%;
    padding: 0.9rem 1.1rem;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
    text-align: left;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.custom-select-trigger:focus,
.custom-select.open .custom-select-trigger {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(200, 149, 108, 0.12);
    outline: none;
}

.custom-select-trigger svg {
    transition: var(--transition);
    opacity: 0.4;
    flex-shrink: 0;
}

.custom-select.open .custom-select-trigger svg {
    transform: rotate(180deg);
    opacity: 0.8;
}

.custom-select-options {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius);
    list-style: none;
    padding: 0.4rem;
    z-index: 50;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.custom-select.open .custom-select-options {
    display: block;
    animation: fadeIn 0.2s ease;
}

.custom-select-options li {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: var(--transition);
    color: var(--text-muted);
}

.custom-select-options li:hover {
    background: rgba(200, 149, 108, 0.1);
    color: var(--text);
}

.custom-select-options li.selected {
    background: rgba(200, 149, 108, 0.12);
    color: var(--accent);
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.95rem 1.8rem;
    border: none;
    border-radius: 50px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
    box-shadow: 0 4px 20px rgba(200, 149, 108, 0.3);
}

@media (hover: hover) {
    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 30px rgba(200, 149, 108, 0.4);
    }
    .btn-secondary:hover {
        background: var(--bg-secondary);
        border-color: var(--accent);
        transform: translateY(-2px);
    }
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 2px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn + .btn {
    margin-top: 0.8rem;
}

/* Menu buttons */
.menu-buttons {
    width: 100%;
    margin-top: 1.5rem;
}

/* Room / Lobby */
.room-code {
    background: var(--bg-card);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    width: 100%;
    margin: 1rem 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.room-code .code {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: 10px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.room-code p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.room-code-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    margin-top: 1rem;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

@media (hover: hover) {
    .btn-icon:hover {
        border-color: var(--accent);
        color: var(--text);
        background: rgba(200, 149, 108, 0.08);
    }
}

.btn-icon.copied {
    border-color: var(--success);
    color: var(--success);
}

.player-list {
    width: 100%;
    list-style: none;
    margin: 1rem 0;
}

.player-list li {
    background: var(--bg-card);
    border: 1px solid rgba(0, 0, 0, 0.06);
    padding: 0.85rem 1.1rem;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.player-list .host-badge {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
    font-size: 0.65rem;
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Question */
.question-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.question-number {
    font-weight: 700;
    color: var(--accent);
    font-size: 0.95rem;
}

.question-category {
    background: var(--bg-secondary);
    border: 1px solid rgba(0, 0, 0, 0.06);
    padding: 0.35rem 1rem;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.03em;
}

.timer {
    width: 100%;
    margin-bottom: 1.5rem;
}

.timer-bar {
    height: 5px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
}

.timer-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 3px;
    transition: width 1s linear;
    width: 100%;
}

.timer-bar-fill.warning {
    background: linear-gradient(90deg, var(--gold), #e6b84d);
}

.timer-bar-fill.danger {
    background: linear-gradient(90deg, var(--error), #ff6b6b);
}

.timer-text {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 0.5rem;
    color: var(--text-muted);
}

.question-text {
    width: 100%;
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1.8rem;
    line-height: 1.4;
    min-height: 3.5rem;
    color: var(--primary);
}

.options {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.option-btn {
    width: 100%;
    padding: 1rem 1.1rem;
    border: 2px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.95rem;
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.9rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

@media (hover: hover) {
    .option-btn:hover:not(:disabled) {
        border-color: var(--accent);
        background: rgba(200, 149, 108, 0.06);
        transform: translateX(4px);
    }
}

.option-btn .option-letter {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: var(--transition);
    color: var(--text-muted);
}

.option-btn.selected {
    border-color: var(--accent);
    background: rgba(200, 149, 108, 0.08);
}

.option-btn.selected .option-letter {
    background: var(--accent);
    color: white;
}

.option-btn.correct {
    border-color: var(--success);
    background: rgba(39, 174, 96, 0.08);
}

.option-btn.correct .option-letter {
    background: var(--success);
    color: white;
}

.option-btn.incorrect {
    border-color: var(--error);
    background: rgba(231, 76, 60, 0.08);
}

.option-btn.incorrect .option-letter {
    background: var(--error);
    color: white;
}

.option-btn:disabled {
    cursor: not-allowed;
}

/* Feedback after answer */
.answer-feedback {
    text-align: center;
    margin-top: 1.2rem;
    font-size: 1.05rem;
    font-weight: 700;
    min-height: 2rem;
    letter-spacing: 0.02em;
}

.answer-feedback.correct {
    color: var(--success);
}

.answer-feedback.incorrect {
    color: var(--error);
}

/* Scoreboard */
.scoreboard {
    width: 100%;
    margin: 1.2rem 0;
}

.scoreboard h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.score-entry {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    margin-bottom: 0.5rem;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.score-position {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.82rem;
    margin-right: 0.8rem;
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.score-entry:nth-child(2) .score-position { background: var(--gold); color: white; }
.score-entry:nth-child(3) .score-position { background: var(--silver); color: white; }
.score-entry:nth-child(4) .score-position { background: var(--bronze); color: white; }

.score-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
}

.score-points {
    font-weight: 800;
    color: var(--accent);
    font-size: 0.95rem;
}

/* Game Over */
.winner-section {
    text-align: center;
    margin: 2.5rem 0;
    width: 100%;
}

.winner-crown {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 4px 12px rgba(200, 149, 108, 0.3));
}

.winner-name {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.winner-score {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-weight: 400;
}

/* Waiting overlay */
.waiting {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.waiting .dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* Countdown */
.countdown {
    font-family: var(--font-heading);
    font-size: 6rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    margin: auto;
    animation: pulse 1s ease infinite;
    filter: drop-shadow(0 0 30px rgba(200, 149, 108, 0.15));
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.85; }
}

/* Error toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--error);
    color: white;
    padding: 0.85rem 1.5rem;
    border-radius: 50px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 1000;
    animation: slideUp 0.3s ease;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 8px 30px rgba(231, 76, 60, 0.2);
}

@keyframes slideUp {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 400px) {
    .logo h1 { font-size: 2.2rem; }
    .room-code .code { font-size: 2.2rem; letter-spacing: 6px; }
    .question-text { font-size: 1.1rem; }
    .container { padding: 0.8rem; }
}
