:root {
    /* === Light Theme (Default) === */
    --color-bg: #f8fafc;
    --color-card-bg: #ffffff;
    --color-text: #334155;
    --color-muted: #64748b;
    --color-border: #e2e8f0;
    
    --color-primary: #0ea5e9;
    --color-primary-dark: #0284c7;
    
    --good-wave: #10b981;
    --moderate-wave: #f59e0b;
    --poor-wave: #ef4444;
    
    --shadow-subtle: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-raised: 0 4px 16px rgba(0,0,0,0.1);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
}

/* === Dark Theme === */
[data-theme="dark"] {
    --color-bg: #0f172a;
    --color-card-bg: #1e293b;
    --color-text: #f1f5f9;
    --color-muted: #94a3b8;
    --color-border: #334155;
    
    --shadow-subtle: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-raised: 0 4px 16px rgba(0,0,0,0.4);
}

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

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: var(--space-md);
}

/* === Data Freshness Badge === */
.freshness-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    background: var(--color-card-bg);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
    font-size: 0.75rem;
    box-shadow: var(--shadow-subtle);
}

.freshness-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.freshness-green { background-color: var(--good-wave); }
.freshness-yellow { background-color: var(--moderate-wave); }
.freshness-red { background-color: var(--poor-wave); }

/* === Summary Banner Enhanced === */
.summary-banner {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-md);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.25);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.summary-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(14, 165, 233, 0.35);
}

.summary-banner.good {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
}

.summary-banner.moderate {
    background: linear-gradient(135deg, #d97706, #f59e0b);
    color: white;
}

.summary-banner.poor {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: white;
}

.summary-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
    animation: pulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse {
    0%, 100% { 
        transform: scale(1); 
        opacity: 1;
    }
    50% { 
        transform: scale(1.15); 
        opacity: 0.9;
    }
}

.summary-content {
    flex: 1;
    z-index: 1;
}

.summary-text {
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: var(--space-xs);
}

.condition-badges {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.badge {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(4px);
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.725rem;
    font-weight: 600;
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.summary-banner::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.2), transparent);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    pointer-events: none;
}

/* === Tide Status Indicator === */
.tide-status {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-xs);
    background: var(--color-card-bg);
    padding: var(--space-sm);
    margin-bottom: var(--space-md);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-subtle);
    font-size: 0.85rem;
    font-weight: 500;
}

.tide-status-icon {
    font-size: 1.1rem;
}

.tide-rising { color: var(--good-wave); }
.tide-falling { color: var(--moderate-wave); }
.tide-neutral { color: var(--color-muted); }

/* === Header === */
header {
    text-align: center;
    margin-bottom: var(--space-lg);
    padding-top: var(--space-sm);
}

header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-primary-dark);
    margin-bottom: var(--space-xs);
}

.subtitle {
    color: var(--color-muted);
    font-size: 0.9rem;
}

#last-updated {
    display: block;
    margin-top: var(--space-xs);
    font-size: 0.75rem;
    color: var(--color-muted);
}

/* === Sponsor Banner === */
.sponsor-banner {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) 0;
    margin-bottom: var(--space-sm);
}

.sponsor-banner a {
    display: inline-block;
    text-decoration: none;
    line-height: 0;
}

.sponsor-label {
    font-size: 0.75rem;
    color: var(--color-muted);
    font-weight: 500;
}

.sponsor-logo {
    height: 70px;          /* Default size for mobile */
    width: auto;
    max-width: 120px;
    object-fit: contain;
    opacity: 0.85;
    transition: opacity 0.2s;
}

/* Tablet and larger screens */
@media (min-width: 600px) {
    .sponsor-logo {
        height: 40px;
        max-width: 180px;
    }
}

/* Desktop */
@media (min-width: 900px) {
    .sponsor-logo {
        height: 52px;
        max-width: 240px;
    }
}

.sponsor-logo:hover {
    opacity: 1;
}

/* === Condition Cards === */
.conditions-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.card {
    background: var(--color-card-bg);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    text-align: center;
    box-shadow: var(--shadow-subtle);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-raised);
}

.icon {
    font-size: 1.5rem;
    display: block;
    margin-bottom: var(--space-xs);
}

.label {
    font-size: 0.65rem;
    color: var(--color-muted);
    margin-bottom: var(--space-xs);
    line-height: 1.2;
}

.value {
    font-size: 1.1rem;
    font-weight: 600;
}

.unit {
    font-size: 0.6rem;
    color: var(--color-muted);
}

/* === Detail Cards === */
.details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.detail-card {
    background: var(--color-card-bg);
    border-radius: var(--radius-sm);
    padding: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    box-shadow: var(--shadow-subtle);
}

.detail-icon {
    font-size: 1.25rem;
}

.detail-label {
    font-size: 0.7rem;
    color: var(--color-muted);
}

.detail-value {
    font-size: 0.95rem;
    font-weight: 600;
}

/* === Wind Hint Card === */
.wind-hint {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-xs);
    background: var(--color-card-bg);
    padding: var(--space-sm);
    margin-bottom: var(--space-md);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-subtle);
    text-align: center;
}

.hint-label {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.hint-value {
    font-weight: 600;
    font-size: 0.95rem;
}

.favorable {
    color: var(--good-wave);
}

.challenging {
    color: var(--moderate-wave);
}

.moderate {
    color: #8b5cf6;
}

/* === Tide & Sun Section === */
.tide-sun-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.info-block {
    background: var(--color-card-bg);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    box-shadow: var(--shadow-subtle);
}

.info-title {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tide-times, .sun-times {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.tide-row, .sun-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.tide-label, .sun-label {
    color: var(--color-muted);
    font-weight: 500;
}

.tide-time, .sun-time {
    font-weight: 600;
    color: var(--color-text);
}

.tide-high .tide-label {
    color: var(--color-primary);
}

.tide-low .tide-label {
    color: var(--moderate-wave);
}

.info-loading {
    font-size: 0.8rem;
    color: var(--color-muted);
    font-style: italic;
}

/* === Hourly Forecast === */
.hourly-section {
    margin-bottom: var(--space-lg);
}

.hourly-section h2 {
    font-size: 1rem;
    margin-bottom: var(--space-sm);
    color: var(--color-text);
}

.hourly-list {
    display: flex;
    overflow-x: auto;
    gap: var(--space-sm);
    padding-bottom: var(--space-sm);
    position: relative;
    scroll-behavior: smooth;
    scrollbar-gutter: stable both-edges;
}

.hourly-list::-webkit-scrollbar {
    height: 6px;
}

.hourly-list::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 4px;
}

.hourly-list::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: 4px;
}

/* BEST WINDOW HIGHLIGHT - FIXED POSITIONING */
.hourly-item.best-window {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
    transform: scale(1.05);
    z-index: 1;
}

.dark-theme .hourly-item.best-window {
    background: linear-gradient(135deg, #92400e, #b45309);
}

.hourly-best-indicator {
    position: absolute;
    top: 4px;
    right: -6px;
    font-size: 1.6rem;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
    animation: float-wave 2.5s ease-in-out infinite;
    z-index: 10;
}

@keyframes float-wave {
    0%, 100% { 
        transform: translateY(0) rotate(0deg); 
        opacity: 1;
    }
    50% { 
        transform: translateY(-6px) rotate(5deg); 
        opacity: 0.9;
    }
}

/* NEW: Weather icon row styling */
.hourly-weather {
    font-size: 1.4rem;
    margin-bottom: 2px;
    opacity: 0.9;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.1));
}

.hourly-item {
    flex-shrink: 0;
    min-width: 72px; /* Slightly wider for comfort */
    background: var(--color-card-bg);
    border-radius: var(--radius-sm);
    /* Extra top padding to fit weather icon + wave indicator */
    padding: calc(var(--space-sm) + 6px) var(--space-xs);
    text-align: center;
    box-shadow: var(--shadow-subtle);
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.hourly-item:hover {
    transform: scale(1.03);
}

.hourly-item[data-wave-rating="good"] {
    border-left: 4px solid var(--good-wave);
}

.hourly-item[data-wave-rating="moderate"] {
    border-left: 4px solid var(--moderate-wave);
}

.hourly-item[data-wave-rating="poor"] {
    border-left: 4px solid var(--poor-wave);
}

.hourly-time {
    font-size: 0.65rem; /* Reduced slightly to fit */
    color: var(--color-muted);
    margin-top: 2px;
}

.hourly-wave {
    font-size: 1rem;
    font-weight: 600;
    margin: 2px 0;
}

.hourly-wind {
    font-size: 0.65rem;
    color: var(--color-muted);
}

.loading-state {
    text-align: center;
    color: var(--color-muted);
    padding: var(--space-md);
    font-style: italic;
}

/* === Footer Enhanced === */
footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border);
}

.footer-actions {
    display: flex;
    gap: var(--space-sm);
}

.refresh-btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

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

.dark-mode-toggle {
    background: var(--color-card-bg);
    color: var(--color-text);
    border: 2px solid var(--color-border);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.dark-mode-toggle:hover {
    border-color: var(--color-primary);
}

.error-message {
    background: #fef2f2;
    color: #dc2626;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.85rem;
}

[data-theme="dark"] .error-message {
    background: #450a0a;
    color: #fecaca;
}

/* === Responsive === */
@media (min-width: 600px) {
    .container {
        max-width: 600px;
        padding: var(--space-lg);
    }
    
    .conditions-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}