:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --secondary: #7c3aed;
    --accent: #06b6d4;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-light: #94a3b8;
    --background: #ffffff;
    --card-bg: #f8fafc;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --whatsapp: #25d366;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    /* 仅由 html 承担纵向滚动；勿在 body 上写 overflow-x:hidden，否则会触发规范把 overflow-y 算成 auto，出现双滚动条 */
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-text-size-adjust: 100%;
    width: 100%;
    max-width: 100%;
    position: relative;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    /* 不要在此设置 overflow-x: hidden，会触发规范把 overflow-y 算成 auto，与 html 双轨滚动 */
    width: 100%;
    max-width: 100%;
    margin: 0;
    min-width: 0;
}

#root {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.container {
    max-width: 440px;
    width: 100%;
    min-width: 0;
    margin-left: auto;
    margin-right: auto;
}

.card {
    background: var(--background);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    padding: 40px 32px;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all 0.4s ease;
    animation: cardEntrance 0.8s ease-out;
    max-width: 100%;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

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

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.12);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    min-width: 0;
    max-width: 100%;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 22px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    animation: iconFloat 3s ease-in-out infinite;
}

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

.logo-text {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.title-accent {
    font-size: 17px;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 12px;
    line-height: 1.35;
}

.viewer-line {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.viewer-count {
    color: var(--secondary);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.5;
}

.input-container {
    position: relative;
    margin-bottom: 28px;
}

.code-input {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid var(--border);
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    background: var(--card-bg);
    color: var(--text-primary);
}

.code-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    outline: none;
    transform: scale(1.02);
}

.code-input.valid {
    border-color: var(--success);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.code-input.invalid {
    border-color: var(--error);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.input-hint {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    position: relative;
    overflow: hidden;
    text-decoration: none;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
}

.btn:hover::before {
    left: 100%;
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-whatsapp {
    background: linear-gradient(135deg, var(--whatsapp), #128C7E);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.btn-whatsapp:hover {
    box-shadow: 0 8px 20px rgba(37, 211, 102, 0.4);
}

.trust-badges {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 28px;
    font-size: 14px;
    color: var(--text-secondary);
}

.trust-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    flex-shrink: 1;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-align: center;
}

.trust-badge i {
    color: var(--success);
}

.step-indicator {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 32px 0;
}

.step {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.3s ease;
}

.step.active {
    background: var(--primary);
    width: 36px;
    border-radius: 6px;
}

.hidden {
    display: none;
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.slide-up {
    animation: slideUp 0.5s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(37, 99, 235, 0.2);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.success-animation {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    position: relative;
}

.success-animation .checkmark {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: block;
    stroke-width: 3;
    stroke: var(--success);
    stroke-miterlimit: 10;
    box-shadow: inset 0 0 0 rgba(16, 185, 129, 0.2);
    animation: fill 0.4s ease-in-out 0.4s forwards, scale 0.3s ease-in-out 0.9s both;
}

.success-animation .checkmark__circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 3;
    stroke-miterlimit: 10;
    stroke: var(--success);
    fill: none;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.success-animation .checkmark__check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes scale {
    0%, 100% {
        transform: none;
    }
    50% {
        transform: scale3d(1.1, 1.1, 1);
    }
}

@keyframes fill {
    100% {
        box-shadow: inset 0 0 0 40px rgba(16, 185, 129, 0.1);
    }
}

.result-message {
    margin: 20px 0;
    font-size: 20px;
    font-weight: 600;
}

.code-display {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin: 12px 0 24px;
    padding: 12px 20px;
    background: rgba(37, 99, 235, 0.1);
    border-radius: 12px;
    display: inline-block;
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: anywhere;
    word-break: break-word;
    border: 2px solid rgba(37, 99, 235, 0.2);
}

.code-display.code-display--compact {
    font-size: 18px;
    margin: 0;
    padding: 8px 14px;
}

#step3 h2 {
    margin-bottom: 6px;
}

#step3 .title-accent {
    margin-bottom: 10px;
}

#step3 .viewer-line {
    margin-bottom: 16px;
}

.result-headline {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px;
    line-height: 1.35;
}

.result-ticker {
    margin: 0 0 14px;
}

.step3-lead {
    margin-bottom: 22px;
    text-align: center;
}

.btn-whatsapp .whatsapp-cta-em {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.disclaimer {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 28px;
    line-height: 1.5;
}

.error-message {
    color: var(--error);
    font-size: 14px;
    margin-top: 10px;
    display: none;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.features {
    display: flex;
    justify-content: space-between;
    margin: 24px 0;
    gap: 16px;
    min-width: 0;
}

.feature {
    flex: 1;
    min-width: 0;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 12px;
    text-align: center;
    transition: transform 0.3s ease;
}

.feature:hover {
    transform: translateY(-2px);
}

.feature i {
    font-size: 24px;
    color: var(--primary);
    margin-bottom: 8px;
}

.feature-text {
    font-size: 14px;
    font-weight: 500;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Mobile: prevent horizontal overflow, safe areas, readable typography */
@media (max-width: 480px) {
    body {
        padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    }

    .card {
        padding: 24px 14px;
        border-radius: 20px;
        /* 大阴影在窄屏会画出视口外，触发横向滚动 */
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.07);
    }

    .card:hover {
        transform: none;
    }

    h1 {
        font-size: 24px;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .title-accent {
        font-size: 15px;
        margin-bottom: 10px;
    }

    .viewer-line {
        font-size: 12px;
        margin-bottom: 18px;
    }

    h2 {
        font-size: 1.25rem;
        line-height: 1.3;
        overflow-wrap: anywhere;
    }

    .subtitle {
        font-size: 15px;
        margin-bottom: 24px;
        overflow-wrap: anywhere;
    }

    .logo-text {
        font-size: 24px;
    }

    /* 保持与桌面相同的横向三列排版，整体缩小以免溢出 */
    .features {
        gap: 6px;
        margin: 18px 0;
    }

    .feature {
        padding: 10px 4px;
    }

    .feature i {
        font-size: 18px;
        margin-bottom: 4px;
    }

    .feature-text {
        font-size: 11px;
        line-height: 1.25;
    }

    .trust-badges {
        flex-wrap: nowrap;
        gap: 6px;
        margin-top: 20px;
        font-size: 10px;
    }

    .trust-badge {
        flex: 1 1 0;
        min-width: 0;
        justify-content: center;
        gap: 2px;
        font-size: 9px;
        line-height: 1.2;
    }

    .trust-badge i {
        flex-shrink: 0;
        font-size: 0.95em;
    }

    .btn {
        padding: 14px 12px;
        font-size: 15px;
        box-shadow: 0 2px 10px rgba(37, 99, 235, 0.28);
    }

    .btn-whatsapp {
        box-shadow: 0 2px 10px rgba(37, 211, 102, 0.28);
    }

    .result-message {
        font-size: 17px;
        overflow-wrap: anywhere;
    }

    .code-display {
        font-size: 20px;
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .code-display.code-display--compact {
        font-size: 15px;
        padding: 6px 10px;
    }

    .result-headline {
        font-size: 16px;
    }

    .step3-lead {
        font-size: 14px;
        margin-bottom: 18px;
    }

    .disclaimer {
        padding: 0 2px;
    }

    .code-input {
        font-size: 16px; /* prevents iOS zoom on focus */
        padding-left: 12px;
        padding-right: 12px;
    }

    .code-input:focus {
        transform: none;
        box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
    }

    .code-input.valid {
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    }

    .code-input.invalid {
        box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
    }

    .input-hint {
        overflow-wrap: anywhere;
    }
}

/* 极窄屏再压一档，避免三列徽章/特性区撑出横向滚动 */
@media (max-width: 360px) {
    .features {
        gap: 4px;
    }

    .feature {
        padding: 8px 2px;
    }

    .feature-text {
        font-size: 10px;
    }

    .trust-badges {
        gap: 4px;
        font-size: 8px;
    }
}

/* 视口高度较矮时收紧间距，减少首屏出现纵向滚动条的概率 */
@media (max-height: 720px) {
    body {
        padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    }

    .card {
        padding: 22px 18px;
    }

    .logo {
        margin-bottom: 16px;
    }

    h1 {
        margin-bottom: 8px;
    }

    .subtitle {
        margin-bottom: 16px;
    }

    .features {
        margin: 14px 0;
    }

    .step-indicator {
        margin: 18px 0;
    }

    .input-container {
        margin-bottom: 18px;
    }

    .trust-badges {
        margin-top: 16px;
    }

    .disclaimer {
        margin-top: 18px;
    }
}
