/* ========== CSS Reset & Base ========== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-primary: #0f1118;
    --bg-secondary: #1a1d2e;
    --bg-card: #222640;
    --bg-input: #2a2e45;
    --text-primary: #e8e9ed;
    --text-secondary: #9ca3b4;
    --text-muted: #6b7280;
    --accent: #4f8cff;
    --accent-hover: #3a7aef;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #eab308;
    --orange: #f97316;
    --border: #2d3148;
    --nav-height: 60px;
    --header-height: 52px;
    --radius: 12px;
    --radius-sm: 8px;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    color: var(--accent-hover);
}

/* ========== Header ========== */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent);
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    background: var(--bg-card);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 44px;
    min-height: 44px;
    overflow: hidden;
}
.icon-btn:hover {
    background: var(--bg-input);
    border-color: var(--accent);
}

/* Header & nav profile picture avatars */
.header-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.nav-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
}
.icon-btn svg {
    width: 22px;
    height: 22px;
}

/* ========== Main Content ========== */
.main-content {
    margin-top: var(--header-height);
    padding: 16px;
    padding-bottom: calc(var(--nav-height) + 80px);
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

/* ========== Messages ========== */
.messages {
    margin-top: var(--header-height);
    padding: 8px 16px;
}
.message {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 0.9rem;
}
.message-success { background: rgba(34,197,94,0.15); color: var(--green); }
.message-error { background: rgba(239,68,68,0.15); color: var(--red); }
.message-warning { background: rgba(234,179,8,0.15); color: var(--yellow); }
.message-info { background: rgba(79,140,255,0.15); color: var(--accent); }

/* ========== Bottom Nav ========== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-around;
    border-top: 1px solid var(--border);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 500;
    text-decoration: none;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    padding: 4px;
}
.nav-item.active {
    color: var(--accent);
}
.nav-item:hover {
    color: var(--text-primary);
}
.nav-item svg {
    width: 22px;
    height: 22px;
}

/* ========== Footer ========== */
.site-footer {
    text-align: center;
    padding: 20px 16px;
    padding-bottom: calc(var(--nav-height) + 20px);
}
.disclaimer {
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.4;
}

/* ========== Cards ========== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}
.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
}
.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* ========== Badges ========== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-green { background: rgba(34,197,94,0.2); color: var(--green); }
.badge-red { background: rgba(239,68,68,0.2); color: var(--red); }
.badge-yellow { background: rgba(234,179,8,0.2); color: var(--yellow); }
.badge-blue { background: rgba(79,140,255,0.2); color: var(--accent); }
.badge-gray { background: rgba(156,163,180,0.2); color: var(--text-secondary); }
.badge-fav {
    background: rgba(234,179,8,0.15);
    color: var(--yellow);
    font-size: 0.7rem;
}
.badge-live {
    background: rgba(239,68,68,0.2);
    color: #ef4444;
    font-size: 0.7rem;
    animation: live-pulse 2s ease-in-out infinite;
}
@keyframes live-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
.game-card-live {
    border-left: 3px solid #ef4444;
}
.section-title-live {
    color: #ef4444;
    display: flex;
    align-items: center;
    gap: 6px;
}
.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    animation: live-pulse 2s ease-in-out infinite;
}
.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* ========== Stat Tiles ========== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.stat-tile {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
    border: 1px solid var(--border);
}
.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}
.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ========== Edge Values ========== */
.edge-positive { color: var(--green); }
.edge-negative { color: var(--red); }
.edge-neutral { color: var(--text-secondary); }

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    min-height: 44px;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent-hover);
    color: #fff;
}
.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: var(--border);
}
.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
    min-height: 36px;
}
.btn-block {
    width: 100%;
}

/* ========== Forms ========== */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 16px; /* prevents iOS zoom */
    outline: none;
    transition: border-color 0.15s;
}
.form-control:focus {
    border-color: var(--accent);
}
select.form-control {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%239ca3b4' stroke-width='2'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}
.form-error {
    color: var(--red);
    font-size: 0.8rem;
    margin-top: 4px;
}
.form-help {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 4px;
}

/* ========== Tables (card style on mobile) ========== */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    text-align: left;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
.data-table tr:last-child td {
    border-bottom: none;
}

/* ========== Confidence Indicators ========== */
.confidence-high { color: var(--green); }
.confidence-med { color: var(--yellow); }
.confidence-low { color: var(--red); }

/* ========== Line Movement ========== */
.line-up { color: var(--green); }
.line-up::before { content: "▲ "; }
.line-down { color: var(--red); }
.line-down::before { content: "▼ "; }

/* ========== Help Modal ========== */
.help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.help-sheet {
    background: var(--bg-secondary);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 20px;
    animation: slideUp 0.2s ease-out;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.help-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}
.help-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.help-body h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--accent);
}
.help-body ul {
    list-style: none;
    padding: 0;
}
.help-body li {
    padding: 6px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    border-bottom: 1px solid var(--border);
}
.help-body li:last-child {
    border-bottom: none;
}
.help-body li strong {
    color: var(--text-primary);
}

/* ========== Utility ========== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-sm { font-size: 0.8rem; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-row { display: flex; gap: 8px; flex-wrap: wrap; }

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 16px;
}
.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

/* ========== Offseason Banner ========== */
.offseason-banner {
    background: rgba(234,179,8,0.12);
    border: 1px solid rgba(234,179,8,0.3);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: var(--yellow);
    line-height: 1.5;
}

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state p {
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* ========== Login Gate ========== */
.login-gate {
    text-align: center;
    padding: 24px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-top: 12px;
}
.login-gate p {
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-size: 0.9rem;
}

/* ========== Filter Bar ========== */
.filter-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
}
.filter-chip {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    white-space: nowrap;
    cursor: pointer;
    min-height: 36px;
    text-decoration: none;
}
.filter-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ========== Game Card ========== */
.game-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    display: block;
    text-decoration: none;
    color: var(--text-primary);
    transition: border-color 0.15s;
}
.game-card:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}
.game-card .teams {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.game-card .team-name {
    font-weight: 600;
    font-size: 0.9rem;
}
.game-card .vs {
    color: var(--text-muted);
    font-size: 0.75rem;
}
.game-score {
    font-weight: 700;
    margin-left: 6px;
    padding: 2px 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    font-size: 0.95em;
}
.game-card .game-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.game-card .edge-row {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.8rem;
}

/* ========== Slider ========== */
input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-input);
    border-radius: 3px;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

/* ========== Tabs ========== */
.tab-bar {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.tab-item {
    padding: 10px 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}
.tab-item.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ========== Profile Dropdown ========== */
.profile-dropdown-wrap {
    position: relative;
}
.profile-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 150;
    overflow: hidden;
}
.profile-dropdown.open {
    display: block;
}
.profile-dropdown-item {
    display: block;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 0.85rem;
    text-decoration: none;
    transition: background 0.1s;
    min-height: 44px;
    display: flex;
    align-items: center;
}
.profile-dropdown-item:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}
.profile-dropdown-divider {
    height: 1px;
    background: var(--border);
}
.profile-dropdown-logout {
    color: var(--red);
}
.profile-dropdown-logout:hover {
    color: var(--red);
}

/* ========== Profile Avatar ========== */
.profile-avatar-section {
    display: flex;
    align-items: center;
    gap: 16px;
}
.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.profile-avatar-placeholder {
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}
.file-input {
    padding: 10px;
}

/* ========== Responsive ========== */

/* Tablet */
@media (min-width: 481px) and (max-width: 768px) {
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
    .card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

/* Desktop */
@media (min-width: 769px) {
    .logo {
        font-size: 1.15rem;
    }
    .main-content {
        padding: 24px 32px;
        padding-bottom: calc(var(--nav-height) + 80px);
    }
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
    .card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

    .help-sheet {
        border-radius: var(--radius);
        margin-bottom: 10vh;
    }
    .help-overlay {
        align-items: center;
    }
}
