:root {
    /* Color Palette */
    --color-1: #cad2c5;
    --color-2: #84a98c;
    --color-3: #52796f;
    --color-4: #354f52;
    --color-5: #2f3e46;

    /* Semantic Mappings */
    --bg-color: var(--color-1);
    --card-bg: #ffffff;
    --primary-color: var(--color-5);
    --secondary-color: var(--color-3);
    --accent-color: var(--color-2);
    --text-color: var(--color-5);
    --text-light: var(--color-1);

    /* UI Defaults */
    --radius: 16px;
    --shadow-flat: 0 4px 6px rgba(0, 0, 0, 0.05);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    line-height: 1.5;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
    min-height: 100dvh;
}

header {
    background-color: var(--primary-color);
    color: var(--text-light);
    padding: 1.5rem 1rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.header-logo {
    height: 52px;
    width: auto;
    margin-bottom: 0.75rem;
    border-radius: 50%; /* Optional: matches the "rounded corners" feel for elements inside cards */
}

header h1 {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    font-size: 2.4rem;
    line-height: 1;
}

.organizer {
    margin: 0 0 0.4rem 0;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.8;
}

.hunt-date {
    display: block;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    color: var(--color-3);
    font-weight: 500;
}

#hunt-name {
    font-size: 1.85rem;
    margin: 0;
    color: var(--color-5);
    word-break: break-word;
    hyphens: auto;
    -webkit-hyphens: auto;
}

main {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
}

/* Page loader — first-paint splash that auto-dismisses */
#page-loader {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    animation: pageLoaderOut 0.7s 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.page-loader-logo {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 10px 30px rgba(47, 62, 70, 0.18);
    animation: pageLoaderPulse 1.4s ease-in-out infinite;
}

.page-loader-ring {
    position: absolute;
    width: 132px;
    height: 132px;
    animation: pageLoaderSpin 1.4s linear infinite;
}

.page-loader-ring circle {
    fill: none;
    stroke: var(--color-3);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 130 500;
}

@keyframes pageLoaderPulse {
    0%, 100% { transform: scale(1);    opacity: 0.92; }
    50%      { transform: scale(1.06); opacity: 1; }
}

@keyframes pageLoaderSpin {
    to { transform: rotate(360deg); }
}

@keyframes pageLoaderOut {
    from { opacity: 1; }
    to   { opacity: 0; visibility: hidden; pointer-events: none; }
}

@media (prefers-reduced-motion: reduce) {
    #page-loader { animation-delay: 0s; animation-duration: 0.2s; }
    .page-loader-logo,
    .page-loader-ring { animation: none; }
}

/* Phase gating — default hide everything phase-dependent until JS decides */
#countdown,
#countdown-pre,
#countdown-live,
#preview-badge,
main > #result-banner,
main > #gallery-stops,
main > #gallery-bts,
main > #thank-you,
main > #scroll-cue {
    display: none;
}

body[data-phase="pre"] #countdown,
body[data-phase="live"] #countdown { display: block; }

body[data-phase="pre"] #countdown-pre,
body[data-phase="live"] #countdown-live { display: block; }

body[data-phase="live"] .countdown-live-greeting {
    opacity: 0;
    animation: slideUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) 0.95s forwards;
}

body[data-phase="live"] .countdown-live-line {
    opacity: 0;
    animation: slideUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) 1.10s forwards;
}

body[data-phase="post"] #result-banner,
body[data-phase="post"] #gallery-stops,
body[data-phase="post"] #gallery-bts,
body[data-phase="post"] #thank-you,
body[data-phase="preview"] #result-banner,
body[data-phase="preview"] #gallery-stops,
body[data-phase="preview"] #gallery-bts,
body[data-phase="preview"] #thank-you { display: block; }

body[data-phase="post"] #scroll-cue,
body[data-phase="preview"] #scroll-cue { display: flex; }

body[data-preview="true"] #preview-badge { display: block; }

/* Countdown layout */
#countdown {
    text-align: center;
    padding: 3rem 0 5rem;
}

.countdown-clock {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin: 0 auto;
    max-width: 700px;
}

.countdown-live-greeting {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-3);
    letter-spacing: -0.02em;
    margin: 1.5rem 0 0.25rem;
}

.countdown-live-line {
    font-size: 2rem;
    font-weight: 600;
    color: var(--color-5);
    letter-spacing: -0.01em;
    margin: 0.25rem 0 1.5rem;
}

.countdown-unit {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    min-width: 6rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: var(--shadow-flat);
}

.countdown-unit [data-unit] {
    display: block;
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    color: var(--color-5);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.countdown-unit label {
    display: block;
    margin-top: 0.45rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--color-3);
    font-weight: 600;
}

.countdown-target {
    margin: 2.5rem 0 0;
    font-size: 0.95rem;
    color: var(--color-4);
}

.countdown-clock .countdown-unit {
    opacity: 0;
    animation: countdownUnitIn 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.countdown-clock .countdown-unit:nth-child(1) { animation-delay: 1.00s; }
.countdown-clock .countdown-unit:nth-child(2) { animation-delay: 1.15s; }
.countdown-clock .countdown-unit:nth-child(3) { animation-delay: 1.30s; }
.countdown-clock .countdown-unit:nth-child(4) { animation-delay: 1.45s; }

#countdown-pre .countdown-target {
    opacity: 0;
    animation: countdownUnitIn 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) 1.70s forwards;
}

@keyframes countdownUnitIn {
    from { opacity: 0; transform: translateY(24px) scale(0.94); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.countdown-unit [data-unit].flip {
    animation: countdownFlip 0.4s ease;
}

@keyframes countdownFlip {
    0%   { transform: translateY(0) scale(1);    opacity: 1; }
    40%  { transform: translateY(-6px) scale(1.06); opacity: 0.7; }
    100% { transform: translateY(0) scale(1);    opacity: 1; }
}

body[data-near-zero] .countdown-unit {
    animation: nearZeroPulse 1.8s ease-in-out infinite;
}

body[data-near-zero] .countdown-unit [data-unit] {
    color: var(--color-3);
}

@keyframes nearZeroPulse {
    0%, 100% { box-shadow: var(--shadow-flat); }
    50%      { box-shadow: 0 8px 24px rgba(82, 121, 111, 0.35), 0 0 0 2px var(--color-2); }
}

#countdown-live h2 { font-size: 2.5rem; }

/* Vorschau preview badge */
#preview-badge {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 3000;
    background: var(--color-5);
    color: var(--color-1);
    border: 1px solid var(--color-2);
    padding: 0.4rem 0.95rem;
    border-radius: 999px;
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

@media (max-width: 600px) {
    #countdown { padding: 1.5rem 0 3rem; }
    .countdown-live-greeting { font-size: 1.75rem; margin: 1rem 0 0.15rem; }
    .countdown-live-line { font-size: 1.4rem; margin: 0.15rem 0 1rem; }
    .countdown-clock { gap: 0.5rem; }
    .countdown-unit {
        padding: 0.85rem 0.4rem;
        min-width: 0;
        flex: 1 1 0;
    }
    .countdown-unit [data-unit] { font-size: 1.85rem; }
    .countdown-unit label { font-size: 0.65rem; letter-spacing: 0.12em; }
    .countdown-target { font-size: 0.85rem; margin-top: 1.75rem; }
    #preview-badge {
        top: 0.5rem;
        right: 0.5rem;
        font-size: 0.6rem;
        padding: 0.3rem 0.7rem;
    }
}

section {
    margin-bottom: 2.25rem;
}

section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.15rem;
    color: var(--color-4);
}

/* Result Banner - Flat Design */
#result-banner {
    background-color: var(--card-bg);
    padding: 1.75rem 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-flat);
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.winner-info {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    flex-wrap: nowrap; /* Keep side by side */
    margin-top: 1.15rem;
}

.winner-info p {
    background: var(--color-1);
    padding: 1rem 1.1rem;
    border-radius: var(--radius);
    margin: 0;
    font-weight: 500;
    flex: 1; /* Equal width */
    max-width: 400px;
}

#prize-type, #winner-name {
    color: var(--color-4);
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.gallery-item {
    position: relative;
    background-color: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-flat);
    transition: var(--transition);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.stop-badge {
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.45rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #2f3e46;
    color: #fff;
    font-size: 1.05rem;
    line-height: 1;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 0 0 1.5px rgba(255, 255, 255, 0.85);
}

.stop-badge--frage {
    background: #f1ead4;
    color: #2f3e46;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 0 0 1.5px rgba(47, 62, 70, 0.5);
}
.stop-badge--challenge_plus { background: #3f7a5e; }
.stop-badge--challenge_minus { background: #a04545; }
.stop-badge--schnaps { background: #6b8f72; }
.stop-badge--gruppenbild { background: #354f52; }

.stop-badge--challenge_plus,
.stop-badge--challenge_minus {
    font-weight: 800;
    letter-spacing: -0.02em;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.gallery-item img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
}

/* Lightbox */
#lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(47, 62, 70, 0.95);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
    transition: var(--transition);
    padding: 1rem;
    gap: 1rem;
    overflow-y: auto;
}

#lightbox.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.lightbox-content {
    max-width: 90%;
    max-height: 70vh;
    border-radius: var(--radius);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    object-fit: contain;
}

#caption {
    width: min(90%, 720px);
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

#caption:empty {
    display: none;
}

.caption-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.caption-icon {
    font-size: 2.75rem;
    line-height: 1;
    flex: 0 0 auto;
}

.caption-icon.is-challenge_plus,
.caption-icon.is-challenge_minus {
    font-weight: 800;
    letter-spacing: -0.04em;
}

.caption-title {
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-size: 0.85rem;
    color: var(--color-1);
}

.caption-question {
    margin: 0.25rem 0 0.75rem;
    font-size: 1.05rem;
}

.caption-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-light);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-size: 0.85rem;
    transition: var(--transition);
}

.caption-toggle:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: var(--color-2);
    color: var(--color-2);
}

.caption-reveal {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.caption-reveal.hidden {
    display: none;
}

.caption-answer,
.caption-fact,
.caption-source {
    margin: 0;
}

.caption-fact {
    color: var(--color-1);
    font-style: italic;
}

.caption-source a {
    color: var(--color-2);
    text-decoration: underline;
}

@media (max-width: 600px) {
    #lightbox { padding: 0.5rem; gap: 0.6rem; }
    .lightbox-content { max-height: 55vh; }
    #caption { padding: 1rem; font-size: 0.9rem; }
    .caption-icon { font-size: 2.25rem; }
    .caption-question { font-size: 1rem; }
}

.close,
.download {
    position: absolute;
    top: 2rem;
    width: 3rem;
    height: 3rem;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}

.close { right: 2rem; }
.download { right: 5.5rem; }

.close svg,
.download svg {
    width: 1.75rem;
    height: 1.75rem;
    fill: currentColor;
}

.close:hover {
    color: var(--color-2);
    transform: rotate(90deg);
}

.download:hover {
    color: var(--color-2);
    transform: translateY(3px);
}

@media (max-width: 600px) {
    .close,
    .download {
        top: 1rem;
        width: 2.5rem;
        height: 2.5rem;
    }
    .close { right: 1rem; }
    .download { right: 4rem; }
    .close svg,
    .download svg { width: 1.5rem; height: 1.5rem; }
}

/* Lightbox Navigation */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 2.5rem;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--radius);
    z-index: 2100;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--color-2);
}

.prev { left: 2rem; }
.next { right: 2rem; }

@media (max-width: 768px) {
    .nav-btn {
        padding: 0.5rem 1rem;
        font-size: 1.5rem;
    }
    .prev { left: 0.5rem; }
    .next { right: 0.5rem; }
}

/* Scroll cue — nudges users toward the galleries below */
#scroll-cue {
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin: 1.25rem 0 2rem auto;
    width: max-content;
    padding: 0.25rem 0.25rem 0.25rem 0.5rem;
    color: var(--color-3);
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    transition: color 0.3s ease, opacity 0.4s ease, transform 0.4s ease;
}

#scroll-cue.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
}

#scroll-cue:hover {
    color: var(--color-5);
}

.scroll-cue-arrow {
    width: 1.1rem;
    height: 1.1rem;
    fill: currentColor;
    animation: scrollCueGlide 1.8s ease-in-out infinite;
}

@keyframes scrollCueGlide {
    0%, 100% { transform: translateY(-3px); }
    50%      { transform: translateY(5px); }
}

@media (prefers-reduced-motion: reduce) {
    .scroll-cue-arrow { animation: none; }
}

@media (max-width: 600px) {
    #scroll-cue {
        margin: 0.75rem 0 1.25rem auto;
        font-size: 0.7rem;
        letter-spacing: 0.14em;
    }
    .scroll-cue-arrow { width: 1rem; height: 1rem; }
}

/* Thank-you sign-off (post / preview) */
#thank-you {
    text-align: center;
    padding: 0.5rem 1rem 1rem;
}

#thank-you p {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 500;
    color: var(--color-4);
    letter-spacing: -0.01em;
}

@media (max-width: 600px) {
    #thank-you { padding: 0 1rem 0.5rem; }
    #thank-you p { font-size: 1.3rem; }
}

/* Animations */
.fade-in {
    opacity: 0;
    animation: slideUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) 1.10s forwards;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

footer {
    text-align: center;
    padding: 3rem;
    background-color: var(--color-5);
    color: var(--text-light);
}

/* Responsive adjustments */
@media (max-width: 600px) {
    header {
        padding: 1rem 1rem 1.1rem;
        margin-bottom: 1rem;
    }
    .header-logo {
        height: 44px;
        margin-bottom: 0.5rem;
    }
    .organizer {
        font-size: 0.8rem;
        margin: 0 0 0.25rem;
    }
    header h1 { font-size: 1.5rem; }

    main { padding: 0 1rem 2rem; }
    section { margin-bottom: 1.25rem; }
    section h2 { font-size: 1.35rem; margin-bottom: 0.85rem; }

    #result-banner { padding: 1.1rem 1rem; }
    #hunt-name { font-size: 1.2rem; }
    .hunt-date { font-size: 0.78rem; margin-top: 0.2rem; }
    .winner-info {
        gap: 0.5rem;
        margin-top: 0.85rem;
    }
    .winner-info p { padding: 0.7rem 0.6rem; font-size: 0.82rem; }
    #prize-type, #winner-name { font-size: 1rem; margin-top: 0.15rem; }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .gallery-item img {
        height: 150px;
    }
}
