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

:root {
    --primary: #0077be;
    --primary-dark: #005a8e;
    --secondary: #00a8cc;
    --background: #f8fcff;
    --surface: #ffffff;
    --text: #1a2332;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --high-tide: #3b82f6;
    --low-tide: #f59e0b;
    --shadow: rgba(0, 119, 190, 0.08);
    --shadow-lg: rgba(0, 119, 190, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* Animated Wave Background */
.wave-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.wave {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 200px;
    background: linear-gradient(180deg, transparent, rgba(0, 168, 204, 0.05));
    animation: wave 15s linear infinite;
}

.wave1 {
    animation-delay: 0s;
    opacity: 0.3;
}

.wave2 {
    animation-delay: -5s;
    opacity: 0.2;
    animation-duration: 20s;
}

.wave3 {
    animation-delay: -10s;
    opacity: 0.1;
    animation-duration: 25s;
}

@keyframes wave {
    0% {
        transform: translateX(0) translateY(0);
    }
    50% {
        transform: translateX(-25%) translateY(-10px);
    }
    100% {
        transform: translateX(-50%) translateY(0);
    }
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
    padding-top: 2rem;
}

.logo {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.tagline {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Sections */
.section {
    background: var(--surface);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 20px var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.section:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--shadow-lg);
}

/* Search */
.search-container {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.location-btn {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border: 2px solid var(--border);
    background: var(--surface);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    transition: all 0.3s ease;
}

.location-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.05);
}

.location-btn:active {
    transform: scale(0.95);
}

#station-search {
    flex: 1;
    padding: 0.75rem 1.25rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
}

#station-search:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 119, 190, 0.1);
}

/* Search Results */
.search-results {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 1rem;
}

.search-result-item {
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    border: 1px solid transparent;
}

.search-result-item:hover {
    background: var(--background);
    border-color: var(--border);
}

.result-name {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.result-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.hidden {
    display: none !important;
}

/* Station Header */
.station-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.station-header h2 {
    font-size: 1.75rem;
    color: var(--text);
    font-weight: 700;
}

.change-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.change-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Current Tide */
.current-tide {
    margin-bottom: 2rem;
}

.tide-status {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.status-badge {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
}

.status-badge.high {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.status-badge.low {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.next-tide {
    flex: 1;
}

.tide-type {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.tide-time {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.tide-height {
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* Tide Chart */
.tide-chart {
    margin-top: 2rem;
}

.tide-chart h3 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text);
    font-weight: 700;
}

.tide-events-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tide-day {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    background: var(--background);
}

.day-header {
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.day-events {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.tide-event {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: 8px;
    border-left: 4px solid;
}

.tide-event.high {
    border-left-color: var(--high-tide);
}

.tide-event.low {
    border-left-color: var(--low-tide);
}

.tide-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tide-icon.high {
    background: var(--high-tide);
}

.tide-icon.low {
    background: var(--low-tide);
}

.tide-details {
    flex: 1;
}

.tide-event-type {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.05em;
}

.tide-event-time {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.tide-event-height {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Tide Graph */
.tide-graph-container {
    margin-bottom: 2rem;
}

.tide-graph-container h3 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text);
    font-weight: 700;
}

/* Current Level Display */
.current-level-display {
    background: linear-gradient(135deg, rgba(0, 168, 204, 0.08), rgba(59, 130, 246, 0.08));
    border: 2px solid rgba(0, 168, 204, 0.25);
    border-radius: 16px;
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
}

.current-level-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.current-level-label {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 700;
}

.current-level-main {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.current-level-height {
    font-size: 3rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.current-level-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.125rem;
}

.current-level-status.rising {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

.current-level-status.falling {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

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

.graph-wrapper {
    position: relative;
    background: var(--background);
    border-radius: 12px;
    padding: 1.5rem;
    overflow: hidden;
}

#tide-curve-canvas {
    width: 100%;
    height: 300px;
    display: block;
    cursor: crosshair;
}

/* Curve Info Panel */
.curve-info-panel {
    margin-top: 1.5rem;
    background: linear-gradient(135deg, rgba(0, 168, 204, 0.05), rgba(59, 130, 246, 0.05));
    border: 2px solid rgba(0, 168, 204, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.curve-info-panel:has(.info-data:not(.hidden)) {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(0, 168, 204, 0.1), rgba(59, 130, 246, 0.1));
    box-shadow: 0 4px 20px rgba(0, 168, 204, 0.15);
}

.info-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
}

.info-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    animation: pulse 2s ease-in-out infinite;
}

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

.info-text {
    flex: 1;
}

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

.info-data {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto 1fr;
    gap: 1.5rem;
    align-items: center;
    margin-top: 0;
    opacity: 1;
    transition: all 0.3s ease;
}

.info-data.hidden {
    display: none;
}

.info-item {
    text-align: center;
}

.info-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.info-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.info-date .info-value {
    color: var(--primary);
}

.info-height .info-value {
    color: var(--secondary);
    font-size: 1.5rem;
}

.info-status .info-value {
    font-size: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    display: inline-block;
}

.info-status .info-value.rising {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

.info-status .info-value.falling {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.info-divider {
    width: 2px;
    height: 40px;
    background: linear-gradient(to bottom, transparent, var(--border), transparent);
}

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

.attribution {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.attribution a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.attribution a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 1rem 0.75rem;
    }

    .logo {
        font-size: 2.5rem;
    }

    .section {
        padding: 1.5rem;
        border-radius: 16px;
    }

    .station-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .tide-status {
        flex-direction: column;
        text-align: center;
    }

    .tide-time {
        font-size: 1.75rem;
    }

    .day-events {
        grid-template-columns: 1fr;
    }

    #tide-curve-canvas {
        height: 250px;
    }

    .graph-wrapper {
        padding: 1rem;
    }

    .info-data {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .info-divider {
        display: none;
    }

    .info-item {
        padding: 0.75rem;
        background: var(--surface);
        border-radius: 8px;
    }

    .current-level-main {
        flex-direction: column;
        gap: 1rem;
    }

    .current-level-height {
        font-size: 2.5rem;
    }

    .current-level-status {
        font-size: 1rem;
        padding: 0.625rem 1.25rem;
    }
}

/* Tide Disclaimer */
.tide-disclaimer {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 119, 190, 0.05);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Scrollbar */
.search-results::-webkit-scrollbar {
    width: 8px;
}

.search-results::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
