:root {
    --bg: #0b0d12;
    --panel: #121720;
    --panel-soft: #171d28;
    --border: #252d3b;
    --text: #f3f5f8;
    --muted: #97a3b6;
    --primary: #6ea8fe;
    --success: #5acb8a;
    --danger: #ff7d7d;
    --radius: 16px;
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: Inter, Segoe UI, Roboto, system-ui, sans-serif;
}

body {
    background: radial-gradient(circle at 20% 0%, #131824 0%, #0b0d12 45%, #090b0f 100%);
    color: var(--text);
    min-height: 100vh;
    padding: 24px;
}

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

.blitz-header,
.stat-card,
.table-wrap,
.modal-content,
.password-content {
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.quick-nav {
    position: sticky;
    top: 10px;
    z-index: 120;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(18, 23, 32, 0.86), rgba(18, 23, 32, 0.68));
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
    margin-bottom: 18px;
}

.quick-nav-account {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.quick-nav-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: 0.2s ease;
}

.quick-nav-btn:hover {
    border-color: #3a4b67;
    color: var(--text);
    background: rgba(110, 168, 254, 0.08);
}

.blitz-header {
    padding: 18px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.blitz-header h1 {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo h1 {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo span {
    display: inline-flex;
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--muted);
    border: 1px solid var(--border);
    font-size: 0.82rem;
}

.subtitle {
    display: inline-flex;
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--muted);
    border: 1px solid var(--border);
    font-size: 0.82rem;
}

.user-panel {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.results-top-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.results-search-input {
    min-width: 320px;
    max-width: 460px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    color: var(--text);
    padding: 10px 12px;
    outline: none;
}

.results-search-input::placeholder {
    color: var(--muted);
}

/* Hide the global "Delete All" button to avoid redundancy with Delete selected */
#clearAllBtn {
    display: none !important;
}

/* Hide admin-only selection controls by default to avoid flicker
   JS will reveal these when permissions & results are known. */
#resultsSelectGroupWrap,
#resultsSelectAllTopWrap,
#resultsDeleteSelectedBtn,
#resultsSelectHeaderCol,
#selectAllToggle {
    display: none;
}

.global-handle-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 12px;
    background: transparent;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

html:not([data-auth-chip-ready="1"]) .global-handle-chip[data-global-handle-chip] {
    visibility: hidden;
}

.global-handle-chip.not-verified {
    display: inline-block;
    background: linear-gradient(180deg,#60a5fa,#3b82f6);
    color: #071325;
    border-color: rgba(59,130,246,0.28);
    font-weight: 700;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13.3333px;
    line-height: normal;
    transition: transform 140ms ease, box-shadow 140ms ease;
}

.global-handle-chip.not-verified:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(59,130,246,0.12); }

/* Results page: use feedback-like primary styling for result action buttons */
.results-btn {
    background: linear-gradient(180deg,#3b82f6,#2563eb);
    color: #ffffff;
    border-color: rgba(59,130,246,0.18);
    box-shadow: 0 10px 24px rgba(59,130,246,0.12);
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 700;
    transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}
.results-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(59,130,246,0.16); }

.global-handle-avatar {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid var(--border);
    object-fit: cover;
}

.back-btn,
.clear-btn,
.details-btn,
.close-btn,
.password-btn {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: 0.2s ease;
}

/* Small destructive button shown next to View in results rows */
.delete-btn {
    border: 1px solid var(--danger);
    border-radius: 8px;
    padding: 6px 8px;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(180deg, #ff9a9a, #ff7d7d);
    color: #250706;
    margin-left: 8px;
    box-shadow: 0 6px 12px rgba(255,125,125,0.12);
    transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease, visibility 0.12s ease;
    /* hidden by default; reveal on row hover to reduce visual clutter */
    opacity: 0;
    visibility: hidden;
}

.results-table tr:hover .delete-btn,
.results-table tr:focus-within .delete-btn {
    opacity: 1;
    visibility: visible;
}

.delete-btn:hover {
    transform: translateY(-1px);
    border-color: #ff6b6b;
    box-shadow: 0 10px 18px rgba(255,109,109,0.16);
}

.delete-btn:active {
    transform: translateY(0);
}

.back-btn,
.details-btn {
    background: linear-gradient(180deg, #79afff, #5a94ef);
    color: #081223;
    border-color: #6ea8fe;
}

.clear-btn,
.confirm-btn {
    background: linear-gradient(180deg, #ff9a9a, #ff7d7d);
    color: #250706;
    border-color: #ff7d7d;
}

.cancel-btn,
.close-btn {
    background: var(--panel-soft);
    color: var(--text);
    border: 1px solid var(--border);
}

.back-btn:hover,
.clear-btn:hover,
.details-btn:hover,
.close-btn:hover,
.password-btn:hover {
    transform: translateY(-1px);
    border-color: #3b4660;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}

.stat-card {
    padding: 14px;
}

.stat-card h3 {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.78rem;
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 800;
    margin-top: 8px;
}

.table-wrap {
    overflow: auto;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

.results-table th {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.76rem;
    color: var(--muted);
    padding: 10px;
    background: #151d2b;
    text-align: left;
}

.results-table td {
    padding: 12px 10px;
    border-top: 1px solid var(--border);
    background: #121925;
}

.results-table tr:hover td {
    background: #162237;
}

.results-table tr.focused-result-row td {
    background: #1e2d46;
    box-shadow: inset 0 0 0 1px #6ea8fe;
}

/* Select checkbox column: hidden by default, visible on row hover or when any row is checked */
.results-table .select-col,
.results-table .select-col-cell {
    width: 42px;
    text-align: center;
}

.results-table .row-select {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease, visibility 0.12s ease;
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.results-table tr:hover .row-select,
.results-table.show-all-checks .row-select {
    opacity: 1;
    visibility: visible;
}

.player-link,
.problem-link {
    color: #9dc4ff;
    text-decoration: none;
    font-weight: 700;
}

.player-link:hover,
.problem-link:hover {
    text-decoration: underline;
}

.winner {
    color: var(--success);
    font-weight: 700;
}

/* Chip style for winner handle in results table */
.winner-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 6px 12px;
    min-height: 32px;
    font-weight: 700;
    font-size: 0.82rem;
    line-height: 1;
    border: 1px solid var(--border);
    background: rgba(90,203,138,0.06);
    text-decoration: none;
}

.winner-chip:hover {
    transform: translateY(-1px);
    border-color: rgba(90,203,138,0.28);
}

/* Ensure winner links rendered as chips use white text instead of green */
.global-handle-chip.winner,
.winner-chip.winner {
    color: var(--text) !important;
    background: transparent;
    border-color: var(--border);
}

/* Tiny tie chip for TIE outcomes */
.tie-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 6px 12px;
    min-height: 32px;
    font-weight: 700;
    font-size: 0.82rem;
    line-height: 1;
    border: 1px solid var(--border);
    background: rgba(255, 196, 88, 0.10);
    color: #ffd98b;
}

.tie-chip:hover {
    transform: translateY(-1px);
    border-color: rgba(255,196,88,0.3);
}

.standing-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    border-radius: 999px;
    padding: 3px 10px;
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.standing-p1 {
    color: #7fd8ff;
    background: rgba(88, 178, 255, 0.16);
    border-color: rgba(88, 178, 255, 0.35);
}

.standing-p2 {
    color: #73d7a3;
    background: rgba(70, 211, 140, 0.1);
    border-color: rgba(70, 211, 140, 0.24);
}

.standing-tie {
    color: #ffd98b;
    background: rgba(255, 196, 88, 0.14);
    border-color: rgba(255, 196, 88, 0.32);
}

.standing-none {
    color: var(--muted);
    background: rgba(255, 255, 255, 0.03);
}

.no-data {
    text-align: center;
    color: var(--muted);
    padding: 32px;
}

.timestamp {
    color: var(--muted);
    font-size: 0.82rem;
}

.modal,
.password-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 10, 0.9);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.modal-content,
.password-content {
    width: min(760px, 100%);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 18px;
    background: #101724;
    border: 1px solid #2b364a;
}

.modal-content h2,
.password-content h2 {
    margin-bottom: 8px;
}

.modal-subtitle {
    margin: 14px 0 8px;
    font-size: 1rem;
}

.result-standings-wrap {
    margin-top: 8px;
    overflow: auto;
}

/* Standings table styles moved to css/standings-shared.css */

.result-total-score {
    color: #ffd966;
}

.problem-detail {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: #131b29;
    margin: 10px 0;
}

.user-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.user-stats-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    padding: 8px 10px;
}

.user-stats-item span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    margin-bottom: 4px;
}

.stats-user-link {
    color: #9dc4ff;
    text-decoration: none;
    font-weight: 600;
}

.stats-user-link:hover {
    text-decoration: underline;
}

.problem-detail-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
    color: var(--muted);
}

.problem-players {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
}

.problem-player-handle {
    margin-left: 4px;
}

.result-problem-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    margin-left: 8px;
    padding: 4px 8px;
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 700;
    vertical-align: middle;
}

.result-problem-status-main {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1;
}

.result-problem-status-time {
    margin-left: 6px;
    font-size: 0.68rem;
    color: var(--muted);
    font-weight: 600;
}

.result-problem-status.status-ac {
    color: #1c3a2d;
    background: linear-gradient(180deg, #c7f7da 0%, #b0f0ca 100%);
}

.result-problem-status.status-wa {
    color: #4b1318;
    background: linear-gradient(180deg, #ffd2d6 0%, #ffbcc3 100%);
}

.result-problem-status.status-pending {
    color: #4a3404;
    background: linear-gradient(180deg, #ffeebf 0%, #ffe39a 100%);
}

.result-problem-status.status-none {
    color: var(--muted);
    background: rgba(255, 255, 255, 0.04);
}

.result-problem-loader {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    border: 2px solid rgba(74, 52, 4, 0.25);
    border-top-color: #7d5a07;
    animation: resultPendingSpin 0.85s linear infinite;
}

/* keyframes moved to css/standings-shared.css */

.muted-link {
    font-size: 0.88rem;
    color: var(--muted);
}

.password-input {
    margin-top: 10px;
    width: 100%;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
}

.password-input:focus {
    border-color: var(--primary);
}

.password-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}

.close-btn {
    margin-top: 12px;
}

.site-footer {
    margin: 16px auto 0;
    max-width: 1100px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
    color: var(--muted);
    text-align: center;
    line-height: 1.5;
    font-size: 0.9rem;
}

.site-footer a {
    color: #9dc4ff;
    text-decoration: none;
    font-weight: 600;
}

.site-footer a:hover {
    text-decoration: underline;
}

.site-version {
    margin-top: 2px;
    font-size: 0.72rem;
    opacity: 0.78;
    letter-spacing: 0.03em;
}

/* Responsive tweaks for small screens: prevent action buttons from stretching full width */
@media (max-width: 480px) {
    .results-top-actions {
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }

    .results-top-actions .results-search-input {
        min-width: 120px;
        max-width: 100%;
        flex: 1 1 auto;
    }

    .results-top-actions .clear-btn,
    .results-top-actions .back-btn,
    .results-top-actions .details-btn {
        display: inline-block;
        width: auto !important;
        flex: 0 0 auto;
        max-width: 140px;
        white-space: nowrap;
        padding: 8px 10px;
        font-size: 0.92rem;
    }
}

/* keep select and delete side-by-side (applies whereever the group is placed) */
.select-delete-group {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    flex: 0 0 auto;
}
.select-delete-group #resultsSelectAllTopWrap {
    white-space: nowrap;
    font-size: 0.95rem;
}

/* narrower delete button inside the group */
.select-delete-group .clear-btn {
    max-width: 140px;
    padding: 8px 10px;
    font-size: 0.92rem;
}

@media (max-width: 980px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Pagination controls */
.results-pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

#resultsPaginationBottom {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.page-btn {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    padding: 6px 10px;
    border-radius: 6px;
    min-width: 36px;
    text-align: center;
    cursor: pointer;
    font-weight: 700;
}

.page-btn:hover {
    background: rgba(110,168,254,0.06);
    color: var(--text);
    border-color: #3a4b67;
}

.page-btn.active {
    background: #f3f5f8;
    color: #081223;
    border-color: #6ea8fe;
}

.page-ellipsis {
    color: var(--muted);
    padding: 6px 4px;
    min-width: 18px;
    text-align: center;
}

/* make prev/next visually smaller */
#resultsPrevBtn, #resultsNextBtn {
    padding: 6px 10px;
    border-radius: 6px;
}
#resultsNextBtn:hover, #resultsPrevBtn:hover {
    cursor: pointer;
}

@media (max-width: 760px) {
    body {
        padding: 14px;
    }

    .blitz-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .user-panel,
    .results-top-actions {
        justify-content: flex-start;
    }

    .results-top-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .results-search-input {
        min-width: 0;
        max-width: 100%;
    }

    .problem-players {
        grid-template-columns: 1fr;
    }

    .user-stats-grid {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .modal,
    .password-modal {
        padding: 10px;
        align-items: flex-start;
    }

    .modal-content,
    .password-content {
        width: 100%;
        max-height: calc(100vh - 20px);
        padding: 14px;
        border-radius: 12px;
    }

    .problem-detail-top {
        flex-direction: column;
        gap: 6px;
    }

    .close-btn,
    .password-buttons .password-btn {
        width: auto;
    }

    .password-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
    }
}

/* Spectator modal styles */
.spectator-list-modal-wrap {
    padding: 8px 0;
}
.spectator-list-modal {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}
.spectator-list-modal li {
    padding: 8px 10px;
    border-radius: 8px;
    background: #0f1620;
    border: 1px solid var(--border);
    color: var(--muted);
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 520px) {
    .spectator-list-modal {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* See-more link styling */
.spectator-see-more {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.03);
    color: var(--muted);
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
}
.spectator-see-more:hover {
    background: rgba(110,168,254,0.06);
    color: var(--primary);
    text-decoration: none;
}
.spectator-see-more:focus {
    outline: 2px solid rgba(110,168,254,0.14);
    outline-offset: 2px;
}
.spectator-see-more::after {
    content: '▾';
    font-size: 0.78rem;
    color: var(--muted);
}
