:root {
    --bg-color: #f0f2f5;
    --bg-gradient: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-backdrop: blur(12px);
    --text-main: #333333;
    --text-sub: #5a6566;
    --header-border: rgba(0, 0, 0, 0.1);
    --stat-bg: rgba(255, 255, 255, 0.5);
    --brand-color: #3498db;
    --toggle-bg: rgba(0, 0, 0, 0.1);
    --badge-sale: #e74c3c;
    --badge-new: #27ae60;
    --focus-ring: #3498db;
    --status-live: #27ae60;
    --status-stale: #e74c3c;
    --upcoming-border: #bdc3c7;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --bg-gradient: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    --card-bg: rgba(30, 30, 30, 0.6);
    --card-backdrop: blur(12px);
    --text-main: #f0f0f0;
    --text-sub: #b0b3b8;
    --header-border: rgba(255, 255, 255, 0.1);
    --stat-bg: rgba(45, 45, 45, 0.4);
    --brand-color: #5dade2;
    --toggle-bg: rgba(255, 255, 255, 0.1);
    --badge-sale: #ff6b6b;
    --badge-new: #2ecc71;
    --focus-ring: #5dade2;
    --status-live: #2ecc71;
    --upcoming-border: #7f8c8d;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    margin: 0;
    padding: 15px;
    padding-bottom: 40px;
    transition: background-color 0.3s, background-image 0.3s, color 0.3s;
    overscroll-behavior-y: none;
    min-height: 100vh;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--header-border);
}

h1 {
    font-size: 1.5rem;
    margin: 0;
    color: var(--text-main);
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    height: 10px;
    width: 10px;
    background-color: var(--status-live);
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

.stale-warning {
    color: var(--status-stale);
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(39, 174, 96, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(39, 174, 96, 0);
    }
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}
.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--toggle-bg);
    transition: .4s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5px;
    box-sizing: border-box;
    border: 1px solid var(--header-border);
}
.slider.round {
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 20px; width: 20px;
    left: 2px; bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .slider:before {
    transform: translateX(24px);
    background-color: #1e1e1e;
}
.slider .icon {
    font-size: 11px;
    z-index: 1;
}

.card {
    background: var(--card-bg);
    backdrop-filter: var(--card-backdrop);
    -webkit-backdrop-filter: var(--card-backdrop);
    border: 1px solid var(--header-border);
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s, border-color 0.3s;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
}

.stat-box {
    background-color: var(--stat-bg);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--brand-color);
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s, opacity 0.3s, background-color 0.3s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    opacity: 0;
    transform: translateY(10px);
    animation: fadeUp 0.5s ease forwards;
}

.stat-box:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.stat-box:active {
    transform: scale(0.98);
}

.stat-box.focused {
    box-shadow: 0 0 0 3px var(--focus-ring);
    transform: scale(1.02);
    z-index: 10;
}

.stat-box.dimmed {
    opacity: 0.4;
    filter: grayscale(0.8);
}

.stat-box.sold-out {
    border-left-color: #e74c3c;
    background-color: rgba(231, 76, 60, 0.1);
}

.stat-box.upcoming {
    border-left-color: var(--upcoming-border);
    opacity: 0.7;
}

.stat-box.upcoming .stat-num {
    font-size: 1rem;
    color: var(--text-sub);
    margin: 15px 0;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.stat-match {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-sub);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-kickoff {
    font-size: 0.72rem;
    color: var(--text-sub);
    opacity: 0.75;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-num {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 5px 0;
}

.stat-sub {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-sub);
    text-transform: uppercase;
    margin-top: -5px;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.stat-time {
    font-size: 0.7rem;
    color: var(--text-sub);
    opacity: 0.6;
}

.velocity-badge {
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.v-down {
    color: var(--badge-sale);
    background: rgba(231, 76, 60, 0.15);
}

.v-up {
    color: var(--badge-new);
    background: rgba(39, 174, 96, 0.15);
}

.graph-header {
    display: flex;
    justify-content: center;
    margin-bottom: 5px;
}

.graph-toggle-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.graph-hint {
    text-align: center;
    font-size: 0.68rem;
    color: var(--text-sub);
    opacity: 0.45;
    margin: 0;
    width: 100%;
    letter-spacing: 0.2px;
    font-style: italic;
    font-weight: 400;
}

.graph-toggle {
    display: flex;
    background: var(--toggle-bg);
    padding: 4px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.toggle-option {
    padding: 6px 15px;
    cursor: pointer;
    border-radius: 6px;
    color: var(--text-sub);
    transition: all 0.2s;
    font-weight: 500;
}

.toggle-option.active {
    background: var(--brand-color);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.graph-wrapper {
    position: relative;
}

.graph-view {
    display: none;
}

.graph-view.active {
    display: block;
}

details.collapsible-card {
    padding: 0;
}

details.collapsible-card>summary {
    cursor: pointer;
    list-style: none;
    user-select: none;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    color: var(--text-main);
}

details.collapsible-card>summary::-webkit-details-marker {
    display: none;
}

details.collapsible-card>summary::after {
    content: '+';
    font-size: 1.5rem;
    font-weight: 300;
    line-height: 1;
    transition: transform 0.2s ease;
    color: var(--brand-color);
}

details.collapsible-card[open]>summary::after {
    transform: rotate(45deg);
}

.collapse-content {
    height: 0;
    overflow: hidden;
    transition: height 0.3s ease;
    border-top: 1px solid transparent;
}

details.is-open>.collapse-content {
    border-top-color: var(--toggle-bg);
}

.collapse-inner {
    padding: 0 15px 15px 15px;
}

.collapsible-hint {
    font-size: 0.75rem;
    color: var(--text-sub);
    opacity: 0.6;
    margin: 0 0 12px 0;
    text-align: center;
}

.faq-section {
    margin-top: 30px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.faq-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--text-main);
    text-align: center;
}

.faq-item {
    background: var(--card-bg);
    border-radius: 12px;
    margin-bottom: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: background-color 0.3s;
}

.faq-item summary {
    padding: 15px 20px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    list-style: none;
    user-select: none;
    color: var(--text-main);
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.5rem;
    font-weight: 300;
    line-height: 1;
    transition: transform 0.2s ease;
    color: var(--brand-color);
}

.faq-item[open] summary::after {
    transform: rotate(45deg);
}

footer {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-sub);
    margin-top: 40px;
    opacity: 0.5;
    padding-bottom: 20px;
}

/* ── Contact links (FAQ) ── */
.contact-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.contact-link {
    display: inline-block;
    padding: 6px 12px;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9rem;
}

.contact-link-email {
    background: #0077cc;
}

.contact-link-x {
    background: #000000;
}

.contact-link:hover {
    opacity: 0.85;
}

/* ── Modal ── */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: var(--card-bg);
    margin: 15% auto;
    padding: 25px;
    border-radius: 16px;
    width: 80%;
    max-width: 400px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.close {
    color: var(--text-sub);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover,
.close:focus {
    color: var(--text-main);
    text-decoration: none;
}

.modal-header {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 20px;
    padding-right: 20px;
    color: var(--text-main);
}

.zone-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.zone-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 8px;
}

.zone-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text-main);
}

.zone-emoji {
    font-size: 1.2rem;
}

.zone-count {
    font-weight: 800;
    color: var(--brand-color);
    font-size: 1.1rem;
}

/* ── Markdown Content Styling ── */
.markdown-body {
    line-height: 1.6;
    color: var(--text-main);
    font-size: 0.95rem;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
    color: var(--brand-color);
    border-bottom: 1px solid var(--header-border);
    padding-bottom: 0.3rem;
}

.markdown-body h1 { font-size: 1.4rem; }
.markdown-body h2 { font-size: 1.25rem; }
.markdown-body h3 { font-size: 1.1rem; }

.markdown-body p, .markdown-body ul, .markdown-body ol {
    margin-bottom: 1rem;
}

.markdown-body ul, .markdown-body ol {
    padding-left: 1.5rem;
}

.markdown-body li {
    margin-bottom: 0.4rem;
}

.markdown-body code {
    background: var(--stat-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.85rem;
}

.markdown-body pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.markdown-body pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.markdown-body th, .markdown-body td {
    border: 1px solid var(--header-border);
    padding: 8px;
    text-align: left;
}

.markdown-body th {
    background: var(--stat-bg);
    font-weight: 700;
}

.markdown-body blockquote {
    border-left: 4px solid var(--brand-color);
    padding-left: 1rem;
    margin-left: 0;
    color: var(--text-sub);
    font-style: italic;
}

.markdown-body hr {
    border: 0;
    border-top: 1px solid var(--header-border);
    margin: 1.5rem 0;
}

/* ── Skeletons & Micro-animations ── */
@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.skeleton {
    background: linear-gradient(90deg, var(--stat-bg) 25%, rgba(255,255,255,0.1) 50%, var(--stat-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-left-color: var(--toggle-bg) !important;
    min-height: 120px;
}

.skeleton-graph {
    background: linear-gradient(90deg, var(--card-bg) 25%, rgba(255,255,255,0.05) 50%, var(--card-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 8px;
    min-height: 350px;
}

@keyframes shimmer {
    to {
        background-position: -200% 0;
    }
}

/* ── Mobile Responsiveness ── */
@media (max-width: 480px) {
    body {
        padding: 10px;
        padding-bottom: 25px;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .theme-switch {
        position: absolute;
        top: 15px;
        right: 15px;
    }

    h1 {
        font-size: 1.2rem;
        padding-right: 50px; /* Space for absolute switch */
    }

    .subtitle {
        font-size: 0.8rem;
        flex-wrap: wrap;
    }

    .card {
        padding: 10px;
        border-radius: 10px;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-box {
        padding: 10px;
    }

    .stat-num {
        font-size: 1.4rem;
    }

    .stat-match {
        font-size: 0.8rem;
    }

    .graph-toggle {
        font-size: 0.8rem;
    }

    .toggle-option {
        padding: 5px 10px;
    }

    .modal-content {
        width: 95%;
        margin: 20% auto;
        padding: 15px;
    }
    
    .zone-emoji {
        font-size: 1rem;
    }
}