:root {
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --secondary: #22D3EE;
    --bg-dark: #0B1120;
    --bg-card: #111827;
    --bg-card-hover: #1F2937;
    --text-light: #F9FAFB;
    --text-muted: #9CA3AF;
    --gradient-primary: linear-gradient(135deg, #2563EB 0%, #22D3EE 100%);
    --border-radius: 16px;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 76px; }

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-light);
    line-height: 1.6;
    min-height: 100vh;
}

body[dir="ltr"] {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

.bg-pattern {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(37, 99, 235, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(34, 211, 238, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(11, 17, 32, 0.92);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    z-index: 1000;
    padding: 15px 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
}

.logo-icon { width: 36px; height: 36px; }

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

nav a:hover, nav a.active { color: var(--secondary); }

.page-main {
    padding: 100px 0 60px;
}

.page-title {
    font-size: 1.75rem;
    margin-bottom: 8px;
}

.page-subtitle {
    color: var(--text-muted);
    margin-bottom: 28px;
}

.card {
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 16px;
}

.me-summary {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.me-summary .rank-badge {
    font-size: 2rem;
    font-weight: 800;
    color: var(--secondary);
}

.comp-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.comp-avatar-lg {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
}

.comp-avatar-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.35);
    font-weight: 700;
    font-size: 1.1rem;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.leaderboard-row .rank-num {
    min-width: 4.5rem;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
}

.leaderboard-row .row-body { flex: 1; min-width: 0; }

.leaderboard-row .row-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.fan-line {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.fan-line img { width: 20px; height: 14px; object-fit: cover; border-radius: 2px; }

.row-points {
    font-weight: 700;
    color: var(--secondary);
    white-space: nowrap;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.history-table th,
.history-table td {
    padding: 10px 8px;
    text-align: right;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

body[dir="ltr"] .history-table th,
body[dir="ltr"] .history-table td { text-align: left; }

.history-table .pts-ok { color: #34d399; }
.history-table .pts-no { color: #f87171; }

.fan-team-current {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 12px 14px;
    background: var(--bg-card-hover);
    border-radius: 10px;
}

.fan-team-current img {
    width: 40px;
    height: 28px;
    object-fit: cover;
    border-radius: 4px;
}

.fan-team-name {
    font-weight: 600;
    font-size: 1rem;
}

.fan-team-change-btn {
    margin-inline-start: auto;
    background: none;
    border: none;
    color: var(--secondary);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 6px 10px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.fan-team-change-btn:hover {
    color: var(--text-light);
}

.team-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
    margin-top: 12px;
}

.team-select-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px;
    background: var(--bg-card-hover);
    border: 2px solid transparent;
    border-radius: 10px;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.8rem;
}

.team-select-btn.selected {
    border-color: var(--primary);
}

.team-select-btn img { width: 32px; height: 22px; object-fit: cover; }

.faq-item { margin-bottom: 20px; }
.faq-item h3 { font-size: 1.05rem; margin-bottom: 8px; color: var(--secondary); }
.faq-item p { color: var(--text-muted); }

.points-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.points-table th, .points-table td {
    padding: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    text-align: right;
}

body[dir="ltr"] .points-table th,
body[dir="ltr"] .points-table td { text-align: left; }

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.install-hero-wrap {
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: 24px;
    border: 1px solid rgba(255,255,255,0.08);
}

.install-hero-img {
    display: block;
    width: 100%;
    max-height: 360px;
    object-fit: cover;
    object-position: center;
}

.install-lead {
    color: var(--text-muted);
    line-height: 1.8;
    margin-bottom: 24px;
}

.install-lead strong {
    color: var(--text-light);
}

.install-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.install-btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 1rem;
}

.install-btn-secondary {
    background: rgba(37, 99, 235, 0.25);
    border: 1px solid rgba(34, 211, 238, 0.4);
}

.install-btn-secondary:hover {
    background: rgba(37, 99, 235, 0.4);
}

.install-back {
    text-align: center;
    font-size: 0.9rem;
    margin: 0;
}

.loading { text-align: center; padding: 40px; color: var(--text-muted); }

.login-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-modal.active { display: flex; }

.login-modal-content {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 28px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    position: relative;
}

.login-modal-close {
    position: absolute;
    top: 12px;
    left: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

body[dir="ltr"] .login-modal-close { left: auto; right: 12px; }

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 15px 30px;
    border-radius: 10px;
    font-weight: 600;
    z-index: 3000;
    transition: transform 0.3s ease;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: rgba(76, 175, 80, 0.5);
    color: #4caf50;
}

.toast.error {
    border-color: rgba(244, 67, 54, 0.5);
    color: #f44336;
}

footer {
    padding: 30px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    margin-top: 40px;
}
