@media (prefers-color-scheme: dark) {
    body.dark-mode {
        --background: #0F172A;
        --surface: #172033;
        --surface-soft: #1D294D;
        --text: #F8FAFC;
        --muted: #AAB4C7;
        --border: rgba(255, 255, 255, .12);
        --focus: rgba(226, 29, 61, .22);
    }
}

.empty-state,
.loading-state,
.error-state {
    display: grid;
    place-items: center;
    gap: 10px;
    min-height: 180px;
    padding: 24px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--muted);
    text-align: center;
}

.empty-state strong,
.loading-state strong,
.error-state strong {
    color: var(--primary);
    font-size: 18px;
}

.skeleton {
    position: relative;
    overflow: hidden;
    min-height: 18px;
    border-radius: var(--radius-sm);
    background: #EDF1F7;
}

.skeleton-short {
    width: 72px;
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent);
    animation: skeleton-wave 1.2s infinite;
}

.tooltip {
    position: relative;
}

.tooltip:hover::after,
.tooltip:focus-visible::after {
    content: attr(aria-label);
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    z-index: 70;
    max-width: 220px;
    padding: 7px 9px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.pagination a,
.pagination span {
    min-width: 40px;
    min-height: 40px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--secondary);
    font-weight: 850;
}

.pagination .current {
    background: var(--primary);
    color: #fff;
}

@keyframes skeleton-wave {
    to {
        transform: translateX(100%);
    }
}

/* Dashboard Tabs */
.dashboard-tabs {
    display: flex;
    gap: 8px;
    margin: 8px 0 16px;
    overflow-x: auto;
    scrollbar-width: thin;
    padding-bottom: 4px;
}

.dashboard-tab {
    min-height: 44px;
    min-width: 120px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--secondary);
    font-weight: 850;
    font-size: 14px;
    transition: all .18s ease;
    flex-shrink: 0;
}

.dashboard-tab:hover {
    border-color: rgba(17, 27, 58, .24);
    background: var(--surface-soft);
    color: var(--primary);
}

.dashboard-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(17, 27, 58, .16);
}

.dashboard-panel {
    display: none;
}

.dashboard-panel.active {
    display: block;
    animation: fade-up .18s ease;
}

/* Running Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 95;
    display: grid;
    place-items: center;
    padding: 18px;
    pointer-events: none;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    animation: fade-in .18s ease;
}

.modal-dialog {
    position: relative;
    z-index: 1;
    width: min(520px, 92vw);
    max-height: 90vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    animation: modal-in .22s ease;
    overflow: hidden;
    pointer-events: auto;
}

.modal-lg {
    width: min(600px, 94vw);
}

.modal-content {
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-soft);
}

.modal-header h2 {
    margin: 0;
    color: var(--primary);
    font-size: 18px;
}

.modal-close {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--secondary);
    transition: all .18s ease;
}

.modal-close:hover {
    background: var(--surface-soft);
    border-color: rgba(17, 27, 58, .24);
}

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    max-height: 65vh;
}

.modal-subheader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.modal-subheader h3 {
    margin: 0;
    color: var(--primary);
    font-size: 16px;
    font-weight: 800;
}

.modal-back {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--secondary);
    transition: all .18s ease;
}

.modal-back .ui-icon {
    transform: rotate(180deg);
}

.modal-back:hover {
    background: var(--surface-soft);
    border-color: rgba(17, 27, 58, .24);
}

/* Running Header List */
.running-header-list {
    display: grid;
    gap: 10px;
}

.running-header-item {
    width: 100%;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-weight: 750;
    text-align: left;
    transition: all .18s ease;
}

.running-header-item:hover {
    border-color: var(--primary);
    background: var(--surface-soft);
    transform: translateX(2px);
}

.running-header-name {
    color: var(--primary);
    font-size: 15px;
}

.running-header-count {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

/* Running Game List */
.running-game-list {
    display: grid;
    gap: 8px;
}

.running-game-item {
    width: 100%;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    text-align: left;
    transition: all .18s ease;
}

.running-game-item:hover {
    border-color: var(--accent);
    background: rgba(226, 29, 61, .04);
    transform: translateX(2px);
}

.running-game-name {
    color: var(--primary);
    font-size: 15px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Game Status Badge */
.game-status-badge {
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
}

.game-status-badge.running {
    background: rgba(25, 185, 120, .12);
    color: #0B7A4F;
}

.game-status-badge.bet-closed {
    background: rgba(226, 29, 61, .12);
    color: #B01731;
}

.game-status-badge.result-published {
    background: rgba(25, 185, 120, .14);
    color: #0B7A4F;
}

.game-status-badge.scheduled {
    background: rgba(17, 27, 58, .10);
    color: var(--secondary);
}

.game-status-badge.result-pending {
    background: rgba(245, 184, 46, .18);
    color: #8B5D00;
}

.game-status-badge.completed {
    background: rgba(17, 27, 58, .10);
    color: var(--secondary);
}

/* Running Stats Grid */
.running-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.running-stats-grid .stat {
    min-height: 110px;
    padding: 16px;
}

.running-stats-grid .stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
}

.running-stats-grid .stat span:not(.stat-icon) {
    font-size: 11px;
}

.running-stats-grid .stat strong {
    font-size: 24px;
}

/* Mobile Responsive */
@media (max-width: 575px) {
    .dashboard-tabs {
        gap: 6px;
        padding-bottom: 6px;
    }

    .dashboard-tab {
        min-width: 100px;
        padding: 10px 12px;
        font-size: 13px;
    }

    .modal-dialog {
        width: 96vw;
        max-height: 95vh;
    }

    .modal-lg {
        width: 98vw;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-body {
        padding: 14px 16px;
        max-height: 70vh;
    }

    .running-header-item,
    .running-game-item {
        min-height: 52px;
        padding: 10px 14px;
    }

    .running-header-name,
    .running-game-name {
        font-size: 14px;
    }

    .running-stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .running-stats-grid .stat {
        min-height: 100px;
        padding: 14px;
    }

    .running-stats-grid .stat strong {
        font-size: 22px;
    }
}

@media (min-width: 576px) and (max-width: 991px) {
    .running-stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
