/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-primary: #6C63FF;
    --color-primary-dark: #5B54D9;
    --color-secondary: #FF6B6B;
    --color-background: #F0F2F5;
    --color-card: #FFFFFF;
    --color-text: #2D3436;
    --color-text-light: #636E72;
    --color-success: #00B894;
    --color-error: #E74C3C;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --radius: 16px;
    --radius-sm: 8px;
    --transition: 0.3s ease;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--color-background);
    color: var(--color-text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding: 24px 0;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--color-text-light);
    font-size: 0.95rem;
}

/* Screens */
.screen {
    display: none;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.screen.active {
    display: flex;
}

/* Cards */
.card {
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

/* Input screen */
#screen-input .card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#screen-input label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    text-align: center;
}

#birthdate {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    border: 2px solid #E0E0E0;
    border-radius: var(--radius-sm);
    background: var(--color-card);
    color: var(--color-text);
    transition: border-color var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

#birthdate:focus {
    outline: none;
    border-color: var(--color-primary);
}

.error-message {
    color: var(--color-error);
    font-size: 0.9rem;
    text-align: center;
    min-height: 1.5em;
}

/* Buttons */
button {
    min-height: 48px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    padding: 16px 24px;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

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

.btn-secondary {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
    padding: 14px 22px;
}

.btn-secondary:hover {
    background: rgba(108, 99, 255, 0.1);
}

/* Age display */
.age-card h2 {
    text-align: center;
    font-size: 1.1rem;
    color: var(--color-text-light);
    margin-bottom: 16px;
}

.age-display {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.age-item {
    text-align: center;
    padding: 12px;
    background: var(--color-background);
    border-radius: var(--radius-sm);
}

.age-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.2;
}

.age-label {
    font-size: 0.85rem;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Totals card */
.totals-card h3 {
    font-size: 1rem;
    color: var(--color-text-light);
    margin-bottom: 12px;
}

.totals-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.totals-list li {
    font-size: 0.95rem;
    color: var(--color-text);
    padding: 8px;
    background: var(--color-background);
    border-radius: var(--radius-sm);
}

.totals-list span {
    font-weight: 700;
    color: var(--color-primary);
}

/* Fun facts */
.funfacts-card h3 {
    font-size: 1rem;
    color: var(--color-text-light);
    margin-bottom: 16px;
    text-align: center;
}

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

.funfact-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 8px;
    background: linear-gradient(135deg, #F8F9FA 0%, #E9ECEF 100%);
    border-radius: var(--radius-sm);
    text-align: center;
}

.funfact-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.funfact-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-secondary);
}

.funfact-label {
    font-size: 0.75rem;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Actions */
.actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

/* Footer */
footer {
    text-align: center;
    padding: 24px 0;
    margin-top: auto;
}

footer p {
    font-size: 0.85rem;
    color: var(--color-text-light);
}

footer a {
    color: var(--color-primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.screen.active .card {
    animation: fadeIn 0.4s ease forwards;
}

.screen.active .card:nth-child(2) {
    animation-delay: 0.1s;
}

.screen.active .card:nth-child(3) {
    animation-delay: 0.2s;
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.age-number.animate {
    animation: countUp 0.5s ease forwards;
}

/* Tablet and up */
@media (min-width: 768px) {
    .container {
        padding: 24px;
    }

    header h1 {
        font-size: 2rem;
    }

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

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

    .actions {
        flex-direction: row;
    }

    .actions button {
        flex: 1;
    }
}
