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

:root {
    --color-good: #22c55e;
    --color-okay: #eab308;
    --color-poor: #ef4444;
    --color-primary: #6366f1;
    --color-primary-dark: #4f46e5;
    --color-bg: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-surface: #ffffff;
    --radius: 16px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

.app {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 24px;
}

/* Header */
header {
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand {
    font-size: 1.75rem;
    line-height: 1;
}

.location-display {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.location-name {
    color: white;
    font-size: 1.125rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.change-location-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.2s;
}

.change-location-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.info-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 0.2s;
    flex-shrink: 0;
}

.info-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Location Panel */
.location-panel {
    background: var(--color-surface);
    border-radius: var(--radius);
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.location-panel-content {
    padding: 16px;
}

.location-search-container {
    position: relative;
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

#locationSearch {
    flex: 1;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.2s;
}

#locationSearch:focus {
    border-color: var(--color-primary);
}

.close-panel-btn {
    width: 44px;
    height: 44px;
    background: #f3f4f6;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1.5rem;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.close-panel-btn:hover {
    background: #e5e7eb;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 52px;
    background: white;
    border: 2px solid var(--color-primary);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
}

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

.search-result-item:hover,
.search-result-item.active {
    background: #f5f3ff;
}

.search-result-name {
    font-weight: 600;
    color: var(--color-text);
}

.search-result-details {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.search-no-results {
    padding: 12px 16px;
    color: var(--color-text-muted);
}

.preset-locations {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
    background: #f3f4f6;
    color: var(--color-primary);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.preset-btn:hover {
    background: #e5e7eb;
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: white;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

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

/* Results Container */
.results {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Hero Score */
.hero-score {
    padding: 32px 24px;
    text-align: center;
    background: linear-gradient(180deg, #fafafa 0%, #ffffff 100%);
}

.hero-score-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.hero-score-value {
    font-size: 5rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -2px;
}

.hero-score-label {
    font-size: 1.25rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hero-score-value.score-good,
.hero-score-label.score-good { color: var(--color-good); }
.hero-score-value.score-okay,
.hero-score-label.score-okay { color: var(--color-okay); }
.hero-score-value.score-poor,
.hero-score-label.score-poor { color: var(--color-poor); }

.hero-date {
    font-size: 1rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.hero-hourly-bar {
    margin-top: 16px;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}

.hero-hourly-bar .hourly-bar {
    gap: 2px;
    height: 12px;
}

.hero-hourly-bar .hourly-bar-segment {
    padding: 0;
    border-radius: 2px;
    height: 100%;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
}

.hero-hourly-bar .hourly-bar-segment:hover {
    transform: scaleY(1.3);
    opacity: 0.85;
}

.hourly-bar-markers {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.65rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.hourly-bar-markers span:nth-child(2) {
    text-align: center;
}

.hourly-bar-markers span:last-child {
    text-align: right;
}

/* Day Selector */
.day-selector-wrapper {
    padding: 0 16px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
}

.day-selector {
    display: flex;
    gap: 8px;
    padding: 12px 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.day-selector::-webkit-scrollbar {
    display: none;
}

.day-selector-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 6px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 0;
}

.day-selector-btn:hover {
    border-color: #d1d5db;
}

.day-selector-btn.active {
    border-color: var(--color-primary);
    background: #f5f3ff;
}

.day-selector-weekday {
    font-size: 0.65rem;
    color: var(--color-text-muted);
    font-weight: 500;
    text-transform: uppercase;
}

.day-selector-btn.active .day-selector-weekday {
    color: var(--color-primary);
}

.day-selector-date {
    font-size: 0.85rem;
    color: var(--color-text);
    font-weight: 600;
}

.day-selector-btn.active .day-selector-date {
    color: var(--color-primary);
}

.day-selector-score {
    font-size: 1.1rem;
    font-weight: 700;
}

.day-selector-score.score-good { color: var(--color-good); }
.day-selector-score.score-okay { color: var(--color-okay); }
.day-selector-score.score-poor { color: var(--color-poor); }

/* Hourly Progress Bar in Day Pills */
.hourly-bar {
    display: flex;
    width: 100%;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 6px;
    gap: 2px;
}

.hourly-bar-segment {
    flex: 1;
    min-width: 0;
    padding: 2px 0;
    text-align: center;
    border-radius: 3px;
}

.hourly-bar-label {
    font-size: 0.55rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
}

.score-bg-good { background-color: var(--color-good); }
.score-bg-okay { background-color: var(--color-okay); }
.score-bg-poor { background-color: var(--color-poor); }

/* Conditions */
.conditions {
    display: flex;
    padding: 20px;
    gap: 16px;
}

.condition-group {
    flex: 1;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.condition-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.condition-data {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.condition-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.condition-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-weight: 500;
}

.condition-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    text-align: right;
}

.condition-divider {
    width: 1px;
    background: #e5e7eb;
    align-self: stretch;
}

/* Hourly Section */
.hourly-section {
    border-top: 1px solid #e5e7eb;
}

.hourly-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f9fafb;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    transition: background 0.2s;
}

.hourly-toggle:hover {
    background: #f3f4f6;
}

.toggle-icon {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    transition: transform 0.2s;
}

.hourly-toggle.expanded .toggle-icon {
    transform: rotate(180deg);
}

.hourly-breakdown {
    display: none;
    padding: 0 16px 16px;
}

.hourly-breakdown.expanded {
    display: block;
}

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

.hourly-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f9fafb;
    border-radius: var(--radius-sm);
    border-left: 3px solid #e5e7eb;
    transition: background 0.3s, box-shadow 0.3s;
}

.hourly-item.highlight {
    background: #e0e7ff;
    box-shadow: 0 0 0 2px var(--color-primary);
}

.hourly-item.score-good { border-left-color: var(--color-good); }
.hourly-item.score-okay { border-left-color: var(--color-okay); }
.hourly-item.score-poor { border-left-color: var(--color-poor); }

.hourly-time {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--color-text);
    min-width: 42px;
}

.hourly-score {
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 36px;
    text-align: center;
}

.hourly-score.score-good { color: var(--color-good); }
.hourly-score.score-okay { color: var(--color-okay); }
.hourly-score.score-poor { color: var(--color-poor); }

.hourly-details {
    flex: 1;
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.hourly-detail {
    display: flex;
    gap: 4px;
}

.hourly-detail span:last-child {
    font-weight: 600;
    color: var(--color-text);
}

/* Error */
.error {
    background: #fef2f2;
    color: #dc2626;
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-top: 16px;
    font-size: 0.9rem;
}

.hidden {
    display: none !important;
}

/* Wind Arrow */
.wind-arrow {
    display: inline-block;
    color: var(--color-primary);
    font-weight: bold;
}

.wind-arrow-small { font-size: 0.9rem; }
.wind-arrow-medium { font-size: 1.1rem; }
.wind-arrow-large { font-size: 1.25rem; vertical-align: middle; }

/* Desktop Enhancements */
@media (min-width: 481px) {
    .app {
        padding-top: 24px;
    }

    .hero-score {
        padding: 40px 32px;
    }

    .hero-score-value {
        font-size: 6rem;
    }

    .conditions {
        padding: 24px 32px;
    }

    .hourly-breakdown {
        padding: 0 24px 24px;
    }
}

/* Info Page Styles */
.info-page {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.info-section {
    margin-bottom: 32px;
}

.info-section:last-of-type {
    margin-bottom: 16px;
}

.info-section h2 {
    font-size: 1.25rem;
    color: var(--color-text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-primary);
}

.info-intro {
    color: var(--color-text-muted);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.score-ranges {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.score-range {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.score-range-good {
    background: #f0fdf4;
    border-left: 3px solid var(--color-good);
}

.score-range-okay {
    background: #fefce8;
    border-left: 3px solid var(--color-okay);
}

.score-range-poor {
    background: #fef2f2;
    border-left: 3px solid var(--color-poor);
}

.range-score {
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 60px;
}

.score-range-good .range-score { color: var(--color-good); }
.score-range-okay .range-score { color: var(--color-okay); }
.score-range-poor .range-score { color: var(--color-poor); }

.range-label {
    font-weight: 600;
    min-width: 50px;
}

.score-range p {
    flex: 1;
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    min-width: 180px;
}

.factor {
    background: #f9fafb;
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
}

.factor h3 {
    color: var(--color-primary);
    margin-bottom: 8px;
    font-size: 1rem;
}

.factor > p {
    color: var(--color-text-muted);
    margin-bottom: 12px;
    font-size: 0.85rem;
}

.penalty-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.penalty-table th,
.penalty-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.penalty-table th {
    background: #e0e7ff;
    color: var(--color-text);
    font-weight: 600;
}

.penalty-table tr.good td { background: #f0fdf4; }
.penalty-table tr.mild td { background: #fefce8; }
.penalty-table tr.moderate td { background: #fff7ed; }
.penalty-table tr.severe td { background: #fef2f2; }

.tips-list {
    list-style: none;
}

.tips-list li {
    padding: 10px 12px;
    background: #f9fafb;
    margin-bottom: 6px;
    border-radius: 6px;
    border-left: 3px solid var(--color-primary);
    font-size: 0.85rem;
}

.back-link {
    text-align: center;
    margin-top: 24px;
}

.back-btn {
    display: inline-block;
    padding: 12px 28px;
    background: var(--color-primary);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s;
}

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