:root {
    --background: #0a0a0a;
    --foreground: #fafafa;
    --card: #1a1a1a;
    --card-foreground: #fafafa;
    --popover: #1a1a1a;
    --popover-foreground: #fafafa;
    --primary: #2563eb;
    --primary-foreground: #fafafa;
    --secondary: #3b3b3b;
    --secondary-foreground: #fafafa;
    --muted: #3b3b3b;
    --muted-foreground: #a1a1aa;
    --accent: #3b3b3b;
    --accent-foreground: #fafafa;
    --destructive: #8b0000;
    --destructive-foreground: #fafafa;
    --border: #27272a;
    --input: #27272a;
    --ring: #2563eb;
    --radius: 0.5rem;
}

body {
    font-family: sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;

}

/* Modal Styles */
.modal {
    display: none; 
    position: fixed; 
    z-index: 100; 
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; 
    background-color: rgba(0,0,0,0.6); 
}

.modal-content {
    background-color: var(--card);
    margin: 0 auto;
    top: 0;
    max-width: 900px;
    position: relative;
    display: flex;
    gap: 20px;
}

h1 {
    font-size: 20px;
    color: var(--foreground);
}

#info-container {
    width: 100%;
    max-width: 800px;
    margin-bottom: 20px;
    padding: 0 20px; /* Add some padding */
    box-sizing: border-box; /* Include padding in width */
}

#info-display {
    width: 100%;
    height: auto;
    min-height: 150px;
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    overflow-y: auto;
    color: var(--card-foreground);
    box-sizing: border-box;
}

#selected-hexagon-container {
    width: 200px;
    max-width: 100%;
    height: 220px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--card);
    gap: 10px;
    padding: 20px 0 40px 0;
}

#bottom-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 800px;
    margin-top: 20px;
}

#selected-terrain {
    width: 200px;
    height: 220px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--card);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 20px 0 40px 0;
}

#selected-hexagon-container h5,
#selected-terrain h5 {
    margin: 0;
}

#selected-terrain img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: var(--radius);
}

#solitary-hexagon-svg {
    width: 100%;
    height: 150px;
}

#map-container {
    position: relative;
    width: 800px;
    height: 600px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--card);
    display: flex;
    justify-content: center;
    align-items: center;
}

#grid-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: visible !important;
}

#marker {
    width: 10%;
    height: 11.67%;
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 10;
}



#temperature-table {
    border-collapse: collapse;
    width: 100%;
    margin-top: 10px;
}

#text-window {
    width: 100%;
    height: auto;
    min-height: 150px;
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    overflow-y: auto;
    color: var(--card-foreground);
    transition: opacity 0.3s ease-in-out;
    box-sizing: border-box;
}

#text-window.fade-out {
    opacity: 0;
}


#temperature-table td, #temperature-table th {
    border: 1px solid var(--border);
    padding: 8px;
    color: var(--muted-foreground);
}

#temperature-table tr td:first-child {
    font-weight: bold;
    font-size: 1.1em;
    width: 22%;
}

#temperature-table tr td:last-child {
    font-size: 0.7em;
}

#temperature-table tr:first-child td {
    font-weight: bold;
    color: var(--foreground);
}

#temperature-table tr:hover {
    background-color: var(--accent);
    cursor: pointer;
}

#temperature-table tr.selected {
    background-color: var(--primary);
}

#temperature-table tr.selected td {
    color: var(--primary-foreground);
}

#temperature-table.locked {
    pointer-events: none;
    opacity: 0.7;
}





.controls {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: flex;
    align-items: center;
    z-index: 20;
}

.controls label {
    font-size: 14px;
    color: var(--muted-foreground);
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    margin-right: 10px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--secondary);
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
    -webkit-transform: translateX(20px);
    -ms-transform: translateX(20px);
    transform: translateX(20px);
}

.hex-text.hidden {
    display: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--card);
}

::-webkit-scrollbar-thumb {
    background: var(--secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

@media (max-width: 820px) {
    #map-container {
        width: 100vw;
        height: calc(620px * (100vw / 820px));
    }

    #map-container {
        transform: scale(calc(100vw / 820px));
        transform-origin: top left;
    }
}



#new-image-container img {
    width: 120px;
    height: auto;
    border-radius: var(--radius);
}

.selected-hex {
    filter: drop-shadow(0 0 3px #00FFFF) drop-shadow(0 0 6px #00FFFF);
}

/* Modal Styles */
.modal {
    display: none; 
    position: fixed; 
    z-index: 100; 
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; 
    background-color: rgba(0,0,0,0.6); 
}

.modal-content {
    background-color: var(--card);
    margin: 10% auto;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: auto; /* Let content define width */
    max-width: 1120px; /* Increased max-width to accommodate larger map */
    position: relative;
    display: flex;
    gap: 20px;
}

#modal-map-container {
    width: 800px;
    height: 600px;
}

#modal-controls-container {
    width: 300px; /* Fixed width for controls */
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#modal-map-container #map-container {
    width: 100%;
    height: 100%;
    transform-origin: top left;
}

.close-button {
    color: var(--muted-foreground);
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    z-index: 100;
}

.close-button:hover,
.close-button:focus {
    color: var(--foreground);
    text-decoration: none;
    cursor: pointer;
}





.dice-roller {
    background-color: var(--secondary);
    padding: 15px;
    border-radius: var(--radius);
}

.dice-roller button {
    background-color: var(--primary);
    color: var(--primary-foreground);
    border: none;
    padding: 10px 15px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 16px;
    margin-bottom: 10px;
}

.dice-roller button:hover {
    opacity: 0.9;
}

.dice-roller p {
    margin: 0;
    font-size: 18px;
}

#terrain-modal .modal-content {
    max-width: 800px;
    flex-direction: column;
}

#terrain-modal .modal-content h2 {
    text-align: center;
}

#terrain-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 20px;
    max-height: 50vh;
    overflow-y: auto;
    padding-bottom: 15px;
}

.terrain-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.terrain-item span {
    margin-top: 5px;
    color: var(--foreground);
    font-size: 14px;
    text-transform: capitalize;
}

#terrain-grid .terrain-item img {
    width: 100%;
    height: 120px; /* Adjusted height */
    object-fit: cover;
    border-radius: var(--radius);
    border: 2px solid transparent;
    transition: border-color 0.3s;
}

#terrain-grid .terrain-item:hover img {
    border-color: var(--primary);
}

#hexagon-modal .close-button {
    left: 20px;
    right: auto;
}

/* Responsive layout for weather modal */
@media (max-width: 1120px) {
    #hexagon-modal .modal-content {
        flex-direction: column;
        align-items: center;
        margin: 2.5vh auto;
        width: 95vw;
        max-width: 900px;
        padding: 10px;
        height: 95vh;
        overflow-y: auto;
        box-sizing: border-box;
    }

    #hexagon-modal #modal-map-container {
        width: 100%;
        aspect-ratio: 800 / 600;
        height: auto;
    }

    #hexagon-modal #map-container {
        transform: none !important;
        width: 100% !important;
        height: 100% !important;
    }

    #hexagon-modal #modal-controls-container {
        width: 100%;
    }
}