:root {
    --app-bg: #f7f8fb;
    --app-surface: #ffffff;
    --app-surface-subtle: #f8fafc;
    --app-text: #212529;
    --app-muted: #6c757d;
    --app-border: #edf0f4;
    --app-border-strong: #cfd6df;
}

[data-theme="dark"] {
    --app-bg: #101419;
    --app-surface: #171d24;
    --app-surface-subtle: #202833;
    --app-text: #edf2f7;
    --app-muted: #a8b3c0;
    --app-border: #2b3542;
    --app-border-strong: #435266;
    color-scheme: dark;
}

body {
    background: var(--app-bg);
    color: var(--app-text);
}

.app-shell {
    max-width: 720px;
}

.match-card {
    border: 0;
    border-radius: 8px;
}

.score-input {
    max-width: 84px;
    text-align: center;
}

.nav-pills .nav-link {
    border-radius: 999px;
}

.nav-superuser-only.d-none,
.nav-hide-superuser.d-none {
    display: none !important;
}

.brand-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex: 0 0 auto;
}

.logout-form {
    flex: 0 0 auto;
}

.theme-toggle {
    min-width: 42px;
}

.theme-icon {
    display: inline-block;
    width: 1.1rem;
    text-align: center;
}

.theme-actions {
    flex: 0 0 auto;
}

.name-heading-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.name-heading-row h1 {
    min-width: 0;
    overflow-wrap: anywhere;
}

.card,
.bg-white,
.table-responsive.bg-white {
    background-color: var(--app-surface) !important;
    color: var(--app-text);
}

.text-secondary {
    color: var(--app-muted) !important;
}

.border-top {
    border-top-color: var(--app-border) !important;
}

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--app-text);
    --bs-table-border-color: var(--app-border);
}

.form-control {
    background-color: var(--app-surface);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

.form-control:focus {
    background-color: var(--app-surface);
    color: var(--app-text);
}

.form-control::placeholder {
    color: var(--app-muted);
}

[data-theme="dark"] .btn-outline-secondary {
    --bs-btn-color: var(--app-muted);
    --bs-btn-border-color: var(--app-border-strong);
    --bs-btn-hover-bg: var(--app-surface-subtle);
    --bs-btn-hover-border-color: var(--app-muted);
}

.login-password-panel summary {
    list-style: none;
}

.login-password-panel summary::-webkit-details-marker {
    display: none;
}

.rules-panel summary {
    cursor: pointer;
}

.rules-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--result-color) 18%, var(--app-surface));
    border: 1px solid color-mix(in srgb, var(--result-color) 45%, var(--app-surface));
}

.rules-row .result-points-number {
    min-width: 42px;
    text-align: center;
}

.loading-state {
    display: flex;
    min-height: 96px;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #6c757d;
    font-weight: 600;
}

.loading-dots {
    display: inline-flex;
    gap: 5px;
    align-items: center;
}

.loading-dots span {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: currentColor;
    animation: loading-dot 0.9s infinite ease-in-out;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

.standings-row {
    cursor: pointer;
}

.standings-row:hover {
    background: var(--app-surface-subtle);
}

.standings-row:focus {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
}

.standings-row-current {
    cursor: default;
}

.standings-row-current:hover {
    background: transparent;
}

.standings-row-current:focus {
    outline: 0;
}

.compare-score {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    text-align: center;
}

.compare-predictions,
.compare-points {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
}

.compare-panel {
    min-width: 0;
    padding: 10px;
    border-radius: 8px;
    background: var(--app-surface-subtle);
}

.compare-panel-value {
    font-size: 1.2rem;
    font-weight: 700;
}

@keyframes loading-dot {
    0%,
    80%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }

    40% {
        opacity: 1;
        transform: translateY(-5px);
    }
}

.prediction-widget {
    border: 0;
    border-radius: 8px;
}

.team-crest {
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.desktop-match-grid {
    display: none !important;
}

.mobile-match-grid {
    display: grid !important;
    position: relative;
}

.mobile-team-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px 72px;
    gap: 10px;
    align-items: center;
}

.mobile-team-row .team-crest {
    width: 40px;
    height: 40px;
}

.team-name {
    min-width: 0;
}

.actual-score {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.prediction-value {
    min-width: 42px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.result-card {
    border-left: 6px solid var(--result-color);
}

.result-card-perfect,
.result-points-perfect {
    --result-color: #198754;
}

.result-card-strong,
.result-points-strong {
    --result-color: #84cc16;
}

.result-card-correct,
.result-points-correct {
    --result-color: #f59e0b;
}

.result-card-partial,
.result-points-partial {
    --result-color: #fde68a;
}

.result-card-miss,
.result-points-miss {
    --result-color: #adb5bd;
}

.result-points {
    min-width: 86px;
    padding: 8px 10px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--result-color) 18%, var(--app-surface));
    color: var(--app-text);
    text-align: center;
    border: 1px solid color-mix(in srgb, var(--result-color) 45%, var(--app-surface));
}

.result-points-number {
    display: block;
    font-size: 1.35rem;
    line-height: 1;
    font-weight: 700;
}

.result-points-number::after {
    content: " pts";
    font-size: 0.75rem;
    font-weight: 600;
}

.result-points-label {
    display: block;
    margin-top: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}

.result-summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.result-main {
    min-width: 0;
}

.result-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 82px minmax(0, 1fr);
    gap: 6px;
    align-items: center;
    width: 100%;
}

.result-team {
    min-width: 0;
    overflow-wrap: anywhere;
}

.result-team:last-child {
    text-align: right;
}

.result-score {
    padding: 3px 8px;
    border-radius: 8px;
    background: var(--app-surface-subtle);
    font-size: 1.15rem;
    font-weight: 800;
    text-align: center;
    white-space: nowrap;
}

.result-summary .result-points {
    grid-column: 1 / -1;
    justify-self: end;
}

.other-prediction-points {
    display: inline-block;
    min-width: 64px;
    padding: 5px 7px;
}

.other-prediction-points .result-points-number {
    font-size: 1rem;
}

.other-prediction-points .result-points-label {
    font-size: 0.65rem;
}

.group-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    overflow: visible;
}

.group-buttons .btn {
    min-width: 42px;
    flex: 1 0 42px;
    max-width: 56px;
}

.group-widget {
    overflow: hidden;
    touch-action: pan-y;
}

.group-swipe-panel {
    transform: translateX(var(--group-swipe-x, 0));
    transition: transform 180ms ease, opacity 180ms ease;
    will-change: transform;
}

.group-widget.is-dragging .group-swipe-panel {
    transition: none;
}

.group-widget.swipe-out-left .group-swipe-panel {
    transform: translateX(-22%);
    opacity: 0.55;
}

.group-widget.swipe-out-right .group-swipe-panel {
    transform: translateX(22%);
    opacity: 0.55;
}

.group-widget.swipe-in-left .group-swipe-panel {
    animation: group-swipe-in-left 180ms ease both;
}

.group-widget.swipe-in-right .group-swipe-panel {
    animation: group-swipe-in-right 180ms ease both;
}

@keyframes group-swipe-in-left {
    from {
        opacity: 0.55;
        transform: translateX(-22%);
    }

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

@keyframes group-swipe-in-right {
    from {
        opacity: 0.55;
        transform: translateX(22%);
    }

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

.group-table th,
.group-table td {
    white-space: nowrap;
}

.group-flag {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex: 0 0 auto;
}

.group-match {
    padding: 12px;
    border-top: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-surface-subtle);
}

.group-match:first-child {
    border-top: 0;
}

.group-match-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px 12px;
    align-items: center;
}

.group-match-team {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 0;
    font-weight: 600;
    align-self: stretch;
}

.group-match-main .group-match-team:first-child {
    grid-column: 1;
    grid-row: 2;
}

.group-match-main .group-match-team:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
}

.group-match-team span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.group-match-center {
    grid-column: 1 / -1;
    grid-row: 1;
    text-align: center;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--app-border);
}

.group-match-stadium {
    grid-column: 1 / -1;
    text-align: center;
}

.group-prediction-row {
    display: grid;
    grid-template-columns: 52px auto 52px minmax(76px, 1fr);
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}

.group-prediction-label {
    grid-column: 1 / -1;
    text-align: center;
}

.group-prediction-row .score-input {
    max-width: none;
}

.group-result-points {
    grid-column: 1 / 3;
    min-width: 70px;
    padding: 5px 7px;
}

.group-prediction-row .js-action {
    grid-column: 3 / 5;
}

.group-result-points .result-points-number {
    font-size: 1rem;
}

.group-result-points .result-points-label {
    font-size: 0.65rem;
}

.playoff-match {
    padding: 10px 0;
    border-top: 1px solid var(--app-border);
}

.playoff-match:first-child {
    border-top: 0;
}

.playoff-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 10px;
    overflow-x: auto;
}

.playoff-round {
    min-height: 88px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border: 1px dashed var(--app-border-strong);
    border-radius: 8px;
    background: var(--app-surface-subtle);
    font-weight: 700;
    text-align: center;
}

.mobile-result-points {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 72px;
    padding: 6px 8px;
}

.mobile-result-points .result-points-number {
    font-size: 1.1rem;
}

.mobile-result-points .result-points-label {
    font-size: 0.68rem;
}

.mobile-match-grid .small.text-secondary.text-center {
    padding-right: 86px;
}

@media (min-width: 768px) {
    .mobile-match-grid {
        display: none !important;
    }

    .desktop-match-grid {
        display: grid !important;
        grid-template-columns: minmax(110px, 1fr) minmax(110px, 1fr) minmax(180px, 1.2fr) minmax(110px, 1fr) minmax(110px, 1fr);
        gap: 14px;
        align-items: center;
    }

    .prediction-widget {
        min-height: calc(100vh - 128px);
    }

    .team-crest {
        width: 72px;
        height: 72px;
    }

    .group-match {
        padding: 10px 0;
        border-radius: 0;
        background: transparent;
    }

    .group-match-main {
        grid-template-columns: minmax(0, 1fr) 70px minmax(0, 1fr);
    }

    .group-match-center {
        grid-column: auto;
        grid-row: auto;
        padding-bottom: 0;
        border-bottom: 0;
    }

    .group-match-main .group-match-team:first-child,
    .group-match-main .group-match-team:nth-child(3) {
        grid-column: auto;
        grid-row: auto;
    }

    .group-prediction-row {
        display: flex;
        justify-content: center;
    }

    .group-prediction-label {
        grid-column: auto;
        text-align: inherit;
    }

    .group-prediction-row .score-input {
        max-width: 68px;
    }

    .group-result-points,
    .group-prediction-row .js-action {
        grid-column: auto;
    }
}
