/* Quiz Race Online - Mobile-first styles */

:root {
    --primary: #6C5CE7;
    --primary-dark: #5849c4;
    --secondary: #00CEC9;
    --success: #00B894;
    --danger: #FF7675;
    --warning: #FDCB6E;
    --bg: #2D3436;
    --bg-light: #3D4446;
    --text: #DFE6E9;
    --text-muted: #B2BEC3;
    --card: #636E72;

    --player1-color: #FF6B6B;
    --player2-color: #4ECDC4;
    --player3-color: #95E87E;

    --transition-speed: 0.3s;
    --border-radius: 12px;
}

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

html, body {
    height: 100%;
    height: 100dvh;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow: hidden;
}

/* Screen Management */
.screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
}

.screen.active {
    display: flex;
}

/* Container */
.container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.center-content {
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 16px;
}

/* Logo */
.logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-emoji {
    font-size: 64px;
    display: block;
    margin-bottom: 8px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    border: 2px solid var(--card);
    border-radius: var(--border-radius);
    background: var(--bg-light);
    color: var(--text);
    transition: border-color var(--transition-speed);
}

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

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

.code-input {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 8px;
    text-transform: uppercase;
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 56px;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text);
    border: 2px solid var(--card);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-small {
    padding: 10px 16px;
    font-size: 0.9rem;
    min-height: 44px;
    width: auto;
}

.btn-icon {
    font-size: 1.2rem;
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--text-muted);
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--card);
}

.divider span {
    padding: 0 16px;
    font-size: 0.85rem;
}

/* Room Info (Waiting Screen) */
.room-info {
    text-align: center;
    padding: 24px;
    background: var(--bg-light);
    border-radius: var(--border-radius);
    margin-bottom: 24px;
}

.room-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.room-code {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 8px;
    color: var(--secondary);
    margin-bottom: 16px;
}

/* Players List */
.players-list {
    flex: 1;
    margin-bottom: 24px;
}

.players-list h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.player-slot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-light);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
}

.player-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.player-avatar.p1 { background: var(--player1-color); }
.player-avatar.p2 { background: var(--player2-color); }
.player-avatar.p3 { background: var(--player3-color); }

.player-name {
    flex: 1;
    font-weight: 500;
}

.host-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    background: var(--warning);
    color: var(--bg);
    border-radius: 4px;
    font-weight: 600;
}

.waiting-slot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    font-style: italic;
}

.waiting-icon {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.waiting-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Race Screen */
.race-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    padding: 12px;
    gap: 12px;
}

/* Race Track */
.race-track {
    background: var(--bg-light);
    border-radius: var(--border-radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    height: 45%;
    min-height: 200px;
}

.track-finish,
.track-start {
    text-align: center;
    padding: 8px;
    font-weight: 600;
    font-size: 0.85rem;
}

.track-finish {
    background: linear-gradient(90deg, var(--bg), var(--warning), var(--bg));
    border-radius: 8px 8px 0 0;
}

.track-start {
    background: linear-gradient(90deg, var(--bg), var(--success), var(--bg));
    border-radius: 0 0 8px 8px;
}

.track-lanes {
    flex: 1;
    display: flex;
    gap: 4px;
    padding: 8px 4px;
    overflow: hidden;
}

.track-lane {
    flex: 1;
    display: flex;
    flex-direction: column-reverse;
    gap: 2px;
    position: relative;
}

.track-lane::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background: repeating-linear-gradient(
        to bottom,
        var(--card) 0,
        var(--card) 8px,
        transparent 8px,
        transparent 16px
    );
    transform: translateX(-50%);
    opacity: 0.3;
}

.track-cell {
    height: calc((100% - 18px) / 10);
    min-height: 16px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.track-cell.has-player {
    background: rgba(255, 255, 255, 0.1);
}

.player-marker {
    font-size: 1.2rem;
    animation: markerPop 0.3s ease-out;
}

@keyframes markerPop {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.lane-header {
    text-align: center;
    padding: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Question Area */
.question-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-light);
    border-radius: var(--border-radius);
    padding: 16px;
    overflow-y: auto;
}

.question-header {
    text-align: center;
    margin-bottom: 12px;
}

.question-header span {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 4px 12px;
    border-radius: 20px;
}

.question-card {
    background: var(--bg);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 16px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.question-text {
    font-size: 1.1rem;
    font-weight: 500;
    text-align: center;
    line-height: 1.4;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.option-btn {
    padding: 14px 16px;
    font-size: 1rem;
    background: var(--bg);
    border: 2px solid var(--card);
    border-radius: var(--border-radius);
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition-speed);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    text-align: left;
}

.option-btn:active:not(:disabled) {
    transform: scale(0.98);
}

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

.option-btn.selected {
    border-color: var(--primary);
    background: rgba(108, 92, 231, 0.2);
}

.option-btn.correct {
    border-color: var(--success);
    background: rgba(0, 184, 148, 0.2);
}

.option-btn.incorrect {
    border-color: var(--danger);
    background: rgba(255, 118, 117, 0.2);
}

/* Feedback */
.feedback {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-radius: var(--border-radius);
    margin-top: 12px;
    font-weight: 600;
}

.feedback.show {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.feedback.correct {
    background: rgba(0, 184, 148, 0.2);
    color: var(--success);
}

.feedback.incorrect {
    background: rgba(255, 118, 117, 0.2);
    color: var(--danger);
}

.feedback-icon {
    font-size: 1.2rem;
}

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

/* Finished Screen */
.result-header {
    text-align: center;
    margin-bottom: 32px;
}

.trophy {
    font-size: 64px;
    display: block;
    margin-bottom: 16px;
    animation: trophyBounce 1s ease-out;
}

@keyframes trophyBounce {
    0% { transform: scale(0) rotate(-15deg); }
    50% { transform: scale(1.2) rotate(5deg); }
    100% { transform: scale(1) rotate(0); }
}

.result-header h2 {
    font-size: 1.5rem;
}

/* Podium */
.podium {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 32px;
}

.podium-position {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-light);
    border-radius: var(--border-radius);
}

.podium-position.first {
    background: linear-gradient(135deg, rgba(253, 203, 110, 0.3), rgba(253, 203, 110, 0.1));
    border: 2px solid var(--warning);
}

.podium-medal {
    font-size: 2rem;
}

.podium-name {
    flex: 1;
    font-weight: 600;
    font-size: 1.1rem;
}

.podium-position.first .podium-name {
    color: var(--warning);
}

.podium-score {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.finished-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
}

/* Error Screen */
.error-icon {
    font-size: 64px;
}

/* Spinner */
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--card);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Tablet+ */
@media (min-width: 768px) {
    .race-container {
        flex-direction: row;
        max-width: 900px;
        margin: 0 auto;
    }

    .race-track {
        width: 40%;
        height: auto;
        min-height: auto;
    }

    .question-area {
        width: 60%;
    }

    .track-lanes {
        height: 100%;
    }
}
