.competition-card,
.featured-card {
    position: relative;
    cursor: pointer;
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.competition-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.competition-card .card-image {
    height: 236px;
    min-height: 236px;
}

.competition-card .card-body {
    min-height: 450px;
    display: flex;
    flex: 1;
    flex-direction: column;
}

.competition-card .card-body .open-entry {
    margin-top: auto;
}

.competition-card:hover,
.competition-card:focus-visible,
.featured-card:hover,
.featured-card:focus-visible {
    transform: translateY(-4px);
    border-color: rgba(255, 90, 31, .5);
    box-shadow: 0 24px 58px rgba(18, 23, 31, .16), 0 0 0 4px rgba(255, 90, 31, .07);
    outline: none;
}

.competition-quick-view {
    display: none !important;
}

.competition-heading-actions {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 1rem;
}

.competition-heading-actions p {
    max-width: 420px;
    margin: 0;
}

#viewAllCompetitions {
    flex: 0 0 auto;
    border: 1px solid var(--line, #e5e7eb);
    background: var(--white, #fff);
    color: var(--ink, #15181d);
}

.competitions-page-link {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    border: 1px solid var(--line, #e5e7eb);
    background: var(--white, #fff);
    color: var(--ink, #15181d);
    text-decoration: none;
    box-shadow: 0 14px 34px rgba(16, 22, 31, .08);
}

/* Keep this CTA readable even when the page's generic button rules load later. */
a.button.competitions-page-link,
a.button.competitions-page-link:visited {
    border-color: #d9dee6 !important;
    background: #ffffff !important;
    color: #15181d !important;
}

html[data-theme="dark"] a.button.competitions-page-link,
html[data-theme="dark"] a.button.competitions-page-link:visited {
    border-color: #303947 !important;
    background: #151b24 !important;
    color: #f4f7fb !important;
}

.competitions-page-link span {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff5a1f, #ff3d77);
    color: #fff;
}

.competition-carousel {
    margin-top: 2.5rem;
    padding: clamp(1.1rem, 3vw, 1.8rem);
    border: 1px solid var(--line, #e5e7eb);
    border-radius: 28px;
    background: var(--paper, #f5f3ef);
    overflow: hidden;
}

.competition-carousel[hidden] {
    display: none;
}

.competition-carousel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.competition-carousel-heading h3 {
    margin: .3rem 0 0;
    font-size: clamp(1.4rem, 3vw, 2rem);
}

.competition-carousel-controls {
    display: flex;
    gap: .55rem;
}

.competition-carousel-controls button {
    width: 46px;
    height: 46px;
    border: 1px solid var(--line, #e5e7eb);
    border-radius: 50%;
    background: var(--white, #fff);
    color: var(--ink, #15181d);
    font-size: 1.2rem;
    font-weight: 900;
    cursor: pointer;
}

.competition-carousel-controls button:disabled {
    cursor: not-allowed;
    opacity: .38;
}

.competition-carousel-viewport {
    overflow: hidden;
}

.competition-carousel-track {
    display: flex;
    gap: 1rem;
    overflow: visible;
    padding: .25rem .15rem 1rem;
    scroll-snap-type: none;
    scroll-behavior: auto;
    will-change: transform;
}

.competition-carousel-track .competition-card {
    /* Keep the row wider than its viewport so it visibly rotates on desktop. */
    flex: 0 0 min(420px, calc(100vw - 74px));
    scroll-snap-align: start;
}

#competitionGrid.view-all-competitions {
    grid-template-columns: repeat(auto-fit, minmax(min(290px, 100%), 1fr));
}

html[data-theme="dark"] .competition-carousel,
html[data-theme="dark"] #viewAllCompetitions,
html[data-theme="dark"] .competition-carousel-controls button {
    background: #151b24;
    color: #f6f7fb;
    border-color: #303b4b;
}

.competition-detail-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(8, 11, 16, .74);
    backdrop-filter: blur(12px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s ease, visibility .18s ease;
}

.competition-detail-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.competition-detail-modal {
    position: relative;
    width: min(940px, 100%);
    max-height: min(760px, 92vh);
    display: grid;
    grid-template-columns: minmax(280px, .9fr) minmax(330px, 1.1fr);
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 30px;
    background: var(--white, #fff);
    color: var(--ink, #15181d);
    box-shadow: 0 34px 100px rgba(0, 0, 0, .4);
    transform: translateY(12px) scale(.985);
    transition: transform .2s ease;
}

.competition-detail-backdrop.open .competition-detail-modal {
    transform: none;
}

.competition-detail-close {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 3;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, .32);
    border-radius: 50%;
    background: rgba(11, 13, 16, .76);
    color: #fff;
    font-size: 1.45rem;
    cursor: pointer;
}

.competition-detail-image {
    position: relative;
    min-height: 520px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: linear-gradient(145deg, #2b1d20, #12161c);
    background-position: center;
    background-size: cover;
}

.competition-detail-image::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(8, 11, 16, .36), transparent 48%);
    pointer-events: none;
}

.competition-detail-image > span:not(.competition-gallery-counter) {
    width: 78px;
    height: 78px;
    z-index: 1;
    display: grid;
    place-items: center;
    border-radius: 24px;
    background: linear-gradient(135deg, #ff5a1f, #ff3868);
    color: #fff;
    font-weight: 950;
}

.competition-detail-image.has-image > span:not(.competition-gallery-counter) {
    display: none;
}

.competition-detail-image {
    touch-action: pan-y;
    user-select: none;
}

.competition-gallery-badge {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 6;
    padding: .43rem .68rem;
    border: 1px solid rgba(255, 255, 255, .4);
    border-radius: 999px;
    background: rgba(11, 13, 16, .8);
    color: #fff;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .2);
    backdrop-filter: blur(10px);
    font-size: .67rem;
    font-weight: 900;
    pointer-events: none;
}

.featured-card > .competition-gallery-badge {
    top: 18px;
    left: 18px;
}

.competition-gallery-nav {
    position: absolute;
    top: 50%;
    z-index: 4;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    transform: translateY(-50%);
    border: 1px solid rgba(255, 255, 255, .42);
    border-radius: 50%;
    background: rgba(10, 14, 20, .78);
    color: #fff;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .25);
    backdrop-filter: blur(10px);
    font: inherit;
    font-size: 1.2rem;
    font-weight: 950;
    cursor: pointer;
}

.competition-gallery-previous {
    left: 16px;
}

.competition-gallery-next {
    right: 16px;
}

.competition-gallery-counter {
    position: absolute;
    bottom: 18px;
    left: 50%;
    z-index: 4;
    width: auto;
    height: auto;
    display: inline-flex;
    transform: translateX(-50%);
    padding: .42rem .72rem;
    border: 1px solid rgba(255, 255, 255, .38);
    border-radius: 999px;
    background: rgba(10, 14, 20, .78);
    color: #fff;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .22);
    backdrop-filter: blur(10px);
    font-size: .72rem;
    font-weight: 900;
}

.competition-gallery-nav[hidden],
.competition-gallery-counter[hidden] {
    display: none !important;
}

.competition-detail-content {
    display: flex;
    flex-direction: column;
    padding: clamp(32px, 5vw, 58px);
}

.competition-detail-content h2 {
    margin: .55rem 0 1rem;
    padding-right: 2.5rem;
    font-size: clamp(2rem, 4vw, 3.35rem);
    line-height: .98;
    letter-spacing: -.055em;
}

.competition-detail-content > p {
    margin: 0 0 1.5rem;
    color: var(--muted, #747c87);
    font-size: 1rem;
    line-height: 1.7;
}

.competition-detail-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 1rem;
}

.competition-detail-stats > div {
    min-width: 0;
    display: grid;
    gap: .32rem;
    padding: 1rem;
    border: 1px solid var(--line, #e5e7eb);
    border-radius: 16px;
    background: var(--paper, #f5f3ef);
}

.competition-detail-stats span {
    color: var(--muted, #747c87);
    font-size: .7rem;
    font-weight: 800;
}

.competition-detail-stats strong {
    overflow-wrap: anywhere;
    font-size: .88rem;
}

.competition-detail-route {
    margin-bottom: 1.35rem;
    padding: 1rem 1.1rem;
    border: 1px solid rgba(255, 90, 31, .24);
    border-radius: 16px;
    background: rgba(255, 90, 31, .08);
    color: var(--ink, #15181d);
    line-height: 1.55;
}

html[data-theme="dark"] .competition-detail-modal {
    --white: #151b24;
    --paper: #1c2430;
    --ink: #f6f7fb;
    --muted: #aeb7c5;
    --line: #303b4b;
}

.competition-detail-prizes {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.competition-detail-prize,
.competition-detail-cash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 15px;
    border: 1px solid var(--line, #e5e7eb);
    border-radius: 15px;
    background: var(--paper, #f5f3ef);
    color: var(--ink, #15181d);
}

.competition-detail-cash {
    border-color: rgba(255, 90, 31, .45);
}

.competition-detail-prize strong,
.competition-detail-cash strong {
    color: var(--accent, #ff5a1f);
    white-space: nowrap;
}

html[data-theme="dark"] .competition-detail-prize,
html[data-theme="dark"] .competition-detail-cash {
    background: #151b24;
    border-color: #303b4b;
    color: #f6f7fb;
}

@media (max-width: 760px) {
    .competition-detail-backdrop {
        padding: 10px;
    }

    .competition-detail-modal {
        grid-template-columns: 1fr;
        border-radius: 24px;
    }

    .competition-detail-image {
        min-height: 240px;
    }

    .competition-gallery-nav {
        width: 42px;
        height: 42px;
    }

    .competition-detail-content {
        padding: 28px 22px;
    }

    .competition-detail-stats {
        grid-template-columns: 1fr 1fr;
    }
}

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

@media (prefers-reduced-motion: reduce) {
    .competition-card,
    .featured-card,
    .competition-detail-modal {
        transition: none;
    }
}

@media (max-width: 760px) {
    .competition-heading-actions {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }

    #viewAllCompetitions {
        width: 100%;
    }

    .competition-carousel-heading {
        align-items: flex-start;
    }

    .competition-card .card-image {
        height: 220px;
        min-height: 220px;
    }

    .competition-card .card-body {
        min-height: 0;
    }
}
