/* ==========================================
   CHESS ONLINE - STYLESHEET
   Modern dark theme with elegant design
   ========================================== */

/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #1e2a45;
    --accent: #e94560;
    --accent-hover: #ff6b81;
    --accent-glow: rgba(233, 69, 96, 0.3);
    --gold: #f0c040;
    --gold-glow: rgba(240, 192, 64, 0.3);
    --text-primary: #eaeaea;
    --text-secondary: #8892a4;
    --text-muted: #5a6478;
    --border: #2a3550;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --board-light: #f0d9b5;
    --board-dark: #b58863;
    --board-highlight: rgba(255, 255, 0, 0.4);
    --board-legal: rgba(0, 0, 0, 0.15);
    --board-check: rgba(255, 0, 0, 0.5);
    --board-lastmove: rgba(155, 199, 0, 0.41);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.5);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);

    /* Rank colors */
    --rank-unranked: #8892a4;
    --rank-bronze: #cd7f32;
    --rank-silver: #b0bec5;
    --rank-gold: #f0c040;
    --rank-platinum: #2ed8a3;
    --rank-diamond: #00d2ff;
    --rank-master: #a855f7;
    --rank-grandmaster: #ff4757;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: var(--accent);
    transition: var(--transition);
}

a:hover {
    color: var(--accent-hover);
}

/* === NAVBAR === */
.navbar {
    background: rgba(15, 15, 26, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.2rem;
}

.logo-icon {
    font-size: 1.8rem;
    color: var(--gold);
    text-shadow: 0 0 10px var(--gold-glow);
}

.logo-text {
    font-family: 'Playfair Display', serif;
    letter-spacing: 1px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.9rem;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-username {
    color: var(--gold);
    font-weight: 600;
    font-size: 0.9rem;
}

.nav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    transition: var(--transition);
}

.nav-avatar-link:hover .nav-avatar {
    border-color: var(--gold);
    box-shadow: 0 0 8px var(--gold-glow);
}

.btn-logout {
    color: var(--danger) !important;
    font-size: 0.85rem;
}

.btn-logout:hover {
    background: rgba(231, 76, 60, 0.1) !important;
}

/* === MAIN CONTENT === */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary, a.btn-primary {
    background: linear-gradient(135deg, var(--accent), #c0392b);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px var(--accent-glow);
    color: white;
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card);
    border-color: var(--accent);
}

.btn-success {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(46, 204, 113, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #c0392b);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold), #e0a800);
    color: #1a1a2e;
    font-weight: 700;
    box-shadow: 0 4px 15px var(--gold-glow);
}

.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px var(--gold-glow);
}

.btn-lg {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    border-radius: var(--radius);
}

.btn-sm {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

/* === CARDS === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.card-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    color: var(--text-primary);
}

/* === FORMS === */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
    color: var(--text-muted);
}

/* === ALERTS === */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-error {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid rgba(231, 76, 60, 0.3);
    color: #ff6b6b;
}

.alert-success {
    background: rgba(46, 204, 113, 0.15);
    border: 1px solid rgba(46, 204, 113, 0.3);
    color: #6bff9e;
}

.alert-info {
    background: rgba(52, 152, 219, 0.15);
    border: 1px solid rgba(52, 152, 219, 0.3);
    color: #6bb5ff;
}

/* === HERO SECTION (INDEX) === */
.hero {
    text-align: center;
    padding: 4rem 0;
}

.hero-icon {
    font-size: 5rem;
    display: block;
    margin-bottom: 1.5rem;
    text-shadow: 0 0 30px var(--gold-glow);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.hero h1 {
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--gold), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto 2rem;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 4rem;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    transition: var(--transition);
}

.feature-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 8px 30px rgba(233, 69, 96, 0.1);
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* === AUTH PAGES === */
.auth-container {
    max-width: 420px;
    margin: 2rem auto;
}

.auth-container .card {
    padding: 2.5rem;
}

.auth-container .card-title {
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* === LOBBY === */
.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.lobby-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
}

.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.room-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.room-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--gold));
}

.room-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.room-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.room-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.room-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
}

.status-waiting {
    background: rgba(240, 192, 64, 0.15);
    color: var(--gold);
}

.status-playing {
    background: rgba(46, 204, 113, 0.15);
    color: var(--success);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.status-waiting .status-dot {
    background: var(--gold);
    animation: pulse 1.5s infinite;
}

.status-playing .status-dot {
    background: var(--success);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.room-players {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.room-players strong {
    color: var(--text-primary);
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

/* === MODAL === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    display: flex;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 450px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.modal-actions .btn {
    flex: 1;
}

/* === GAME PAGE === */
.game-container {
    display: flex;
    gap: 2rem;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.game-board-wrapper {
    position: relative;
}

/* Player info panels */
.player-panel {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.player-panel.active-turn {
    border-color: var(--gold);
    box-shadow: 0 0 15px var(--gold-glow);
}

.player-panel .player-color {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
}

.player-panel .player-color.white {
    background: #f0d9b5;
}

.player-panel .player-color.black {
    background: #58422d;
}

.player-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.player-captured {
    font-size: 1.1rem;
    letter-spacing: 1px;
    min-height: 1.4rem;
}

/* Chess board */
.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    border: 3px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    width: 480px;
    height: 480px;
}

.chess-square {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.6rem;
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: background 0.15s ease;
}

.chess-square.light {
    background: var(--board-light);
}

.chess-square.dark {
    background: var(--board-dark);
}

.chess-square.selected {
    background: rgba(255, 255, 0, 0.6) !important;
}

.chess-square.legal-move::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: var(--board-legal);
    border-radius: 50%;
}

.chess-square.legal-capture {
    position: relative;
}

.chess-square.legal-capture::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(transparent 55%, rgba(233, 69, 96, 0.45) 55%);
    border-radius: 0;
}

.chess-square.last-move {
    background: var(--board-lastmove) !important;
}

.chess-square.last-move.light {
    background: rgba(186, 202, 68, 0.6) !important;
}

.chess-square.last-move.dark {
    background: rgba(130, 151, 36, 0.7) !important;
}

.chess-square.check {
    background: var(--board-check) !important;
    animation: check-pulse 1s infinite;
}

@keyframes check-pulse {
    0%, 100% { box-shadow: inset 0 0 15px rgba(255, 0, 0, 0.5); }
    50% { box-shadow: inset 0 0 30px rgba(255, 0, 0, 0.8); }
}

.chess-square .piece {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
    cursor: grab;
    line-height: 1;
}

.chess-square .piece.piece-white {
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5), 0 0 2px rgba(0, 0, 0, 0.3);
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.4));
}

.chess-square .piece.piece-black {
    color: #1a1a2e;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    filter: drop-shadow(0 1px 1px rgba(255,255,255,0.15));
}

.chess-square:hover .piece {
    transform: scale(1.1);
}

/* Board coordinates */
.board-with-coords {
    display: grid;
    grid-template-columns: 24px 480px;
    grid-template-rows: 480px 24px;
    gap: 0;
}

.board-coords-left {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    padding-right: 4px;
}

.board-coords-bottom {
    display: flex;
    justify-content: space-around;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    padding-top: 4px;
    grid-column: 2;
}

/* Game sidebar */
.game-sidebar {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.game-info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.game-info-card h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.game-status {
    text-align: center;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.game-status.your-turn {
    color: var(--success);
}

.game-status.opponent-turn {
    color: var(--text-secondary);
}

.game-status.game-over {
    color: var(--gold);
    font-size: 1.2rem;
}

/* Move history */
.moves-list {
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}

.moves-list::-webkit-scrollbar {
    width: 4px;
}

.moves-list::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.moves-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.move-row {
    display: flex;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.move-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.02);
}

.move-number {
    color: var(--text-muted);
    min-width: 28px;
}

.move-white, .move-black {
    min-width: 70px;
    color: var(--text-secondary);
}

.move-white:last-child, .move-black:last-child {
    color: var(--gold);
    font-weight: 600;
}

/* Promotion modal */
.promotion-modal {
    position: absolute;
    background: var(--bg-secondary);
    border: 2px solid var(--gold);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: none;
    padding: 0.5rem;
}

.promotion-modal.active {
    display: flex;
    gap: 0.25rem;
}

.promotion-piece {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
}

.promotion-piece:hover {
    background: var(--accent);
}

/* Waiting overlay */
.waiting-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
}

.waiting-content {
    text-align: center;
    padding: 3rem;
}

.waiting-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border);
    border-top: 4px solid var(--gold);
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.waiting-content h2 {
    font-family: 'Playfair Display', serif;
    margin-bottom: 0.5rem;
    color: var(--gold);
}

.waiting-content p {
    color: var(--text-secondary);
}

/* Game over overlay */
.gameover-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.gameover-overlay.active {
    display: flex;
}

.gameover-content {
    text-align: center;
    padding: 3rem;
    background: var(--bg-secondary);
    border: 2px solid var(--gold);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 350px;
}

.gameover-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.gameover-content h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.gameover-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.gameover-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Stats badges */
.stats-row {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

.stat-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    min-width: 70px;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--gold);
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
}

/* === FOOTER === */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 1.5rem 2rem;
    text-align: center;
    margin-top: auto;
}

.footer-content {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* === LOADING === */
.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* === RESPONSIVE === */
@media (max-width: 900px) {
    .game-container {
        flex-direction: column;
        align-items: center;
    }

    .game-sidebar {
        width: 100%;
        max-width: 480px;
    }
}

@media (max-width: 560px) {
    .chess-board {
        width: 320px;
        height: 320px;
    }

    .chess-square {
        width: 40px;
        height: 40px;
        font-size: 1.8rem;
    }

    .board-with-coords {
        grid-template-columns: 20px 320px;
        grid-template-rows: 320px 20px;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero-icon {
        font-size: 3.5rem;
    }

    .nav-container {
        padding: 0 1rem;
    }

    .main-content {
        padding: 1rem;
    }
}

/* === PROFILE PAGE === */
.profile-container {
    max-width: 700px;
    margin: 0 auto;
}

.profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.profile-avatar-wrapper {
    position: relative;
    text-align: center;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border);
    background: var(--bg-input);
}

.avatar-form {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.avatar-upload-btn {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.avatar-upload-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.profile-info {
    flex: 1;
}

.profile-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    margin-bottom: 0.25rem;
}

.profile-joined {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.profile-stat-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem 0.75rem;
    text-align: center;
    transition: var(--transition);
}

.profile-stat-card:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
}

.profile-stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
}

.profile-stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-win .stat-value { color: var(--success); }
.stat-loss .stat-value { color: var(--danger); }
.stat-draw .stat-value { color: var(--warning); }
.stat-rate .stat-value { color: var(--gold); }

.profile-stat-card .stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-top: 0.2rem;
}

/* Win rate bar */
.profile-winbar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 1.5rem;
    background: var(--bg-input);
}

.winbar-fill {
    height: 100%;
    transition: width 0.5s ease;
}

.winbar-win { background: var(--success); }
.winbar-draw { background: var(--warning); }
.winbar-loss { background: var(--danger); }

.winbar-legend {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

/* Game history */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.history-result {
    font-weight: 700;
    min-width: 50px;
    text-align: center;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.result-win {
    background: rgba(46, 204, 113, 0.2);
    color: var(--success);
}

.result-loss {
    background: rgba(231, 76, 60, 0.2);
    color: var(--danger);
}

.result-draw {
    background: rgba(243, 156, 18, 0.2);
    color: var(--warning);
}

.history-opponent {
    flex: 1;
    color: var(--text-secondary);
}

.history-opponent strong {
    color: var(--text-primary);
}

.history-color {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.history-moves {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.history-date {
    color: var(--text-muted);
    font-size: 0.8rem;
}

@media (max-width: 560px) {
    .profile-header {
        flex-direction: column;
        text-align: center;
    }

    .profile-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .history-row {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .history-color, .history-moves, .history-date {
        font-size: 0.75rem;
    }
}

/* === SPLASH INTRO SCREEN === */
.splash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.splash-overlay.splash-fadeout {
    animation: splashFadeOut 0.6s ease forwards;
}

@keyframes splashFadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; pointer-events: none; }
}

.splash-content {
    text-align: center;
    position: relative;
}

.splash-chess-pieces {
    display: flex;
    justify-content: center;
    gap: 0.3rem;
    margin-bottom: 2rem;
    font-size: 2rem;
    opacity: 0;
    animation: splashPiecesIn 0.8s ease 0.3s forwards;
}

@keyframes splashPiecesIn {
    0% { opacity: 0; transform: translateY(-30px); }
    100% { opacity: 1; transform: translateY(0); }
}

.splash-piece {
    display: inline-block;
    color: var(--text-muted);
    animation: splashPieceDrop 0.5s ease forwards;
    opacity: 0;
    transform: translateY(-20px);
}

.splash-piece.sp-1 { animation-delay: 0.2s; }
.splash-piece.sp-2 { animation-delay: 0.3s; }
.splash-piece.sp-3 { animation-delay: 0.4s; }
.splash-piece.sp-4 { animation-delay: 0.5s; }
.splash-piece.sp-king {
    font-size: 2.8rem;
    color: var(--gold);
    animation-delay: 0.6s;
    filter: drop-shadow(0 0 12px var(--gold-glow));
}
.splash-piece.sp-5 { animation-delay: 0.7s; }
.splash-piece.sp-6 { animation-delay: 0.8s; }
.splash-piece.sp-7 { animation-delay: 0.9s; }

@keyframes splashPieceDrop {
    0% { opacity: 0; transform: translateY(-20px) scale(0.5); }
    60% { opacity: 1; transform: translateY(4px) scale(1.05); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.splash-logo {
    opacity: 0;
    animation: splashLogoIn 0.8s ease 0.9s forwards;
}

@keyframes splashLogoIn {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

.splash-logo-icon {
    font-size: 4.5rem;
    display: block;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 40px var(--gold-glow), 0 0 80px rgba(240, 192, 64, 0.15);
    animation: splashGlow 2s ease-in-out infinite;
}

@keyframes splashGlow {
    0%, 100% { text-shadow: 0 0 30px var(--gold-glow), 0 0 60px rgba(240, 192, 64, 0.1); }
    50% { text-shadow: 0 0 50px var(--gold-glow), 0 0 100px rgba(240, 192, 64, 0.25); }
}

.splash-title {
    font-family: 'Playfair Display', serif;
    font-size: 3.2rem;
    background: linear-gradient(135deg, var(--gold), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.8rem;
}

.splash-divider {
    width: 80px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    margin: 0 auto 0.8rem;
}

.splash-tagline {
    font-size: 1.1rem;
    color: var(--text-secondary);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 300;
}

.splash-loading {
    margin-top: 2.5rem;
    opacity: 0;
    animation: splashLogoIn 0.5s ease 1.4s forwards;
}

.splash-bar {
    width: 200px;
    height: 3px;
    background: var(--border);
    border-radius: 3px;
    margin: 0 auto;
    overflow: hidden;
}

.splash-bar-fill {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--accent));
    border-radius: 3px;
    transition: width 2s ease;
}

/* === SPECTATOR BADGE === */
.spectator-badge {
    display: inline-block;
    padding: 0.35rem 0.8rem;
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.15), rgba(240, 192, 64, 0.15));
    border: 1px solid var(--accent);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.8rem;
    letter-spacing: 1px;
}

/* === WATCH BUTTON === */
.btn-watch {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: var(--transition);
    font-size: 0.9rem;
}

.btn-watch:hover {
    background: linear-gradient(135deg, #34495e, #4a6074);
    border-color: var(--gold);
    color: var(--gold);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(240, 192, 64, 0.15);
}

/* === LIVE GAMES SECTION (INDEX) === */
.live-section {
    margin-top: 4rem;
}

.section-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.live-games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.live-game-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.live-game-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: 0 8px 25px rgba(233, 69, 96, 0.15);
}

.live-badge {
    display: inline-block;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.6rem;
    letter-spacing: 1px;
    animation: livePulse 1.5s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.live-players {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
}

.live-vs {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.8rem;
}

.live-moves {
    color: var(--text-muted);
    font-size: 0.8rem;
}

@media (max-width: 560px) {
    .splash-title {
        font-size: 2.2rem;
    }

    .splash-logo-icon {
        font-size: 3.5rem;
    }

    .splash-chess-pieces {
        font-size: 1.5rem;
    }

    .splash-piece.sp-king {
        font-size: 2rem;
    }
}

/* ==========================================
   XIANGQI (CỜ TƯỚNG) STYLES
   ========================================== */

/* Board */
.xiangqi-board {
    display: grid;
    grid-template-columns: repeat(9, 56px);
    grid-template-rows: repeat(10, 56px);
    background: #e8c87a;
    border: 3px solid #8b5e3c;
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    position: relative;
    padding: 0;
    /* Draw grid lines via background */
    background-image:
        /* Vertical lines */
        repeating-linear-gradient(90deg, transparent, transparent 55px, #8b5e3c 55px, #8b5e3c 56px),
        /* Horizontal lines */
        repeating-linear-gradient(0deg, transparent, transparent 55px, #8b5e3c 55px, #8b5e3c 56px);
    background-size: 56px 56px;
}

.xq-board-wrapper {
    align-items: center;
}

/* Cell */
.xq-cell {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    z-index: 1;
}

.xq-cell:hover {
    background: rgba(255,255,255,0.15);
}

/* River area styling */
.xq-river-row {
    position: relative;
}

/* Piece stones */
.xq-piece {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
    z-index: 2;
    font-family: 'KaiTi', 'STKaiti', 'SimSun', 'Noto Serif CJK SC', serif;
}

.xq-piece:hover {
    transform: scale(1.08);
}

.xq-piece-red {
    background: radial-gradient(circle at 35% 35%, #fff5f5, #f4d0d0);
    color: #c0392b;
    border-color: #c0392b;
}

.xq-piece-black {
    background: radial-gradient(circle at 35% 35%, #f5f5f5, #d5d5d5);
    color: #2c3e50;
    border-color: #2c3e50;
}

/* Selection */
.xq-selected {
    background: rgba(240, 192, 64, 0.4) !important;
}

.xq-selected .xq-piece {
    transform: scale(1.12);
    box-shadow: 0 0 15px var(--gold-glow);
}

/* Last move highlight */
.xq-lastmove {
    background: rgba(155, 199, 0, 0.3);
}

/* Check highlight */
.xq-check {
    background: rgba(255, 0, 0, 0.3);
    animation: xq-check-pulse 1s ease-in-out infinite;
}

@keyframes xq-check-pulse {
    0%, 100% { background: rgba(255, 0, 0, 0.2); }
    50% { background: rgba(255, 0, 0, 0.45); }
}

/* Move indicators */
.xq-move-indicator {
    width: 14px;
    height: 14px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    position: absolute;
    z-index: 3;
}

.xq-capture-indicator {
    width: 46px;
    height: 46px;
    border: 3px solid rgba(233, 69, 96, 0.7);
    border-radius: 50%;
    position: absolute;
    z-index: 3;
}

/* Color indicators for panels */
.xq-color-red {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #c0392b;
    flex-shrink: 0;
}

.xq-color-black {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #2c3e50;
    flex-shrink: 0;
}

.xq-panel {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Game selection cards on index */
.game-select-section {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.game-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.game-select-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    transition: var(--transition);
    display: block;
    color: var(--text-primary);
}

.game-select-card:hover {
    border-color: var(--gold);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(240, 192, 64, 0.15);
    color: var(--text-primary);
}

.game-select-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    display: block;
}

.game-select-card h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--gold);
}

.game-select-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Responsive xiangqi board */
@media (max-width: 560px) {
    .xiangqi-board {
        grid-template-columns: repeat(9, 40px);
        grid-template-rows: repeat(10, 40px);
        background-size: 40px 40px;
    }

    .xq-cell {
        width: 40px;
        height: 40px;
    }

    .xq-piece {
        width: 34px;
        height: 34px;
        font-size: 1rem;
    }

    .xq-capture-indicator {
        width: 34px;
        height: 34px;
    }
}

/* ==========================================
   AI MODE STYLES
   ========================================== */

/* AI Button */
.btn-ai {
    background: linear-gradient(135deg, #6c5ce7, #a855f7);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.btn-ai:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(108, 92, 231, 0.5);
    background: linear-gradient(135deg, #7c6cf7, #b865ff);
}

.lobby-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Color picker for AI modal */
.color-picker-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.color-option {
    flex: 1;
    cursor: pointer;
}

.color-option input[type="radio"] {
    display: none;
}

.color-box {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.95rem;
    transition: var(--transition);
    text-align: center;
}

.color-option input[type="radio"]:checked + .color-box {
    border-color: var(--gold);
    box-shadow: 0 0 12px var(--gold-glow);
}

.color-white {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.color-black {
    background: rgba(0, 0, 0, 0.3);
    color: #ccc;
}

.color-red {
    background: rgba(220, 50, 50, 0.15);
    color: #ff6b6b;
}

.color-black-xq {
    background: rgba(0, 0, 0, 0.3);
    color: #ccc;
}

/* Difficulty picker */
.difficulty-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.diff-option {
    flex: 1;
    cursor: pointer;
}

.diff-option input[type="radio"] {
    display: none;
}

.diff-box {
    display: block;
    padding: 0.6rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--transition);
    text-align: center;
}

.diff-option input[type="radio"]:checked + .diff-box {
    border-color: var(--gold);
    box-shadow: 0 0 12px var(--gold-glow);
}

.diff-easy {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
}

.diff-medium {
    background: rgba(243, 156, 18, 0.15);
    color: #f39c12;
}

.diff-hard {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

/* ==========================================
   RANK SYSTEM STYLES
   ========================================== */

/* Rank Badge */
.rank-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border: 1px solid;
    white-space: nowrap;
    transition: var(--transition);
}

.rank-badge .rank-pip {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.rank-unranked { background: rgba(136,146,164,0.12); border-color: rgba(136,146,164,0.3); color: var(--rank-unranked); }
.rank-unranked .rank-pip { background: var(--rank-unranked); }

.rank-bronze { background: rgba(205,127,50,0.12); border-color: rgba(205,127,50,0.3); color: var(--rank-bronze); }
.rank-bronze .rank-pip { background: var(--rank-bronze); }

.rank-silver { background: rgba(176,190,197,0.12); border-color: rgba(176,190,197,0.3); color: var(--rank-silver); }
.rank-silver .rank-pip { background: var(--rank-silver); }

.rank-gold { background: rgba(240,192,64,0.12); border-color: rgba(240,192,64,0.3); color: var(--rank-gold); }
.rank-gold .rank-pip { background: var(--rank-gold); box-shadow: 0 0 6px var(--gold-glow); }

.rank-platinum { background: rgba(46,216,163,0.12); border-color: rgba(46,216,163,0.3); color: var(--rank-platinum); }
.rank-platinum .rank-pip { background: var(--rank-platinum); box-shadow: 0 0 6px rgba(46,216,163,0.4); }

.rank-diamond { background: rgba(0,210,255,0.12); border-color: rgba(0,210,255,0.3); color: var(--rank-diamond); }
.rank-diamond .rank-pip { background: var(--rank-diamond); box-shadow: 0 0 8px rgba(0,210,255,0.4); animation: rankShimmer 2s ease-in-out infinite; }

.rank-master { background: rgba(168,85,247,0.12); border-color: rgba(168,85,247,0.3); color: var(--rank-master); }
.rank-master .rank-pip { background: var(--rank-master); box-shadow: 0 0 8px rgba(168,85,247,0.5); animation: rankShimmer 1.5s ease-in-out infinite; }

.rank-grandmaster {
    background: linear-gradient(135deg, rgba(255,71,87,0.15), rgba(240,192,64,0.15));
    border-color: rgba(255,71,87,0.4);
    color: var(--rank-grandmaster);
    animation: grandmasterGlow 3s ease-in-out infinite;
}
.rank-grandmaster .rank-pip {
    background: linear-gradient(135deg, var(--rank-grandmaster), var(--gold));
    box-shadow: 0 0 10px rgba(255,71,87,0.5);
    animation: rankShimmer 1s ease-in-out infinite;
}

@keyframes rankShimmer {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.85); }
}

@keyframes grandmasterGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(255,71,87,0.2); }
    50% { box-shadow: 0 0 16px rgba(255,71,87,0.4); }
}

/* ELO display */
.elo-display {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.elo-change {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    animation: eloPopIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.elo-change.positive {
    color: var(--success);
    background: rgba(46,204,113,0.15);
}

.elo-change.negative {
    color: var(--danger);
    background: rgba(231,76,60,0.15);
}

@keyframes eloPopIn {
    0% { opacity: 0; transform: scale(0.5) translateY(-5px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Title badge */
.title-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, rgba(240,192,64,0.2), rgba(233,69,96,0.2));
    color: var(--gold);
    border: 1px solid rgba(240,192,64,0.3);
}

/* Nav rank badge (compact) */
.nav-rank-badge {
    font-size: 0.65rem;
    padding: 2px 7px;
    margin-left: -4px;
}

/* ==========================================
   ENHANCED ANIMATIONS
   ========================================== */

/* Page entrance animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Apply entrance animations */
.hero {
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.feature-card {
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.feature-card:nth-child(1) { animation-delay: 0.1s; }
.feature-card:nth-child(2) { animation-delay: 0.2s; }
.feature-card:nth-child(3) { animation-delay: 0.3s; }
.feature-card:nth-child(4) { animation-delay: 0.4s; }

.game-select-card {
    animation: scaleIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.game-select-card:nth-child(1) { animation-delay: 0.1s; }
.game-select-card:nth-child(2) { animation-delay: 0.2s; }

.auth-container .card {
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.profile-card {
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.lobby-header {
    animation: fadeInDown 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.room-card {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.live-game-card {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.live-section {
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
    animation-delay: 0.3s;
}

/* Smooth modal entrance */
.modal {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
    transform: scale(0.9) translateY(10px);
    opacity: 0;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Enhanced button hover effects */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
}

.btn:active::after {
    width: 300px;
    height: 300px;
}

/* Card hover glow effect */
.room-card:hover,
.feature-card:hover,
.game-select-card:hover,
.live-game-card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(240, 192, 64, 0.1);
}

/* Smooth alert animation */
.alert {
    animation: fadeInDown 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* Profile stat cards stagger */
.profile-stat-card {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.profile-stat-card:nth-child(1) { animation-delay: 0.05s; }
.profile-stat-card:nth-child(2) { animation-delay: 0.1s; }
.profile-stat-card:nth-child(3) { animation-delay: 0.15s; }
.profile-stat-card:nth-child(4) { animation-delay: 0.2s; }
.profile-stat-card:nth-child(5) { animation-delay: 0.25s; }

/* History rows stagger */
.history-row {
    animation: fadeInLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.history-row:nth-child(1) { animation-delay: 0.05s; }
.history-row:nth-child(2) { animation-delay: 0.1s; }
.history-row:nth-child(3) { animation-delay: 0.15s; }
.history-row:nth-child(4) { animation-delay: 0.2s; }
.history-row:nth-child(5) { animation-delay: 0.25s; }

/* Game over overlay enhanced */
.gameover-overlay.active {
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.gameover-overlay.active .gameover-content {
    animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    animation-delay: 0.1s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Waiting spinner enhanced */
.waiting-spinner {
    border-right: 4px solid var(--accent);
}

@keyframes spinMulti {
    to { transform: rotate(360deg); }
}

/* Smooth stat badge number counting feel */
.stat-value {
    transition: color 0.3s;
}

/* Smooth scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* Rank progress bar on profile */
.rank-progress-container {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.rank-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.rank-progress-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.rank-progress-elo {
    font-size: 0.9rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.rank-progress-bar {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.rank-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.rank-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: progressShine 2s ease-in-out infinite;
}

@keyframes progressShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.rank-progress-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.4rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Rank demotion warning */
.rank-demote-warning {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--warning);
    margin-top: 0.4rem;
    opacity: 0.8;
}

/* Leaderboard-style rank display in lobby */
.lobby-rank-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-top: 0.75rem;
    animation: fadeInLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
    animation-delay: 0.2s;
}

.lobby-rank-elo {
    font-size: 1.2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Room card rank styling */
.room-player-rank {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
}

.room-player-rank .rank-badge {
    font-size: 0.6rem;
    padding: 1px 6px;
}

/* Nav user rank */
.nav-user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

/* Smooth page transitions */
.main-content {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}
