:root {
    --bg: #0a1326;
    --cyan: #3ad5f7;
    --cyan-bright: #4ed5f3;
    --cyan-dim: #b1e4ee;
    --text-muted: #b3dce3;
    --text-dim: #687a87;
    --border: #30445a;
    --border-light: #31556c;
    --track: #435d7c;
    --btn-text: #06404d;
    --fail: #f87171;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--cyan-dim);
    min-height: 100vh;
    overflow-x: hidden;
}

.screen {
    position: relative;
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
}

.screen.hidden {
    display: none !important;
}

/* ===== Shared background glow ===== */
.bg-glow {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}

.bg-glow--bl {
    width: clamp(300px, 36vw, 688px);
    height: clamp(300px, 36vw, 688px);
    left: -9px;
    bottom: -120px;
    background: radial-gradient(circle, rgba(58, 213, 247, 0.12) 0%, transparent 70%);
}

.bg-glow--tr {
    width: clamp(300px, 36vw, 688px);
    height: clamp(300px, 36vw, 688px);
    right: -80px;
    top: -188px;
    background: radial-gradient(circle, rgba(58, 213, 247, 0.1) 0%, transparent 70%);
}

.screen-inner {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: clamp(24px, 4vh, 48px) clamp(16px, 3vw, 32px);
}

/* ===== Loading ===== */
#screenLoading .screen-inner {
    justify-content: center;
    gap: clamp(20px, 3vh, 32px);
}

#screenLoading.screen-reconnecting #loadingSubtitle {
    color: var(--cyan, #3ad5f7);
}

#screenLoading.screen-reconnecting .ripple-core {
    animation-duration: 2s;
}

.loading-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.ripple-wrap {
    position: relative;
    width: clamp(200px, 25vw, 484px);
    height: clamp(200px, 25vw, 484px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ripple-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(58, 213, 247, 0.25);
    animation: ripple-pulse 3s ease-in-out infinite;
}

.ripple-ring:nth-child(1) { width: 54%; height: 54%; animation-delay: 0s; }
.ripple-ring:nth-child(2) { width: 69%; height: 69%; animation-delay: 0.4s; }
.ripple-ring:nth-child(3) { width: 85%; height: 85%; animation-delay: 0.8s; }
.ripple-ring:nth-child(4) { width: 100%; height: 100%; animation-delay: 1.2s; border-color: rgba(58, 213, 247, 0.15); }

@keyframes ripple-pulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.02); }
}

.ripple-core {
    position: relative;
    width: clamp(100px, 10vw, 186px);
    height: clamp(100px, 10vw, 186px);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(58, 213, 247, 0.25) 0%, rgba(58, 213, 247, 0.05) 70%);
    box-shadow: 0 0 40px rgba(58, 213, 247, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-cloud-icon {
    width: clamp(80px, 8vw, 120px);
    height: auto;
}

.loading-text {
    text-align: center;
    max-width: 220px;
}

#loadingTitle {
    font-size: 18px;
    font-weight: 600;
    color: var(--cyan);
    margin-bottom: 6px;
}

#loadingSubtitle {
    font-size: 12px;
    color: var(--cyan-dim);
    opacity: 0.8;
}

.progress-card {
    width: 100%;
    max-width: 764px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 26px 30px 30px;
    background: linear-gradient(135deg, rgba(48, 68, 90, 0.15) 0%, rgba(10, 19, 38, 0.6) 100%);
    position: relative;
    overflow: hidden;
}

.progress-card::before {
    content: '';
    position: absolute;
    width: 162px;
    height: 159px;
    right: 15%;
    top: -40px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(78, 213, 243, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.progress-card::after {
    content: '';
    position: absolute;
    width: 162px;
    height: 159px;
    left: 12%;
    bottom: -50px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(78, 213, 243, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

.progress-card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}

.progress-card-label {
    font-size: 12px;
    color: var(--text-muted);
}

#progressPercent {
    font-size: 24px;
    font-weight: 700;
    color: var(--cyan-bright);
    font-variant-numeric: tabular-nums;
    font-family: "DIN Alternate", "Segoe UI", sans-serif;
}

.progress-bar-wrap {
    height: 6px;
    background: var(--track);
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 28px;
    position: relative;
    z-index: 1;
}

#progressBar {
    width: 0%;
    height: 100%;
    background: var(--cyan-bright);
    border-radius: 15px;
    transition: width 0.35s ease;
}

.milestone-track {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    z-index: 1;
}

.milestone-track::before,
.milestone-track::after {
    content: '';
    position: absolute;
    top: 15px;
    height: 2px;
    width: calc(33.33% - 30px);
    background: var(--track);
    z-index: 0;
}

.milestone-track::before {
    left: calc(16.67% + 15px);
}

.milestone-track::after {
    left: calc(50% + 15px);
}

.milestone-track.line-active-1::before {
    background: var(--cyan-bright);
}

.milestone-track.line-active-2::before,
.milestone-track.line-active-2::after {
    background: var(--cyan-bright);
}

.milestone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.milestone-icon {
    position: relative;
    z-index: 1;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--track);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
}

.milestone-icon img,
.milestone-icon svg {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

.milestone-img--muted {
    opacity: 0.55;
}

.milestone-label {
    font-size: 12px;
    text-align: center;
    line-height: 1.4;
    max-width: 100px;
    color: var(--text-dim);
    transition: color 0.3s;
}

.milestone.step-done .milestone-icon {
    border-color: var(--cyan-bright);
    background: rgba(78, 213, 243, 0.12);
}

.milestone.step-done .milestone-label {
    color: var(--cyan-bright);
}

.milestone.step-active .milestone-icon {
    border-color: var(--cyan);
    box-shadow: 0 0 16px rgba(58, 213, 247, 0.45);
    background: rgba(58, 213, 247, 0.15);
}

.milestone.step-active .milestone-label {
    color: var(--cyan);
    font-weight: 600;
}

.milestone.step-failed .milestone-icon {
    border-color: var(--fail);
    box-shadow: 0 0 12px rgba(248, 113, 113, 0.35);
    background: rgba(248, 113, 113, 0.12);
}

.milestone.step-failed .milestone-label {
    color: var(--fail);
    font-weight: 600;
}

#stepAuthFailReason {
    display: none;
    font-size: 11px;
    color: var(--fail);
    opacity: 0.85;
    margin-top: -4px;
}

#stepAuthFailReason.visible {
    display: block;
}

.loading-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 764px;
}

#loadingError {
    display: none;
    width: 100%;
    padding: 10px 16px;
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: 8px;
    font-size: 12px;
    color: var(--fail);
    text-align: center;
}

#loadingError.visible {
    display: block;
}

#btnRetry {
    display: none;
    padding: 10px 32px;
    font-size: 14px;
    font-weight: 500;
    color: var(--btn-text);
    background: linear-gradient(-90deg, #0aa3be 0%, #4cd4f2 100%);
    border: none;
    border-radius: 73px;
    cursor: pointer;
    transition: opacity 0.2s;
}

#btnRetry.visible {
    display: inline-block;
}

#btnRetry:hover {
    opacity: 0.9;
}

/* ===== Experience ===== */
#screenExperience .screen-inner,
#screenExperience .experience-layout {
    justify-content: center;
    padding-top: clamp(16px, 2vh, 30px);
}

.experience-layout {
    min-height: 100dvh;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    --trial-panel-height: 120px;
    --experience-h-pad: clamp(16px, 3vw, 32px);
    --experience-v-pad: clamp(16px, 2vh, 30px);
}

.trial-panel {
    position: fixed;
    top: var(--experience-v-pad);
    right: var(--experience-h-pad);
    z-index: 20;
    width: 202px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    pointer-events: auto;
}

#trialTimer {
    font-size: 18px;
    font-weight: 600;
    color: var(--cyan);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    height: 40px;
    padding: 0 16px;
    font-size: 16px;
    font-family: inherit;
    color: var(--btn-text);
    background: linear-gradient(-90deg, #0aa3be 0%, #4cd4f2 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.btn-download:hover:not(:disabled) {
    opacity: 0.92;
}

.btn-download:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-download svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

#hangupButton {
    display: none;
    position: absolute;
    top: clamp(16px, 2vh, 30px);
    left: clamp(16px, 3vw, 30px);
    z-index: 20;
    padding: 6px 14px;
    font-size: 12px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    cursor: pointer;
}

#hangupButton.dev-visible {
    display: block;
}

.experience-body {
    display: flex;
    flex: 1;
    min-height: 0;
    width: 100%;
    gap: 24px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    padding: 8px var(--experience-h-pad) var(--experience-v-pad);
    box-sizing: border-box;
}

.phone-frame {
    position: relative;
    flex-shrink: 0;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    background: #000;
    border: 1px solid var(--border-light);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 0 110px 8px rgba(58, 213, 247, 0.1);
}

.phone-frame.landscape {
    max-width: calc(100vw - var(--experience-h-pad) * 2);
}

#remoteVideo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    touch-action: none;
    user-select: none;
    cursor: default;
}

#videoBorderCanvas {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
}

#videoResolution {
    position: absolute;
    top: 8px;
    left: 8px;
    color: var(--cyan-bright);
    font-family: monospace;
    font-size: 11px;
    z-index: 10;
    pointer-events: none;
    text-shadow: 1px 1px 0 #000;
    opacity: 0.7;
}

.control-panel {
    width: 220px;
    display: none;
    flex-direction: column;
    gap: 16px;
}

.control-panel.dev-visible {
    display: flex;
}

.control-group {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 14px;
}

.control-group-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.control-row:last-child { margin-bottom: 0; }

.ctrl-btn {
    padding: 7px 12px;
    font-size: 12px;
    color: var(--cyan-dim);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.ctrl-btn.danger {
    color: var(--fail);
    border-color: rgba(248, 113, 113, 0.3);
    background: rgba(248, 113, 113, 0.12);
}

.ctrl-input {
    flex: 1;
    min-width: 80px;
    padding: 6px 8px;
    font-size: 12px;
    color: var(--cyan-dim);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    outline: none;
}

/* ===== Ended ===== */
#screenEnded .screen-inner {
    justify-content: center;
    gap: 28px;
    padding-bottom: 48px;
}

.ended-icon {
    width: clamp(120px, 9vw, 170px);
    height: clamp(120px, 9vw, 170px);
    border-radius: 50%;
    background: #11293B;
    box-shadow: 0 0 60px rgba(58, 213, 247, 0.15);
    border: 1px solid #3AD5F7;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ended-icon img,
.ended-icon svg {
    width: clamp(60px, 6vw, 99px);
    height: auto;
    object-fit: contain;
}

.ended-headline {
    text-align: center;
    max-width: 220px;
}

.ended-headline h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--cyan);
    margin-bottom: 12px;
}

.ended-headline p {
    font-size: 12px;
    color: var(--cyan-dim);
    opacity: 0.8;
}

.ended-features {
    width: 100%;
    max-width: 418px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 24px 24px;
    background: url('../image/overTipBack.svg') no-repeat center / 100% 100%;
    position: relative;
    overflow: hidden;
}

.ended-features-title {
    font-size: 16px;
    font-weight: 600;
    color: #abd8e0;
    text-align: center;
    margin-bottom: 24px;
}

.ended-features-grid {
    display: flex;
    justify-content: center;
    gap: clamp(24px, 8vw, 53px);
}

.feature-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.feature-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(78, 213, 243, 0.1);
    border: 1px solid rgba(78, 213, 243, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
}

.feature-icon img,
.feature-icon svg {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.feature-label {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.btn-download--large {
    width: auto;
    min-width: 290px;
    height: 48px;
    padding: 0 28px;
    border-radius: 73px;
    font-size: 16px;
    font-weight: 600;
}

.ended-footnote {
    font-size: 12px;
    color: var(--cyan-dim);
    opacity: 0.8;
    text-align: center;
}

/* ===== Dev Debug Bar ===== */
#devDebugBar {
    display: none;
    position: fixed;
    bottom: 6px;
    left: 8px;
    font-size: 10px;
    line-height: 1.5;
    color: var(--text-dim);
    font-family: monospace;
    z-index: 9999;
    pointer-events: none;
    max-width: calc(100vw - 16px);
    word-break: break-all;
}

#devDebugBar.visible {
    display: block;
}

@media (max-width: 768px) {
    .experience-layout {
        --trial-panel-height: 72px;
    }

    .trial-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: none;
        margin-bottom: 0;
        border-radius: 16px 16px 0 0;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    }

    #trialTimer {
        font-size: 14px;
    }

    .trial-panel .btn-download {
        width: auto;
        min-width: 120px;
        height: 36px;
        font-size: 14px;
        flex-shrink: 0;
    }

    #screenExperience .experience-layout {
        flex-direction: column;
        padding-bottom: 0;
    }

    .experience-body {
        padding-right: var(--experience-h-pad);
        padding-bottom: var(--trial-panel-height);
        align-items: center;
        justify-content: center;
    }

    .phone-frame.landscape {
        max-width: 100%;
    }
}
