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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --accent: #a855f7;
    --card-bg: #ffffff;
    --surface: #f8fafc;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: rgba(15, 23, 42, 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-x: hidden;
}

/* Colorful Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(168, 85, 247, 0.15) 0%, transparent 50%);
    animation: backgroundShift 15s ease infinite;
    z-index: -1;
}

@keyframes backgroundShift {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.container {
    width: 100%;
    max-width: 550px;
    position: relative;
    margin: 0 auto;
}

.section {
    display: none;
    animation: fadeIn 0.6s ease forwards;
}

.section.active {
    display: block;
}

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

.card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 48px 40px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.15),
        0 1px 3px rgba(0, 0, 0, 0.1);
    border: none;
}

/* Input Section */
.title {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 16px;
    color: var(--text);
    letter-spacing: -0.02em;
}

.emoji {
    display: inline-block;
    animation: bounce 2s ease-in-out infinite;
}

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

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 40px;
    font-size: 1.1rem;
    line-height: 1.6;
}

.input-group {
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.input-group input {
    width: 140px;
    padding: 20px 24px;
    font-size: 2.5rem;
    border: 2px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    transition: all 0.3s ease;
    font-weight: 700;
    text-align: center;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
    transform: scale(1.05);
}

.input-label-inline {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
}

.btn-primary {
    width: 100%;
    padding: 18px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

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

.btn-icon {
    font-size: 1.5rem;
    transition: transform 0.3s ease;
}

.btn-primary:hover .btn-icon {
    transform: translateX(5px);
}

/* Results Section */
.results-card {
    position: relative;
}

.btn-back {
    position: absolute;
    top: 20px;
    left: 20px;
    padding: 10px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-back:hover {
    background: var(--border);
    color: var(--text);
    transform: translateX(-5px);
}

.result-header {
    text-align: center;
    margin-bottom: 40px;
    padding-top: 40px;
}

.result-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.stat-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 48px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.stat-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    border: 1px solid var(--border);
    animation: statCardPop 0.6s ease forwards;
    opacity: 0;
    transform: scale(0.8);
}

.stat-card:nth-child(1) {
    animation-delay: 0.2s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.4s;
}

@keyframes statCardPop {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.stat-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.stat-value {
    font-size: 3rem;
    font-weight: 800;
    color: var(--danger);
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

/* Progress Bar */
.progress-container {
    margin-bottom: 40px;
    animation: slideIn 0.6s ease 0.6s forwards;
    opacity: 0;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.progress-bar {
    height: 12px;
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--danger) 0%, var(--warning) 50%, var(--success) 100%);
    border-radius: 12px;
    transition: width 2s cubic-bezier(0.65, 0, 0.35, 1);
    width: 0;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Comparison Section */
.comparison-section {
    margin-bottom: 48px;
    animation: slideIn 0.6s ease 0.8s forwards;
    opacity: 0;
}

.comparison-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
    text-align: center;
    color: var(--text);
}

.percentile-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    margin-bottom: 32px;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.25);
}

.percentile-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.percentile-value {
    font-size: 4rem;
    font-weight: 800;
    color: white;
    margin-bottom: 8px;
    line-height: 1;
}

.percentile-sublabel {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    font-weight: 500;
}

.chart-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    overflow: visible;
}

.chart-header {
    margin-bottom: 24px;
    text-align: center;
}

.chart-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Donut Chart */
.donut-chart-wrapper {
    position: relative;
    max-width: 280px;
    margin: 0 auto;
}

.donut-chart {
    width: 100%;
    height: auto;
    transform: rotate(-90deg);
}

.donut-background {
    fill: none;
    stroke: var(--border);
    stroke-width: 20;
}

.donut-segment {
    fill: none;
    stroke: url(#donut-gradient);
    stroke-width: 20;
    stroke-linecap: round;
    stroke-dasharray: 502.65;
    stroke-dashoffset: 502.65;
    transition: stroke-dashoffset 2s cubic-bezier(0.65, 0, 0.35, 1);
}

.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.donut-center-value {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 4px;
}

.donut-center-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Radial Bars */
.radial-bars {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    gap: 20px;
    padding: 30px 10px;
    min-height: 220px;
    overflow: visible;
}

.radial-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    flex: 0 1 auto;
}

.radial-circle {
    width: 70px;
    height: 70px;
    flex-shrink: 0;
    border-radius: 50%;
    background: conic-gradient(
        var(--primary) 0deg,
        var(--accent) var(--angle, 0deg),
        var(--border) var(--angle, 0deg)
    );
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.8s cubic-bezier(0.65, 0, 0.35, 1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.radial-circle::before {
    content: '';
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--surface);
    position: absolute;
}

.radial-bar.highlight .radial-circle {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    transform: scale(1.15);
}

.radial-value {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text);
    z-index: 1;
}

.radial-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-align: center;
    word-break: keep-all;
    white-space: nowrap;
}

/* Wave Chart */
.wave-chart {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.wave-item {
    display: grid;
    grid-template-columns: 100px 1fr 60px;
    align-items: center;
    gap: 16px;
}

.wave-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.wave-item.highlight .wave-label {
    color: var(--primary);
    font-weight: 700;
}

.wave-bar-container {
    position: relative;
    height: 40px;
    background: var(--border);
    border-radius: 20px;
    overflow: hidden;
}

.wave-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--text-secondary) 0%, var(--border) 100%);
    border-radius: 20px;
    width: 0;
    transition: width 1.5s cubic-bezier(0.65, 0, 0.35, 1);
    position: relative;
    overflow: hidden;
}

.wave-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: wave 2s infinite;
}

@keyframes wave {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.wave-bar.you {
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.wave-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
    text-align: right;
}

/* Achievements */
.achievements {
    margin-bottom: 32px;
    animation: slideIn 0.6s ease 1.2s forwards;
    opacity: 0;
}

.achievements-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
    text-align: center;
    color: var(--text);
}

.achievement-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.achievement-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 16px;
    animation: achievementPop 0.5s ease forwards;
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.2s ease;
}

.achievement-item:hover {
    background: var(--border);
    transform: translateX(4px);
}

@keyframes achievementPop {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.achievement-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.achievement-text {
    flex: 1;
    font-size: 1.05rem;
    line-height: 1.5;
}

.achievement-number {
    font-weight: 800;
    color: var(--primary);
}

.achievement-time {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
    padding: 4px 12px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

/* CTA Section */
.cta-section {
    text-align: center;
    padding-top: 32px;
    margin-top: 32px;
    border-top: 1px solid var(--border);
    animation: slideIn 0.6s ease 1s forwards;
    opacity: 0;
}

.cta-text {
    font-size: 1.15rem;
    color: var(--text-secondary);
    margin: 0;
    font-style: italic;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 640px) {
    body {
        padding: 16px;
    }

    .card {
        padding: 28px 20px;
    }

    .title {
        font-size: 1.75rem;
        line-height: 1.2;
    }

    .subtitle {
        font-size: 0.95rem;
        margin-bottom: 32px;
    }

    .input-group {
        margin-bottom: 28px;
    }

    .input-group input {
        width: 120px;
        padding: 18px 20px;
        font-size: 2rem;
    }

    .input-label-inline {
        font-size: 1.1rem;
    }

    .btn-primary {
        padding: 16px 28px;
        font-size: 1rem;
    }

    .stat-container {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .stat-card {
        padding: 20px;
    }

    .stat-value {
        font-size: 2.5rem;
    }

    .btn-back {
        position: static;
        margin-bottom: 20px;
        width: 100%;
    }

    .result-header {
        padding-top: 0;
        margin-bottom: 32px;
    }

    .result-title {
        font-size: 1.5rem;
    }

    .achievements-title {
        font-size: 1.25rem;
    }

    .achievement-item {
        padding: 14px 16px;
        gap: 12px;
    }

    .achievement-icon {
        font-size: 1.75rem;
    }

    .achievement-text {
        font-size: 0.95rem;
    }

    .achievement-time {
        font-size: 0.75rem;
        padding: 3px 8px;
    }

    .achievement-item {
        padding: 14px 16px;
        gap: 12px;
    }

    .cta-text {
        font-size: 1rem;
    }

    .percentile-value {
        font-size: 3rem;
    }

    .donut-chart-wrapper {
        max-width: 220px;
    }

    .donut-center-value {
        font-size: 2rem;
    }

    .radial-bars {
        gap: 12px;
        min-height: 180px;
        padding: 30px 5px;
    }

    .radial-circle {
        width: 55px;
        height: 55px;
    }

    .radial-circle::before {
        width: 42px;
        height: 42px;
    }

    .radial-value {
        font-size: 0.8rem;
    }

    .radial-label {
        font-size: 0.65rem;
    }

    .radial-bar.highlight .radial-circle {
        transform: scale(1.08);
    }

    .wave-item {
        grid-template-columns: 80px 1fr 50px;
        gap: 12px;
    }

    .wave-bar-container {
        height: 32px;
    }

    .wave-label {
        font-size: 0.8rem;
    }

    .wave-value {
        font-size: 0.95rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .input-group input {
        font-size: 2.2rem;
        padding: 22px 24px;
    }

    .btn-primary,
    .btn-secondary {
        padding: 18px 32px;
        min-height: 56px;
    }

    .btn-back {
        min-height: 48px;
        font-size: 1rem;
    }
}
