/* ============================================
   頭痛よほう - Design System & Styles v2.1
   ============================================ */

/* --- CSS Variables (Default Theme: Sky Blue) --- */
:root {
    --primary-50: #E0F2FE;
    --primary-100: #BAE6FD;
    --primary-200: #7DD3FC;
    --primary-300: #38BDF8;
    --primary-400: #0EA5E9;
    --primary-500: #0284C7;
    --primary-600: #0369A1;
    --primary-700: #075985;
    --primary-800: #0C4A6E;
    --primary-900: #082F49;

    --white: #FFFFFF;
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;

    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --orange: #F97316;

    --font: 'M PLUS Rounded 1c', 'Zen Maru Gothic', 'Kosugi Maru', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius-sm: 8px;
    --radius: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    --nav-height: 72px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: linear-gradient(180deg, var(--primary-50) 0%, var(--white) 30%, var(--primary-50) 100%);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    font-family: var(--font);
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
    -webkit-tap-highlight-color: transparent;
}

input, select {
    font-family: var(--font);
    outline: none;
}

/* --- Screen System --- */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 1;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    z-index: 10;
}

.screen.exit {
    opacity: 0;
    transform: translateY(-20px);
    visibility: hidden;
}

/* --- Welcome Screen --- */
#screen-welcome {
    background: linear-gradient(160deg, var(--primary-500) 0%, var(--primary-700) 50%, var(--primary-900) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: hidden;
}

#screen-welcome::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
    animation: float-orb 8s ease-in-out infinite;
}

#screen-welcome::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -20%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
    border-radius: 50%;
    animation: float-orb 6s ease-in-out infinite reverse;
}

.welcome-content {
    text-align: center;
    position: relative;
    z-index: 2;
    animation: fadeInUp 0.8s ease-out;
}

.mascot-welcome {
    width: 180px;
    height: 180px;
    margin: 0 auto 28px;
    animation: bounce-gentle 3s ease-in-out infinite;
    filter: drop-shadow(0 12px 24px rgba(0,0,0,0.2));
    border-radius: 50%;
    object-fit: contain;
}

.welcome-content h1 {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--white);
    margin-bottom: 8px;
    letter-spacing: 0.04em;
}

.welcome-subtitle {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.8);
    margin-bottom: 8px;
    font-weight: 400;
}

.welcome-mascot-name {
    display: inline-block;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 6px 20px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    color: rgba(255,255,255,0.85);
    margin-bottom: 40px;
    border: 1px solid rgba(255,255,255,0.15);
}

#btn-start {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--white);
    color: var(--primary-700);
    font-size: 1.1rem;
    font-weight: 700;
    padding: 16px 48px;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg), 0 8px 24px -4px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

#btn-start::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.04), transparent);
    transition: left 0.5s ease;
}

#btn-start:hover::after,
#btn-start:active::after {
    left: 100%;
}

#btn-start:active {
    transform: scale(0.96);
}

/* --- Onboarding Screen --- */
#screen-onboarding {
    background: var(--white);
    display: flex;
    flex-direction: column;
    padding: calc(var(--safe-top) + 40px) 24px calc(var(--safe-bottom) + 24px);
}

.onboarding-progress {
    display: flex;
    gap: 8px;
    margin-bottom: 40px;
    padding: 0 20px;
}

.progress-dot {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--gray-200);
    transition: background 0.4s ease;
}

.progress-dot.active {
    background: var(--primary-500);
}

.progress-dot.done {
    background: var(--primary-300);
}

.onboarding-step {
    flex: 1;
    display: none;
    flex-direction: column;
    animation: fadeInUp 0.4s ease-out;
    padding: 0 4px;
}

.onboarding-step.active {
    display: flex;
}

.onboarding-step h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 8px;
    line-height: 1.3;
}

.onboarding-step .step-desc {
    font-size: 0.9rem;
    color: var(--gray-500);
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--gray-50);
    color: var(--gray-800);
    transition: all 0.3s ease;
}

.form-group input:focus {
    border-color: var(--primary-400);
    background: var(--white);
    box-shadow: 0 0 0 4px var(--primary-50);
}

.form-group input::placeholder {
    color: var(--gray-400);
}

/* Gender Buttons */
.gender-buttons {
    display: flex;
    gap: 10px;
}

.gender-btn {
    flex: 1;
    padding: 14px 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    transition: all 0.3s ease;
}

.gender-btn.selected {
    color: var(--primary-700);
    background: var(--primary-50);
    border-color: var(--primary-400);
    box-shadow: 0 0 0 4px var(--primary-50);
}

.gender-btn:active {
    transform: scale(0.97);
}

/* Region Select */
.form-group select {
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--gray-50);
    color: var(--gray-800);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    transition: all 0.3s ease;
}

.form-group select:focus {
    border-color: var(--primary-400);
    background-color: var(--white);
    box-shadow: 0 0 0 4px var(--primary-50);
}

/* Primary Button */
.btn-primary {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
    border-radius: var(--radius-full);
    box-shadow: 0 8px 24px -4px var(--primary-300);
    transition: all 0.3s ease;
    margin-top: auto;
}

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

.btn-primary:not(:disabled):active {
    transform: scale(0.97);
}

/* --- Dashboard Screen --- */
#screen-dashboard {
    background: linear-gradient(180deg, var(--primary-600) 0%, var(--primary-700) 380px, var(--primary-50) 380px, var(--white) 100%);
    padding-top: calc(var(--safe-top) + 20px);
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 24px);
}

.dashboard-header {
    padding: 0 24px 16px;
    color: var(--white);
}

.greeting {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 2px;
}

.date-display {
    font-size: 0.82rem;
    color: rgba(255,255,255,0.75);
    font-weight: 400;
}

/* Risk Section */
.risk-section {
    display: flex;
    justify-content: center;
    padding: 8px 24px 24px;
    position: relative;
}

.risk-gauge-container {
    position: relative;
    width: 220px;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#risk-gauge {
    position: absolute;
    top: 0;
    left: 0;
}

.risk-center {
    text-align: center;
    z-index: 2;
}

.risk-value {
    font-size: 3rem;
    font-weight: 900;
    color: var(--white);
    line-height: 1;
    text-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.risk-unit {
    font-size: 1.2rem;
    font-weight: 400;
    opacity: 0.8;
}

.risk-label {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.75);
    font-weight: 500;
    margin-top: 4px;
}

/* Mascot Message */
.mascot-section {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 0 24px;
    margin-top: -8px;
    margin-bottom: 24px;
}

.mascot-dashboard {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    animation: bounce-gentle 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
    border-radius: 50%;
    object-fit: contain;
}

.speech-bubble {
    background: var(--white);
    border-radius: var(--radius);
    border-top-left-radius: 4px;
    padding: 14px 18px;
    font-size: 0.9rem;
    color: var(--gray-700);
    line-height: 1.6;
    box-shadow: var(--shadow);
    position: relative;
    flex: 1;
    border-left: 4px solid var(--primary-400);
}

.speech-bubble::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 16px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid var(--primary-400);
}

/* --- 3-Day Migraine Probability Section --- */
.headache-forecast-section {
    padding: 0 24px;
    margin-bottom: 28px;
}

.headache-forecast-section h3 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--gray-800);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.headache-forecast-cards {
    display: flex;
    gap: 12px;
}

.headache-forecast-card {
    flex: 1;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 20px 14px 18px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 2px solid var(--primary-100);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.headache-forecast-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: linear-gradient(90deg, var(--primary-400), var(--primary-600));
}

.headache-forecast-card:active {
    transform: scale(0.97);
}

.headache-day {
    font-size: 0.82rem;
    color: var(--primary-700);
    font-weight: 700;
    margin-bottom: 14px;
    letter-spacing: 0.02em;
}

.migraine-main-container {
    margin-bottom: 6px;
}

.migraine-main-label {
    font-size: 0.65rem;
    color: var(--gray-400);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.migraine-main-value {
    font-size: 2.2rem;
    font-weight: 900;
    line-height: 1;
}

.migraine-main-unit {
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.7;
}

.migraine-main-value.risk-low {
    color: #059669;
    background: none;
}
.migraine-main-value.risk-medium {
    color: #D97706;
    background: none;
}
.migraine-main-value.risk-high {
    color: #EA580C;
    background: none;
}
.migraine-main-value.risk-very-high {
    color: #DC2626;
    background: none;
}

.migraine-status {
    font-size: 0.7rem;
    font-weight: 700;
    margin-top: 8px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    display: inline-block;
}

.migraine-status.status-safe {
    background: #D1FAE5;
    color: #065F46;
}
.migraine-status.status-caution {
    background: #FEF3C7;
    color: #92400E;
}
.migraine-status.status-warning {
    background: #FED7AA;
    color: #9A3412;
}
.migraine-status.status-danger {
    background: #FEE2E2;
    color: #991B1B;
}

/* Risk badge classes (general) */
.risk-low {
    background: var(--success-light);
    color: #065F46;
}
.risk-medium {
    background: var(--warning-light);
    color: #92400E;
}
.risk-high {
    background: #FED7AA;
    color: #9A3412;
}
.risk-very-high {
    background: var(--danger-light);
    color: #991B1B;
}

/* Tips Section */
.tips-section {
    padding: 0 24px;
    margin-bottom: 28px;
}

.tips-section h3 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--gray-800);
    margin-bottom: 14px;
}

.tips-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tip-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--white);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--primary-100);
    border-left: 4px solid var(--primary-300);
}

.tip-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.tip-text {
    font-size: 0.85rem;
    color: var(--gray-600);
    line-height: 1.5;
}

/* --- Settings Screen --- */
#screen-settings {
    background: linear-gradient(180deg, var(--primary-50) 0%, var(--gray-50) 30%, var(--gray-50) 100%);
    padding-top: calc(var(--safe-top) + 20px);
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 24px);
}

.settings-header {
    padding: 0 24px 24px;
}

.settings-header h2 {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--gray-900);
}

.settings-section {
    padding: 0 24px;
    margin-bottom: 24px;
}

.settings-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-600);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
    padding-left: 4px;
}

.settings-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--primary-100);
    overflow: hidden;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.2s ease;
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item:active {
    background: var(--primary-50);
}

.settings-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-item-icon {
    font-size: 1.2rem;
}

.settings-item-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-700);
}

.settings-item-value {
    font-size: 0.85rem;
    color: var(--primary-500);
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

/* Theme Picker in Settings */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    padding: 8px 0;
}

.theme-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.theme-swatch:hover,
.theme-swatch:active {
    transform: scale(1.15);
}

.theme-swatch.active {
    border-color: var(--gray-800);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.15), 0 4px 12px rgba(0,0,0,0.2);
    transform: scale(1.1);
}

.theme-swatch.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.85rem;
    font-weight: 900;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.theme-name-display {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-600);
    margin-top: 14px;
    padding: 10px;
    background: var(--primary-50);
    border-radius: var(--radius);
}

.settings-mascot {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 24px;
    text-align: center;
}

.settings-mascot img {
    width: 80px;
    height: 80px;
    margin-bottom: 12px;
    animation: bounce-gentle 3s ease-in-out infinite;
    border-radius: 50%;
    object-fit: contain;
}

.settings-mascot-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.settings-mascot-desc {
    font-size: 0.8rem;
    color: var(--gray-400);
}

.settings-version {
    text-align: center;
    padding: 16px;
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* Edit Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 24px 24px calc(var(--safe-bottom) + 24px);
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin: 0 auto 20px;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.btn-secondary {
    flex: 1;
    padding: 14px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-100);
    border-radius: var(--radius-full);
    transition: all 0.2s ease;
}

.btn-secondary:active {
    background: var(--gray-200);
}

.modal-buttons .btn-primary {
    flex: 1;
    margin-top: 0;
}

/* --- Bottom Navigation --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--gray-200);
    display: none;
    align-items: center;
    justify-content: space-around;
    z-index: 50;
}

.bottom-nav.visible {
    display: flex;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 24px;
    min-width: 80px;
    transition: all 0.2s ease;
    position: relative;
}

.nav-icon {
    font-size: 1.5rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-400);
    transition: color 0.2s ease;
}

.nav-item.active .nav-label {
    color: var(--primary-600);
}

.nav-item.active .nav-icon {
    transform: scale(1.15);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-400), var(--primary-600));
    border-radius: 0 0 3px 3px;
}

.nav-item:active {
    transform: scale(0.9);
}

/* --- Loading Overlay --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--primary-100);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

.loading-text {
    font-size: 0.9rem;
    color: var(--gray-500);
    font-weight: 500;
}

/* --- Refresh Button --- */
.refresh-btn {
    position: absolute;
    top: calc(var(--safe-top) + 20px);
    right: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--white);
    z-index: 20;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.refresh-btn:active {
    transform: scale(0.9) rotate(180deg);
}

.refresh-btn.spinning {
    animation: spin 0.8s linear infinite;
}

/* --- Animations --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes float-orb {
    0%, 100% {
        transform: translate(0, 0);
    }
    33% {
        transform: translate(20px, -20px);
    }
    66% {
        transform: translate(-10px, 10px);
    }
}

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes pop-in {
    0% {
        opacity: 0;
        transform: scale(0.6);
    }
    70% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Stagger animation for headache cards */
.headache-forecast-card:nth-child(1) { animation: pop-in 0.4s ease-out 0.1s both; }
.headache-forecast-card:nth-child(2) { animation: pop-in 0.4s ease-out 0.2s both; }
.headache-forecast-card:nth-child(3) { animation: pop-in 0.4s ease-out 0.3s both; }

.tip-item:nth-child(1) { animation: fadeInUp 0.4s ease-out 0.1s both; }
.tip-item:nth-child(2) { animation: fadeInUp 0.4s ease-out 0.2s both; }
.tip-item:nth-child(3) { animation: fadeInUp 0.4s ease-out 0.3s both; }

/* --- Responsive --- */
@media (min-width: 480px) {
    .welcome-content h1 {
        font-size: 2.6rem;
    }
    
    .mascot-welcome {
        width: 200px;
        height: 200px;
    }
    
    .risk-gauge-container {
        width: 260px;
        height: 260px;
    }
}

@media (min-width: 768px) {
    body {
        max-width: 480px;
        margin: 0 auto;
        box-shadow: -1px 0 0 var(--gray-200), 1px 0 0 var(--gray-200);
    }
    
    .bottom-nav {
        max-width: 480px;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .modal-content {
        border-radius: var(--radius-xl);
        margin-bottom: 24px;
    }
    
    .loading-overlay,
    .modal-overlay {
        max-width: 480px;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
