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

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #21242f;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-light: rgba(124, 58, 237, 0.15);
    --gold: #f59e0b;
    --silver: #94a3b8;
    --bronze: #cd7f32;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --primary: #7c3aed;
    --success: #10b981;
    --error: #ef4444;
    --dotnet-purple: #512bd4;
    --csharp-green: #68bc71;
    --radius: 16px;
    --font-heading: 'JetBrains Mono', 'Fira Code', monospace;
    --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(124, 58, 237, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(81, 43, 212, 0.06) 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.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--csharp-green), 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;
}

.logo .version-badge {
    display: inline-block;
    margin-top: 0.6rem;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--csharp-green);
    background: rgba(104, 188, 113, 0.1);
    border: 1px solid rgba(104, 188, 113, 0.2);
    padding: 0.2rem 0.8rem;
    border-radius: 50px;
    letter-spacing: 0.05em;
}

/* 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(255, 255, 255, 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.2);
}

input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.15);
}

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

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

/* 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(--dotnet-purple));
    color: white;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.3);
}

@media (hover: hover) {
    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 30px rgba(124, 58, 237, 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(255, 255, 255, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

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

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

/* Level buttons */
.level-btn {
    position: relative;
    overflow: hidden;
}

.level-btn .level-desc {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    opacity: 0.7;
    margin-top: 0.2rem;
}

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

/* Room / Lobby */
.room-code {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 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.3);
}

.room-code .code {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: 10px;
    background: linear-gradient(135deg, var(--csharp-green), 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(255, 255, 255, 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(124, 58, 237, 0.1);
    }
}

.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(255, 255, 255, 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.2);
}

.player-list .host-badge {
    background: linear-gradient(135deg, var(--accent), var(--dotnet-purple));
    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;
    font-family: var(--font-heading);
}

.question-category {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 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(--csharp-green), var(--accent));
    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);
    font-family: var(--font-heading);
}

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

.question-text code {
    font-family: var(--font-heading);
    background: rgba(124, 58, 237, 0.15);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.95em;
    color: var(--csharp-green);
}

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

.option-btn {
    width: 100%;
    padding: 1rem 1.1rem;
    border: 2px solid rgba(255, 255, 255, 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.2);
}

@media (hover: hover) {
    .option-btn:hover:not(:disabled) {
        border-color: var(--accent);
        background: rgba(124, 58, 237, 0.08);
        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(124, 58, 237, 0.1);
}

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

.option-btn.correct {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

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

.option-btn.incorrect {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.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(255, 255, 255, 0.06);
    border-radius: 12px;
    margin-bottom: 0.5rem;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.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(1) .score-position { background: var(--gold); color: #1a1d27; }
.score-entry:nth-child(2) .score-position { background: var(--silver); color: #1a1d27; }
.score-entry:nth-child(3) .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;
    font-family: var(--font-heading);
}

/* 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(124, 58, 237, 0.3));
}

.winner-name {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--csharp-green), 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;
}

/* Level badge on game over */
.game-level-badge {
    display: inline-block;
    margin-top: 0.8rem;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-light);
    border: 1px solid rgba(124, 58, 237, 0.3);
    padding: 0.3rem 1rem;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Review Questions */
#review-section {
    margin-top: 1rem;
}

.review-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    padding: 1.2rem;
    margin-bottom: 0.8rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.review-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.review-number {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--accent);
}

.review-category {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0.2rem 0.7rem;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
}

.review-status {
    margin-left: auto;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.2rem 0.7rem;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.review-correct {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.review-incorrect {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.review-skipped {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
}

.review-text {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    line-height: 1.5;
}

.review-options {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.review-option {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
    font-size: 0.88rem;
    background: var(--bg-secondary);
    border: 1px solid transparent;
}

.review-option-correct {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.review-option-wrong {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.review-option-letter {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}

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

.review-option-wrong .review-option-letter {
    background: var(--error);
    color: white;
}

/* 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(--csharp-green), 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(124, 58, 237, 0.2));
}

@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(239, 68, 68, 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: 1.9rem; }
    .room-code .code { font-size: 2.2rem; letter-spacing: 6px; }
    .question-text { font-size: 1.05rem; }
    .container { padding: 0.8rem; }
}
