/* ===== CSS Reset & Variables ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f8f9fc;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-subtle: #eef2f7;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent: #6366f1;
    --accent-light: #e0e7ff;
    --accent-hover: #4f46e5;
    --win: #10b981;
    --win-bg: #d1fae5;
    --loss: #ef4444;
    --loss-bg: #fee2e2;
    --nr: #6b7280;
    --nr-bg: #f3f4f6;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== Layout ===== */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* ===== Header ===== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #f7a400, #f9cd05);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text);
}

.header-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
}

.header-badge {
    padding: 6px 14px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--bg-subtle);
    border-radius: var(--radius);
    padding: 3px;
    margin-bottom: 16px;
}

.tabs .header-stats {
    margin-left: auto;
    padding-right: 8px;
}

.tab {
    padding: 10px 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    white-space: nowrap;
}

.tab:hover:not(.active) {
    color: var(--text);
    background: var(--bg-card);
}

.tab.active {
    background: var(--bg-card);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

/* ===== Points Table ===== */
.section { display: none; }
.section.active { display: block; }

.table-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--bg-subtle);
    padding: 10px 10px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    font-weight: 700;
    text-align: center;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

thead th:first-child {
    text-align: left;
    padding-left: 20px;
}

tbody td {
    padding: 10px 10px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
    font-weight: 500;
}

tbody td:first-child {
    text-align: left;
    padding-left: 20px;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg-hover);
}

tbody tr.qualify-zone {
    background: rgba(99, 102, 241, 0.03);
}

tbody tr.qualify-zone:hover {
    background: rgba(99, 102, 241, 0.06);
}

tbody tr.qualify-line td {
    border-bottom: 2px dashed var(--accent);
}

/* Team Cell */
.team-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.team-pos {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-subtle);
}

.qualify-zone .team-pos {
    background: var(--accent-light);
    color: var(--accent);
}

.team-badge {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.5rem;
    color: #fff;
    letter-spacing: 0.3px;
}

.team-name {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text);
}

.team-short {
    display: none;
}

/* Stats */
.pts-value {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--text);
}

.nrr-positive { color: var(--win); font-weight: 600; }
.nrr-negative { color: var(--loss); font-weight: 600; }

/* Form Badges */
.form-group {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.form-pip {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
}

.form-pip.W { background: var(--win-bg); color: var(--win); }
.form-pip.L { background: var(--loss-bg); color: var(--loss); }
.form-pip.NR { background: var(--nr-bg); color: var(--nr); }

/* Legend */
.legend {
    display: flex;
    gap: 20px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

/* ===== Predictor ===== */
.predictor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 10px;
}

.predictor-toolbar h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}

.predictor-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-bar {
    width: 120px;
    height: 6px;
    background: var(--bg-subtle);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.btn-reset {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: var(--transition);
}

.btn-reset:hover {
    border-color: var(--loss);
    color: var(--loss);
    background: var(--loss-bg);
}

/* Match Cards */
.matches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 6px;
    margin-bottom: 28px;
}



.match-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: var(--transition);
}

.match-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--accent);
}

.match-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.match-number {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-muted);
}

.match-date {
    font-size: 0.6rem;
    color: var(--accent);
    font-weight: 600;
}

.match-teams {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.pick-btn {
    padding: 5px 10px;
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    color: #fff;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.68rem;
    transition: var(--transition);
    min-width: 44px;
    text-align: center;
    flex: 1;
    position: relative;
}

.pick-btn.selected {
    border-color: var(--win);
    box-shadow: 0 0 0 1px var(--win);
    opacity: 1;
}

.pick-btn.not-selected {
    opacity: 0.4;
}

.pick-btn .win-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 14px;
    height: 14px;
    background: var(--win);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    color: #fff;
    font-weight: 800;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.pick-btn:hover {
    opacity: 0.85;
    transform: scale(1.02);
}

.pick-btn.selected:hover {
    opacity: 1;
}

.match-vs {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Team Simulator Toggle */
.simulator-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
}

.simulator-bar label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.team-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.team-picker-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid transparent;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.team-picker-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.team-picker-btn.active {
    border-color: var(--text);
    transform: scale(1.2);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.3), 0 4px 12px rgba(0,0,0,0.2);
}

.team-picker-btn .tick {
    display: none;
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid #fff;
    align-items: center;
    justify-content: center;
}

.team-picker-btn .tick svg {
    width: 10px;
    height: 10px;
    fill: #fff;
}

.team-picker-btn.active .tick {
    display: flex;
}

.simulator-info {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
    margin-left: auto;
}

.highlight-team td {
    background: rgba(99, 102, 241, 0.06) !important;
}

.highlight-team .team-name,
.highlight-team .team-short {
    color: var(--accent);
    font-weight: 800;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: auto;
}

.toast-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 999;
    animation: fadeIn 0.2s ease;
}

.toast {
    padding: 14px 20px;
    padding-right: 40px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-left: 5px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 8px 20px rgba(0,0,0,0.1);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    animation: toastPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    min-width: 260px;
}

.toast .toast-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 22px;
    height: 22px;
    border: none;
    background: var(--bg-subtle);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: var(--transition);
    pointer-events: auto;
}

.toast .toast-close:hover {
    background: var(--loss-bg);
    color: var(--loss);
}

.toast .toast-team {
    font-weight: 800;
    color: var(--accent);
}

.toast .toast-pos {
    font-weight: 800;
}

.toast .toast-pos.top4 { color: var(--win); }
.toast .toast-pos.bottom { color: var(--loss); }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes toastPop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@media (max-width: 768px) {
    .toast-container { width: 90%; min-width: auto; }
    .toast { font-size: 0.78rem; padding: 12px 16px; padding-right: 36px; min-width: auto; }
}

/* Predicted Table */
.predicted-section {
    margin-top: 24px;
}

.predicted-section h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.predicted-section h3::before {
    content: '';
    width: 4px;
    height: 18px;
    background: var(--accent);
    border-radius: 2px;
}

.info-tooltip {
    cursor: pointer;
    font-size: 0.85rem;
    position: relative;
    display: inline-flex;
    align-items: center;
}

.info-icon {
    display: inline-block;
}

.info-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    left: 50%;
    top: calc(100% + 8px);
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 400;
    font-style: normal;
    padding: 8px 12px;
    border-radius: 6px;
    width: 220px;
    line-height: 1.4;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    white-space: normal;
    pointer-events: none;
    transition: opacity 0.2s;
}

.info-text::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--text);
}

.info-tooltip:hover .info-text,
.info-tooltip.show .info-text {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.matches-hint {
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 16px;
    margin-bottom: 20px;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 32px 20px 24px;
    margin-top: 40px;
    border-top: 1px solid var(--bg-subtle);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 14px;
}

.footer-links a {
    color: var(--text-secondary);
    transition: color 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--accent);
    transform: translateY(-2px);
}

.footer-copy {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.footer-built {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.footer-built a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.footer-built a:hover {
    text-decoration: underline;
}

.footer .heart {
    color: #ef4444;
    font-size: 0.9rem;
}

/* Header Stats (views + like) */
.header-stats {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
}

.view-counter {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.view-counter svg {
    fill: var(--text-muted);
}

.view-counter #viewCount {
    font-weight: 700;
    color: var(--text-secondary);
}

/* Like Button */
.like-counter {
    display: flex;
    align-items: center;
    gap: 4px;
}

.like-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    outline: none;
    transition: transform 0.2s;
}

.like-btn:hover {
    transform: scale(1.15);
}

.like-heart {
    fill: var(--text-muted);
    transition: fill 0.3s, transform 0.3s;
}

.like-btn.liked .like-heart {
    fill: #ef4444;
    transform: scale(1.1);
}

.like-btn.liked {
    animation: heartPulse 0.4s ease;
}

.like-count {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* Hearts Burst Animation */
.hearts-burst {
    position: absolute;
    top: 50%;
    left: 50%;
    pointer-events: none;
}

.burst-heart {
    position: absolute;
    font-size: 1rem;
    animation: burstFloat 1s ease-out forwards;
    opacity: 0;
}

@keyframes heartPulse {
    0% { transform: scale(1); }
    30% { transform: scale(1.4); }
    60% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

@keyframes burstFloat {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(1.2);
    }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .container { padding: 12px 10px; }
    .header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .header-badge { display: none; }
    .team-name { display: none; }
    .team-short { display: block; font-weight: 700; font-size: 0.75rem; }
    .form-pip { width: 18px; height: 18px; font-size: 0.55rem; }
    thead th, tbody td { padding: 8px 6px; font-size: 0.72rem; }
    .matches-grid { grid-template-columns: repeat(2, 1fr); gap: 5px; }
    .tabs { width: 100%; }
    .tab { flex: 1; text-align: center; padding: 9px 10px; font-size: 0.8rem; }
    .simulator-bar { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
    .simulator-info { margin-left: 0; }
    .predictor-toolbar { flex-direction: column; align-items: flex-start; gap: 8px; }
    .predicted-section { margin-top: 20px; }
    .table-card { border-radius: var(--radius-sm); }
}

@media (max-width: 380px) {
    .header-title { font-size: 1.1rem; }
    .matches-grid { grid-template-columns: repeat(2, 1fr); gap: 4px; }
    .match-card { padding: 6px 8px; gap: 4px; }
    .pick-btn { padding: 4px 6px; min-width: 36px; font-size: 0.62rem; }
    .match-number, .match-date { font-size: 0.55rem; }
    .match-vs { font-size: 0.5rem; }
    thead th, tbody td { padding: 6px 4px; font-size: 0.68rem; }
    .team-badge { width: 24px; height: 24px; font-size: 0.45rem; }
    .team-pos { width: 18px; height: 18px; font-size: 0.6rem; }
}
