:root {
    --ink-color: #2c241b;
    --blood-red: #8b0000;
    --parchment: #e8dcc8;
    --parchment-dark: #d4c4a8;
    --font-typewriter: 'Special Elite', monospace;
    --font-handwriting: 'Caveat', cursive;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--ink-color);
    font-family: var(--font-typewriter);
    color: var(--ink-color);
    /* Prevent pull-to-refresh on mobile */
    overscroll-behavior-y: none; 
}

#app {
    width: 100vw;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--parchment);
    /* Subtle parchment texture overlay using radial gradients */
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(0,0,0,0) 40%, rgba(139, 69, 19, 0.1) 100%),
        url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="noiseFilter"><feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noiseFilter)" opacity="0.05"/></svg>');
}

/* Header Styling */
.title-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10;
    padding: 1rem;
    background: linear-gradient(to bottom, var(--parchment) 60%, transparent);
    pointer-events: none;
}

.title-content {
    text-align: center;
    border-bottom: 2px solid rgba(44, 36, 27, 0.3);
    padding-bottom: 0.5rem;
}

.title-bar h1 {
    font-size: 1.4rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}

.title-bar .subtitle {
    font-size: 0.9rem;
    opacity: 0.8;
}

.signature {
    font-family: var(--font-handwriting);
    font-size: 1.2rem;
    color: var(--blood-red);
}

/* Map Viewport & Dragging */
#map-viewport {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    touch-action: none; /* Crucial for custom pointer events */
    cursor: grab;
}

#map-viewport:active {
    cursor: grabbing;
}

#map-content {
    position: absolute;
    top: 0;
    left: 0;
    /* Make map larger than screen to allow panning */
    width: 150vw; 
    height: 120vh;
    transform-origin: 0 0;
    will-change: transform;
}

#base-map {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    opacity: 0.85; /* Blend with parchment background slightly */
    filter: sepia(0.4) contrast(1.1) brightness(0.9);
}

#marker-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Markers */
.scuttler-marker {
    position: absolute;
    width: 44px; /* Touch friendly size */
    height: 44px;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.marker-icon {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: var(--blood-red);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.5));
    transition: transform 0.2s ease;
}

.scuttler-marker:active .marker-icon {
    transform: scale(0.8);
}

/* Marker Label (Lex's handwriting) */
.marker-label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-handwriting);
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--ink-color);
    text-shadow: 1px 1px 0 var(--parchment), -1px -1px 0 var(--parchment), 1px -1px 0 var(--parchment), -1px 1px 0 var(--parchment);
    white-space: nowrap;
    pointer-events: none;
}

#drag-hint {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(232, 220, 200, 0.8);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    pointer-events: none;
    opacity: 0.7;
    animation: fadeOut 3s forwards;
    animation-delay: 2s;
    border: 1px solid var(--ink-color);
}

@keyframes fadeOut {
    to { opacity: 0; visibility: hidden; }
}

/* Bottom Sheet */
#bottom-sheet {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--parchment-dark);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.3);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 20;
    /* Notebook aesthetic */
    background-image: repeating-linear-gradient(transparent, transparent 27px, rgba(44, 36, 27, 0.1) 28px);
    border-top: 2px solid var(--ink-color);
}

.sheet-hidden {
    transform: translateY(105%);
}

.sheet-handle-container {
    width: 100%;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background-color: var(--ink-color);
    border-radius: 2px;
    opacity: 0.5;
}

.sheet-content {
    padding: 0 1.5rem 2rem 1.5rem;
    max-height: 50vh;
    overflow-y: auto;
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: Baseline;
    margin-bottom: 0.5rem;
}

#sheet-title {
    font-family: var(--font-handwriting);
    font-size: 2.2rem;
    color: var(--blood-red);
    line-height: 1;
}

#sheet-location {
    font-size: 0.9rem;
    text-transform: uppercase;
    font-weight: bold;
    opacity: 0.7;
}

.divider {
    height: 1px;
    background-color: var(--ink-color);
    opacity: 0.2;
    margin-bottom: 1rem;
}

#sheet-desc {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    /* Align with the repeating gradient lines */
    margin-top: 5px; 
}

#close-sheet {
    display: block;
    width: 100%;
    padding: 12px;
    background-color: transparent;
    border: 2px solid var(--ink-color);
    color: var(--ink-color);
    font-family: var(--font-typewriter);
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
}

#close-sheet:active {
    background-color: var(--ink-color);
    color: var(--parchment);
}