:root {
    --bg: #080808;
    --surface: #101010;
    --surface-2: #181818;
    --border: #2A2A2A;
    --border-2: #383838;
    --cream: #F5EFE0;
    --champ: #e8e8e8;
    --champ-light: #e8e8e8;
    --champ-bright: #e8e8e8;
    --champ-dim: rgba(255, 255, 255, 0.054);
    --champ-border: rgba(255, 255, 255, 0.15);
    --text-1: #F5EFE0;
    --text-2: #B0A898;
    --text-3: #6A6258;
    --transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100vh;
    height: 100dvh;
    background: var(--bg);
    color: var(--text-1);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

body {
    display: flex;
    flex-direction: column;
}

/* Background overlay elements */
.bg-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(16, 16, 16, 0.4) 0%, rgba(8, 8, 8, 0.9) 100%);
    pointer-events: none;
    z-index: 1;
}

.bg-noise {
    position: fixed;
    inset: 0;
    opacity: 0.02;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1;
}

/* Overall App Layout */
.app-layout {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    height: 100svh;
    width: 100%;
    overflow: hidden;
}

/* Sticky Header Section */
.header-section {
    position: sticky;
    top: 0;
    z-index: 50;
    text-align: center;
    padding: 16px 24px;
    background: rgba(8, 8, 8, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.page-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(28px, 3.2vw, 42px);
    font-weight: 400;
    letter-spacing: 1px;
    margin-bottom: 6px;
    background: linear-gradient(135deg, var(--text-1) 20%, var(--champ-bright) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.gold-divider {
    width: 120px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--champ), transparent);
    margin: 0 auto 8px;
}

.sub-headline {
    font-size: clamp(12px, 1.3vw, 14px);
    color: var(--text-2);
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.4;
}

/* Main Scrollable Content Area */
.main-content {
    flex: 1 1 0%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 24px;
    overflow: hidden;
}

/* Loading / Error States */
.spinner-container, .error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    text-align: center;
    color: var(--text-2);
    margin: auto;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.06);
    border-radius: 50%;
    border-top-color: var(--champ);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-container p {
    color: #ef4444;
    margin-bottom: 16px;
}

.btn-retry {
    background: var(--surface-2);
    color: var(--text-1);
    border: 1px solid var(--border);
    padding: 10px 24px;
    border-radius: 3px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-retry:hover {
    border-color: var(--text-3);
    background: var(--border);
}

/* ── Swipeable card stack ── */
.stack-stage {
    flex: 1 1 0%;
    min-height: 0;
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.stack-stage.loaded {
    opacity: 1;
    transform: translateY(0);
}

.stack-area {
    flex: 1 1 0%;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    container-type: size;
}

/* square deck sized to whatever room is available (leaves space for the stacked edges) */
.card-stack {
    position: relative;
    width: min(100%, 560px);
    height: min(100%, 560px);
    width: min(calc(100cqw - 32px), calc(100cqh - 44px), 560px);
    height: min(calc(100cqw - 32px), calc(100cqh - 44px), 560px);
    margin-bottom: 28px;
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
}

.stack-card {
    position: absolute;
    inset: 0;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
    cursor: grab;
    transform-origin: 50% 60%;
    will-change: transform, opacity;
    transition:
        transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.35s ease,
        filter 0.35s ease,
        border-color 0.2s ease;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

/* stacked positions behind the top card */
.stack-card[data-rel="0"] { transform: rotate(-1.5deg); opacity: 1; }
.stack-card[data-rel="1"] { transform: translate(10px, 12px) rotate(4deg) scale(0.96); opacity: 1; filter: brightness(0.75); }
.stack-card[data-rel="2"] { transform: translate(-10px, 22px) rotate(-5deg) scale(0.92); opacity: 1; filter: brightness(0.55); }
.stack-card[data-rel="3"] { transform: translate(0, 30px) rotate(3deg) scale(0.88); opacity: 0; }

/* swiped away — flies off to the left and fades */
.stack-card[data-rel="gone"] {
    transform: translateX(-115%) rotate(-10deg);
    opacity: 0;
    pointer-events: none;
}

.stack-card:not(.is-top) {
    pointer-events: none;
    cursor: default;
}

.stack-card.is-top:hover {
    border-color: var(--champ-border);
}

.stack-card.is-top:focus-visible {
    outline: 2px solid var(--champ-light);
    outline-offset: 3px;
}

.stack-card.dragging {
    transition: none;
    cursor: grabbing;
}

.stack-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    -webkit-user-drag: none;
}

/* ── Controls ── */
.stack-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    flex-shrink: 0;
    padding-bottom: 4px;
}

.stack-arrow {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(16, 16, 16, 0.7);
    border: 1px solid var(--border-2);
    color: var(--text-1);
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.stack-arrow:hover:not(:disabled) {
    border-color: var(--champ);
    color: var(--champ-bright);
    background: var(--champ-dim);
}

.stack-arrow:active:not(:disabled) {
    transform: scale(0.94);
}

.stack-arrow:focus-visible {
    outline: 2px solid var(--champ-light);
    outline-offset: 3px;
}

.stack-arrow:disabled {
    opacity: 0.3;
    cursor: default;
}

.stack-arrow[hidden] {
    display: none;
}

.stack-status {
    min-width: 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.stack-counter {
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: 0.12em;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
}

.stack-dots {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stack-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border-2);
    transition: background 0.25s ease, transform 0.25s ease, width 0.25s ease;
}

.stack-dots span.active {
    width: 18px;
    border-radius: 3px;
    background: var(--champ);
}

@media (prefers-reduced-motion: reduce) {
    .stack-card,
    .stack-stage {
        transition-duration: 0.01ms;
    }
}
.btn-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--champ) 0%, var(--champ-light) 100%);
    color: #120e08;
    border: none;
    padding: 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    text-decoration: none;
}

.btn-download:hover {
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.24);
    transform: translateY(-2px);
    background: linear-gradient(135deg, var(--champ-light) 0%, var(--champ-bright) 100%);
}

.btn-download:active {
    transform: translateY(0);
}

.btn-download svg {
    transition: transform 0.2s ease;
}

.btn-download:hover svg {
    transform: translateY(2px);
}

/* Sticky Footer */
.footer {
    position: sticky;
    bottom: 0;
    z-index: 50;
    text-align: center;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: rgba(8, 8, 8, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font-size: 12px;
    color: var(--text-3);
    flex-shrink: 0;
}

.footer-links {
    margin-top: 4px;
    display: flex;
    justify-content: center;
    gap: 16px;
}

.footer-links a {
    color: var(--text-3);
    text-decoration: none;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--champ-light);
}

/* Image Viewer Lightbox */
.image-viewer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 4, 4, 0.92);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    cursor: zoom-out;
}

.viewer-content {
    position: relative;
    z-index: 10;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    animation: zoomIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.viewer-image-wrapper {
    position: relative;
    background: transparent;
    border-radius: 4px;
    overflow: visible;
    max-height: 75vh;
    border: none;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-close {
    position: absolute;
    top: 0;
    left: calc(100% + 5px);
    z-index: 20;
    background: rgba(16, 16, 16, 0.85);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-1);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.viewer-close:hover {
    color: var(--champ-bright);
    background: rgba(40, 40, 40, 0.95);
    border-color: var(--champ);
    transform: scale(1.08);
}

.viewer-content img {
    max-height: 75vh;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

.viewer-actions {
    width: 100%;
    max-width: 240px;
}

/* Responsive Rules */
@media (max-width: 768px) {
    .header-section {
        padding: 12px 16px;
    }
    .page-title {
        font-size: 26px;
    }
    .main-content {
        padding: 12px 16px;
    }
    .stack-controls {
        gap: 16px;
    }
    .viewer-close {
        left: auto !important;
        right: 0 !important;
        top: -41px !important;
    }
}

/* ═══════════════════════════════════════════════════
   SOFT UI THEME — matches the portal (dark)
═══════════════════════════════════════════════════ */
:root {
    --bg:            #080707;
    --surface:       #121111;
    --surface-2:     #1b1a1a;
    --surface-3:     #232222;
    --border:        #201f1f;
    --border-2:      #2e2d2d;
    --border-hover:  #3a3939;
    --border-accent: #8a8a8a;

    --text-1:        #f5f5f5;
    --text-2:        #a3a3a3;
    --text-3:        #727272;
    --cream:         #f5f5f5;

    --champ:         #e8e8e8;
    --champ-light:   #f2f2f2;
    --champ-bright:  #fafafa;
    --champ-dim:     rgba(255, 255, 255, 0.06);
    --champ-border:  rgba(255, 255, 255, 0.16);

    --btn-solid-bg:  #f5f5f5;
    --btn-solid-fg:  #080707;
}

html,
body {
    background-color: var(--bg);
}

input:focus,
input:focus-visible,
select:focus,
textarea:focus {
    outline: none !important;
    box-shadow: none !important;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 3px;
}
.header-section {
    background: rgba(8, 7, 7, 0.88);
    border-bottom-color: var(--border);
}

.page-title {
    background: none;
    -webkit-text-fill-color: var(--text-1);
    color: var(--text-1);
}

.gold-divider {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
}

.footer {
    background: rgba(8, 7, 7, 0.95);
    border-top-color: var(--border);
}

.btn-retry {
    border-radius: 999px;
    background: transparent;
    border-color: rgba(245, 245, 245, 0.32);
}

.btn-retry:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(245, 245, 245, 0.55);
}

.stack-card {
    border-radius: 22px;
    background: var(--surface);
    border-color: var(--border);
}

.stack-card.is-top:hover {
    border-color: var(--border-2);
}

.stack-arrow {
    background: var(--surface-2);
    border-color: transparent;
}

.stack-arrow:hover:not(:disabled) {
    background: var(--btn-solid-bg);
    color: var(--btn-solid-fg);
    border-color: transparent;
}

.stack-dots span.active {
    background: var(--text-1);
}

.btn-download {
    background: var(--btn-solid-bg);
    color: var(--btn-solid-fg);
    border-radius: 999px;
}

.btn-download:hover {
    background: #dcdcdc;
    box-shadow: none;
    transform: translateY(-1px);
}

.viewer-close:hover {
    color: var(--text-1);
    border-color: var(--border-accent);
}