/* ============================================================================
   Global Styles
   ============================================================================ */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #333;
}

.container {
    width: 100%;
    max-width: 800px;
}

/* ============================================================================
   Typography
   ============================================================================ */

h1 {
    font-size: 2.5rem;
    color: #fff;
    text-align: center;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

h2 {
    font-size: 2rem;
    color: #333;
    margin-bottom: 20px;
}

h3 {
    font-size: 1.3rem;
    color: #555;
    margin-bottom: 15px;
}

.subtitle {
    text-align: center;
    color: rgba(255,255,255,0.9);
    font-size: 1.1rem;
    margin-bottom: 30px;
}

.green-text {
    color: #10b981;
    font-weight: bold;
}

/* ============================================================================
   Main Menu
   ============================================================================ */

.main-menu {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.menu-buttons {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.menu-buttons .btn {
    flex: 1;
    padding: 30px;
    font-size: 1.3rem;
}

.btn-icon {
    display: block;
    font-size: 3rem;
    margin-bottom: 10px;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
    display: inline-block;
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

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

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-secondary {
    background: #6366f1;
    color: white;
}

.btn-secondary:hover {
    background: #4f46e5;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-back {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 10px 20px;
    font-size: 0.9rem;
}

.btn-large {
    padding: 20px 50px;
    font-size: 1.5rem;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

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

/* ============================================================================
   Info Box
   ============================================================================ */

.info-box {
    background: #f8fafc;
    border-left: 4px solid #667eea;
    padding: 20px;
    border-radius: 10px;
}

.info-box ul {
    list-style: none;
    padding-left: 0;
}

.info-box li {
    padding: 10px 0;
    border-bottom: 1px solid #e2e8f0;
}

.info-box li:last-child {
    border-bottom: none;
}

/* ============================================================================
   Game Header
   ============================================================================ */

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* ============================================================================
   Screen Management
   ============================================================================ */

.screen {
    display: none;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.screen.active {
    display: block;
}

/* ============================================================================
   Reaction Box (Core Game Element)
   ============================================================================ */

.reaction-box {
    width: 100%;
    height: 400px;
    border-radius: 15px;
    cursor: pointer;
    transition: background-color 0.1s ease;
    box-shadow: inset 0 4px 10px rgba(0,0,0,0.1);
    margin-top: 20px;
}

.reaction-box.waiting {
    background-color: #e5e7eb;
}

.reaction-box.ready {
    background-color: white;
}

.reaction-box.go {
    background-color: #10b981;
}

.reaction-box.too-early {
    background-color: #ef4444;
}

.status-text {
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

/* ============================================================================
   Results
   ============================================================================ */

.results-container {
    text-align: center;
}

.result-time {
    margin: 30px 0;
}

.big-number {
    font-size: 5rem;
    font-weight: bold;
    color: #667eea;
}

.unit {
    font-size: 2rem;
    color: #666;
}

.result-message {
    font-size: 1.2rem;
    color: #555;
    margin-bottom: 30px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.stat-item {
    background: #f8fafc;
    padding: 20px;
    border-radius: 10px;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #667eea;
}

.result-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

.warning {
    color: #ef4444;
    font-weight: bold;
}

/* ============================================================================
   Multiplayer - Join/Create
   ============================================================================ */

.join-container {
    max-width: 600px;
    margin: 0 auto;
}

.input-text, .input-number {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 15px;
}

.input-text:focus, .input-number:focus {
    outline: none;
    border-color: #667eea;
}

.join-options {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 30px;
    margin-top: 30px;
}

.option-box {
    background: #f8fafc;
    padding: 20px;
    border-radius: 10px;
}

.option-box .btn {
    width: 100%;
    margin-top: 10px;
}

.divider {
    display: flex;
    align-items: center;
    font-weight: bold;
    color: #999;
}

/* ============================================================================
   Lobbies List
   ============================================================================ */

.lobbies-list {
    margin-top: 15px;
    max-height: 200px;
    overflow-y: auto;
}

.lobby-item {
    background: white;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid #e2e8f0;
    transition: all 0.2s;
}

.lobby-item:hover {
    border-color: #667eea;
    background: #f8fafc;
}

.lobby-item-header {
    font-weight: bold;
    color: #333;
}

.lobby-item-info {
    font-size: 0.9rem;
    color: #666;
}

/* ============================================================================
   Lobby Screen
   ============================================================================ */

.lobby-container {
    max-width: 600px;
    margin: 0 auto;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.lobby-info {
    background: #f8fafc;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.lobby-info p {
    margin: 5px 0;
}

.players-list {
    margin-bottom: 30px;
}

.players-list ul {
    list-style: none;
    background: #f8fafc;
    padding: 15px;
    border-radius: 10px;
}

.players-list li {
    padding: 10px;
    margin-bottom: 5px;
    background: white;
    border-radius: 5px;
}

.players-list .host {
    font-weight: bold;
    color: #667eea;
}

.players-list .host::after {
    content: " (Host)";
    font-size: 0.85rem;
}

.host-controls {
    text-align: center;
}

.host-controls .hint {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #666;
}

.waiting-message {
    text-align: center;
    padding: 30px;
    background: #f8fafc;
    border-radius: 10px;
}

.waiting-message p {
    font-size: 1.1rem;
    color: #666;
}

/* ============================================================================
   Game Info
   ============================================================================ */

.game-info {
    text-align: center;
    margin-bottom: 20px;
}

.round-info {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
}

/* ============================================================================
   Round Results
   ============================================================================ */

.round-results-list, .final-results-list {
    margin: 20px 0;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    background: #f8fafc;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.result-item.first {
    border-left-color: #fbbf24;
    background: #fffbeb;
}

.result-item.flagged {
    border-left-color: #ef4444;
    background: #fef2f2;
}

.result-name {
    font-weight: bold;
    font-size: 1.1rem;
}

.result-time-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: #667eea;
}

.result-rank {
    font-size: 2rem;
    font-weight: bold;
    color: #999;
    margin-right: 15px;
}

.result-item.first .result-rank {
    color: #fbbf24;
}

.flag-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-left: 10px;
}

.flag-badge.too-fast {
    background: #fef2f2;
    color: #ef4444;
}

.flag-badge.too-slow {
    background: #fef3c7;
    color: #f59e0b;
}

.next-round-message {
    text-align: center;
    margin-top: 20px;
    font-size: 1.1rem;
    color: #666;
}

/* ============================================================================
   Final Results
   ============================================================================ */

.final-stats {
    display: flex;
    justify-content: space-around;
    font-size: 0.9rem;
    color: #666;
    margin-top: 5px;
}

/* ============================================================================
   Error Message
   ============================================================================ */

.error-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ef4444;
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: none;
    animation: slideIn 0.3s ease;
}

.error-message.show {
    display: block;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    .menu-buttons {
        flex-direction: column;
    }

    .join-options {
        grid-template-columns: 1fr;
    }

    .divider {
        justify-content: center;
        padding: 10px 0;
    }

    .reaction-box {
        height: 300px;
    }

    .big-number {
        font-size: 3.5rem;
    }

    .result-buttons {
        flex-direction: column;
    }

    .result-buttons .btn {
        width: 100%;
    }
}
