/* Parchment Theme Styles */
:root {
    --parchment-bg: #f4f1e8;
    --parchment-dark: #e8e0d0;
    --ink-dark: #2c1810;
    --ink-medium: #5d4e37;
    --accent-gold: #d4af37;
    --border-brown: #8b6914;
}

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

body {
    font-family: 'Cinzel', serif;
    background: var(--parchment-bg);
    color: var(--ink-dark);
    min-height: 100vh;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(139, 105, 20, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(139, 105, 20, 0.1) 0%, transparent 50%);
}

header {
    background: var(--parchment-dark);
    padding: 1rem 2rem;
    border-bottom: 2px solid var(--border-brown);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(139, 105, 20, 0.2);
}

header nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

header h1 {
    font-family: 'Uncial Antiqua', cursive;
    font-size: 2rem;
    color: var(--ink-dark);
    text-shadow: 1px 1px 2px rgba(139, 105, 20, 0.3);
}

.settings-link, .back-link {
    color: var(--ink-medium);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-brown);
    border-radius: 4px;
    background: var(--parchment-bg);
    transition: all 0.3s ease;
}

.settings-link:hover, .back-link:hover {
    background: var(--accent-gold);
    color: var(--ink-dark);
}

main {
    padding: 0;
    max-width: none;
    margin: 0;
    height: calc(100vh - 80px);
}

/* Split Layout Styles */
.split-layout {
    display: flex;
    height: 100%;
}

.map-section {
    flex: 0 0 55%;
    padding: 1rem;
    overflow: hidden;
}

.info-section {
    flex: 0 0 45%;
    background: var(--parchment-dark);
    border-left: 3px solid var(--border-brown);
    padding: 1rem;
    overflow-y: auto;
    min-width: 300px;
}

/* Hex Grid Styles */
#map-container {
    background: var(--parchment-bg);
    border: 3px solid var(--border-brown);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: inset 0 0 10px rgba(139, 105, 20, 0.2);
    height: 100%;
    display: flex;
    flex-direction: column;
}

#hex-grid {
    width: 100%;
    flex: 1;
    min-height: 500px;
    background: radial-gradient(circle at 50% 50%, var(--parchment-bg) 0%, var(--parchment-dark) 100%);
}

.hex {
    fill: var(--parchment-bg);
    stroke: var(--border-brown);
    stroke-width: 1.5;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hex:hover {
    fill: var(--accent-gold);
    stroke-width: 2;
}

.hex.selected {
    fill: var(--accent-gold);
    stroke: var(--ink-dark);
    stroke-width: 2.5;
}

.hex-text {
    font-family: 'Cinzel', serif;
    font-size: 10px;
    text-anchor: middle;
    fill: var(--ink-dark);
    pointer-events: none;
    display: none;
}

.hex-icon {
    filter: sepia(10%) saturate(90%) hue-rotate(10deg);
    opacity: 0.95;
}

/* Info Panel Styles */
.hex-info-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.hex-info-panel h2 {
    font-family: 'Uncial Antiqua', cursive;
    margin-bottom: 1rem;
    color: var(--ink-dark);
    text-align: center;
}

.selected-hex {
    background: var(--parchment-bg);
    border: 2px solid var(--border-brown);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.no-selection {
    text-align: center;
    color: var(--ink-medium);
    font-style: italic;
}

.hex-details {
    background: var(--parchment-bg);
    border: 2px solid var(--border-brown);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.detail-group {
    margin-bottom: 1rem;
}

.detail-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--ink-medium);
}

.detail-group input, .detail-group select, .detail-group textarea {
    width: 100%;
    padding: 0.5rem;
    background: var(--parchment-dark);
    border: 1px solid var(--border-brown);
    border-radius: 4px;
    font-family: 'Cinzel', serif;
    color: var(--ink-dark);
}

.detail-group textarea {
    resize: vertical;
    min-height: 60px;
}

.detail-actions {
    margin-top: 1rem;
    text-align: center;
}

.neighbors-section {
    flex: 1;
    margin-top: 1rem;
}

.neighbors-section h3 {
    font-family: 'Uncial Antiqua', cursive;
    margin-bottom: 1rem;
    color: var(--ink-dark);
    text-align: center;
    font-size: 1.2rem;
}

.neighbors-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0.1rem;
    max-width: 240px;
    margin: 0 auto;
    align-items: center;
    justify-items: center;
}

/* Position hexes in proper spatial arrangement using IDs */
#neighbor-NW { grid-area: 1 / 1 / 2 / 2; transform: translate(30px, 30px); }
#neighbor-N  { grid-area: 1 / 2 / 2 / 3; transform: translate(0px, 0px); }
#neighbor-NE { grid-area: 1 / 3 / 2 / 4; transform: translate(-30px, 30px); }
#neighbor-SW { grid-area: 3 / 1 / 4 / 2; transform: translate(30px, -30px); }
#neighbor-S  { grid-area: 3 / 2 / 4 / 3; transform: translate(0px, 0px); }
#neighbor-SE { grid-area: 3 / 3 / 4 / 4; transform: translate(-30px, -30px); }
#neighbor-CENTER { grid-area: 2 / 2 / 3 / 3; }

.neighbor-hex.current {
    background: var(--accent-gold);
    border-color: var(--ink-dark);
    border-width: 3px;
    cursor: default;
}

.neighbor-hex.current:hover {
    background: var(--accent-gold);
    transform: none;
}

.neighbor-hex {
    width: 60px;
    height: 52px;
    background: var(--parchment-bg);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 0.65rem;
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    margin: 2px;
}

.neighbor-hex:hover {
    background: var(--accent-gold);
    transform: scale(1.05);
}

.neighbor-hex.empty {
    background: var(--parchment-dark);
    color: var(--ink-medium);
    cursor: default;
}

.neighbor-hex.empty:hover {
    background: var(--parchment-dark);
    transform: none;
}

.neighbor-direction {
    font-weight: 600;
    color: var(--ink-medium);
    font-size: 0.6rem;
    margin-bottom: 0.1rem;
    line-height: 1;
}

.neighbor-biome {
    font-weight: 600;
    color: var(--ink-dark);
    font-size: 0.65rem;
    line-height: 1;
    text-align: center;
}

.neighbor-feature {
    color: var(--ink-medium);
    font-style: italic;
    font-size: 0.5rem;
    line-height: 0.9;
    text-align: center;
    margin-top: 0.05rem;
}

.neighbor-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    margin: 2px 0;
    filter: sepia(20%) saturate(80%);
}


button {
    padding: 0.5rem 1rem;
    background: var(--accent-gold);
    color: var(--ink-dark);
    border: 1px solid var(--border-brown);
    border-radius: 4px;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

button:hover {
    background: var(--border-brown);
    color: var(--parchment-bg);
}

button.danger {
    background: #c74545;
    color: white;
}

button.danger:hover {
    background: #a03030;
}

button.primary {
    background: var(--ink-dark);
    color: var(--parchment-bg);
    font-weight: 700;
}

button.primary:hover {
    background: var(--ink-medium);
}

button.disabled, button:disabled {
    background: var(--parchment-dark);
    color: var(--ink-medium);
    cursor: not-allowed;
    opacity: 0.6;
}

button.disabled:hover, button:disabled:hover {
    background: var(--parchment-dark);
    color: var(--ink-medium);
}

/* Fog of War Toggle Button */
.fog-toggle {
    padding: 0.5rem 1rem;
    background: var(--parchment-bg);
    color: var(--ink-medium);
    border: 1px solid var(--border-brown);
    border-radius: 4px;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.fog-toggle:hover {
    background: var(--accent-gold);
    color: var(--ink-dark);
}

.fog-toggle.active {
    background: var(--ink-dark);
    color: var(--parchment-bg);
}

.fog-toggle.active:hover {
    background: var(--ink-medium);
}

/* Help Button */
.help-button {
    padding: 0.5rem 1rem;
    background: var(--parchment-bg);
    color: var(--ink-medium);
    border: 1px solid var(--border-brown);
    border-radius: 4px;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.help-button:hover {
    background: var(--accent-gold);
    color: var(--ink-dark);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.modal-content {
    background: var(--parchment-bg);
    border: 3px solid var(--border-brown);
    border-radius: 8px;
    max-width: 800px;
    max-height: 90vh;
    width: 100%;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(139, 105, 20, 0.4);
}

.modal-header {
    background: var(--parchment-dark);
    border-bottom: 2px solid var(--border-brown);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-family: 'Uncial Antiqua', cursive;
    color: var(--ink-dark);
    margin: 0;
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--ink-medium);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--accent-gold);
    color: var(--ink-dark);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(90vh - 100px);
}

.help-section {
    margin-bottom: 2rem;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    font-family: 'Uncial Antiqua', cursive;
    color: var(--ink-dark);
    margin-bottom: 0.75rem;
    font-size: 1.2rem;
    border-bottom: 1px solid var(--border-brown);
    padding-bottom: 0.25rem;
}

.help-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-section li {
    margin-bottom: 0.5rem;
    padding-left: 1rem;
    position: relative;
    color: var(--ink-dark);
    line-height: 1.5;
}

.help-section li:before {
    content: '•';
    color: var(--accent-gold);
    font-weight: bold;
    position: absolute;
    left: 0;
}

.help-section strong {
    color: var(--ink-dark);
    font-weight: 700;
}

/* Starting Point Prompt */
.starting-point-prompt {
    background: var(--parchment-bg);
    border: 3px solid var(--accent-gold);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem;
    text-align: center;
    box-shadow: 0 4px 12px rgba(139, 105, 20, 0.3);
}

.starting-point-prompt h3 {
    font-family: 'Uncial Antiqua', cursive;
    color: var(--ink-dark);
    margin-bottom: 0.75rem;
    font-size: 1.3rem;
}

.starting-point-prompt p {
    color: var(--ink-medium);
    margin-bottom: 1.25rem;
    font-size: 1rem;
}

.primary-link {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--accent-gold);
    color: var(--ink-dark);
    text-decoration: none;
    border-radius: 4px;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 1px solid var(--border-brown);
}

.primary-link:hover {
    background: var(--border-brown);
    color: var(--parchment-bg);
}

/* Starting Point Controls */
.starting-point-inputs {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.starting-point-inputs input[type="number"] {
    width: 60px;
    text-align: center;
}

.coordinate-separator {
    font-weight: bold;
    color: var(--ink-medium);
}

/* Edge Selection Grid */
.edge-selection-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0.5rem;
    max-width: 300px;
    margin: 0.5rem 0;
}

.edge-btn {
    padding: 0.75rem 0.5rem;
    background: var(--parchment-bg);
    color: var(--ink-medium);
    border: 1px solid var(--border-brown);
    border-radius: 4px;
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    line-height: 1.2;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.edge-btn:hover {
    background: var(--accent-gold);
    color: var(--ink-dark);
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(139, 105, 20, 0.2);
}

.edge-btn.center-btn {
    background: var(--parchment-dark);
    border: 2px solid var(--border-brown);
}

.edge-btn.center-btn:hover {
    background: var(--accent-gold);
    color: var(--ink-dark);
}

/* Danger Zone Styles */
.danger-section {
    border-color: #c74545 !important;
    background: rgba(199, 69, 69, 0.05) !important;
}

.danger-section h2 {
    color: #c74545;
    text-align: center;
}

.danger-controls {
    text-align: center;
}

.danger-controls .control-group {
    justify-content: center;
}

.danger-controls small {
    color: #c74545;
    font-weight: 600;
    text-align: center;
}

/* Settings Page Styles */
.settings-main {
    max-width: 800px;
    padding: 2rem;
    margin: 0 auto;
}

.settings-section {
    background: var(--parchment-dark);
    border: 2px solid var(--border-brown);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(139, 105, 20, 0.2);
}

.settings-section h2 {
    font-family: 'Uncial Antiqua', cursive;
    margin-bottom: 1rem;
    color: var(--ink-dark);
}

.control-group {
    margin-bottom: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.control-group label {
    font-weight: 600;
    color: var(--ink-medium);
    min-width: 100px;
}

.control-group input, .control-group select {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem;
    border: 1px solid var(--border-brown);
    border-radius: 4px;
    background: var(--parchment-bg);
    font-family: 'Cinzel', serif;
    color: var(--ink-dark);
}

.control-group small {
    color: var(--ink-medium);
    font-style: italic;
    flex-basis: 100%;
    margin-top: 0.25rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .split-layout {
        flex-direction: column;
    }

    .map-section {
        flex: 1;
        height: 60vh;
    }

    .info-section {
        flex: none;
        height: 40vh;
        border-left: none;
        border-top: 3px solid var(--border-brown);
        min-width: auto;
    }

    .neighbors-grid {
        grid-template-columns: repeat(2, 1fr);
        max-width: 250px;
    }

    .control-group {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group label {
        min-width: auto;
    }
}