/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #fff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top: 5px solid #00ff88;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.2em;
    color: #00ff88;
    font-weight: bold;
}

/* Container */
.container {
    width: 100%;
    max-width: 1400px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

/* Auth Section */
.auth-section {
    padding: 50px 30px;
    text-align: center;
}

.logo {
    margin-bottom: 40px;
}

.logo i {
    font-size: 3.5em;
    color: #00ff88;
    margin-bottom: 15px;
}

.logo h2 {
    font-size: 2.2em;
    color: white;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}

.auth-form {
    max-width: 400px;
    margin: 0 auto;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #00ff88;
    font-size: 1.2em;
}

.input-group input {
    width: 100%;
    padding: 15px 15px 15px 45px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: white;
    font-size: 1em;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #00ff88;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
}

.auth-form button {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #00ff88, #00cc6a);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.auth-form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 255, 136, 0.4);
}

.auth-options {
    margin: 20px 0;
}

.option-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: rgba(255, 255, 255, 0.5);
}

.option-divider::before,
.option-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
}

.option-divider span {
    padding: 0 15px;
    font-size: 0.9em;
}

.btn-google {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #4285F4, #3367D6);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-google:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(66, 133, 244, 0.4);
}

.note {
    margin-top: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.note i {
    color: #00ff88;
}

/* Game Section */
.game-section {
    display: none;
}

/* Header */
header {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.game-title h1 {
    font-size: 1.8em;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

.game-title i {
    color: #00ff88;
}

.player-info-card {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 10px;
    min-width: 250px;
}

.player-avatar i {
    font-size: 2.5em;
    color: #00ff88;
}

.player-details {
    flex: 1;
}

.player-name {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 5px;
}

.player-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.7);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00ff88;
}

.status-indicator.online {
    background: #00ff88;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.btn-logout {
    background: rgba(255, 51, 102, 0.2);
    color: #ff3366;
    border: 1px solid rgba(255, 51, 102, 0.3);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: rgba(255, 51, 102, 0.3);
    transform: scale(1.1);
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 20px;
    padding: 30px;
    min-height: 600px;
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .left-panel,
    .right-panel {
        order: 2;
    }
    
    .center-panel {
        order: 1;
    }
}

/* Panel Cards */
.panel-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-card h3 {
    color: #00ff88;
    margin-bottom: 20px;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-card h3 i {
    font-size: 1.1em;
}

/* Left Panel */
.option-section {
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.option-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.option-section h4 {
    color: white;
    margin-bottom: 10px;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-section p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9em;
    margin-bottom: 15px;
    line-height: 1.4;
}

.btn-primary,
.btn-secondary,
.btn-danger {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #00ff88, #00cc6a);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 255, 136, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, #ff3366, #cc2952);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 51, 102, 0.4);
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.code-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.join-game {
    display: flex;
    gap: 10px;
}

.join-game .input-group {
    flex: 1;
    margin: 0;
}

.join-game .input-group input {
    text-align: center;
    font-size: 1.1em;
    letter-spacing: 2px;
    font-weight: bold;
    padding: 12px;
}

.game-info-section .game-details {
    margin-top: 15px;
}

.game-code-show,
.game-status-display {
    margin-bottom: 15px;
}

.game-code-show label,
.game-status-display label {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9em;
    margin-bottom: 5px;
}

.code-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.code-display span {
    font-size: 1.5em;
    font-weight: bold;
    letter-spacing: 3px;
    color: #00ff88;
}

.btn-copy {
    background: rgba(0, 255, 136, 0.2);
    color: #00ff88;
    border: none;
    border-radius: 6px;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-copy:hover {
    background: rgba(0, 255, 136, 0.3);
    transform: scale(1.1);
}

#currentGameStatus {
    font-size: 1.1em;
    font-weight: bold;
    color: #ffcc00;
}

/* Players List */
.players-list {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 5px;
}

.players-list::-webkit-scrollbar {
    width: 6px;
}

.players-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.players-list::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 136, 0.3);
    border-radius: 3px;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.player-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.player-item-avatar {
    width: 35px;
    height: 35px;
    background: rgba(0, 255, 136, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-item-avatar i {
    color: #00ff88;
}

.player-item-name {
    flex: 1;
    font-size: 0.95em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-item-status .status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00ff88;
}

/* Center Panel */
.game-status-card {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.1), rgba(0, 204, 106, 0.1));
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid rgba(0, 255, 136, 0.2);
}

.status-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-icon i {
    font-size: 2.5em;
    color: #00ff88;
}

.status-text h3 {
    font-size: 1.4em;
    margin-bottom: 5px;
    color: white;
}

.status-text p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.95em;
}

.turn-indicator {
    margin-top: 15px;
    padding: 10px 15px;
    background: rgba(255, 204, 0, 0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ffcc00;
    font-weight: bold;
    animation: pulseTurn 1.5s infinite;
}

@keyframes pulseTurn {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.game-board-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 15px;
    max-width: 400px;
    margin: 0 auto 25px;
    aspect-ratio: 1/1;
}

.cell {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.cell:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

.cell.x {
    color: #00ff88;
    text-shadow: 0 0 15px rgba(0, 255, 136, 0.5);
}

.cell.o {
    color: #ff3366;
    text-shadow: 0 0 15px rgba(255, 51, 102, 0.5);
}

.cell.win {
    background: rgba(255, 215, 0, 0.3);
    border-color: gold;
    animation: winGlow 0.5s infinite alternate;
}

@keyframes winGlow {
    from { box-shadow: 0 0 10px gold; }
    to { box-shadow: 0 0 20px gold; }
}

.cell.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.board-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.player-symbols {
    display: flex;
    align-items: center;
    gap: 20px;
}

.symbol-display {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border-radius: 10px;
    min-width: 150px;
}

.player-x {
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.player-o {
    background: rgba(255, 51, 102, 0.1);
    border: 1px solid rgba(255, 51, 102, 0.3);
}

.symbol {
    font-size: 1.8em;
    font-weight: bold;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.player-x .symbol {
    background: rgba(0, 255, 136, 0.2);
    color: #00ff88;
}

.player-o .symbol {
    background: rgba(255, 51, 102, 0.2);
    color: #ff3366;
}

.symbol-label {
    font-size: 1em;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.vs-text {
    font-size: 1.2em;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.5);
}

.btn-restart {
    padding: 12px 25px;
    background: linear-gradient(135deg, #4a6fa5, #3a5980);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-restart:hover:not(:disabled) {
    background: linear-gradient(135deg, #5a7fb5, #4a6980);
    transform: translateY(-2px);
}

/* History Section */
.history-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.history-section h3 {
    color: white;
    margin-bottom: 15px;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.moves-list {
    max-height: 150px;
    overflow-y: auto;
    padding-right: 5px;
}

.moves-list::-webkit-scrollbar {
    width: 6px;
}

.moves-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.moves-list::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 136, 0.3);
    border-radius: 3px;
}

.empty-moves {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    padding: 20px;
}

.move-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.move-player {
    font-weight: bold;
    min-width: 30px;
    text-align: center;
}

.move-player.x {
    color: #00ff88;
}

.move-player.o {
    color: #ff3366;
}

.move-details {
    flex: 1;
    font-size: 0.9em;
}

.move-time {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8em;
}

/* Right Panel */
.game-players {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.player-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.player-card-header {
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    font-weight: bold;
}

.player-card-header.player-x {
    background: rgba(0, 255, 136, 0.2);
}

.player-card-header.player-o {
    background: rgba(255, 51, 102, 0.2);
}

.player-card-header i {
    font-size: 1.2em;
}

.player-symbol {
    font-size: 1.3em;
}

.player-card-body {
    padding: 15px;
    text-align: center;
}

.player-card-name {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-card-status {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.7);
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.game-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.stat-item i {
    font-size: 1.5em;
    color: #00ff88;
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.3em;
    font-weight: bold;
    color: white;
}

/* Chat Section */
.chat-container {
    height: 200px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-bottom: 10px;
}

.chat-welcome {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    padding: 20px;
}

.chat-welcome i {
    font-size: 2em;
    margin-bottom: 10px;
    display: block;
}

.chat-input {
    display: flex;
    gap: 10px;
}

.chat-input input {
    flex: 1;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
}

.chat-input button {
    width: 45px;
    background: linear-gradient(135deg, #00ff88, #00cc6a);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-input button:hover:not(:disabled) {
    background: linear-gradient(135deg, #00ff88, #00cc6a);
    transform: scale(1.05);
}

/* Footer */
footer {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9em;
}

.footer-left i {
    color: #ff3366;
}

.footer-right {
    font-size: 0.9em;
    color: #00ff88;
    font-weight: bold;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        border-radius: 10px;
    }
    
    .main-content {
        padding: 15px;
        grid-template-columns: 1fr;
    }
    
    .game-board {
        max-width: 300px;
    }
    
    .cell {
        font-size: 3em;
    }
    
    .board-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .player-symbols {
        justify-content: center;
    }
    
    .header-content {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .player-info-card {
        justify-content: center;
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .game-board {
        max-width: 250px;
    }
    
    .cell {
        font-size: 2.5em;
    }
    
    .symbol-display {
        min-width: 120px;
    }
    
    .auth-section {
        padding: 30px 15px;
    }
    
    .logo h2 {
        font-size: 1.8em;
    }
}

/* Animation for new moves */
@keyframes newMove {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.new-move {
    animation: newMove 0.3s ease-out;
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    border-left: 4px solid #00ff88;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
    max-width: 300px;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success {
    border-left-color: #00ff88;
}

.toast.error {
    border-left-color: #ff3366;
}

.toast.info {
    border-left-color: #4a6fa5;
}