/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Screen management */
.screen {
    display: none;
    width: 100%;
}

.screen.active {
    display: block;
}

/* Typography */
h1 {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    text-align: center;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

h2 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    min-width: 120px;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
}

.btn-secondary {
    background: linear-gradient(45deg, #48CAE4, #0077B6);
    color: white;
    box-shadow: 0 4px 15px rgba(72, 202, 228, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(72, 202, 228, 0.6);
}

.btn-outline {
    background: transparent;
    color: white;
    border: 2px solid white;
}

.btn-outline:hover {
    background: white;
    color: #667eea;
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(45deg, #FF6B6B, #FF8E53);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
}

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

.btn-icon {
    background: none;
    border: none;
    color: #666;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: #f0f0f0;
}

/* Input fields */
input[type="text"] {
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 12px;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    background: white;
    transition: all 0.3s ease;
    min-width: 200px;
}

input[type="text"]:focus {
    outline: none;
    border-color: #4ECDC4;
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.1);
}

/* Lobby Styles */
.lobby-content {
    background: white;
    padding: 3rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.player-setup {
    margin-bottom: 2rem;
}

.game-modes {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.room-section {
    border-top: 1px solid #eee;
    padding-top: 1.5rem;
}

.room-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.join-room {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

/* Waiting Screen */
.waiting-content {
    background: white;
    padding: 3rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4ECDC4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 2rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Game Screen */
#game .container {
    max-width: 1400px;
    justify-content: flex-start;
    padding-top: 20px;
}

.game-header {
    width: 100%;
    background: white;
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.player {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    background: #f8f9fa;
    transition: all 0.3s ease;
}

.player.active {
    background: linear-gradient(45deg, #4ECDC4, #44A08D);
    color: white;
    transform: scale(1.05);
}

.player-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.turn-indicator {
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.player.active .turn-indicator {
    opacity: 1;
    color: #FFD93D;
}

.vs {
    font-weight: 700;
    color: #666;
    font-size: 1.2rem;
}

.game-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

#game-status {
    font-weight: 600;
    color: #4ECDC4;
    font-size: 1.1rem;
}

#room-code-display {
    font-size: 0.9rem;
    color: #666;
    background: #f0f0f0;
    padding: 4px 8px;
    border-radius: 6px;
}

/* Game Content */
.game-content {
    display: flex;
    gap: 2rem;
    width: 100%;
    align-items: flex-start;
}

.game-board {
    flex: 1;
    min-width: 0;
}

.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    background: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    max-width: 400px;
    margin: 0 auto;
}

.cell {
    aspect-ratio: 1;
    background: #f8f9fa;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.cell:hover {
    background: #e9ecef;
    transform: scale(1.05);
}

.cell.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.cell img {
    width: 80%;
    height: 80%;
    object-fit: contain;
    animation: placeMove 0.3s ease-out;
}

@keyframes placeMove {
    0% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Chat Section */
.chat-section {
    width: 300px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    height: 400px;
}

.chat-header {
    padding: 1rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background: #f8f9fa;
}

.chat-message {
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.chat-message .player-name {
    font-weight: 600;
    color: #4ECDC4;
    font-size: 0.9rem;
}

.chat-message .timestamp {
    font-size: 0.8rem;
    color: #666;
    float: right;
}

.chat-message .message {
    margin-top: 0.25rem;
    font-size: 0.9rem;
}

.chat-input {
    padding: 1rem;
    border-top: 1px solid #eee;
    display: flex;
    gap: 0.5rem;
}

.chat-input input {
    flex: 1;
    min-width: 0;
    margin: 0;
}

/* Game Controls */
.game-controls {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    0% {
        transform: translateY(-50px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header h2 {
    color: #333;
    margin-bottom: 1rem;
}

.winner-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
}

.winner-display img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid #4ECDC4;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.winner-display span {
    font-size: 1.5rem;
    font-weight: 600;
    color: #4ECDC4;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Notification Toast */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 2000;
    max-width: 300px;
}

.notification.show {
    transform: translateX(0);
}

.notification.error {
    background: #FF6B6B;
}

.notification.success {
    background: #4ECDC4;
}

.notification.warning {
    background: #FFD93D;
    color: #333;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .game-content {
        flex-direction: column;
        align-items: center;
    }
    
    .chat-section {
        width: 100%;
        max-width: 400px;
        height: 300px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .lobby-content,
    .waiting-content {
        padding: 2rem 1.5rem;
    }
    
    .game-header {
        flex-direction: column;
        text-align: center;
    }
    
    .player-info {
        gap: 1rem;
    }
    
    .board {
        max-width: 300px;
        padding: 15px;
    }
    
    .game-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .join-room {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 5px;
    }
    
    .lobby-content,
    .waiting-content {
        padding: 1.5rem 1rem;
    }
    
    .board {
        max-width: 250px;
        padding: 10px;
        gap: 6px;
    }
    
    .player {
        flex-direction: column;
        gap: 0.25rem;
        padding: 0.5rem;
    }
    
    .player-icon {
        width: 24px;
        height: 24px;
    }
    
    .vs {
        display: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .modal-content,
    .lobby-content,
    .waiting-content,
    .game-header,
    .board,
    .chat-section {
        background: #2a2a2a;
        color: #e0e0e0;
    }
    
    .cell {
        background: #3a3a3a;
    }
    
    .cell:hover {
        background: #4a4a4a;
    }
    
    .chat-messages {
        background: #1a1a1a;
    }
    
    .chat-message {
        background: #3a3a3a;
    }
    
    input[type="text"] {
        background: #3a3a3a;
        border-color: #555;
        color: #e0e0e0;
    }
}

/* Print styles */
@media print {
    .screen:not(#game) {
        display: none !important;
    }
    
    .chat-section,
    .game-controls {
        display: none !important;
    }
}
