/* ==========================================
   Life Map - JRPG World Map Style
   ========================================== */

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-parchment: #2d2a4a;
    --text-primary: #eaeaea;
    --text-secondary: #a0a0b0;
    --accent-gold: #ffd700;
    --accent-gold-light: #ffe566;
    --accent-emerald: #10b981;
    --accent-blue: #3b82f6;
    --accent-orange: #f59e0b;
    --accent-pink: #ec4899;
    --accent-purple: #8b5cf6;
    --shadow-dark: rgba(0, 0, 0, 0.5);
    --glow-gold: rgba(255, 215, 0, 0.4);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.page-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.site-header {
    background: linear-gradient(180deg, var(--bg-secondary) 0%, transparent 100%);
    padding: 1rem 2rem;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--accent-gold);
    text-decoration: none;
    text-shadow: 0 2px 4px var(--shadow-dark);
}

.main-nav {
    display: flex;
    gap: 1.5rem;
}

.main-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
    font-size: 0.95rem;
}

.main-nav a:hover,
.main-nav a.active {
    color: var(--accent-gold);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 5rem 2rem 1rem;
}

.hero h1 {
    font-size: 2.2rem;
    margin-bottom: 0.3rem;
    color: var(--accent-gold);
    text-shadow: 0 2px 8px var(--shadow-dark);
    letter-spacing: 0.1em;
}

.hero p {
    color: var(--text-secondary);
    font-size: 1rem;
    font-style: italic;
}

/* World Map Container */
.world-map-container {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    min-height: 600px;
    z-index: 1;
}

/* Parchment Background */
.parchment-bg {
    position: absolute;
    inset: 2rem;
    z-index: 0;
    background:
        radial-gradient(ellipse at center, var(--bg-parchment) 0%, var(--bg-secondary) 100%);
    border-radius: 8px;
    border: 3px solid rgba(139, 90, 43, 0.6);
    box-shadow:
        inset 0 0 60px rgba(0, 0, 0, 0.3),
        0 8px 32px var(--shadow-dark);
}

.parchment-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    border-radius: 8px;
    pointer-events: none;
}

/* World Map */
.world-map {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 500px;
    z-index: 2;
}

/* Paths */
.map-paths {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.path-main {
    fill: none;
    stroke: #8b7355;
    stroke-width: 6;
    stroke-linecap: round;
}

.path-main-dashed {
    fill: none;
    stroke: #c4a77d;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 8, 12;
}

.path-branch {
    fill: none;
    stroke: #6b5344;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 4, 6;
}

/* Terrain Decorations */
.terrain {
    position: absolute;
    opacity: 0.4;
    font-size: 3rem;
    filter: sepia(30%);
}

.mountains { left: 85%; top: 5%; }
.forest { left: 35%; top: 70%; font-size: 2.5rem; }
.water { left: 90%; top: 65%; font-size: 2rem; }
.hills { left: 45%; top: 85%; font-size: 2rem; }

/* Location Markers */
.location {
    position: absolute;
    cursor: pointer;
    transition: transform 0.3s ease, z-index 0s;
}

.location:hover {
    z-index: 20;
}

.location:hover .location-marker {
    transform: scale(1.15);
}

.location:hover .location-card {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.location-marker {
    position: relative;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.marker-icon {
    font-size: 2.8rem;
    filter: drop-shadow(0 4px 6px var(--shadow-dark));
    position: relative;
    z-index: 2;
}

.marker-glow {
    position: absolute;
    width: 50px;
    height: 50px;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.3); opacity: 0.8; }
}

/* Castle flag animation */
.marker-flag {
    position: absolute;
    top: -5px;
    right: 5px;
    font-size: 1.2rem;
    animation: flag-wave 1s ease-in-out infinite;
}

@keyframes flag-wave {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

/* Location Labels */
.location-label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    margin-top: 0.5rem;
    white-space: nowrap;
}

.location-name {
    display: block;
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--accent-gold);
    text-shadow: 0 2px 4px var(--shadow-dark);
}

.location-sub {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Location Cards (hover tooltips) */
.location-card {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    width: 220px;
    background: linear-gradient(135deg, rgba(45, 42, 74, 0.98) 0%, rgba(22, 33, 62, 0.98) 100%);
    border: 2px solid var(--accent-gold);
    border-radius: 8px;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 8px 24px var(--shadow-dark);
    margin-bottom: 1rem;
}

.location-card.featured {
    border-color: var(--accent-emerald);
    background: linear-gradient(135deg, rgba(16, 100, 70, 0.3) 0%, rgba(22, 33, 62, 0.98) 100%);
}

.location-card h4 {
    font-size: 1.1rem;
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
}

.location-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 0.75rem;
}

.card-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.card-link {
    display: block;
    padding: 0.5rem 0.8rem;
    background: rgba(255, 215, 0, 0.15);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 4px;
    color: var(--accent-gold-light);
    text-decoration: none;
    font-size: 0.85rem;
    text-align: center;
    transition: all 0.2s;
}

.card-link:hover {
    background: var(--accent-gold);
    color: var(--bg-primary);
}

.card-link.primary {
    background: var(--accent-emerald);
    border-color: var(--accent-emerald);
    color: white;
    font-weight: bold;
}

.card-link.primary:hover {
    background: #059669;
}

/* Compass Rose */
.compass {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
}

.compass-body {
    width: 100%;
    height: 100%;
    border: 2px solid rgba(139, 90, 43, 0.6);
    border-radius: 50%;
    background: rgba(45, 42, 74, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.compass-needle {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #c41e3a 50%, #ffd700 50%);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.compass-letters {
    position: absolute;
    inset: 0;
    font-size: 0.6rem;
    color: var(--accent-gold);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
}

.compass-letters span:nth-child(1) { align-self: flex-start; }
.compass-letters span:nth-child(2) { margin-left: auto; }
.compass-letters span:nth-child(3) { align-self: flex-end; margin-left: auto; }
.compass-letters span:nth-child(4) { align-self: flex-end; }

/* Map Title Cartouche */
.map-title-cartouche {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(45, 42, 74, 0.9) 0%, rgba(22, 33, 62, 0.9) 100%);
    border: 2px solid rgba(139, 90, 43, 0.6);
    border-radius: 20px;
    padding: 0.4rem 1.5rem;
    font-size: 0.9rem;
    color: var(--accent-gold);
    font-style: italic;
    letter-spacing: 0.15em;
}

/* Decorative Elements */
.decor-ship {
    position: absolute;
    bottom: 60px;
    left: 75%;
    font-size: 2rem;
    opacity: 0.5;
    animation: ship-rock 4s ease-in-out infinite;
}

@keyframes ship-rock {
    0%, 100% { transform: rotate(-3deg) translateY(0); }
    50% { transform: rotate(3deg) translateY(-5px); }
}

.decor-castle {
    position: absolute;
    top: 45%;
    right: 8%;
    font-size: 1.5rem;
    opacity: 0.3;
}

/* Player Marker */
.player-marker {
    position: absolute;
    bottom: 30%;
    left: 40%;
    z-index: 15;
}

.player-icon {
    font-size: 1.8rem;
    position: relative;
    z-index: 2;
    animation: player-bounce 1s ease-in-out infinite;
}

@keyframes player-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.player-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.4) 0%, transparent 70%);
    border-radius: 50%;
    animation: pulse-ring 1.5s ease-out infinite;
}

@keyframes pulse-ring {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

.player-label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--accent-gold);
    white-space: nowrap;
    margin-top: 0.3rem;
    text-shadow: 0 1px 3px var(--shadow-dark);
}

/* Detail Panel - positioned within map container */
.detail-panel {
    position: fixed;
    top: 50%;
    right: 2rem;
    transform: translateY(-50%) translateX(120%);
    width: 260px;
    background: linear-gradient(135deg, rgba(45, 42, 74, 0.98) 0%, rgba(22, 33, 62, 0.98) 100%);
    border: 2px solid var(--accent-gold);
    border-radius: 12px;
    padding: 1.25rem;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    box-shadow: 0 8px 32px var(--shadow-dark);
}

.detail-panel.visible {
    transform: translateY(-50%) translateX(0);
}

.detail-panel .close-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 215, 0, 0.2);
    color: var(--accent-gold);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    transition: all 0.2s;
}

.detail-panel .close-btn:hover {
    background: var(--accent-gold);
    color: var(--bg-primary);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel-icon {
    font-size: 2.5rem;
}

.panel-titles h2 {
    font-size: 1.3rem;
    color: var(--accent-gold);
}

.panel-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

.panel-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.5), transparent);
    margin: 0.75rem 0;
}

#panelDesc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.panel-section-title {
    font-size: 0.75rem;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.panel-tools {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.panel-tool-link {
    display: block;
    padding: 0.6rem 0.8rem;
    background: rgba(255, 215, 0, 0.15);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 6px;
    color: var(--accent-gold-light);
    text-decoration: none;
    font-size: 0.85rem;
    text-align: center;
    transition: all 0.2s;
}

.panel-tool-link:hover {
    background: var(--accent-gold);
    color: var(--bg-primary);
}

.panel-tool-link.primary {
    background: var(--accent-emerald);
    border-color: var(--accent-emerald);
    color: white;
    font-weight: bold;
}

.panel-tool-link.primary:hover {
    background: #059669;
}

/* Footer */
.site-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Settings Button */
.settings-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(139, 90, 43, 0.6);
    border-radius: 50%;
    background: rgba(45, 42, 74, 0.8);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 30;
}

.settings-btn:hover {
    background: var(--accent-gold);
    transform: rotate(45deg);
}

/* Init Modal */
.init-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.init-modal.visible {
    opacity: 1;
    visibility: visible;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 500px;
    background: linear-gradient(135deg, var(--bg-parchment) 0%, var(--bg-secondary) 100%);
    border: 3px solid var(--accent-gold);
    border-radius: 16px;
    padding: 2rem;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
    box-shadow: 0 20px 60px var(--shadow-dark);
}

.init-modal.visible .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    font-size: 1.6rem;
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
}

.modal-header p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

.modal-body {
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.form-group input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-gold);
}

.form-group input[type="number"]::placeholder {
    color: var(--text-secondary);
}

/* Stage Selector */
.stage-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

/* Make sure 4 items form a nice 2x2 grid */
.stage-selector:has(.stage-option:nth-child(4)) {
    grid-template-columns: repeat(2, 1fr);
}

.stage-option {
    cursor: pointer;
}

.stage-option input {
    display: none;
}

.stage-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 215, 0, 0.2);
    border-radius: 10px;
    transition: all 0.2s ease;
}

.stage-card:hover {
    border-color: rgba(255, 215, 0, 0.5);
    background: rgba(0, 0, 0, 0.3);
}

.stage-option input:checked + .stage-card {
    border-color: var(--accent-gold);
    background: rgba(255, 215, 0, 0.15);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

.stage-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.stage-name {
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stage-desc {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.modal-footer {
    text-align: center;
}

.btn-primary {
    padding: 0.85rem 2.5rem;
    background: linear-gradient(135deg, var(--accent-gold) 0%, #cc9900 100%);
    border: none;
    border-radius: 8px;
    color: var(--bg-primary);
    font-size: 1rem;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
    background: linear-gradient(135deg, var(--accent-gold-light) 0%, var(--accent-gold) 100%);
}

/* Responsive */
@media (max-width: 768px) {
    .world-map {
        height: 400px;
    }

    .parchment-bg {
        inset: 1rem;
    }

    .location-marker {
        width: 55px;
        height: 55px;
    }

    .marker-icon {
        font-size: 2.2rem;
    }

    .location-card {
        width: 180px;
        padding: 0.75rem;
    }

    .detail-panel {
        position: fixed;
        right: 1rem;
        left: 1rem;
        width: auto;
        top: auto;
        bottom: 1rem;
        transform: translateY(150%);
    }

    .detail-panel.visible {
        transform: translateY(0);
    }

    .compass {
        width: 45px;
        height: 45px;
        bottom: 10px;
        right: 10px;
    }

    .decor-ship,
    .decor-castle {
        display: none;
    }
}