/* ===========================
   RESET & BASE
=========================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #241725;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===========================
   ACCENT COLOR
=========================== */
.accent {
    color: #5e53eb;
}

/* ===========================
   HEADER
=========================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(180deg, #0d0d14 80%, transparent 100%);
    gap: 12px;
}

.progress-bar-wrapper {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

/* ===========================
   BACK BUTTON
=========================== */
.back-btn {
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    opacity: 1;
    pointer-events: all;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.back-btn.hidden {
    display: flex !important;
    opacity: 0;
    pointer-events: none;
}

/* ===========================
   PROGRESS BAR
=========================== */
.progress-bar {
    display: flex;
    align-items: center;
    background: #5b3373;
    border-radius: 40px;
    padding: 8px 14px;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

.progress-bar::-webkit-scrollbar {
    display: none;
}

.progress-step {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #2a1a4e;
    border: 2px solid #3a2a5e;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.progress-step img {
    width: 16px;
    height: 16px;
    filter: brightness(0.4);
    transition: filter 0.3s ease;
}

.progress-step.active {
background: #8e1a74;
    border-color: #ff60cb;
    box-shadow: 0 0 12px rgba(192, 96, 255, 0.5);
}

.progress-step.active img {
    filter: brightness(0) invert(1);
}

.progress-step.completed {
    background: #3a1a6e;
    border-color: #9040cc;
}

.progress-step.completed img {
    filter: brightness(0) saturate(100%) invert(40%) sepia(80%) saturate(500%) hue-rotate(260deg) brightness(120%);
}

.progress-divider {
    width: 16px;
    height: 2px;
    background: #3a2a5e;
    flex-shrink: 0;
    border-radius: 1px;
}

/* ===========================
   MAIN
=========================== */
.main {
    flex: 1;
    padding: 100px 20px 100px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* ===========================
   STEPS
=========================== */
.step {
    display: none;
    flex-direction: column;
    gap: 24px;
    animation: fadeIn 0.3s ease;
}

.step.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* ===========================
   TITLES
=========================== */
.step-title {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    color: #ffffff;
}

.step-subtitle {
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    color: #ffffff;
    margin-bottom: 8px;
}

/* ===========================
   OPTIONS GRID
=========================== */
.options-grid {
    display: grid;
    gap: 12px;
    width: 100%;
}

.options-grid--2 {
    grid-template-columns: repeat(2, 1fr);
}

.options-grid--4 {
    grid-template-columns: repeat(4, 1fr);
}

.options-grid--5 {
    grid-template-columns: repeat(5, 1fr);
}

.options-grid--6 {
    grid-template-columns: repeat(6, 1fr);
}

/* ===========================
   VIDEO OPTION CARD
=========================== */
.option-card {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    background: #1a1a2e;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    display: flex;
    flex-direction: column;
}

.option-card:hover {
    transform: translateY(-2px);
    border-color: rgba(224, 64, 251, 0.4);
}

.option-card.selected {
    border-color: #4090fb;
    box-shadow: 0 0 16px rgba(224, 64, 251, 0.4);
}

.option-card video {
    width: 100%;
    aspect-ratio: 1 / 2;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.option-card .card-label {
    padding: 8px 6px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    background: #1a1a2e;
}

/* step 1 — fixed-size centered cards */
#options-step-1 {
    grid-template-columns: repeat(2, 200px);
    justify-content: center;
}

/* step 2 ethnicity — flexbox so last row is always centered */
#options-step-2-ethnicity {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

#options-step-2-ethnicity .option-card {
    width: calc(20% - 10px);
    flex-shrink: 0;
}

#options-step-1 .option-card video {
    aspect-ratio: 1 / 2;
}

/* ===========================
   AGE SECTION
=========================== */
.age-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.slider-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
}

.age-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #e040fb 0%, #e040fb var(--slider-pct, 12.5%), #3a2a5e var(--slider-pct, 12.5%), #3a2a5e 100%);
    outline: none;
    cursor: pointer;
}

.age-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e040fb;
    box-shadow: 0 0 8px rgba(224, 64, 251, 0.6);
    cursor: pointer;
    transition: transform 0.15s;
}

.age-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.age-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e040fb;
    box-shadow: 0 0 8px rgba(224, 64, 251, 0.6);
    cursor: pointer;
    border: none;
}

.slider-value {
    font-size: 20px;
    font-weight: 700;
    color: #e040fb;
    min-width: 36px;
    text-align: center;
}

/* ===========================
   COLOR SECTION
=========================== */
.color-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.color-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.color-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.color-circle:hover {
    transform: scale(1.1);
    border-color: rgba(224, 64, 251, 0.5);
}

.color-circle.selected {
    border-color: #e040fb;
    box-shadow: 0 0 12px rgba(224, 64, 251, 0.5);
}

/* ===========================
   VOICE SECTION
=========================== */
.voice-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.voice-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.voice-card {
    background: #1a1a2e;
    border: 2px solid #2a2a4e;
    border-radius: 14px;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.voice-card:hover {
    transform: translateY(-2px);
    border-color: rgba(224, 64, 251, 0.4);
}

.voice-card.selected {
    border-color: #e040fb;
    box-shadow: 0 0 16px rgba(224, 64, 251, 0.4);
}

.voice-card svg {
    color: #aaaaaa;
}

.voice-card.selected svg {
    color: #e040fb;
}

.voice-card.playing svg {
    animation: pulse-voice 0.8s ease-in-out infinite;
}

@keyframes pulse-voice {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }
}

.voice-card .voice-name {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    text-align: center;
}

.voice-card .voice-label {
    font-size: 12px;
    color: #888888;
    text-align: center;
}

/* ===========================
   SUMMARY CHIPS
=========================== */
.summary-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.summary-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #1a1a2e;
    border: 1px solid #2a2a4e;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    text-transform: capitalize;
    white-space: nowrap;
}

.summary-chip em {
    font-style: normal;
    color: #888888;
    font-size: 11px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chip-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

/* ===========================
   STEP 8 — RESULT
=========================== */
.step8-tagline {
    text-align: center;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.7);
    margin: -4px 0 12px;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.step8-tagline.visible {
    opacity: 1;
}

.step8-center {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    height: calc(100vh - 360px);
    width: calc((100vh - 360px) * 768 / 1352);
    max-width: 100%;
    margin: 0 auto;
    background: rgba(26, 26, 46, 0.4);
    border-radius: 20px;
    transition: background 0.6s ease;
}

.step8-center.loaded {
    background: transparent;
}

.step8-center .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #2a2a4e;
    border-top-color: #e040fb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    position: absolute;
    transition: opacity 0.4s ease;
}

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

.step8-center .spinner.fade-out {
    opacity: 0;
}

.step8-center img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 20px;
    display: block;
    border: 2px solid #3a2a5e;
    box-shadow: 0 8px 40px rgba(224, 64, 251, 0.2);
    opacity: 0;
    transition: opacity 0.6s ease;
}

.step8-center img.visible {
    opacity: 1;
}

.step8-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 40px 0;
    color: #aaaaaa;
    font-size: 16px;
}

.retry-btn {
    padding: 12px 32px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(90deg, #c020e0, #e040fb);
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
}

.retry-btn:hover {
    opacity: 0.9;
}

.hidden {
    display: none !important;
}

/* ===========================
   FOOTER
=========================== */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 20px;
    background: linear-gradient(0deg, #0d0d14 80%, transparent 100%);
    z-index: 100;
    display: flex;
    justify-content: center;
}

.next-btn {
    width: auto;
    min-width: 280px;
    padding: 16px 48px;
    border: none;
    border-radius: 14px;
       background: linear-gradient(90deg, #65799d, #3c0b79);
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
}

.next-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.next-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}

a.next-btn {
    text-decoration: none;
    text-align: center;
    display: inline-block;
}

/* ===========================
   RESPONSIVE — 700px (tablet / large phone)
=========================== */
@media (max-width: 700px) {

    /* step 1 — stack vertically on narrow screens */
    #options-step-1 {
        grid-template-columns: repeat(2, 160px);
    }

    /* ethnicity — 3 per row, last 2 centered */
    #options-step-2-ethnicity .option-card {
        width: calc(33.333% - 9px);
    }

    .options-grid--4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .options-grid--5 {
        grid-template-columns: repeat(3, 1fr);
    }

    .options-grid--6 {
        grid-template-columns: repeat(3, 1fr);
    }

    .voice-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .summary-chips {
        justify-content: center;
    }

    .step-title {
        font-size: 22px;
    }

    .step-subtitle {
        font-size: 17px;
    }

    /* reduce main padding on mobile */
    .main {
        padding: 88px 12px 90px;
    }

    /* tighter gap between cards */
    .options-grid {
        gap: 8px;
    }

    /* bigger slider thumb for touch */
    .age-slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }

    .age-slider::-moz-range-thumb {
        width: 28px;
        height: 28px;
    }

    .age-slider {
        height: 8px;
    }

    /* voice cards less padding */
    .voice-card {
        padding: 14px 8px;
        gap: 6px;
    }
}

/* ===========================
   RESPONSIVE — 440px (small phone)
=========================== */
@media (max-width: 440px) {

    /* step 1 — full width single column */
    #options-step-1 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* ethnicity — 2 per row, last 1 centered */
    #options-step-2-ethnicity .option-card {
        width: calc(50% - 6px);
    }

    /* other 5-col grids → 2 columns */
    .options-grid--5 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* 6 hair cards → 2 columns */
    .options-grid--6 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* progress bar — compact */
    .progress-step {
        width: 28px;
        height: 28px;
    }

    .progress-step img {
        width: 13px;
        height: 13px;
    }

    .progress-divider {
        width: 6px;
    }

    .progress-bar {
        padding: 6px 10px;
        gap: 3px;
    }

    .step-title {
        font-size: 19px;
    }

    .step-subtitle {
        font-size: 15px;
    }

    /* header less padding so progress bar has room */
    .header {
        padding: 10px 12px;
    }

    .main {
        padding: 76px 10px 84px;
    }

    .next-btn {
        width: 100%;
        padding: 14px 16px;
        font-size: 15px;
        min-width: unset;
    }

    a.next-btn {
        width: 100%;
    }

}