* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90d9;
    --primary-dark: #357abd;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --bg-color: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --text-color: #eee;
    --text-muted: #aaa;
    --border-radius: 12px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
}

#app {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.header {
    background: var(--bg-secondary);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.header h1 {
    font-size: 1.3rem;
    font-weight: 600;
}

.player-info {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.main-content {
    flex: 1;
    padding: 16px;
    padding-bottom: 30px;
}

.section {
    display: none;
}

.section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.name-input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}

.name-input-container input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--bg-card);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    color: var(--text-color);
    font-size: 1rem;
}

.name-input-container input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
}

.game-list h2, .room-list h2 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.game-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.game-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.game-card:active {
    transform: scale(0.98);
}

.game-card.selected {
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 20px rgba(74, 144, 217, 0.3);
}

.game-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.game-info h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.game-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.room-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.join-room {
    display: flex;
    gap: 10px;
}

.join-room input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--bg-card);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    color: var(--text-color);
    font-size: 1rem;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 4px;
}

.room-list {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--border-radius);
}

#roomListContainer {
    margin-bottom: 12px;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-card);
    border-radius: 8px;
    margin-bottom: 8px;
}

.room-item-code {
    font-weight: 600;
    font-size: 1.1rem;
}

.room-item-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.room-code {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
}

.room-info {
    text-align: center;
    margin-bottom: 24px;
}

.room-info h2 {
    font-size: 1.5rem;
    margin-bottom: 16px;
}

.players-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.player-badge {
    padding: 10px 20px;
    background: var(--bg-card);
    border-radius: 20px;
    font-size: 0.95rem;
}

.player-badge.host {
    border: 2px solid var(--warning-color);
}

.player-badge.current {
    background: var(--primary-color);
}

.room-status {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 1rem;
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-status {
    font-size: 1.1rem;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-color);
    padding: 12px 24px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1000;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    opacity: 1;
}

.toast.error {
    background: var(--danger-color);
}

.toast.success {
    background: var(--success-color);
}

@media (min-width: 768px) {
    .main-content {
        max-width: 600px;
        margin: 0 auto;
    }
    
    .game-cards {
        flex-direction: row;
    }
    
    .game-card {
        flex: 1;
    }
}
