:root {
    --color-cream: #fbf9f7;
    --color-warm-white: #ffffff;
    --color-gold: #c9a962;
    --color-sage: #9caf88;
    --color-charcoal: #3d3d3d;
    --color-shadow: rgba(61, 61, 61, 0.08);
    --color-danger: #b84b4b;
    --radius-pill: 999px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    height: 100%;
    background: var(--color-cream);
    color: var(--color-charcoal);
    font-family: 'Montserrat', system-ui, sans-serif;
}

body {
    overflow: hidden;
}

img,
video,
canvas {
    max-width: 100%;
    display: block;
}

button {
    font: inherit;
    border: 0;
    cursor: pointer;
}

.is-hidden {
    display: none !important;
}

.app-shell {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--color-cream);
    overflow: hidden;
}

@supports (-webkit-touch-callout: none) {
    html,
    body {
        height: -webkit-fill-available;
    }

    .app-shell {
        height: -webkit-fill-available;
        min-height: -webkit-fill-available;
    }
}

.screen {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.title-serif,
.subtitle-serif,
.camera-monogram,
.completion-names,
#welcome-monogram {
    font-family: 'Cormorant Garamond', Georgia, serif;
}

.welcome-screen,
.completion-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding:
        max(24px, var(--safe-top))
        calc(20px + var(--safe-right))
        max(24px, var(--safe-bottom))
        calc(20px + var(--safe-left));
    background:
        radial-gradient(circle at top left, rgba(201, 169, 98, 0.08), transparent 30%),
        radial-gradient(circle at bottom right, rgba(156, 175, 136, 0.12), transparent 30%),
        var(--color-cream);
}

.welcome-card,
.completion-card {
    width: min(100%, 360px);
    text-align: center;
    position: relative;
    z-index: 2;
}

.decor-top,
.decor-bottom {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0.5;
    z-index: 1;
}

.decor-top {
    top: calc(18px + var(--safe-top));
}

.decor-bottom {
    bottom: calc(18px + var(--safe-bottom));
}

.monogram-circle {
    width: clamp(74px, 18vw, 84px);
    height: clamp(74px, 18vw, 84px);
    margin: 0 auto 24px;
    border-radius: 50%;
    border: 1.5px solid var(--color-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-gold);
    font-size: clamp(24px, 5vw, 28px);
    letter-spacing: 0.08em;
    background: rgba(255, 255, 255, 0.5);
}

.title-serif {
    margin: 0 0 6px;
    font-size: clamp(34px, 9vw, 42px);
    line-height: 1;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.title-serif.smaller {
    font-size: clamp(28px, 8vw, 34px);
    line-height: 1.1;
}

.eyebrow {
    margin: 0 0 24px;
    font-size: 11px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--color-sage);
}

.decorative-line {
    width: 96px;
    height: 1px;
    margin: 0 auto 24px;
    background: linear-gradient(90deg, transparent, var(--color-gold), transparent);
}

.decorative-line.small {
    width: 72px;
}

.subtitle-serif {
    margin: 0 0 14px;
    font-size: clamp(22px, 6vw, 28px);
    line-height: 1.15;
    font-style: italic;
    font-weight: 400;
}

.welcome-copy,
.completion-copy {
    margin: 0 0 24px;
    font-size: 14px;
    line-height: 1.7;
    color: rgba(61, 61, 61, 0.75);
}

.accent {
    color: var(--color-gold);
    font-weight: 600;
}

.primary-button,
.secondary-button {
    width: min(100%, 290px);
    margin: 0 auto;
    padding: 16px 20px;
    border-radius: var(--radius-pill);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 13px;
    transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

.primary-button {
    background: var(--color-charcoal);
    color: #fff;
    margin-bottom: 18px;
}

.primary-button:active,
.secondary-button:active,
.capture-btn:active,
.icon-button:active {
    transform: scale(0.98);
}

.secondary-button {
    background: var(--color-gold);
    color: #fff;
}

.permission-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    font-size: 12px;
    color: rgba(61, 61, 61, 0.55);
    flex-wrap: wrap;
}

.soft-warning {
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(184, 75, 75, 0.08);
    color: var(--color-danger);
    font-size: 12px;
    line-height: 1.5;
}

.camera-screen {
    display: flex;
    flex-direction: column;
    background: #000;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.video-wrap {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: #000;
    touch-action: manipulation;
}

#camera-preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: linear-gradient(145deg, #f5f3e8 0%, #e8dcc8 100%);
}

.overlay-top-gradient {
    position: absolute;
    inset: 0 0 auto 0;
    height: min(136px, 22vh);
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.52), transparent);
    pointer-events: none;
}

.overlay-bottom-gradient {
    position: absolute;
    inset: auto 0 0 0;
    height: min(220px, 30vh);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.68), transparent);
    pointer-events: none;
}

.focus-ring {
    position: absolute;
    width: 92px;
    height: 92px;
    margin-left: -46px;
    margin-top: -46px;
    border-radius: 50%;
    border: 2px solid rgba(201, 169, 98, 0.95);
    box-shadow:
        0 0 0 6px rgba(201, 169, 98, 0.14),
        0 8px 22px rgba(0, 0, 0, 0.14);
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 60%, transparent 100%);
    pointer-events: none;
    z-index: 12;
    animation: focusPulse 0.65s ease;
}

.focus-ring::before,
.focus-ring::after {
    content: "";
    position: absolute;
    background: rgba(201, 169, 98, 0.95);
    border-radius: 99px;
}

.focus-ring::before {
    left: 50%;
    top: 10px;
    transform: translateX(-50%);
    width: 2px;
    height: 16px;
}

.focus-ring::after {
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    width: 16px;
    height: 2px;
}

@keyframes focusPulse {
    0% {
        opacity: 0;
        transform: scale(1.35);
    }
    35% {
        opacity: 1;
        transform: scale(0.94);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding:
        calc(10px + var(--safe-top))
        calc(12px + var(--safe-right))
        0
        calc(12px + var(--safe-left));
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    z-index: 14;
}

.light-glass,
.dark-glass,
.success-feedback,
.message-box,
.summary-card,
.overlay-chip,
.overlay-hint,
.overlay-strip {
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.light-glass {
    background: rgba(255, 255, 255, 0.84);
}

.dark-glass {
    background: rgba(61, 61, 61, 0.58);
    color: rgba(255, 255, 255, 0.92);
}

.pill-label {
    min-height: 38px;
    padding: 9px 12px;
    border-radius: var(--radius-pill);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    font-size: 12px;
    white-space: nowrap;
    max-width: 100%;
}

#shot-counter {
    justify-self: end;
    color: var(--color-charcoal);
}

#shots-remaining {
    color: var(--color-gold);
    font-weight: 700;
}

.progress-dots {
    position: absolute;
    top: calc(58px + var(--safe-top));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    justify-content: center;
    width: min(280px, calc(100% - 40px));
    padding: 0 10px;
    z-index: 13;
}

.progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-gold);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.progress-dot.used {
    opacity: 0.35;
}

.progress-dot.available {
    opacity: 1;
}

.success-feedback {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(220px, calc(100% - 32px));
    min-width: 0;
    padding: 16px 18px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--color-charcoal);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
    z-index: 16;
    text-align: center;
}

.success-feedback svg {
    color: var(--color-sage);
}

.success-feedback small {
    color: var(--color-gold);
    font-size: 12px;
}

.message-box {
    position: absolute;
    left: 50%;
    bottom: calc(132px + var(--safe-bottom));
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 340px;
    padding: 13px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--color-charcoal);
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.1);
    z-index: 16;
}

.message-box.error {
    color: var(--color-danger);
}

.bottom-overlay-ui {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding:
        0
        calc(14px + var(--safe-right))
        calc(12px + var(--safe-bottom))
        calc(14px + var(--safe-left));
    z-index: 15;
    pointer-events: none;
}

.bottom-overlay-ui > * {
    pointer-events: auto;
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(10px, 3vw, 16px);
    max-width: 380px;
    margin: 0 auto;
}

.overlay-chip {
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.16);
}

.thumbnail-container {
    width: clamp(50px, 13vw, 56px);
    height: clamp(50px, 13vw, 56px);
    border-radius: 16px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.95);
    flex: 0 0 auto;
}

.thumbnail-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.capture-btn {
    width: clamp(70px, 19vw, 82px);
    height: clamp(70px, 19vw, 82px);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #ffffff 0%, #f5f3f0 100%);
    box-shadow:
        0 8px 24px rgba(201, 169, 98, 0.28),
        inset 0 2px 4px rgba(255, 255, 255, 0.8),
        inset 0 -2px 4px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s ease, opacity 0.15s ease;
    flex: 0 0 auto;
}

.capture-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.capture-btn-inner {
    width: clamp(54px, 15vw, 64px);
    height: clamp(54px, 15vw, 64px);
    border-radius: 50%;
    background: linear-gradient(145deg, var(--color-gold) 0%, #b8984f 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-button {
    width: clamp(50px, 13vw, 56px);
    height: clamp(50px, 13vw, 56px);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.icon-button[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.icon-button svg {
    display: block;
}

.light-solid {
    color: var(--color-charcoal);
    border: 2px solid rgba(255, 255, 255, 0.95);
}

.camera-hint-row {
    margin-top: 10px;
    text-align: center;
}

.overlay-hint {
    width: fit-content;
    max-width: calc(100% - 24px);
    margin-left: auto;
    margin-right: auto;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
}

.camera-hint {
    display: inline-block;
    font-size: 10px;
    letter-spacing: 0.04em;
    color: rgba(61, 61, 61, 0.72);
    line-height: 1.4;
}

.overlay-strip {
    margin: 10px auto 0;
    max-width: 320px;
    padding: 8px 10px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
}

.thumbnail-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    justify-content: center;
    padding-bottom: 0;
    scrollbar-width: none;
}

.thumbnail-strip::-webkit-scrollbar {
    display: none;
}

.thumbnail-strip img {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
}

.completion-icon {
    width: clamp(84px, 22vw, 96px);
    height: clamp(84px, 22vw, 96px);
    margin: 0 auto 24px;
    border-radius: 50%;
    background: rgba(156, 175, 136, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-sage);
}

.summary-card {
    width: 100%;
    margin: 0 auto 24px;
    padding: 16px 18px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid rgba(201, 169, 98, 0.2);
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    box-shadow: 0 12px 30px var(--color-shadow);
}

.summary-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(201, 169, 98, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.summary-text p {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 600;
}

.summary-text small {
    color: rgba(61, 61, 61, 0.6);
}

.completion-names {
    margin: 20px 0 0;
    font-size: clamp(20px, 6vw, 24px);
    color: var(--color-gold);
    font-style: italic;
}

.auth-page,
.gallery-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(201, 169, 98, 0.08), transparent 32%),
        radial-gradient(circle at bottom right, rgba(156, 175, 136, 0.12), transparent 32%),
        var(--color-cream);
    padding: 24px;
    color: var(--color-charcoal);
}

.auth-wrap,
.gallery-wrap {
    max-width: 980px;
    margin: 0 auto;
}

.auth-card {
    max-width: 420px;
    margin: 60px auto 0;
    background: rgba(255, 255, 255, 0.84);
    border-radius: 28px;
    padding: 30px 24px;
    box-shadow: 0 20px 50px var(--color-shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.auth-card h1,
.gallery-header h1 {
    margin: 0 0 8px;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 40px;
    font-weight: 400;
}

.auth-card p,
.gallery-header p {
    margin: 0 0 20px;
    color: rgba(61, 61, 61, 0.72);
    line-height: 1.6;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
}

.input-field {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid rgba(61, 61, 61, 0.12);
    border-radius: 16px;
    background: #fff;
    color: var(--color-charcoal);
    outline: none;
    font-size: 14px;
}

.input-field:focus {
    border-color: var(--color-gold);
    box-shadow: 0 0 0 4px rgba(201, 169, 98, 0.12);
}

.alert {
    margin-bottom: 16px;
    padding: 13px 15px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
}

.alert.error {
    background: rgba(184, 75, 75, 0.08);
    color: var(--color-danger);
}

.gallery-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.gallery-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.ghost-button,
.small-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-pill);
    padding: 12px 18px;
    font-size: 13px;
    text-decoration: none;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.ghost-button {
    background: rgba(255, 255, 255, 0.84);
    color: var(--color-charcoal);
    box-shadow: 0 10px 24px var(--color-shadow);
}

.small-button {
    background: var(--color-gold);
    color: #fff;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.84);
    border-radius: 22px;
    padding: 18px;
    box-shadow: 0 16px 36px var(--color-shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.stat-card small {
    display: block;
    margin-bottom: 8px;
    color: rgba(61, 61, 61, 0.6);
}

.stat-card strong {
    font-size: 26px;
    font-weight: 600;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.photo-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 18px 40px var(--color-shadow);
}

.photo-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background: #f0ede7;
}

.photo-card-body {
    padding: 14px;
}

.meta-line {
    margin: 0 0 8px;
    font-size: 12px;
    line-height: 1.5;
    color: rgba(61, 61, 61, 0.7);
    word-break: break-word;
}

.meta-line strong {
    color: var(--color-charcoal);
}

.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.card-actions a {
    flex: 1;
    text-align: center;
    text-decoration: none;
}

.empty-state {
    background: rgba(255, 255, 255, 0.84);
    border-radius: 24px;
    padding: 28px 20px;
    text-align: center;
    box-shadow: 0 18px 40px var(--color-shadow);
}

@media (max-width: 860px) {
    .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .gallery-header {
        flex-direction: column;
    }
}

@media (max-width: 520px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .focus-ring {
        width: 78px;
        height: 78px;
        margin-left: -39px;
        margin-top: -39px;
    }

    .top-bar {
        gap: 8px;
    }

    .pill-label {
        min-height: 36px;
        padding: 8px 11px;
        font-size: 11px;
    }

    .overlay-strip {
        max-width: 280px;
    }
}

@media (max-height: 720px) {
    .overlay-hint {
        display: none;
    }

    .overlay-strip {
        margin-top: 8px;
        padding: 6px 8px;
    }

    .thumbnail-strip img {
        width: 34px;
        height: 34px;
    }

    .message-box {
        bottom: calc(116px + var(--safe-bottom));
    }
}