/* ==================== CSS VARIABLES ==================== */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-tertiary: #1a1a3a;
    --bg-card: rgba(30, 30, 60, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.05);
    
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    
    --red: #ff4757;
    --red-glow: rgba(255, 71, 87, 0.5);
    --yellow: #ffc048;
    --yellow-glow: rgba(255, 192, 72, 0.5);
    
    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --accent-glow: rgba(108, 92, 231, 0.4);
    
    --success: #00d26a;
    --warning: #ffc048;
    --error: #ff4757;
    
    --border-radius: 16px;
    --border-radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px var(--accent-glow);
}

/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-primary);
    background-image: 
        radial-gradient(ellipse at top, rgba(108, 92, 231, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at bottom, rgba(255, 71, 87, 0.1) 0%, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ==================== HOME BUTTON ==================== */
.home-button {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 48px;
    height: 48px;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    z-index: 1000;
}

.home-button:hover {
    background: var(--accent);
    color: white;
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.home-button svg {
    width: 24px;
    height: 24px;
}

/* ==================== SCREENS ==================== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.screen.active {
    display: flex;
}

/* ==================== MENU ==================== */
.menu-container {
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.logo {
    margin-bottom: 40px;
}

.logo-grid {
    display: grid;
    grid-template-columns: repeat(4, 30px);
    gap: 6px;
    justify-content: center;
    margin-bottom: 20px;
}

.logo-grid span {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    animation: logoPulse 2s infinite;
}

.logo-grid span.red {
    background: var(--red);
    box-shadow: 0 0 20px var(--red-glow);
}

.logo-grid span.yellow {
    background: var(--yellow);
    box-shadow: 0 0 20px var(--yellow-glow);
    animation-delay: 0.5s;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.9); opacity: 0.8; }
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--red), var(--yellow));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 40px rgba(255, 71, 87, 0.3);
}

/* Player Info */
.player-info {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
}

.player-info input {
    flex: 1;
    padding: 14px 18px;
    background: var(--bg-glass);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.player-info input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.rating-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    background: var(--bg-glass);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    color: var(--yellow);
    font-weight: 600;
}

/* Menu Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon {
    font-size: 1.3rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    box-shadow: var(--shadow-md), 0 0 20px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 30px var(--accent-glow);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--red), #ff6b7a);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 20px var(--red-glow);
}

.btn-tertiary {
    background: var(--bg-glass);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    backdrop-filter: blur(10px);
}

.btn-tertiary:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

.btn-back {
    background: transparent;
    color: var(--text-secondary);
    padding: 12px;
}

.btn-back:hover {
    color: var(--text-primary);
}

.btn-copy {
    background: var(--bg-glass);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 12px 20px;
    font-size: 0.95rem;
}

.btn-copy:hover {
    background: var(--accent);
}

/* ==================== MODAL CONTAINER ==================== */
.modal-container {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 40px;
    text-align: center;
    max-width: 450px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.modal-container h2 {
    font-size: 1.6rem;
    margin-bottom: 24px;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-container input {
    width: 100%;
    padding: 16px 20px;
    background: var(--bg-glass);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1.1rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 4px;
    margin-bottom: 20px;
    transition: var(--transition);
}

.modal-container input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Difficulty Buttons */
.difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.difficulty-btn {
    display: flex;
    align-items: center;
    padding: 20px;
    background: var(--bg-glass);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}

.difficulty-btn:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.difficulty-icon {
    font-size: 2rem;
    margin-right: 16px;
}

.difficulty-name {
    font-size: 1.1rem;
    font-weight: 600;
    display: block;
}

.difficulty-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.difficulty-btn.easy:hover { border-color: var(--success); }
.difficulty-btn.medium:hover { border-color: var(--warning); }
.difficulty-btn.hard:hover { border-color: var(--error); }

/* Waiting Screen */
.modal-container.waiting {
    padding: 50px 40px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--bg-glass);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.room-code {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 8px;
    color: var(--accent-light);
    background: var(--bg-glass);
    padding: 16px 24px;
    border-radius: var(--border-radius-sm);
    margin: 20px 0;
    font-family: monospace;
}

.queue-position {
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* ==================== GAME SCREEN ==================== */
.game-container {
    display: grid;
    grid-template-columns: 1fr 280px;
    grid-template-rows: auto 1fr;
    gap: 20px;
    max-width: 1000px;
    width: 100%;
    height: 100%;
    max-height: 700px;
    padding: 20px;
}

/* Players Bar */
.players-bar {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    padding: 16px 24px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
}

.player {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.player.active {
    background: var(--bg-glass);
    box-shadow: var(--shadow-sm);
}

.player-piece {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.player-piece.red {
    background: var(--red);
    box-shadow: 0 0 15px var(--red-glow);
}

.player-piece.yellow {
    background: var(--yellow);
    box-shadow: 0 0 15px var(--yellow-glow);
}

.player-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.player-name {
    font-weight: 600;
    font-size: 1rem;
}

.player-rating {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.turn-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bg-glass);
    transition: var(--transition);
}

.turn-indicator.active {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.vs {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* Game Board */
.board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.column-indicators {
    display: grid;
    grid-template-columns: repeat(7, 60px);
    gap: 8px;
    margin-bottom: 10px;
}

.indicator {
    height: 30px;
    border-radius: 50%;
    opacity: 0;
    transition: var(--transition);
}

.indicator.red {
    background: var(--red);
    box-shadow: 0 0 20px var(--red-glow);
    opacity: 0.8;
}

.indicator.yellow {
    background: var(--yellow);
    box-shadow: 0 0 20px var(--yellow-glow);
    opacity: 0.8;
}

.board {
    display: grid;
    grid-template-columns: repeat(7, 60px);
    grid-template-rows: repeat(6, 60px);
    gap: 8px;
    padding: 16px;
    background: linear-gradient(145deg, #2a4dd6, #1e3bb0);
    border-radius: var(--border-radius);
    box-shadow: 
        var(--shadow-lg),
        inset 0 2px 10px rgba(255, 255, 255, 0.1),
        inset 0 -2px 10px rgba(0, 0, 0, 0.3);
}

.cell {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: 
        radial-gradient(circle at 30% 30%, rgba(10, 10, 26, 0.9), rgba(10, 10, 26, 1));
    box-shadow: 
        inset 0 4px 10px rgba(0, 0, 0, 0.5),
        0 2px 3px rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.cell:hover:not(.red):not(.yellow) {
    background: 
        radial-gradient(circle at 30% 30%, rgba(30, 30, 60, 0.9), rgba(20, 20, 40, 1));
}

.cell.red {
    background: radial-gradient(circle at 35% 35%, #ff6b7a, var(--red));
    box-shadow: 
        inset 0 -4px 10px rgba(0, 0, 0, 0.3),
        0 0 20px var(--red-glow);
}

.cell.yellow {
    background: radial-gradient(circle at 35% 35%, #ffd06a, var(--yellow));
    box-shadow: 
        inset 0 -4px 10px rgba(0, 0, 0, 0.2),
        0 0 20px var(--yellow-glow);
}

.cell.winning {
    animation: winPulse 0.5s ease-in-out infinite alternate;
}

@keyframes winPulse {
    from { 
        transform: scale(1);
        filter: brightness(1);
    }
    to { 
        transform: scale(1.1);
        filter: brightness(1.3);
    }
}

.cell.dropping {
    animation: drop 0.4s ease-out forwards;
}

@keyframes drop {
    0% { 
        transform: translateY(-400px);
        opacity: 0;
    }
    60% { 
        transform: translateY(10px);
    }
    80% {
        transform: translateY(-5px);
    }
    100% { 
        transform: translateY(0);
        opacity: 1;
    }
}

/* Side Panel */
.side-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.panel-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-btn {
    flex: 1;
    padding: 14px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn.active {
    color: var(--text-primary);
    background: var(--bg-glass);
}

.tab-btn:hover:not(.active) {
    color: var(--text-secondary);
}

.tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.tab-content.active {
    display: flex;
}

/* Chat */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    background: var(--bg-glass);
    max-width: 90%;
}

.chat-message.player-0 {
    align-self: flex-start;
    border-left: 3px solid var(--red);
}

.chat-message.player-1 {
    align-self: flex-end;
    border-right: 3px solid var(--yellow);
}

.chat-message.system {
    align-self: center;
    background: transparent;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85rem;
}

.chat-sender {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.chat-text {
    font-size: 0.95rem;
    word-break: break-word;
}

.chat-input-container {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input-container input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-glass);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
}

.chat-input-container input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-send {
    padding: 10px 16px;
    background: var(--accent);
    border: none;
    border-radius: var(--border-radius-sm);
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

.btn-send:hover {
    background: var(--accent-light);
}

/* Moves List */
.moves-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.move-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 6px;
    background: var(--bg-glass);
    font-size: 0.9rem;
}

.move-number {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 600;
}

.move-item.player-0 .move-number {
    background: var(--red);
    color: white;
}

.move-item.player-1 .move-number {
    background: var(--yellow);
    color: #333;
}

/* ==================== GAME OVER MODAL ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.modal-content h2 {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.rating-change {
    padding: 12px 20px;
    background: var(--bg-glass);
    border-radius: var(--border-radius-sm);
    margin-bottom: 24px;
    font-size: 1.1rem;
}

.rating-change.positive {
    color: var(--success);
}

.rating-change.negative {
    color: var(--error);
}

.game-over-buttons {
    display: flex;
    gap: 12px;
}

.game-over-buttons .btn {
    flex: 1;
}

.rematch-status {
    margin-top: 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-glass);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-light);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
    .game-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
        max-height: none;
        height: auto;
        padding: 10px;
    }
    
    .side-panel {
        order: 3;
        max-height: 200px;
    }
    
    .board-container {
        order: 2;
    }
    
    .players-bar {
        order: 1;
        gap: 15px;
        padding: 12px 16px;
        flex-wrap: wrap;
    }
    
    .column-indicators {
        grid-template-columns: repeat(7, 45px);
    }
    
    .board {
        grid-template-columns: repeat(7, 45px);
        grid-template-rows: repeat(6, 45px);
        gap: 6px;
        padding: 12px;
    }
    
    .cell {
        width: 45px;
        height: 45px;
    }
}

@media (max-width: 500px) {
    .logo h1 {
        font-size: 2rem;
    }
    
    .logo-grid span {
        width: 24px;
        height: 24px;
    }
    
    .menu-container {
        padding: 0 16px;
    }
    
    .modal-container {
        padding: 30px 20px;
    }
    
    .column-indicators {
        grid-template-columns: repeat(7, 38px);
    }
    
    .board {
        grid-template-columns: repeat(7, 38px);
        grid-template-rows: repeat(6, 38px);
        gap: 4px;
        padding: 10px;
    }
    
    .cell {
        width: 38px;
        height: 38px;
    }
    
    .player-piece {
        width: 28px;
        height: 28px;
    }
    
    .player-name {
        font-size: 0.9rem;
    }
    
    .vs {
        display: none;
    }
}
