:root {
    --bg: #0a0a0b;
    --surface: #141416;
    --surface-2: #1c1c1f;
    --border: #2a2a2e;
    --text: #e8e8ec;
    --text-secondary: #8e8e93;
    --accent: #d4a574;
    --accent-dim: rgba(212, 165, 116, 0.12);
    --green: #34c759;
    --red: #ff453a;
    --yellow: #ffd60a;
    --radius: 14px;
    --radius-sm: 10px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ── Onboarding ── */

.logo {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 6px;
    color: var(--accent);
}

.disclaimer-icon {
    font-size: 36px;
    opacity: 0.7;
}

.ob-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px 0;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
}

.ob-back {
    width: 32px;
    height: 32px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text);
    cursor: pointer;
    transition: opacity 0.2s;
}

.ob-back:active {
    opacity: 0.7;
}

.ob-dots {
    flex: 1;
    display: flex;
    gap: 5px;
}

.ob-dot {
    flex: 1;
    height: 3px;
    border-radius: 2px;
    background: var(--border);
    overflow: hidden;
}

.ob-dot::after {
    content: '';
    display: block;
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.ob-dot.done::after {
    width: 100%;
}

.ob-dot.current::after {
    width: 100%;
}

.ob-skip {
    flex: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 6px 2px;
    cursor: pointer;
}

.ob-skip:active {
    opacity: 0.7;
}

.ob-track {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.ob-slide {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(24px);
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.32s ease;
}

.ob-slide.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.ob-slide.leaving {
    transform: translateX(-24px);
}

.ob-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 8px 24px 24px;
    gap: 14px;
    overflow-y: auto;
}

.ob-body-center {
    align-items: center;
    text-align: center;
}

.ob-eyebrow {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--accent);
    opacity: 0.9;
}

.ob-title {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.3px;
}

.ob-figure {
    font-size: 15px;
}

.ob-num {
    font-size: 64px;
    font-weight: 800;
    line-height: 1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    margin-top: 4px;
}

.ob-text {
    font-size: 15px;
    line-height: 1.55;
    color: var(--text-secondary);
    max-width: 340px;
}

.ob-text-sub {
    font-size: 12.5px;
    opacity: 0.65;
}

/* Halo effect comparison */

.ob-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ob-compare-col {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
}

.ob-compare-good {
    border-color: rgba(212, 165, 116, 0.35);
}

.ob-compare-head {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.ob-compare-good .ob-compare-head {
    color: var(--accent);
}

.ob-compare-row {
    font-size: 14px;
    padding: 5px 0;
    color: var(--text);
}

.ob-strike {
    color: var(--text-secondary);
    opacity: 0.45;
    text-decoration: line-through;
}

/* Metrics list */

.ob-metrics {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ob-metric {
    display: grid;
    grid-template-columns: 84px 1fr;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.ob-metric-bar {
    height: 6px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
}

.ob-metric-bar i {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transform: scaleX(0);
    transform-origin: left;
    animation: obGrow 0.7s ease forwards;
    animation-delay: 0.15s;
}

@keyframes obGrow {
    to { transform: scaleX(1); }
}

/* Scan frame */

.ob-scan-frame {
    position: relative;
    align-self: center;
    width: 100%;
    max-width: 220px;
    aspect-ratio: 1;
    border-radius: 20px;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--accent);
}

.ob-scan-frame span {
    font-size: 12px;
    color: var(--text-secondary);
}

.ob-scan-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--accent);
    opacity: 0.8;
}

.ob-c-tl { top: 10px; left: 10px; border-right: none; border-bottom: none; border-radius: 6px 0 0 0; }
.ob-c-tr { top: 10px; right: 10px; border-left: none; border-bottom: none; border-radius: 0 6px 0 0; }
.ob-c-bl { bottom: 10px; left: 10px; border-right: none; border-top: none; border-radius: 0 0 0 6px; }
.ob-c-br { bottom: 10px; right: 10px; border-left: none; border-top: none; border-radius: 0 0 6px 0; }

.ob-footer {
    padding: 12px 24px 24px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.ob-footer .btn-primary {
    max-width: none;
    margin-top: 0;
}

/* ── Buttons ── */

.btn-primary {
    width: 100%;
    max-width: 320px;
    padding: 16px 24px;
    background: var(--accent);
    color: #0a0a0b;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    margin-top: 12px;
}

.btn-primary:active {
    opacity: 0.85;
    transform: scale(0.98);
}

.btn-secondary {
    width: 100%;
    padding: 14px 24px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
    margin-top: 16px;
}

.btn-secondary:active {
    opacity: 0.8;
}

/* ── Tab Bar ── */

.tab-bar {
    display: flex;
    padding: 8px 16px 0;
    gap: 4px;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.tab {
    flex: 1;
    padding: 12px 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
    padding: 20px 16px 32px;
    animation: fadeIn 0.25s ease;
}

.tab-content.active {
    display: block;
}

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

/* ── Upload ── */

.upload-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 60px;
}

.upload-area {
    width: 100%;
    max-width: 340px;
    aspect-ratio: 1;
    border: 2px dashed var(--border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-area:active {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.upload-icon {
    color: var(--accent);
    opacity: 0.8;
}

.upload-label {
    font-size: 17px;
    font-weight: 600;
}

.upload-hint {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    max-width: 200px;
    line-height: 1.4;
}

/* ── Loading ── */

.loading-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 80px;
    gap: 24px;
}

.loader {
    width: 48px;
    height: 48px;
    border: 3px solid var(--surface-2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 15px;
    color: var(--text-secondary);
}

.loading-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.step {
    font-size: 13px;
    color: var(--text-secondary);
    opacity: 0.4;
    padding-left: 20px;
    position: relative;
    transition: opacity 0.3s, color 0.3s;
}

.step::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.3s;
}

.step.active {
    opacity: 1;
    color: var(--text);
}

.step.active::before {
    background: var(--accent);
}

.step.done {
    opacity: 0.7;
    color: var(--green);
}

.step.done::before {
    background: var(--green);
}

/* ── Results ── */

.results-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.score-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 28px 0 12px;
    gap: 8px;
}

.score-ring {
    position: relative;
    width: 140px;
    height: 140px;
}

.score-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: var(--surface-2);
    stroke-width: 6;
}

.ring-fill {
    fill: none;
    stroke: var(--accent);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 339.292;
    stroke-dashoffset: 339.292;
    transition: stroke-dashoffset 1.2s ease-out, stroke 0.3s;
}

.score-value {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.score-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Sub-scores */

.subscores {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.subscore-item {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.subscore-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.subscore-name {
    font-size: 13px;
    color: var(--text-secondary);
}

.subscore-value {
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.subscore-bar {
    height: 4px;
    background: var(--surface-2);
    border-radius: 2px;
    overflow: hidden;
}

.subscore-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.8s ease-out;
    width: 0;
}

/* Section cards */

.section-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px;
}

.section-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 14px;
}

.section-card ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-card li {
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-secondary);
    padding-left: 16px;
    position: relative;
}

.section-card li::before {
    content: '+';
    position: absolute;
    left: 0;
    color: var(--green);
    font-weight: 600;
}

/* Recommendations */

.rec-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.rec-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.rec-item:first-child {
    padding-top: 0;
}

.rec-area {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.rec-tip {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.45;
}

.rec-method {
    display: inline-block;
    margin-top: 6px;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--accent-dim);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Referrals ── */

.referral-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
}

.referral-card h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.referral-card > p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.referral-stats {
    margin-bottom: 24px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-size: 40px;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ── Leaderboard ── */

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lb-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    gap: 14px;
}

.lb-rank {
    font-size: 16px;
    font-weight: 700;
    min-width: 28px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.lb-item:nth-child(1) .lb-rank { color: #ffd700; }
.lb-item:nth-child(2) .lb-rank { color: #c0c0c0; }
.lb-item:nth-child(3) .lb-rank { color: #cd7f32; }

.lb-name {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-score {
    font-size: 17px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

/* ── Utilities ── */

.hidden {
    display: none !important;
}

/* Color helpers for scores */
.score-low { color: var(--red); }
.score-mid { color: var(--yellow); }
.score-high { color: var(--green); }

.fill-low { background: var(--red); }
.fill-mid { background: var(--yellow); }
.fill-high { background: var(--green); }

/* Safe area padding for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .tab-content {
        padding-bottom: calc(32px + env(safe-area-inset-bottom));
    }
}
