/* ============================================================
   CuencaGames Web - Professional Dark Theme
   ============================================================ */

/* --- CSS Variables --- */
:root {
    --bg-dark: #0F1117;
    --bg-card: #181A20;
    --bg-card-hover: #1E2028;
    --bg-input: #14161C;
    --bg-modal: rgba(15, 17, 23, 0.95);

    --accent: #4F8EF7;
    --accent-light: #6BA3FF;
    --accent-dark: #3B6FCC;
    --success: #34C77B;
    --danger: #EF4444;
    --warning: #F59E0B;
    --purple: #8B5CF6;
    --orange: #F97316;
    --pink: #EC4899;
    --teal: #14B8A6;

    --text-primary: #E4E5EA;
    --text-secondary: #9094A6;
    --text-muted: #5A5E72;

    --border: #262833;
    --border-hover: #3A3D4A;

    --font-display: 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;

    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.35);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

/* --- Reset --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    font-size: 0.95rem;
}

/* --- NAVBAR --- */
#navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: rgba(15, 17, 23, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1000;
}

.nav-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.nav-logo span {
    color: var(--accent);
}

#nav-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#nav-guest, #nav-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#nav-username {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
    margin-right: 0.5rem;
}

/* --- MAIN APP --- */
#app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding-top: 56px;
}

/* --- BUTTONS --- */
.btn {
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.55rem 1.3rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    outline: none;
    letter-spacing: 0.2px;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-light);
    border-color: var(--accent-light);
    box-shadow: 0 0 0 3px rgba(79, 142, 247, 0.15);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--border-hover);
}
.btn-outline:hover {
    background: rgba(79, 142, 247, 0.08);
    border-color: var(--accent);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--border-hover);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: var(--danger);
}

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}
.btn-success:hover {
    background: #2db86f;
    border-color: #2db86f;
}

.btn-sm {
    font-size: 0.7rem;
    padding: 0.4rem 0.8rem;
}

.btn-lg {
    font-size: 1rem;
    padding: 0.8rem 2rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.btn-ghost:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* --- FORMS --- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-family: var(--font-display);
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 142, 247, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 0.3rem;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* --- CARDS --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all var(--transition);
}

.card:hover {
    border-color: var(--border-hover);
}

/* --- PAGE LAYOUTS --- */
.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.page-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 56px);
    padding: 2rem;
}

.page-title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.page-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

/* --- AUTH PAGES --- */
.auth-container {
    width: 100%;
    max-width: 440px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

.auth-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 2rem;
    letter-spacing: -0.3px;
}

.auth-separator {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.auth-separator::before,
.auth-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-link {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-link a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* --- HOME PAGE --- */
.hero {
    text-align: center;
    padding: 4rem 0 2.5rem;
}

.hero-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(79, 142, 247, 0.08);
    border: 1px solid rgba(79, 142, 247, 0.2);
    padding: 0.35rem 1rem;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 1.25rem;
}

.hero-title {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 0.6rem;
    line-height: 1.1;
}

.hero-title .cyan { color: var(--accent); }
.hero-title .white { color: var(--text-primary); }

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
    max-width: 420px;
    margin: 0 auto;
    line-height: 1.5;
}

.hero-welcome {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 1rem;
}

.hero-welcome strong {
    color: var(--accent);
}

.hero-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.hero-stat {
    text-align: center;
}

.hero-stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.hero-stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- SECTION HEADER --- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.section-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.section-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.04);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* --- GAME GRID --- */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.game-card-accent {
    height: 3px;
    transition: opacity 0.2s;
}

.game-card-body {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem 1.5rem 1.25rem 1.25rem;
}

.game-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.game-card-icon {
    font-size: 2.2rem;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius);
}

.game-card-content {
    flex: 1;
    min-width: 0;
}

.game-card-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.game-card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.45;
}

.game-card-tags {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.tag {
    font-family: var(--font-display);
    font-size: 0.6rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border: 1px solid;
    font-weight: 600;
}

.tag-solo {
    color: var(--success);
    border-color: rgba(52, 199, 123, 0.3);
    background: rgba(52, 199, 123, 0.06);
}

.tag-multi {
    color: var(--purple);
    border-color: rgba(139, 92, 246, 0.3);
    background: rgba(139, 92, 246, 0.06);
}

.tag-ai {
    color: var(--orange);
    border-color: rgba(249, 115, 22, 0.3);
    background: rgba(249, 115, 22, 0.06);
}

/* Card accent per game */
.game-card[data-game="puissance4"] .game-card-accent { background: var(--danger); }
.game-card[data-game="snake"] .game-card-accent { background: var(--success); }
.game-card[data-game="blackjack"] .game-card-accent { background: var(--warning); }
.game-card[data-game="echecs"] .game-card-accent { background: var(--orange); }
.game-card[data-game="dames"] .game-card-accent { background: var(--accent); }
.game-card[data-game="poker"] .game-card-accent { background: var(--purple); }
.game-card[data-game="chevaux"] .game-card-accent { background: var(--teal); }
.game-card[data-game="mort_pion"] .game-card-accent { background: var(--pink); }

/* --- LEADERBOARD SIDEBAR --- */
.home-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    align-items: start;
}

.leaderboard-panel {
    position: sticky;
    top: 72px;
}

.leaderboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.leaderboard-title {
    font-family: var(--font-display);
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.lb-entry {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(42, 42, 62, 0.5);
    font-size: 0.85rem;
}

.lb-entry:last-child {
    border-bottom: none;
}

.lb-rank {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text-muted);
    min-width: 1.5rem;
    text-align: center;
}

.lb-rank.gold { color: #FFD700; }
.lb-rank.silver { color: #C0C0C0; }
.lb-rank.bronze { color: #CD7F32; }

.lb-name {
    flex: 1;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-score {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--success);
    font-size: 0.8rem;
}

.lb-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.lb-tab {
    font-family: var(--font-display);
    font-size: 0.6rem;
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.lb-tab.active, .lb-tab:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(79, 142, 247, 0.08);
}

/* --- GAME PAGE --- */
.game-page {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 56px);
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 800px;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
}

.game-header-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
}

.game-info {
    display: flex;
    gap: 1.5rem;
    font-family: var(--font-display);
    font-size: 0.8rem;
}

.game-info-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.game-info-label {
    color: var(--text-muted);
}

.game-info-value {
    color: var(--accent);
    font-weight: 600;
}

.game-canvas-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    position: relative;
}

.game-canvas-container canvas {
    display: block;
    border-radius: var(--radius);
}

.game-controls {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* --- PROFILE PAGE --- */
.profile-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--border-hover);
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.profile-info h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--text-primary);
    font-weight: 700;
}

.profile-info p {
    color: var(--text-secondary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.stat-card-title {
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-card-value {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-card-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* --- TOAST --- */
#toasts {
    position: fixed;
    top: 72px;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    max-width: 380px;
    border-left: 3px solid var(--accent);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(50px); }
}

/* --- MODAL --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    position: relative;
}

.modal-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 1rem;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- GAME OVERLAY (start/end) --- */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 18, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: var(--radius-lg);
}

.game-overlay-title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 900;
    margin-bottom: 0.5rem;
}

.game-overlay-subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 1.1rem;
}

/* --- LOADING --- */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
    .home-layout {
        grid-template-columns: 1fr;
    }

    .leaderboard-panel {
        position: static;
    }

    .hero-title {
        font-size: 2.2rem;
    }

    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 600px) {
    #navbar {
        padding: 0 1rem;
    }

    .hero-title {
        font-size: 1.8rem;
    }

    .hero-subtitle {
        font-size: 0.95rem;
    }

    .page {
        padding: 1.5rem 1rem;
    }

    .auth-card {
        padding: 1.5rem;
    }

    .game-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
    }
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- GAME-SPECIFIC: Board styles --- */
.board-container {
    display: inline-block;
    position: relative;
}

.board-grid {
    display: grid;
    gap: 2px;
    background: var(--border);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius);
    overflow: hidden;
}

.board-cell {
    width: 60px;
    height: 60px;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.board-cell:hover {
    background: var(--bg-card-hover);
}

.board-cell.highlight {
    background: rgba(52, 199, 123, 0.12);
}

.board-cell.last-move {
    background: rgba(79, 142, 247, 0.08);
}

.board-cell.winning {
    animation: winGlow 0.8s ease infinite alternate;
}

@keyframes winGlow {
    from { box-shadow: inset 0 0 8px rgba(52, 199, 123, 0.2); }
    to { box-shadow: inset 0 0 20px rgba(52, 199, 123, 0.4); }
}

/* Pieces */
.piece {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    transition: transform 0.15s;
}

.piece.red { background: var(--danger); box-shadow: 0 2px 8px rgba(239,68,68,0.3); }
.piece.yellow { background: var(--warning); box-shadow: 0 2px 8px rgba(245,158,11,0.3); }
.piece.black-piece { background: #333; border: 2px solid #555; }
.piece.white-piece { background: #eee; border: 2px solid #ccc; }

/* Turn indicator */
.turn-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-display);
    font-size: 1rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.turn-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.85); }
}

/* Score display */
.score-display {
    display: flex;
    gap: 2rem;
    align-items: center;
    font-family: var(--font-display);
}

.score-player {
    text-align: center;
}

.score-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

.score-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
}

.score-separator {
    font-size: 1.5rem;
    color: var(--text-muted);
}

/* --- Cards (playing cards for blackjack/poker) --- */
.playing-card {
    width: 80px;
    height: 120px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    position: relative;
    transition: transform 0.2s;
}

.playing-card:hover {
    transform: translateY(-5px);
}

.playing-card.red-suit { color: #cc0000; }
.playing-card.black-suit { color: #111; }

.playing-card.face-down {
    background: linear-gradient(135deg, #1a1a6e, #4a0080);
    border: 2px solid #6633cc;
}

.playing-card .card-value {
    font-size: 1.2rem;
}

.playing-card .card-suit {
    font-size: 1.8rem;
}

/* --- Chip buttons (betting) --- */
.chip-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px dashed;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chip-btn:hover {
    transform: scale(1.15);
}

.chip-btn.chip-10 { background: #224488; border-color: #4488dd; color: #88bbff; }
.chip-btn.chip-25 { background: #226644; border-color: #44bb66; color: #88ffaa; }
.chip-btn.chip-50 { background: #664422; border-color: #bb8844; color: #ffcc88; }
.chip-btn.chip-100 { background: #662222; border-color: #bb4444; color: #ff8888; }

/* ============================================================
   v2.2 — New styles
   ============================================================ */

/* --- FILTER TABS --- */
.filter-tabs {
    display: flex;
    gap: 0.25rem;
}

.filter-tab {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.8rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.filter-tab:hover {
    border-color: var(--border-hover);
    color: var(--text-secondary);
}

.filter-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* --- GAME CARD FOOTER --- */
.game-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.btn-multi-play {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: var(--purple);
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    white-space: nowrap;
}

.btn-multi-play:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--purple);
}

/* --- HOME MAIN --- */
.home-main {
    min-width: 0;
}

/* --- SECTION HEADER IMPROVED --- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* --- NAV AVATAR --- */
.nav-avatar-icon {
    font-size: 1.2rem;
    margin-right: 0.25rem;
}

/* --- LB AVATAR --- */
.lb-avatar {
    font-size: 1rem;
    flex-shrink: 0;
}

/* --- ANIMATION --- */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- MODE SELECT --- */
.mode-select-card {
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 2.5rem;
    max-width: 520px;
    width: 100%;
    animation: fadeSlideUp 0.4s ease;
}

.mode-select-icon {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.8rem;
    margin: 0 auto 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.mode-select-title {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.mode-select-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
    letter-spacing: 0.02em;
}

.mode-select-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* --- Mode Cards --- */
.mode-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: inherit;
    color: var(--text-primary);
    font-size: 1rem;
}

.mode-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

.mode-card-solo:hover { border-color: #22d3ee; background: rgba(34, 211, 238, 0.06); }
.mode-card-ai:hover   { border-color: #a78bfa; background: rgba(167, 139, 250, 0.06); }
.mode-card-multi:hover { border-color: #34d399; background: rgba(52, 211, 153, 0.06); }

.mode-card-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.mode-card-solo .mode-card-icon { background: rgba(34, 211, 238, 0.12); }
.mode-card-ai   .mode-card-icon { background: rgba(167, 139, 250, 0.12); }
.mode-card-multi .mode-card-icon { background: rgba(52, 211, 153, 0.12); }

.mode-card-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.mode-card-title {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.3;
}

.mode-card-desc {
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.3;
}

.mode-card-arrow {
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: transform 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.mode-card:hover .mode-card-arrow {
    transform: translateX(4px);
    color: var(--text-primary);
}

/* --- PROFILE v2 --- */
.profile-card-main {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.profile-card-main::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--purple), var(--pink));
}

.profile-header-new {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.profile-avatar-large {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 3px solid var(--border-hover);
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.8rem;
    flex-shrink: 0;
    transition: border-color 0.2s;
}

.profile-avatar-large:hover {
    border-color: var(--accent);
}

.profile-info-main h2 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    color: var(--text-primary);
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.profile-date {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
}

.profile-bio-display {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.profile-sections {
    display: grid;
    gap: 1.5rem;
}

.profile-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.profile-section-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.profile-form-card {
    max-width: 500px;
}

/* --- AVATAR GRID --- */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 0.5rem;
    max-width: 500px;
}

.avatar-option {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    background: var(--bg-input);
    cursor: pointer;
    transition: all 0.15s;
}

.avatar-option:hover {
    border-color: var(--border-hover);
    transform: scale(1.1);
    background: var(--bg-card-hover);
}

.avatar-option.active {
    border-color: var(--accent);
    background: rgba(79, 142, 247, 0.1);
    box-shadow: 0 0 0 3px rgba(79, 142, 247, 0.15);
}

/* --- STATS OVERVIEW --- */
.stats-overview {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.stat-overview-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 1rem 1.5rem;
    background: var(--bg-input);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    min-width: 100px;
}

.stat-overview-value {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-overview-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* --- STAT CARD BAR --- */
.stat-card-bar {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.stat-card-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* --- LOBBY --- */
.lobby-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.lobby-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.lobby-icon {
    font-size: 2rem;
}

.lobby-title h2 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
}

.lobby-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.lobby-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.lobby-card-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.lobby-card-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* --- ROOM ITEMS --- */
.room-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
}

.room-item:last-child {
    border-bottom: none;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.room-avatar {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.room-host {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.room-meta {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.room-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.room-code {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--accent);
    background: rgba(79, 142, 247, 0.08);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius);
    letter-spacing: 1px;
}

.room-code-small {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--accent);
    background: rgba(79, 142, 247, 0.08);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius);
    letter-spacing: 1px;
}

/* --- WAITING ROOM --- */
.waiting-card {
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 2.5rem;
    max-width: 450px;
    width: 100%;
}

.waiting-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.waiting-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.room-code-display {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg-input);
    border: 2px dashed var(--accent);
    border-radius: var(--radius-lg);
    padding: 1rem 2rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 1rem;
}

.room-code-display:hover {
    background: rgba(79, 142, 247, 0.08);
    border-style: solid;
}

.room-code-display span {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 6px;
}

.room-code-display small {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.waiting-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

/* --- MULTI PLAYER BAR --- */
.multi-players {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin: 1rem 0;
}

.multi-player {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    transition: all 0.2s;
}

.multi-player.active {
    border-color: var(--accent);
    background: rgba(79, 142, 247, 0.08);
    box-shadow: 0 0 0 3px rgba(79, 142, 247, 0.1);
}

.multi-player-avatar {
    font-size: 1.2rem;
}

.multi-player-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.85rem;
}

.multi-vs {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- MULTI STATUS --- */
.multi-status {
    text-align: center;
    margin-bottom: 0.75rem;
    font-family: var(--font-display);
    font-size: 0.9rem;
}

.status-win { color: var(--success); font-weight: 700; }
.status-lose { color: var(--danger); font-weight: 700; }
.status-draw { color: var(--warning); font-weight: 700; }
.status-turn { color: var(--success); font-weight: 600; }
.status-wait { color: var(--text-muted); }

/* --- P4 MULTI BOARD --- */
.p4-multi-board {
    display: grid;
    grid-template-columns: repeat(7, 50px);
    gap: 2px;
    background: var(--accent-dark);
    border-radius: var(--radius);
    overflow: hidden;
    justify-content: center;
    padding: 2px;
}

.p4-cell {
    width: 50px;
    height: 50px;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.p4-cell.clickable {
    cursor: pointer;
}

.p4-cell.clickable:hover {
    background: var(--bg-card-hover);
}

.p4-cell.last-move {
    background: rgba(79, 142, 247, 0.1);
}

.p4-cell .piece {
    width: 38px;
    height: 38px;
    animation: dropIn 0.3s ease;
}

@keyframes dropIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* --- MORT PION MULTI BOARD --- */
.mp-multi-board {
    display: grid;
    grid-template-columns: repeat(10, 40px);
    gap: 1px;
    background: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    justify-content: center;
    padding: 1px;
}

.mp-cell {
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.mp-cell.clickable {
    cursor: pointer;
}

.mp-cell.clickable:hover {
    background: var(--bg-card-hover);
}

.mp-cell.last-move {
    background: rgba(79, 142, 247, 0.1);
}

.mp-piece {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    animation: dropIn 0.2s ease;
}

.mp-piece.p1 {
    background: var(--accent);
    box-shadow: 0 2px 8px rgba(79, 142, 247, 0.3);
}

.mp-piece.p2 {
    background: var(--danger);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* --- RESPONSIVE v2 --- */
@media (max-width: 900px) {
    .lobby-layout {
        grid-template-columns: 1fr;
    }

    .profile-header-new {
        flex-direction: column;
        text-align: center;
    }

    .multi-players {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .p4-multi-board {
        grid-template-columns: repeat(7, 42px);
    }

    .p4-cell {
        width: 42px;
        height: 42px;
    }

    .p4-cell .piece {
        width: 32px;
        height: 32px;
    }

    .mp-multi-board {
        grid-template-columns: repeat(10, 32px);
    }

    .mp-cell {
        width: 32px;
        height: 32px;
    }

    .mp-piece {
        width: 22px;
        height: 22px;
    }
}

@media (max-width: 600px) {
    .filter-tabs {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .mode-select-card {
        padding: 2rem 1.25rem;
    }

    .mode-card {
        padding: 0.85rem 1rem;
    }

    .p4-multi-board {
        grid-template-columns: repeat(7, 36px);
    }

    .p4-cell {
        width: 36px;
        height: 36px;
    }

    .p4-cell .piece {
        width: 28px;
        height: 28px;
    }

    .mp-multi-board {
        grid-template-columns: repeat(10, 28px);
    }

    .mp-cell {
        width: 28px;
        height: 28px;
    }

    .mp-piece {
        width: 20px;
        height: 20px;
    }

    .avatar-grid {
        grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
    }

    .avatar-option {
        width: 42px;
        height: 42px;
        font-size: 1.3rem;
    }

    .waiting-card {
        padding: 2rem 1.5rem;
    }

    .room-code-display span {
        font-size: 1.5rem;
        letter-spacing: 4px;
    }
}
