/* GameHub Global Styles */
:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a2332;
    --bg-card: #1e2d3d;
    --text-primary: #e1e8ed;
    --text-secondary: #8899a6;
    --accent: #1da1f2;
    --accent-hover: #1a91da;
    --success: #17bf63;
    --warning: #ffad1f;
    --danger: #e0245e;
    --border: #2d3f50;
    --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); }

h2 { margin-bottom: 1rem; }

/* Page layout */
.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Bar */
.top-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    height: 60px;
    gap: 2rem;
}

.brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}

.nav-links { display: flex; gap: 1.5rem; flex: 1; }
.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}
.nav-links a:hover { color: var(--text-primary); }

.auth-section { display: flex; gap: 0.75rem; align-items: center; }
.btn-login, .btn-logout {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}
.btn-login { background: var(--accent); color: #fff; }
.btn-login:hover { background: var(--accent-hover); }
.btn-login.btn-steam { background: #171a21; }
.btn-login.btn-steam:hover { background: #2a475e; }
.btn-logout { color: var(--text-secondary); border: 1px solid var(--border); }
.btn-logout:hover { color: var(--danger); border-color: var(--danger); }
.profile-link { color: var(--accent); text-decoration: none; font-weight: 600; }

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

/* Hero */
.hero { text-align: center; margin-bottom: 2.5rem; }
.hero h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.hero .subtitle { color: var(--text-secondary); font-size: 1.1rem; }

/* Game Cards */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s;
}
.game-card:hover { transform: translateY(-4px); border-color: var(--accent); }

.game-thumb {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a2332, #2d3f50);
}
.game-icon { font-size: 4rem; }

.game-info { padding: 1.25rem; }
.game-info h3 { margin-bottom: 0.5rem; font-size: 1.2rem; }
.game-info p { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1rem; }

.btn-play {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    background: var(--success);
    color: #fff;
    text-decoration: none;
    border-radius: 20px;
    font-weight: 600;
    transition: background 0.2s;
}
.btn-play:hover { background: #15a857; }

/* Tabs */
.tab-bar { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.tab:hover { border-color: var(--accent); color: var(--text-primary); }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Sort */
.sort-bar { margin-bottom: 1rem; display: flex; align-items: center; gap: 0.75rem; }
.sort-bar select {
    padding: 0.4rem 0.75rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
}

/* Leaderboard Table */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
}
.leaderboard-table th {
    background: var(--bg-secondary);
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}
.leaderboard-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.rank-cell { font-weight: 700; color: var(--warning); width: 50px; }
.elo-cell { font-weight: 700; color: var(--accent); }
.player-cell .avatar { margin-right: 0.5rem; }
.empty-state { text-align: center; color: var(--text-secondary); padding: 2rem !important; }

/* Chat */
.chat-container { display: flex; height: calc(100vh - 160px); gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.channel-sidebar {
    width: 200px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 1rem;
    flex-shrink: 0;
}
.channel-sidebar h3 { margin-bottom: 1rem; font-size: 0.95rem; color: var(--text-secondary); }
.channel-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 0.9rem;
}
.channel-btn:hover { background: var(--bg-card); color: var(--text-primary); }
.channel-btn.active { background: var(--accent); color: #fff; }
.channel-count {
    margin-left: auto;
    background: var(--bg-primary);
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
}

.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-header { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); background: var(--bg-secondary); }
.chat-header h3 { font-size: 1rem; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.chat-message { display: flex; align-items: flex-start; gap: 0.5rem; }
.msg-avatar { font-size: 1.2rem; }
.msg-body { flex: 1; }
.msg-name { font-weight: 600; margin-right: 0.5rem; color: var(--accent); }
.msg-text { color: var(--text-primary); }
.msg-time { color: var(--text-secondary); font-size: 0.75rem; white-space: nowrap; }

.chat-input-bar { border-top: 1px solid var(--border); padding: 0.75rem 1rem; background: var(--bg-secondary); }
.emote-bar { display: flex; gap: 0.25rem; margin-bottom: 0.5rem; }
.emote-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background 0.2s;
}
.emote-btn:hover { background: var(--bg-card); }

.msg-form { display: flex; gap: 0.5rem; }
.msg-input {
    flex: 1;
    padding: 0.5rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-primary);
    outline: none;
}
.msg-input:focus { border-color: var(--accent); }
.btn-send {
    padding: 0.5rem 1.25rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
}
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }
.login-prompt { color: var(--text-secondary); }
.login-prompt a { color: var(--accent); }

/* Profile */
.auth-prompt { text-align: center; padding: 4rem 1rem; }
.auth-prompt h2 { margin-bottom: 1.5rem; }
.auth-prompt .btn-login { margin: 0 0.5rem; }

.profile-page { max-width: 800px; }
.profile-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius);
}
.avatar-container { position: relative; cursor: pointer; }
.avatar-container:hover .avatar-edit-hint { opacity: 1; }
.avatar-edit-hint {
    position: absolute;
    bottom: -4px;
    right: -4px;
    font-size: 0.75rem;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.profile-avatar { font-size: 3rem; }
.profile-avatar-img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent); }
.profile-info h2 { margin-bottom: 0.25rem; }
.rank-badge { color: var(--warning); font-weight: 600; display: block; }
.provider-badge { color: var(--text-secondary); font-size: 0.85rem; }
.bio { color: var(--text-secondary); margin-top: 0.5rem; }

/* Linked Accounts */
.linked-accounts { display: flex; flex-direction: column; gap: 0.5rem; }
.linked-account {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.linked-account.linked { border-color: var(--success); }
.la-icon { font-size: 1.3rem; width: 1.5rem; text-align: center; font-weight: 700; }
.la-name { flex: 1; font-weight: 500; }
.la-status { color: var(--success); font-size: 0.85rem; }
.la-link-btn {
    padding: 0.3rem 0.75rem;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}
.la-link-btn:hover { background: var(--accent-hover); }

/* Avatar Picker */
.avatar-picker-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}
.avatar-picker-section h4 { margin: 1rem 0 0.5rem; color: var(--text-secondary); font-size: 0.85rem; }
.avatar-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.avatar-option {
    width: 56px;
    height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.avatar-option:hover { border-color: var(--accent); transform: scale(1.1); }
.avatar-option.selected { border-color: var(--success); background: rgba(23, 191, 99, 0.1); }
.avatar-option-img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.avatar-option-emoji { font-size: 1.8rem; }
.avatar-provider-label { font-size: 0.55rem; color: var(--text-secondary); margin-top: 2px; }

.profile-section { margin-bottom: 2rem; }
.profile-section h3 { margin-bottom: 1rem; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.stat-card {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: var(--radius);
    text-align: center;
    border: 1px solid var(--border);
}
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.stat-label { color: var(--text-secondary); font-size: 0.85rem; }

.game-stats-card {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 0.75rem;
}
.game-stats-card h4 { margin-bottom: 0.5rem; }
.stats-row { display: flex; gap: 1.5rem; color: var(--text-secondary); font-size: 0.9rem; flex-wrap: wrap; }
.no-stats { color: var(--text-secondary); font-style: italic; font-size: 0.9rem; }

.friend-card { padding: 0.5rem; border-bottom: 1px solid var(--border); }
.friend-request { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem; border-bottom: 1px solid var(--border); }
.friend-request button {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
}
.friend-request button:first-of-type { background: var(--success); color: #fff; }
.friend-request button:last-of-type { background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border); }

/* Footer */
.footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

/* Login Gate Page */
.login-layout {
    min-height: 100vh;
    background: var(--bg-primary);
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.login-card {
    text-align: center;
    padding: 3rem 2.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    max-width: 420px;
    width: 90%;
}

.login-card h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.login-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.btn-provider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.25rem;
    border-radius: 10px;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s;
    border: 1px solid transparent;
}
.btn-provider:hover { filter: brightness(1.15); transform: translateY(-1px); }

.provider-icon {
    font-size: 1.2rem;
    width: 1.5rem;
    text-align: center;
}

.btn-google { background: #4285f4; color: #fff; }
.btn-steam { background: #171a21; color: #c7d5e0; border-color: #2a475e; }
.btn-microsoft { background: #00a4ef; color: #fff; }
.btn-discord { background: #5865f2; color: #fff; }
.btn-github { background: #24292e; color: #fff; }
.btn-twitch { background: #9146ff; color: #fff; }

.login-footer {
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.btn-login-large {
    display: block;
    padding: 0.85rem 1.5rem;
    border-radius: 10px;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s;
    text-align: center;
}

.btn-login-large.btn-google {
    background: #4285f4;
    color: #fff;
}
.btn-login-large.btn-google:hover { background: #3574e2; }

.btn-login-large.btn-steam-large {
    background: #171a21;
    color: #c7d5e0;
    border: 1px solid #2a475e;
}
.btn-login-large.btn-steam-large:hover { background: #2a475e; }

/* Blazor Error */
#blazor-error-ui {
    display: none;
    background: var(--danger);
    color: #fff;
    padding: 0.5rem;
    text-align: center;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .reload { color: #fff; text-decoration: underline; }
#blazor-error-ui .dismiss { cursor: pointer; margin-left: 1rem; }

.blazor-error-boundary { padding: 1rem; background: var(--danger); color: #fff; border-radius: var(--radius); }
.blazor-error-boundary::after { content: "An error has occurred."; }