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

:root {
    --primary: #0a3a52;
    --secondary: #1e5a7a;
    --accent: #f39c12;
    --light: #ecf0f1;
    --text: #0a0f14;
    --text-light: #3d5166;
    --water: #06d6d0;
    --success: #27ae60;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Montserrat', sans-serif;
    background: linear-gradient(135deg, #0f2c3f 0%, #1a4d6d 50%, #0a3a52 100%);
    color: var(--text);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

@media (max-width: 768px) {
    body {
        margin: 0;
        padding: 0;
        overflow: hidden;
    }
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(30, 90, 122, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(15, 44, 63, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
    position: relative;
    z-index: 1;
}

@media (max-width: 768px) {
    .container {
        max-width: 100%;
        margin: 0;
        padding: 0;
    }
}

.header {
    text-align: center;
    animation: slideDown 0.8s ease-out;
    position: relative;
}

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

h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.5em;
    font-weight: 800;
    color: #ecf0f1;
    margin-bottom: 10px;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.3em;
    color: #ecf0f1;
    font-weight: 300;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.tagline {
    color: var(--water);
    font-size: 0.95em;
    font-weight: 500;
    letter-spacing: 1px;
}

.content {
    display: block;
    margin-bottom: 30px;
    width: 100%;
    height: auto;
}

.content > div {
    display: block;
    width: 100%;
}

.map-container {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: fadeIn 1s ease-out 0.2s both;
    height: 600px;
    min-height: 600px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#windy {
    height: 600px;
    width: 100%;
    display: block;
    background-color: #1a1a1a;
    margin: 0;
    padding: 0;
}

#windy .leaflet-bottom {
    display: none !important;
}

#windy.windy-active .leaflet-bottom {
    display: block !important;
}

@media (max-width: 768px) {
    #windy {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
    }
}

.stats-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 1s ease-out 0.4s both;
    position: relative;
}

.stat-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 14px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s cubic-bezier(0.23, 1, 0.320, 1);
    position: relative;
    overflow: visible;
}

#stat-tooltip-toast {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100vw - 40px);
    max-width: 320px;
    background: var(--primary);
    color: white;
    font-size: 13px;
    font-family: 'Montserrat', sans-serif;
    line-height: 1.5;
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
    z-index: 9999;
}
#stat-tooltip-toast.visible { display: block; }

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--water));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.stat-card:hover::before {
    transform: scaleX(1);
}

.stat-label {
    font-size: 0.6em;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-icon {
    font-size: 1.3em;
}

.stat-value {
    font-size: 1em;
    font-weight: 700;
    color: var(--primary);
    font-family: 'Playfair Display', serif;
    word-break: break-word;
    display: inline;
}

.stat-unit {
    font-size: 1em;
    color: var(--primary);
    font-weight: 700;
    font-family: 'Playfair Display', serif;
    display: inline;
    margin-left: 0.2em;
    vertical-align: baseline;
}

.stat-card.highlight {
    background: linear-gradient(135deg, rgba(30, 90, 122, 0.1), rgba(243, 156, 18, 0.1));
    border: 2px solid var(--accent);
}

.stat-card.highlight .stat-value {
    color: var(--accent);
}

#lastComment {
    margin-top: 10px;
}

.msg-entry {
    padding: 6px 0 6px 12px;
    border-left: 3px solid var(--water);
    margin-bottom: 8px;
}

.msg-entry.msg-latest {
    border-left-width: 4px;
    border-left-color: var(--accent, #f39c12);
}

.msg-date {
    display: block;
    font-size: 0.72em;
    color: #999;
    margin-bottom: 2px;
    letter-spacing: 0.02em;
}

.msg-entry.msg-latest .msg-date {
    color: var(--water);
    font-weight: 600;
}

.msg-text {
    display: block;
    font-size: 0.9em;
    font-style: italic;
    color: #444;
    line-height: 1.4;
}

.msg-entry.msg-latest .msg-text {
    font-size: 1em;
    color: #222;
    font-weight: 500;
}

.msg-entry.msg-prev {
    opacity: 0.6;
}

.loading {
    text-align: center;
    color: #ecf0f1;
    font-size: 1.1em;
    padding: 40px 20px;
    animation: pulse 1.5s ease-in-out infinite;
    z-index: 10;
    position: relative;
}

@media (max-width: 768px) {
    .loading {
        padding: 20px;
        font-size: 1em;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        z-index: 200;
    }
}

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

.loading.error {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid #e74c3c;
    animation: none;
}

.footer {
    text-align: center;
    padding: 30px 20px;
    color: rgba(236, 240, 241, 0.7);
    font-size: 0.9em;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 50px;
    animation: fadeIn 1s ease-out 0.6s both;
}

.refresh-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--water);
    margin: 0 5px;
    animation: blink 2s ease-in-out infinite;
}

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

@media (min-width: 769px) {
    body {
        margin: 0;
        padding: 0;
        overflow: hidden;
    }

    .container {
        max-width: 100%;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        height: 100vh;
    }

    .header {
        padding: 10px 30px;
        background: rgba(10, 58, 82, 0.98);
        backdrop-filter: blur(10px);
        z-index: 101;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    }

    h1 {
        font-size: 1.8em;
        margin-bottom: 3px;
        margin-top: 0;
    }

    .subtitle {
        font-size: 0.9em;
        margin-bottom: 1px;
    }

    .tagline {
        font-size: 0.8em;
    }

    #content {
        display: grid !important;
        grid-template-columns: 2.5fr 1fr !important;
        gap: 20px !important;
        flex: 1 !important;
        min-height: 0 !important;
        width: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        position: relative !important;
        margin: 0 !important;
        padding: 20px !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        box-sizing: border-box !important;
        align-items: stretch !important;
    }

    #content > div {
        display: contents !important;
    }

    .map-container {
        border-radius: 15px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.2);
        height: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        overflow: hidden;
        position: sticky !important;
        top: 0 !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        padding: 0 !important;
        background: white;
    }

    #windy {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .stats-container {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        padding: 0 0 20px 0 !important;
        background: transparent !important;
        overflow: visible !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        z-index: auto !important;
        width: auto !important;
        margin: 0 !important;
        opacity: 1 !important;
        transform: none !important;
        align-self: start !important;
    }

    .stats-container.hidden {
        opacity: 1 !important;
        transform: none !important;
        display: flex !important;
    }

    .stat-card {
        margin: 0 !important;
        border-radius: 12px;
        min-height: unset;
        backdrop-filter: blur(10px);
        background: rgba(255, 255, 255, 0.95) !important;
        border: 1px solid rgba(255, 255, 255, 0.3);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-content: space-between;
    }

    .stat-label {
        font-size: 0.6em;
        margin-bottom: 4px;
        width: 100%;
    }

    .stat-value, .stat-unit {
        font-size: 0.95em;
        display: inline;
    }

    #lastComment .msg-text {
        font-size: 0.85em;
    }

    .footer {
        display: none;
    }
}

@media (max-width: 768px) {
    body {
        display: flex;
        flex-direction: column;
    }

    .container {
        padding: 0;
        max-width: 100%;
        display: flex;
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
        position: relative;
    }

    .header {
        padding: 12px 15px;
        margin-bottom: 0;
        background: rgba(10, 58, 82, 0.95);
        backdrop-filter: blur(10px);
        flex-shrink: 0;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 101;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    }

    h1 {
        font-size: 1.5em;
        margin-bottom: 2px;
    }

    .subtitle {
        font-size: 0.8em;
        margin-bottom: 0;
    }

    .tagline {
        font-size: 0.7em;
    }

    #content {
        display: block !important;
        height: 100vh;
        width: 100%;
        overflow: hidden;
        position: fixed;
        margin: 0 !important;
        padding: 0 !important;
        top: 90px;
        left: 0;
        right: 0;
        bottom: 0;
    }

    #content > div {
        display: block !important;
        height: 100% !important;
        width: 100% !important;
        grid-template-columns: none !important;
        gap: 0 !important;
        position: relative;
        padding: 0 !important;
        margin: 0 !important;
    }

    .map-container {
        border-radius: 0;
        box-shadow: none;
        border: none !important;
        height: 100%;
        width: 100%;
        margin: 0 !important;
        overflow: hidden;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 0 !important;
        background: transparent;
    }

    #windy {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .stats-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 10px;
        padding-bottom: 15px;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.75), transparent);
        max-height: 45vh;
        overflow-y: auto;
        overflow-x: hidden;
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
        gap: 8px;
        z-index: 500;
        width: 100%;
        margin: 0;
    }

    .stat-card {
        padding: 5px 8px;
        margin: 0 !important;
        border-radius: 8px;
        min-height: auto;
        backdrop-filter: blur(10px);
        background: rgba(255, 255, 255, 0.95) !important;
        border: 1px solid rgba(255, 255, 255, 0.3);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .stat-card.highlight {
        grid-column: auto;
    }

    .stat-card-message {
        grid-column: 1 / -1;
    }

    .stat-label {
        font-size: 0.55em;
        margin-bottom: 4px;
    }

    .stat-value, .stat-unit {
        font-size: 0.8em;
    }

    #lastComment .msg-entry {
        padding: 4px 0 4px 8px;
        margin-bottom: 5px;
        border-left-width: 2px;
    }

    #lastComment .msg-date {
        font-size: 0.68em;
    }

    #lastComment .msg-text {
        font-size: 0.78em;
    }

    .footer {
        display: none;
    }
}

@media (max-width: 600px) {
    .header {
        padding: 10px 12px;
        box-shadow: 0 2px 15px rgba(0, 0, 0, 0.15);
    }

    h1 {
        font-size: 1.6em;
        margin-bottom: 1px;
    }

    .subtitle {
        font-size: 0.75em;
    }

    .tagline {
        font-size: 0.65em;
    }

    #content {
        top: 80px;
    }

    .stats-container {
        padding: 8px;
        gap: 6px;
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }

    .stat-card {
        padding: 4px 8px;
    }

    .stat-card.highlight {
        grid-column: auto;
    }

    .stat-card-message {
        grid-column: 1 / -1;
    }

    .stat-label {
        font-size: 0.5em;
    }

    .stat-value, .stat-unit {
        font-size: 1em;
    }

    #lastComment .msg-text {
        font-size: 0.72em;
    }
}

#content {
    opacity: 0;
    transition: opacity 0.5s ease;
}

#content.visible {
    opacity: 1;
}

@media (min-width: 769px) {
    .stats-toggle {
        display: none !important;
    }
}

@media (max-width: 768px) {
    #content {
        opacity: 1;
    }

    #content.visible {
        opacity: 1;
    }
}

.stats-toggle {
    display: flex;
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: white;
    border: none;
    border-radius: 4px;
    width: 44px;
    height: 44px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.stats-toggle::before,
.stats-toggle::after {
    content: '';
    display: block;
    width: 24px;
    height: 2px;
    background: var(--primary);
    transition: all 0.3s ease;
}

.stats-toggle::before {
    transform: translateY(-7px);
}

.stats-toggle::after {
    transform: translateY(7px);
}

.stats-toggle .hamburger-middle {
    width: 24px;
    height: 2px;
    background: var(--primary);
    transition: all 0.3s ease;
}

.stats-toggle:hover {
    background: var(--primary);
    box-shadow: 0 4px 12px rgba(10, 58, 82, 0.2);
}

.stats-toggle:hover::before,
.stats-toggle:hover::after,
.stats-toggle:hover .hamburger-middle {
    background: white;
}

.stats-toggle:active {
    transform: scale(0.95);
}

#saveOfflineBtn {
    position: absolute;
    top: 20px;
    right: 124px;
}

@media (max-width: 768px) {
    #saveOfflineBtn { display: none; }
}

.wind-btn {
    position: absolute;
    top: 20px;
    right: 70px;
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.9);
    border: none;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(10,58,82,0.2);
    z-index: 1000;
    transition: all 0.3s ease;
}

.wind-btn.active {
    background: var(--primary);
}

.stats-toggle {
    transition: transform 0.4s ease-in-out;
}

.stats-toggle.active {
    transform: rotate(90deg);
}

.eta-display {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.9em;
    text-align: center;
    z-index: 500;
    white-space: normal;
    min-width: 180px;
}

.eta-display div {
    margin: 4px 0;
}

.eta-display .eta-label {
    font-size: 0.85em;
    color: #7f8c8d;
    font-weight: 500;
}

.eta-display .eta-title {
    font-weight: 600;
    color: #0a3a52;
}

.eta-display .eta-time {
    color: #666;
    font-size: 0.95em;
}

@media (max-width: 768px) {
    .eta-display {
        display: block;
        left: 10px;
        transform: none;
        max-width: calc(100vw - 140px);
    }

    .stats-container {
        transform: translateY(0) scale(1);
        opacity: 1;
        transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
        animation: bounceIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .stats-container.hidden {
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transform: translateY(30px) scale(0.95);
        transition: all 0.5s ease-out;
        animation: none;
    }

    .unit-label {
        font-size: 0.75em !important;
    }

    @keyframes bounceIn {
        0% {
            opacity: 0;
            transform: translateY(30px) scale(0.95);
        }
        50% {
            transform: translateY(-5px) scale(1.02);
        }
        100% {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }
}

.route-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 16px 0 8px;
    flex-wrap: wrap;
}

.route-tab {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ecf0f1;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.8em;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 6px 18px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.route-tab:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.route-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #0a0f14;
    font-weight: 700;
}

@media (max-width: 768px) {
    .route-tabs {
        margin: 6px 0 0;
        gap: 6px;
    }
    .route-tab {
        font-size: 0.72em;
        padding: 4px 12px;
    }
}
