body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: 'Lora', serif;
    color: #2c1e1a;
    overflow: hidden;
}

#map {
    height: 100%;
    width: 100%;
    background: #d4c5ad;
    z-index: 1;
}

.vintage-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #f4e4bc;
    mix-blend-mode: multiply;
    pointer-events: none;
    z-index: 500;
}

.ui-panel {
    position: absolute; top: 15%; right: -50px; width: 400px;
    background-color: #fdfbf7; padding: 30px 40px 30px 60px;
    box-shadow: -10px 10px 20px rgba(0,0,0,0.5); z-index: 1000;
    transform: translateY(-50%) rotate(-6deg); transform-origin: center right;
    transition: all 0.3s ease-in-out; border: 1px solid #c9b4a1;
}

.ui-panel::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -15px;
    width: 15px;
    bottom: -2px;
    background-color: #5a463a;
    border-radius: 5px 0 0 5px;
    box-shadow: inset 5px 0 10px rgba(0, 0, 0, 0.4);
}

.ui-panel:hover { right: -20px; }

h2 {
    font-family: 'Cinzel', serif;
    margin: 0;
    color: #8b0000;
    text-transform: uppercase;
    border-bottom: 2px solid #2c1e1a;
    padding-bottom: 10px;
}

hr {
    border: none;
    border-top: 1px dashed #5a463a;
    margin: 20px 0;
}

.nautical-tool-overlay {
    position: absolute;
    pointer-events: none;
    z-index: 900;
}

#compass-overlay { display: none; }

.nautical-tool-overlay img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
}

.stat {
    text-align: center;
    width: 30%;
}

.stat span {
    font-size: 1.5rem;
    font-weight: bold;
    display: block;
    color: #2c1e1a;
}

input {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    background: #fff;
    font-family: 'Lora', serif;
}

button {
    width: 100%;
    padding: 10px;
    background: #2c1e1a;
    color: #fff;
    border: none;
    font-family: 'Cinzel', serif;
    cursor: pointer;
    font-size: 1rem;
}

button:hover {
    background: #8b0000;
}

.leaflet-popup-content-wrapper {
    background: #fdfbf7;
    border: 3px solid #5a463a;
    border-radius: 0;
    box-shadow: 4px 4px 10px rgba(0,0,0,0.3);
}
.leaflet-popup-tip {
    background: #fdfbf7 !important;
    border: 3px solid #5a463a;
    border-top: none;
    border-left: none;
    height: 15px;
    width: 15px;
    transform: rotate(45deg);
    margin-top: -10px;
}
.leaflet-popup-content b {
    color: #8b0000;
    font-family: 'Cinzel', serif;
}

.leaflet-tooltip {
    background: #fdfbf7;
    border: 3px solid #5a463a;
    border-radius: 5px;
    box-shadow: 3px 3px 8px rgba(0,0,0,0.3);
    padding: 5px 10px;
    opacity: 1;
    margin-top: 0;
    margin-left: 0;
    font-family: 'Cinzel', serif;
    color: #8b0000;
    font-size: 1em;
    font-style: normal;
    font-weight: bold;
    text-shadow: none;
    line-height: 1.2;
}

.leaflet-tooltip-tip {
    display: none !important;
}

.leaflet-tooltip-bottom {

}

.city-marker {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.diary-header {
    font-family: 'Cinzel', serif;
    font-weight: bold;
    border-bottom: 2px solid #5a463a;
    margin-bottom: 15px;
    padding-bottom: 5px;
    color: #5a463a;
}

.diary-header h3 {
    margin: 0;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
}

#facts-list {
    overflow-y: auto;
    max-height: 55vh;
    padding-right: 10px;
}

.fact-title {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
}

.cat-myth { background: #f3e5f5; color: #7b1fa2; }
.cat-history { background: #efebe9; color: #5d4037; }
.cat-fact { background: #e1f5fe; color: #0277bd; }

.fact-content {
    padding: 10px 12px;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #444;
    border-top: 1px solid #f0f0f0;
}

.fact-title { padding: 8px 12px; cursor: pointer; font-weight: bold; display: flex; justify-content: space-between; font-size: 0.85rem; }
.fact-content { padding: 10px; font-size: 0.8rem; border-top: 1px solid #f0f0f0; }

.cat-myth { background: #f3e5f5; color: #7b1fa2; }
.cat-history { background: #efebe9; color: #5d4037; }
.cat-fact { background: #e1f5fe; color: #0277bd; }

.book-closed {
    border: none !important;
    box-shadow: none !important;
}

.book-cover span {
    color: #2c1e1a;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    font-size: 0.9rem;
    margin-top: 10px;
    pointer-events: none;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.5);
}

#book-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 2000; display: flex; align-items: center; justify-content: center;
}
#book-modal.hidden { display: none !important; }
.book-overlay-bg {
    position: absolute; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); backdrop-filter: blur(8px); cursor: zoom-out;
}

.book-wrapper { position: relative; width: 900px; height: 600px; z-index: 2001; }
.book {
    width: 100%; height: 100%;
    display: flex;
    perspective: 1500px;
    transition: transform 0.5s ease-in-out, opacity 0.3s;
}

.page-turning { transform: rotateY(-10deg) scale(0.95); opacity: 0.5; }

.page {
    width: 50%; height: 100%; background: #fdfbf7;
    padding: 40px; box-sizing: border-box;
    border: 1px solid #d4c5ad; box-shadow: inset 0 0 50px rgba(0,0,0,0.05);
    overflow-y: auto;
}

.page-left { border-radius: 10px 0 0 10px; border-right: 2px solid rgba(0,0,0,0.1); }
.page-right { border-radius: 0 10px 10px 0; }

.book-fact-title { font-family: 'Cinzel', serif; color: #8b0000; border-bottom: 1px solid #5a463a; margin-bottom: 15px; }
.book-fact-title h2 { margin: 0; border: none; padding: 0; }
.book-fact-content { line-height: 1.6; font-size: 1.1rem; text-align: justify; }

#close-book {
    position: absolute; top: -40px; right: 0;
    background: none; border: none; color: white; font-size: 2rem; cursor: pointer;
}

.book-controls {
    position: absolute; bottom: -60px; width: 100%;
    display: flex; justify-content: space-between;
}
.book-controls button { width: auto; padding: 10px 30px; }

#book-trigger {
    position: absolute;
    bottom: 30px;
    left: 40px;
    width: 300px;
    height: 400px;
    background: url('img/book.png') no-repeat center center;
    background-size: contain;
    cursor: pointer;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(-5deg);
    transition: transform 0.4s ease, bottom 0.3s ease, background-image 0.3s ease;
}

#book-trigger:hover {
    transform: rotate(3deg) scale(1.1);
    bottom: 40px;
}

#book-trigger.notified {
    background-image: url('img/book-notify.png');
}

#close-book-btn {
    background: #5a463a;
}

.book-page-container {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.645, 0.045, 0.355, 1);
}

.slide-out { transform: translateX(-100%) opacity(0); }
.slide-in { transform: translateX(0) opacity(1); }

.book-image {
    width: 100%; max-height: 250px; object-fit: cover;
    border: 5px solid #fff; box-shadow: 2px 2px 10px rgba(0,0,0,0.2);
    margin: 15px 0; transform: rotate(-1deg);
}

.hidden { display: none !important; }

#message-area {
    display: none;
    margin-top: 15px;
    padding: 12px 15px;
    border-radius: 5px;
    font-family: 'Lora', serif;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: opacity 0.3s ease;
}

#message-area.message.success {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

#message-area.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

#windrose-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 200px;
    height: auto;
    z-index: 600;
    pointer-events: none;
    opacity: 0.85;
    filter: drop-shadow(4px 4px 6px rgba(0,0,0,0.4));
}

.mobile-only { display: none; }

@media (max-width: 768px) {
    #windrose-overlay,
    #book-trigger {
        display: none !important;
    }

    .ui-panel {
        position: absolute;
        top: auto !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        box-sizing: border-box;
        width: 100% !important;
        transform: none !important;
        padding: 15px 20px;
        box-shadow: 0 -5px 15px rgba(0,0,0,0.3);
        z-index: 2000;
        transition: transform 0.3s ease;
        border-radius: 20px 20px 0 0;
        border: none;
    }

    .ui-content {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s ease-out;
    }

    .ui-panel.collapsed .ui-content {
        max-height: 0;
        display: block;
    }

    .ui-panel:not(.collapsed) .ui-content {
        max-height: 500px;
        margin-top: 15px;
    }

    .ui-panel::before { display: none; }

    .mobile-only {
        display: block;
        width: 100%;
        padding: 12px;
        margin: 0 0 10px 0;
        background: #8b0000;
        border-radius: 8px;
        font-size: 1.1rem;
        box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    }

    .stats-row {
        gap: 5px;
    }

    .stat span {
        font-size: 1.1rem;
    }

    /* shitty ios auto zoom fix? */
    input,
    select,
    textarea {
        font-size: 16px !important;
    }

    .stat span {
        font-size: 1.2rem;
    }

    button {
        font-size: 16px;
    }
}
