/* ===================== CSS VARIABLES ===================== */
:root {
    --bg-primary:    #1a1a2e;
    --bg-secondary:  #16213e;
    --bg-card:       #0f3460;
    --bg-input:      #1a2744;
    --accent:        #e94560;
    --accent-hover:  #c73652;
    --accent-gold:   #f0c040;
    --text-primary:  #eaeaea;
    --text-secondary:#a0aec0;
    --border:        #2d3748;
    --success:       #48bb78;
    --danger:        #fc5c7d;
    --warning:       #f6ad55;
    --shadow:        rgba(0,0,0,0.4);
    --radius:        12px;
    --transition:    0.3s ease;
}
[data-theme="light"] {
    --bg-primary:    #f7f9fc;
    --bg-secondary:  #edf2f7;
    --bg-card:       #ffffff;
    --bg-input:      #edf2f7;
    --accent:        #e94560;
    --accent-hover:  #c73652;
    --text-primary:  #1a202c;
    --text-secondary:#4a5568;
    --border:        #e2e8f0;
    --shadow:        rgba(0,0,0,0.1);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background var(--transition), color var(--transition);
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ===================== NAVBAR ===================== */
.navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px var(--shadow);
}
.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.nav-logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.nav-link {
    color: var(--text-secondary);
    font-size: 0.95rem;
    transition: color var(--transition);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.nav-link:hover { color: var(--text-primary); }
.nav-balance {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.3rem 0.8rem;
    font-size: 0.9rem;
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.nav-online {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.online-dot-nav {
    width: 9px;
    height: 9px;
    background: #48bb78;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px #48bb78;
    animation: pulse-green 2s infinite;
}
.nav-friends-online {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.nav-friends-online i { color: var(--accent); }
@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 4px #48bb78; }
    50%       { box-shadow: 0 0 10px #48bb78, 0 0 20px #48bb7855; }
}
.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.theme-toggle:hover { background: var(--accent); color: #fff; }
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.3rem;
    cursor: pointer;
}
.mobile-menu {
    display: none;
    flex-direction: column;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 1rem;
    gap: 0.8rem;
}
.mobile-menu.open { display: flex; }
.mobile-menu a { color: var(--text-primary); padding: 0.5rem 0; border-bottom: 1px solid var(--border); }

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.4rem;
    border-radius: var(--radius);
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-warning   { background: var(--warning); color: #1a202c; }
.btn-full      { width: 100%; justify-content: center; }
.btn-sm        { padding: 0.4rem 0.9rem; font-size: 0.85rem; }
.btn:disabled, .btn.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ===================== HERO ===================== */
.hero {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
}
.hero-content { text-align: center; max-width: 900px; width: 100%; }
.casino-logo { margin-bottom: 2rem; }
.logo-icon { font-size: 4rem; display: block; margin-bottom: 0.5rem; }
.casino-logo h1 {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.tagline { color: var(--text-secondary); font-size: 1.1rem; margin-top: 0.5rem; }
.welcome-back h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.welcome-back h2 .highlight { color: var(--accent-gold); }
.balance-display {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 0.5rem 1.2rem;
    color: var(--accent-gold);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 2rem;
}
.game-cards, .game-preview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}
.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    display: block;
}
.game-card:hover:not(.coming-soon) {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(233,69,96,0.2);
}
.game-card.coming-soon { opacity: 0.5; cursor: default; }
.card-icon { font-size: 2.5rem; margin-bottom: 0.8rem; }
.game-card h3 { font-size: 1.2rem; margin-bottom: 0.4rem; }
.game-card p  { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1rem; }
.play-btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 0.5rem 1.2rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}
.play-btn.disabled { background: var(--border); color: var(--text-secondary); }
.cta-section { margin-bottom: 2rem; }
.cta-text { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 1.5rem; }
.cta-buttons { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* ===================== AUTH ===================== */
.auth-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
}
.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) * 1.5);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 10px 40px var(--shadow);
}
.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-icon { font-size: 3rem; display: block; margin-bottom: 0.5rem; }
.auth-header h1 { font-size: 1.8rem; }
.auth-header p  { color: var(--text-secondary); margin-top: 0.3rem; }
.auth-form { display: flex; flex-direction: column; gap: 1.2rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.form-group input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition);
    width: 100%;
}
.form-group input:focus { border-color: var(--accent); }
.form-group small { color: var(--text-secondary); font-size: 0.8rem; }
.input-group { display: flex; position: relative; }
.input-group input { border-radius: 8px 0 0 8px; flex: 1; }
.toggle-password {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 8px 8px 0;
    padding: 0 0.9rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color var(--transition);
}
.toggle-password:hover { color: var(--accent); }
.auth-footer { text-align: center; margin-top: 1.5rem; color: var(--text-secondary); font-size: 0.9rem; }

/* ===================== ALERTS ===================== */
.alert {
    padding: 0.85rem 1.1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}
.alert-error   { background: rgba(252,92,125,0.15); border: 1px solid var(--danger); color: var(--danger); }
.alert-success { background: rgba(72,187,120,0.15); border: 1px solid var(--success); color: var(--success); }

/* ===================== PROFILE ===================== */
.profile-page { flex: 1; padding: 2rem 1.5rem; }
.profile-container { max-width: 900px; margin: 0 auto; }
.profile-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
    position: relative;
}
.avatar-wrapper { position: relative; flex-shrink: 0; }
.avatar {
    width: 80px; height: 80px;
    background: linear-gradient(135deg, var(--accent), var(--accent-gold));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; font-weight: 800; color: #fff;
}
.avatar-img {
    width: 80px; height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent);
}
.avatar-edit-btn {
    position: absolute;
    bottom: 0; right: 0;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    width: 26px; height: 26px;
    cursor: pointer;
    color: #fff;
    font-size: 0.7rem;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--transition);
}
.avatar-edit-btn:hover { background: var(--accent-hover); }
.avatar-url-form {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
}
.avatar-url-form.hidden { display: none; }
.avatar-input-row { display: flex; gap: 0.7rem; margin-bottom: 0.4rem; }
.avatar-input-row input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    color: var(--text-primary);
    outline: none;
    font-size: 0.9rem;
}
.avatar-input-row input:focus { border-color: var(--accent); }
.avatar-url-form small { color: var(--text-secondary); font-size: 0.8rem; }
.profile-info h1 { font-size: 1.8rem; }
.member-since { color: var(--text-secondary); font-size: 0.9rem; margin: 0.3rem 0; display: flex; align-items: center; gap: 0.4rem; }
.balance-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.4rem 1rem;
    color: var(--accent-gold);
    font-weight: 600;
    margin-top: 0.5rem;
}
.online-badge { font-size: 0.85rem; margin-left: 0.5rem; }
.online-dot-large {
    position: absolute;
    bottom: 4px; right: 4px;
    width: 14px; height: 14px;
    background: #48bb78;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
    box-shadow: 0 0 8px #48bb78;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}
.stat-icon.wins    { background: rgba(72,187,120,0.2); color: var(--success); }
.stat-icon.losses  { background: rgba(252,92,125,0.2); color: var(--danger); }
.stat-icon.rate    { background: rgba(240,192,64,0.2); color: var(--accent-gold); }
.stat-icon.profit.positive { background: rgba(72,187,120,0.2); color: var(--success); }
.stat-icon.profit.negative { background: rgba(252,92,125,0.2); color: var(--danger); }
.stat-value { font-size: 1.4rem; font-weight: 700; display: block; }
.stat-label { font-size: 0.85rem; color: var(--text-secondary); }
.text-green { color: var(--success) !important; }
.text-red   { color: var(--danger) !important; }

/* ===================== FRIENDS ===================== */
.friends-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}
.friends-section h2 { margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.friend-search { position: relative; margin-bottom: 1.2rem; }
.friend-search input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.7rem 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition);
}
.friend-search input:focus { border-color: var(--accent); }
.friend-search-results {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    z-index: 50;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 8px 24px var(--shadow);
}
.friend-search-results.active { display: block; }
.search-item {
    padding: 0.7rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    gap: 0.8rem;
}
.search-item:last-child { border-bottom: none; }
.search-user {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    text-decoration: none;
    color: var(--text-primary);
    flex: 1;
}
.search-avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--accent), var(--accent-gold));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem; color: #fff;
    flex-shrink: 0;
}
.search-avatar-img {
    width: 34px; height: 34px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.dot-green {
    width: 8px; height: 8px;
    background: #48bb78;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 5px #48bb78;
}
.friend-requests {
    background: rgba(240,192,64,0.07);
    border: 1px solid rgba(240,192,64,0.2);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}
.friend-requests h3 { font-size: 0.95rem; margin-bottom: 0.8rem; color: var(--accent-gold); display: flex; align-items: center; gap: 0.5rem; }
.friends-list { display: flex; flex-direction: column; gap: 0.5rem; }
.friend-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border);
}
.friend-avatar {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--accent), var(--accent-gold));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1rem; color: #fff;
    position: relative;
    flex-shrink: 0;
}
.friend-avatar img {
    width: 38px; height: 38px;
    border-radius: 50%;
    object-fit: cover;
}
.friend-avatar .online-dot {
    position: absolute;
    bottom: 0; right: 0;
    width: 10px; height: 10px;
    background: #48bb78;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
}
.friend-info { display: flex; flex-direction: column; }
.friend-name { font-weight: 600; font-size: 0.95rem; color: var(--text-primary); }
.friend-status { font-size: 0.78rem; }
.friend-status.online  { color: #48bb78; }
.friend-status.offline { color: var(--text-secondary); }
.friend-actions { display: flex; gap: 0.4rem; margin-left: auto; }
.friend-action-btn { margin-top: 0.8rem; display: flex; align-items: center; gap: 0.5rem; }

/* ===================== HISTORY ===================== */
.history-section { margin-bottom: 2rem; }
.history-section h2 { margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.history-table-wrapper { overflow-x: auto; }
.history-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.history-table th, .history-table td {
    padding: 0.8rem 1rem;
    text-align: left;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}
.history-table th { background: var(--bg-card); color: var(--text-secondary); font-weight: 600; }
.history-table tr:last-child td { border-bottom: none; }
.badge {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}
.badge-win  { background: rgba(72,187,120,0.2); color: var(--success); }
.badge-lose { background: rgba(252,92,125,0.2); color: var(--danger); }
.badge-draw { background: rgba(240,192,64,0.2); color: var(--accent-gold); }
.empty-history {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}
.empty-history i { font-size: 3rem; margin-bottom: 1rem; display: block; }

/* ===================== FOOTER ===================== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 1.5rem;
    text-align: center;
}
.footer p { color: var(--text-secondary); font-size: 0.9rem; }
.disclaimer { font-size: 0.8rem; margin-top: 0.3rem; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
    .nav-links { display: none; }
    .mobile-menu-btn { display: block; }
    .profile-header { flex-direction: column; text-align: center; }
    .cta-buttons { flex-direction: column; align-items: center; }
    .nav-online, .nav-friends-online { display: none; }
}
