/* --- THEME VARIABLES --- */
:root {
    --bg-deep: #1a261a;        /* Deep Jungle Dark */
    --bg-panel: #263828;       /* Slightly lighter green for panels */
    --accent-gold: #d4af37;    /* Gold/Amber for highlights */
    --parchment: #f0e6d2;      /* Main text background */
    --parchment-dark: #e6dcc3; /* Secondary background */
    --ink: #3e2723;            /* Dark Brown Text */
    --text-light: #f0f0f0;     /* White/Light text for dark backgrounds */
    --border-color: #5d4037;   /* Wood/Earth border */
    
    --font-header: 'Cinzel', serif;
    --font-body: 'Lato', sans-serif;

    /* --- FILIGREE BORDER PATTERN (Golden Vine Braid) --- */
    --filigree-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Cpath d='M0 0h30v30H0z' fill='none'/%3E%3Cpath d='M2 15c0-7.18 5.82-13 13-13s13 5.82 13 13-5.82 13-13 13S2 22.18 2 15z' fill='none' stroke='%23d4af37' stroke-width='2' opacity='0.3'/%3E%3Cpath d='M0 0l15 15m15-15L15 15m0 15L0 15m30 15L15 15' stroke='%23d4af37' stroke-width='2' fill='none'/%3E%3Crect x='4' y='4' width='22' height='22' stroke='%23d4af37' stroke-width='1' fill='none'/%3E%3C/svg%3E");
}

/* --- Global Resets --- */
* { box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background-color: var(--bg-deep);
    color: var(--ink);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    
    /* Javascript handles the dappled background, this is the fallback */
    background-attachment: fixed;
    background-position: center;
    transition: background 1s ease;
}

/* --- Top Navigation --- */
.top-nav {
    background-color: #111a11;
    /* Double border for a premium feel */
    border-bottom: 4px double var(--accent-gold);
    padding: 15px 30px;
    position: sticky; top: 0;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.nav-brand {
    font-family: var(--font-header);
    font-weight: 700;
    font-size: 1.6em;
    color: var(--accent-gold);
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.nav-links { list-style: none; padding: 0; margin: 0; display: flex; gap: 20px; }
.nav-links li a {
    color: #b0c4b1;
    text-decoration: none;
    font-size: 1em;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.3s ease;
}
.nav-links li a:hover {
    color: var(--accent-gold);
    background-color: rgba(212, 175, 55, 0.1);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

/* --- Main Content Area --- */
main { width: 100%; max-width: 1200px; margin: 0 auto; padding: 40px 20px; }

/* The Welcome Box - Now with Filigree! */
.welcome-box {
    text-align: center;
    padding: 60px;
    color: var(--text-light);
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(3px);
    
    /* Filigree Border Settings */
    border: 10px solid transparent;
    border-image: var(--filigree-pattern) 30 round;
}
.welcome-box h2 { font-family: var(--font-header); font-size: 2.5em; color: var(--accent-gold); margin-bottom: 10px; }

/* --- Headers & Controls --- */
.view-header {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-light);
}
.view-header h2 {
    font-family: var(--font-header);
    font-size: 2.5em;
    border-bottom: 2px solid var(--accent-gold);
    display: inline-block;
    padding-bottom: 10px;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.controls {
    margin-bottom: 30px; padding: 15px;
    background: var(--bg-panel);
    border: 1px solid var(--accent-gold);
    /* Simple gold border for controls, radius kept */
    border-radius: 4px;
    color: var(--accent-gold);
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.controls select {
    padding: 10px;
    border-radius: 4px;
    border: 1px solid var(--accent-gold);
    background: #111;
    color: var(--parchment);
    font-family: var(--font-body);
    font-size: 1em;
    min-width: 250px;
    cursor: pointer;
}

/* --- Cards (Characters, NPCs, Locations) --- */
.grid-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 25px; }

.char-card, .npc-card {
    background-color: var(--parchment);
    border: 1px solid #cbb997;
    /* Add a double internal border for style */
    outline: 4px double rgba(139, 69, 19, 0.2);
    outline-offset: -10px;
    padding: 25px; 
    border-radius: 2px;
    box-shadow: 5px 5px 15px rgba(0,0,0,0.4);
    position: relative;
    background-image: linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0));
}

.npc-card { border-left: 6px solid var(--bg-panel); }

.char-card h3, .npc-card h3 {
    margin-top: 0;
    color: #2c3e50;
    font-family: var(--font-header);
    font-size: 1.4em;
    border-bottom: 1px solid #cbb997;
    padding-bottom: 8px;
}

/* --- Character Sheet Specifics --- */
.sheet-hidden { display: none; }

/* The Main Sheet Header - Now with Filigree! */
.sheet-header {
    background-color: var(--parchment);
    padding: 30px;
    margin-bottom: 25px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    
    /* Filigree Border Settings */
    border: 12px solid transparent;
    border-image: var(--filigree-pattern) 30 round;
}

.char-identity h1 { margin: 0; color: #5d4037; font-size: 3em; font-family: var(--font-header); line-height: 1; text-transform: uppercase; }
.char-identity p { margin: 5px 0 0 0; color: #777; font-style: italic; font-family: var(--font-header); }

.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 15px; margin-top: 20px; }
.meta-field { background: rgba(93, 64, 55, 0.1); padding: 10px; border-radius: 4px; border-left: 4px solid var(--border-color); }
.meta-label { display: block; font-size: 0.65em; text-transform: uppercase; letter-spacing: 1px; color: #5d4037; font-weight: bold; margin-bottom: 5px; }
.meta-value { display: block; font-weight: bold; font-size: 1.1em; color: #222; font-family: var(--font-header); }

/* Sheet Body */
.sheet-body { display: grid; grid-template-columns: 100px 1fr; gap: 25px; }

/* Stats Tower */
.stats-column { display: flex; flex-direction: column; gap: 15px; }
.stat-box {
    background: white; border: 2px solid #333;
    border-radius: 8px; text-align: center; overflow: hidden;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.2);
}
.stat-label { background: #333; color: var(--accent-gold); font-size: 0.7em; font-weight: bold; padding: 4px 0; font-family: var(--font-body); letter-spacing: 1px; }
.stat-mod { font-size: 1.8em; font-weight: bold; padding: 5px 0; color: #333; font-family: var(--font-header); }
.stat-score { font-size: 0.9em; background: #eee; padding: 3px 0; color: #555; border-top: 1px solid #ccc; }

/* Main Column */
.main-column { display: flex; flex-direction: column; gap: 25px; }

/* Combat Row */
.combat-row {
    display: flex; gap: 15px; justify-content: space-around;
    background: var(--parchment-dark);
    padding: 20px; border-radius: 8px; border: 1px solid #cbb997;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
}
.combat-stat { text-align: center; }
.combat-stat label { display: block; font-size: 0.7em; text-transform: uppercase; letter-spacing: 1px; color: #666; margin-bottom: 5px;}
.combat-stat span { font-size: 2em; font-weight: bold; color: #800000; font-family: var(--font-header); }

/* Content Boxes */
.section-box {
    background: var(--parchment);
    padding: 20px; border: 1px solid #cbb997;
    border-radius: 4px; position: relative;
    /* Add inner accent border */
    box-shadow: 0 0 0 1px rgba(139, 69, 19, 0.2) inset;
}
.section-box h3 {
    margin-top: 0; border-bottom: 2px solid var(--border-color);
    color: var(--border-color); font-family: var(--font-header);
    font-size: 1.2em; padding-bottom: 5px; margin-bottom: 15px;
}

/* Skills Grid */
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.skill-box {
    background: white; border: 1px solid #ccc;
    border-radius: 4px; display: flex; justify-content: space-between;
    align-items: center; padding: 8px 12px;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.05);
}
.skill-name { font-size: 0.9em; font-weight: bold; color: #444; }
.skill-val {
    font-weight: bold; color: white;
    font-size: 0.9em; background: var(--bg-panel);
    padding: 2px 8px; border-radius: 10px;
}

ul { padding-left: 20px; color: #333; }
li { margin-bottom: 6px; line-height: 1.4; }

/* --- Story View Specifics --- */
.single-column { grid-template-columns: 1fr !important; }
.story-content {
    font-size: 1.1em; line-height: 1.7; color: #2c3e50;
    font-family: var(--font-body);
}
.story-content h3 {
    margin-top: 30px; margin-bottom: 10px;
    border-bottom: 1px solid #8b4513;
    padding-bottom: 5px; color: #8b4513;
    font-family: var(--font-header);
}

/* --- Timeline Styling --- */
.timeline-entry {
    background: var(--parchment);
    border-left: 5px solid var(--accent-gold);
    padding: 20px; margin-bottom: 25px;
    border-radius: 2px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.timeline-entry h3 { margin: 5px 0 10px 0; font-family: var(--font-header); color: #2c3e50; }
.timeline-entry .date { font-size: 0.8em; color: #888; text-transform: uppercase; font-weight: bold; letter-spacing: 1px; }

/* --- Mobile Overrides --- */
@media (max-width: 768px) {
    .top-nav { flex-direction: column; align-items: center; }
    .nav-links { margin-top: 15px; width: 100%; justify-content: center; flex-wrap: wrap; }
    .sheet-body { grid-template-columns: 1fr; }
    .stats-column { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 15px; }
    .stat-box { width: 90px; }
}

/* --- Map View Layout --- */
.map-layout {
    display: grid;
    grid-template-columns: 2fr 1fr; /* Map takes 2/3 space, Info takes 1/3 */
    gap: 30px;
    align-items: start;
}

.map-container {
    border: 12px solid transparent;
    border-image: var(--filigree-pattern) 30 round;
    background: var(--parchment);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    overflow: hidden; /* Ensures image doesn't bleed out of border corners */
}

.map-image {
    width: 100%;
    height: auto;
    display: block;
    /* This makes the cursor change when hovering over a clickable area */
    cursor: crosshair; 
}

/* Make areas pointer cursors */
area { cursor: pointer; }

.info-panel-container {
    position: sticky;
    top: 100px; /* Keeps info panel in view while scrolling tall maps */
}

/* Simple fade in animation for when a location is clicked */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile Stack for Map View */
@media (max-width: 900px) {
    .map-layout {
        grid-template-columns: 1fr; /* Stack them on smaller screens */
    }
    .info-panel-container {
        position: static; /* Remove sticky behavior on mobile */
    }
}

/* --- Map Markers (The Black Circles) --- */
.map-marker {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #111; /* Black Circle */
    border: 1px solid var(--accent-gold); /* Gold Border */
    border-radius: 50%;
    cursor: pointer;
    transform: translate(-50%, -50%); /* Centers the dot exactly on the coordinate */
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    transition: all 0.3s ease;
    z-index: 10;
    padding: 0;
}

.map-marker:hover {
    background-color: var(--accent-gold);
    border-color: #111;
    transform: translate(-50%, -50%) scale(1.3); /* Grow slightly on hover */
}

/* Tooltip Labels (Hidden by default, shown on hover) */
.marker-label {
    position: absolute;
    bottom: 30px; /* Floats above the dot */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8em;
    font-family: var(--font-body);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    border: 1px solid var(--accent-gold);
}

.map-marker:hover .marker-label {
    opacity: 1;
}

/* Update map layout to handle positioning relative */
.map-container {
    position: relative; /* CRITICAL: Allows dots to be positioned inside */
}

/* --- Resource / Counters Grid --- */
.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.resource-box {
    background-color: var(--bg-panel); /* Dark Green Background */
    border: 2px solid var(--accent-gold);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    color: var(--text-light);
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.res-name {
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #b0c4b1;
    margin-bottom: 5px;
}

.res-tracker {
    font-family: var(--font-header);
    font-size: 1.5em;
    color: var(--accent-gold);
    font-weight: bold;
}

.res-divider {
    color: #555;
    font-size: 0.8em;
    vertical-align: middle;
}

.res-max {
    font-size: 0.7em;
    color: #888;
}

.res-reset {
    margin-top: 5px;
    font-size: 0.65em;
    font-style: italic;
    color: #888;
    border-top: 1px solid #444;
    padding-top: 3px;
}

/* --- Adjustable Counters --- */
.tracker-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-adjust {
    background: #222;
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
    line-height: 1;
    transition: all 0.2s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-adjust:hover {
    background: var(--accent-gold);
    color: #111;
}

.btn-adjust:active {
    transform: scale(0.9);
}

/* Specific sizing for the big HP display */
.hp-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: var(--font-header);
    font-size: 1.2em; /* Slightly smaller to fit buttons */
}

/* --- Inventory Containers --- */
.inventory-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.inv-group {
    background: rgba(255,255,255,0.4);
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 10px;
}

.inv-header {
    margin: 0 0 8px 0;
    padding-bottom: 5px;
    border-bottom: 1px dashed var(--border-color);
    color: var(--border-color);
    font-family: var(--font-header);
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.inv-list {
    margin: 0;
    padding-left: 20px;
}

.inv-list li {
    font-size: 0.95em;
    color: #333;
    margin-bottom: 4px;
}