@font-face {
  font-family: 'nihonium';
  src: url('assets/Nihonium113.woff') format('woff');
  font-weight: normal;
  font-style: normal;
}

/* svg {   } */

* {
    font-family: 'nihonium';
}

html, body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden; 
    background-color: #111;
}


#app-viewport {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}


#pages-container {
    display: flex;
    width: 200vw; 
    height: 100vh;
    transition: transform 0.3s ease-in-out; 
    will-change: transform;
}

#main-page, #galaxy-page {
    position: relative;
    width: 100vw;
    height: 100vh;
    flex-shrink: 0;
}

/* State class to slide over to the galaxy view */
#pages-container.show-galaxy {
    transform: translateX(-100vw); /* Shifts left to reveal galaxy page */
}

 #galaxy-page {
    background-color: #111;
 }



#menu-navigation {
    position: relative;
    width: 100vw; 
    height: 100vh;
    background-color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
}

#top-bar {
    position: absolute;
    user-select: none;
    top: 0;
    width: 100%;
    height: 10vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#top-bar-text {
    color: #eee;
    font-size: 3vh;
}

/* --- Bottom Navigation Control Bar --- */
#nav-debug-controls {
    position: absolute;
    bottom: 3vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 10px 16px;
    z-index: 5;
    user-select: none;
    box-sizing: border-box;
}

.nav-control-group, 
.nav-teleport-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Action Buttons styled like your existing game framework buttons */
.nav-action-btn {
    font-family: 'nihonium', sans-serif;
    background-color: transparent;
    box-sizing: border-box;
    border: 1px solid #eee;
    color: #eee;
    font-size: 1em;
    height: 32px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}


.nav-sizing-btn {
    width: 32px !important;
}

.nav-action-btn:hover {
    color: #fff;
}

#map-reset-btn, #teleport-submit-btn {
    letter-spacing: 1px;
}

/* Dark, minimal coordinate entry boxes */
.nav-coord-input {
    font-family: 'nihonium', sans-serif;
    background-color: #111;
    border: 1px solid #444;
    color: #fff;
    width: 50px;
    height: 32px;
    text-align: center;
    font-size: 1.1rem;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

input.nav-coord-input[type="number"] {
    -moz-appearance: textfield;
}

input.nav-coord-input::-webkit-outer-spin-button,
input.nav-coord-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.nav-coord-input:focus {
    border-color: #eee; /* Accent flash highlight on focus */
}

/* Optional Placeholder Coloring */
.nav-coord-input::placeholder {
    color: #555;
    opacity: 1;
}

.nav-toggle-btn {
    background-color: transparent;
    border: 1px solid #eee;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#nav-debug-controls.collapsed > *:not(.nav-toggle-btn) {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#nav-toggle-square {
    width: 12px;
    height: 12px;
    background-color: #eee;
}

.nav-toggle-btn:hover {
    cursor: pointer;
}

#menu-tile {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    z-index: 10;
    width: 30vw;
    height: 100vh;
    background-color: #222;
    border-left: 1px solid #333; 
}

#menu-tile[data-visible="true"] { 
    display: block;  
    width: 30vw;
} 

#tile-menu-options {
    background-color: #1A1A1A;
    width: 30vw;
    height: 6vh;
    display: flex;
    align-items: center;
    justify-content: space-evenly;
}

.submenu-tile {
    display: none; /* Hidden by default */
    background-color: #222;
    color: #eee;

    /* Calculate remaining height: 100vh (menu-tile) - 6vh (tile-menu-options) */
    height: 94vh;
    overflow-y: auto; /* Allow scrolling if content overflows */
    box-sizing: border-box; /* Include padding in height calculation */
}

.submenu-tile[data-visible="true"] {
    display: flex; /* Show when data-visible is true */
    align-items: center;
    justify-content: space-evenly;
}

.tile-menu-button {
    display: flex;
    min-width: fit-content;
    align-items: center;
    justify-content: center;
    width: 6.5vw;
    height: 4.5vh;
    font-size: 2.5vh;
    border: 1px solid #444;
    background-color: #111;
    color: #ddd;
    user-select: none;
}


:root {
    --grid-cols: 1;
    --grid-rows: 1;
}

#player-menu-options {
    position: absolute;
    gap: 10px;
    left: 1vw;  
    display: flex;
    flex-direction: column;
}

.player-menu-button {
    right: 1vw;
    user-select: none;
    width: 3vh;
    height: 3vh;
    border: 1px solid #ddd;
    color: #eee;
    font-size: 1.5em;
    display: flex; 
    justify-content: center; 
    align-items: center;
}

.player-menu-button:hover {
    cursor: pointer;
}

.swap-view-arrows {
    position: absolute;
    user-select: none;
    cursor: pointer;
    right: 1vw;
    width: 4vh;
    height: 4vh;
    color: #eee;
    font-size: 2em;
    display: flex; 
    justify-content: center; 
    align-items: center;
}

.swap-view-toggle-btn {
    position: absolute; /* Changed from fixed */
    top: 0; 
    bottom: 0; 
    width: 7vw; 
    display: flex;
    align-items: center; 
    justify-content: center; 
    background: transparent;
    z-index: 1; 
}

#galaxy-toggle-view-btn {
    transform: rotate(180deg);
    left: 0;
}

#main-toggle-view-btn {
    right: 0;
}

.swap-view-toggle-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, #111111 0%, #171717 100%);
    opacity: 0;
    transition: opacity 0.3s ease-in-out; /*Have this togglable this in settings "reduce motion"*/
    z-index: -1;
}

.swap-view-toggle-btn:hover::before {
    cursor: pointer;
    opacity: 1; 
}


/* Flip the arrow direction when viewing galaxy page */


#grid-exploration { 
    -webkit-user-select: none;
    user-select: none;
    height: 70vmin;
    aspect-ratio: 1/1;
    color: #eee;
    display: grid;
    grid-gap: 0;
    grid-template-rows: repeat(var(--grid-rows), 1fr);
    grid-template-columns: repeat(var(--grid-cols), 1fr);
}

/* Base grid cell styling */
.grid-item, 
.grid-item-center {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(3px, 4cqmin, 8px); 
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    font-family: sans-serif;
    color: #eee;
    background: #222;
    border: 2px solid #111;
    overflow: hidden; 
    position: relative;
    container-type: size;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Resting inner ring values */
.grid-item {
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--element-color) 10%, transparent);
}

.grid-item-center {
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--element-color) 80%, transparent);
    cursor: pointer;
}

/* Grouped hover state for precision pointer devices */
@media (hover: hover) and (pointer: fine) {
    :is(.grid-item, .grid-item-center):hover {
        box-shadow: inset 0 0 0 2px var(--element-color);
    }
}

/* Active state during press */
:is(.grid-item, .grid-item-center):active {
    box-shadow: inset 0 0 0 2px var(--element-color);
    opacity: 0.9;
}

/* Remove default focus ring on non-keyboard clicks */
:is(.grid-item, .grid-item-center):focus:not(:focus-visible) {
    outline: none;
}

/* Layout Rows */
.tile-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Typography bounds */
.tile-coords,
.tile-stat-left, 
.tile-stat-right {
    font-size: clamp(0.55rem, 15cqmin, 1rem);
    white-space: nowrap;
    line-height: 1;
    user-select: none;
}

.tile-coords {
    align-self: flex-start;
    font-size: clamp(0.45rem, 11cqmin, 0.9rem); 
}

.tile-stat-left, 
.tile-stat-right {
    opacity: 0.85;
}

/* Icon scaling & behavior */
.tile-icon {
    width: clamp(16px, 34cqmin, 40px);
    aspect-ratio: 1 / 1;
    flex-shrink: 0;          
    min-height: 0;          
}

.tile-icon use {
    fill: var(--element-color, #fff);
}

/* Dynamic snap for small container dimensions */
@container (max-height: 35px) or (max-width: 35px) {
    .tile-coords,
    .tile-stat-left,
    .tile-stat-right,
    .tile-row.bottom-row {
        display: none;
    }

    .tile-row.top-row {
        height: 100%;
        justify-content: center;
    }

    .tile-icon {
        width: clamp(14px, 65cqmin, 40px);
    }
}

.submenu-sanctuary {
    flex-direction: column;
    justify-content: center; 
}

.info-text {
    color: #ccc;
    font-size: 1.2em;
    text-align: center;
    padding: 10px;
}

.progress-bar {
    width: 80%; /* Adjust width as needed */
    height: 50px; /* Height of the progress bar */
    background-color: #444; /* Background of the bar */
    border: 1px solid #777; 
    overflow: hidden; /* Ensure content stays within bounds */
    position: relative; /* Needed to absolutely position the text inside */
}

.progress-fill {
    height: 100%;
    background-color: #2364af; 
    width: 0%; 
}

#sanctuary-title {
    font-size: 4vh;
}

#sanctuary-amount { 
    font-size: 3vh;
}

.progress-text {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #eee;
    text-shadow: 1px 1px 2px #000; /* Text shadow to ensure readability over both the dark background and light fill */
}

.meditate-button {
    padding: 10px 20px;
    font-size: 1.1em;
    background-color: #007bff; 
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.meditate-button:hover {
    background-color: #0056b3; 
}

.sanctuary-upgrade-section {
    height: 40vh;
    width: 100%;
    margin-bottom: 0;
    background-color: red;
}

#menu-player {
    display: none;
    position: absolute;
    left: 0;
    z-index: 10;
    width: 0vw;
    height: 100vh;
    background-color: #222;
    border-right: 1px solid #333; 
}

#menu-player[data-visible="true"] { 
    display: block;  
    color: #eee;
    width: 30vw;
} 

.player-dropdown {
    position: relative;
    width: 100%;
    background-color: #111;
    border-bottom: 1px solid #333;
}

.player-dropdown-header {
    padding: 15px;
    font-size: 1.5em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.player-dropdown-header:hover {
    background-color: #333;
    cursor: pointer;
}

.player-dropdown-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: #333;
    border-bottom: 1px solid #ddd;
    z-index: 20;
    user-select: none;
}

.player-dropdown-option {
    padding: 15px;
    font-size: 1.2em;
    border-top: 1px solid #444;
}

.player-dropdown-option:hover {
    background-color: #444;
    cursor: pointer;
}

.submenu-player {
    display: none;
    /* Give submenus a height to fill the player menu, accounting for the dropdown header */
    height: calc(100% - 65px); /* Adjust 65px if header height changes */
    overflow: hidden; /* We'll handle scrolling inside sub-components */
}

.submenu-player[data-visible="true"] {
    display: flex;
}

.close-menu-button {
    width: 25px;
    height: 25px;
    background-color: #333;
    border: 1px solid #555;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
}

.close-menu-button:hover {
    background-color: #d32f2f;
    border-color: #d32f2f;
    cursor: pointer;
}

#close-player-menu-square, #close-tile-menu-square {
    width: 11px;
    height: 11px;
    background-color: #eee;
    user-select: none;
}




#spell-display {
    background-image: var(--spell-icon);
    width: 10vw;
    height: 10vw;
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

#spell-generation {
    display: flex;
    width: 100%;
    flex-direction: column;
    row-gap: 1vh;
    justify-content: space-between;
    align-items: center;
}

.inventory-display-container {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-content: start;
    gap: 8px;
    width: 100%;
    flex-grow: 1; /* Allow this container to fill available vertical space */
    overflow-y: auto; /* Enable vertical scrolling if content overflows */
    overflow-x: hidden;
    padding: 10px;
    box-sizing: border-box;
}

/* WebKit simplistic scrollbar */
.inventory-display-container::-webkit-scrollbar {
    width: 6px;
}

.inventory-display-container::-webkit-scrollbar-track {
    background: #444;
}

.inventory-display-container::-webkit-scrollbar-thumb {
    background-color: #555;
}

.inventory-display-container::-webkit-scrollbar-thumb:hover {
    background-color: #777;
}

/* Firefox-specific scrollbar styling */
@-moz-document url-prefix() {
    .inventory-display-container {
        scrollbar-width: thin;
        scrollbar-color: #555 #444;
    }
}

.inventory-slot {
    width: 100%;
    background-image: var(--icon);
    aspect-ratio: 1 / 1; /* Create square slots */
    background-color: #333;
    border: 1px solid #555;
    box-sizing: border-box;
}

#generate-spell-button, #randomize-button {
    padding: 10px 20px;
    font-size: 1.1em;
    background-color: #007bff;
    color: white;
    border: none;
    cursor: pointer;
}

#generate-spell-button:hover {
    background-color: #0056b3;
}


.submenu-awakening {
    width: 100%;
    height: 90%;
    padding: 20px;
    box-sizing: border-box;
    font-family: sans-serif;
    color: #eee;
}

.submenu-player[data-visible="true"].submenu-awakening {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.menu-title {
    margin: 0;
    font-size: 1.2rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #fff;
}

.mp-display-bar {
    font-size: 1.1rem;
    font-weight: bold;
}


.progress-square-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin: auto 0;
}

.progress-square-outer {
    position: relative;
    width: 25vh;
    height: 25vh;
    background: #fff;
}

.progress-square-fill {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0%;
    height: 0%;
    background: #ffca28;
}

.timer-display {
    position: absolute;
    bottom: -25px; 
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    font-weight: 600;
    color: #aaa;
    letter-spacing: 0.5px;
    white-space: nowrap;
}



.timer-display.hidden {
    display: none;
}

.awaken-btn {
    width: 80%;
    max-width: 200px;
    padding: 12px;
    font-size: 2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    background: #eee;
    color: #111;
}



.awaken-btn:disabled {
    background: #444 !important;
    color: #777 !important;
    transform: none !important;
}

.formation-element-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
}

.element-tab-btn {
    width: 44px;
    height: 44px;
    background: #1a1a1a;
    border: 2px solid #333;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
}

.element-tab-btn svg {
    width: 100%;
    height: 100%;
}

.element-tab-btn .cls-1 {
    fill: #888; /* Inactive color */
    transition: fill 0.2s;
}

/* Hover & Active States */
.element-tab-btn:hover .cls-1 {
    fill: #bbb;
}

.element-tab-btn.active {
    background: #2a2a2a;
    border-color: #ffd700; /* Gold or accent outline */
}

.element-tab-btn.active .cls-1 {
    fill: #fff; /* Bright color when active */
}




.submenu-cultivation {
    flex-direction: column;
    align-items: center;
    justify-content: space-between; /* Spreads components evenly from top to bottom */
    padding: 20px;
    box-sizing: border-box;
}




.dust-display {
    margin-top: 30px;
    font-size: 2rem;
    color: #e0e0e0;
    text-transform: uppercase;
    letter-spacing: 1px;
   
}


/* Options Menu*/
.cultivation-dropdown-container {
    position: relative; 
    width: 70%;
    min-width: 200px;  
    font-family: sans-serif;
    margin-bottom: 10%;

}

.cultivation-dropdown-header {
    background-color: #333;
    width: 100%;
    padding: 12px 15px; 
    font-size: 1.3em;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    cursor: pointer;
    border: 2px solid #444;
    box-sizing: border-box;
    transition: background-color 0.2s ease;
}

.cultivation-dropdown-header:hover {
    background-color: #444;
}

.cultivation-dropdown-options {
    position: absolute; 
    top: 100%;          
    left: 0;
    width: 100%;
    display: none;
    flex-direction: column; 
    background-color: #222; 
    border: 1px solid #444;
    border-top: none;       
    box-sizing: border-box;
    z-index: 20;
    max-height: 250px;
    overflow-y: auto; 
    user-select: none;
}

.cultivation-drop-button {
    width: 100%;
    padding: 12px 15px;
    font-size: 1.1em;
    color: #ccc;
    text-align: center;
    cursor: pointer;
    border-bottom: 1px solid #333; 
    box-sizing: border-box;
    transition: background-color 0.2s, color 0.2s;
    user-select: none;
}

.cultivation-drop-button:last-child {
    border-bottom: none;
}

.cultivation-drop-button:hover {
    background-color: #444;
    color: #fff;
}




/* 3. Central Progress Square */
.progress-square-container {
    margin: 20px 0;
}

.progress-square {
    width: 256px;
    height: 256px; 
    border: 3px solid #555;

    /* radial */
    background: linear-gradient(to top, #4a90e2 var(--progress, 0%), #1a1a1a var(--progress, 0%));
}

/* 4. Boost Slots Grid */
.soul-slots-grid {
    display: grid;
    /* Creates up to 6 columns, automatically sizing them to fit the container */
    grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
    gap: 10px;
    width: 90%;
    max-width: 320px;
    margin-bottom: 20px;
}

.soul-slot {
    aspect-ratio: 1 / 1; 
    background-color: #222;
    border: 2px solid #444;
    transition: border-color 0.2s;
}

.soul-slot:hover {
    border-color: #666; 
}

/* 5. Cultivate Action Button */
.btn-cultivate {
    width: 80%;
    max-width: 200px;
    padding: 12px;
    background-color: #27ae60;
    color: white;
    border: none;
    font-size: 1rem;
    text-transform: uppercase;
    transition: background-color;
}

.btn-cultivate:hover {
    background-color: #2ecc71;
}


.submenu-player.submenu-formation[data-visible="true"] {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: calc(100vh - 65px);
    max-height: calc(100vh - 65px);
    padding: 15px;
    box-sizing: border-box;
    overflow: hidden; 
}

.submenu-formation .formation-element-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    justify-content: center;
    margin-bottom: 10px;
    border-bottom: 1px solid #333;
    padding-bottom: 12px;
}

.formation-info-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    text-align: center;
    margin-bottom: 15px;
    background-color: #1a1a1a;
    padding: 10px;
    border: 1px solid #333;
    box-sizing: border-box;
    font-size: 1.4em;
}


.formation-info-container .formation-display {
    font-size: 1rem;
    color: #888;
}

/* 3. Canvas Container Box */
.formation-display-container {
    position: relative;
    width: 80%;
    
    aspect-ratio: 1 / 1; 
    background-color: #151515;
    border: 2px solid #444;
    box-sizing: border-box;
    margin-top: 10%;
    display: flex;
 
    flex-shrink: 1; 
    min-height: 0; 
}


.formation-display-container canvas {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
    image-rendering: pixelated; 
}



.formation-actions-row {
    user-select: none;
    display: flex;
    flex-direction: row; 
    width: 80%;        
    gap: 10px;          
    margin-top: auto;   
    margin-bottom: 10%;
    flex-shrink: 0;    
    box-sizing: border-box; 
}

.formation-element-button {
    display: flex;
    align-items: center;
    justify-content: center; 
    height: 2vw;
    width: 2vw;
    border: 2px solid color-mix(in srgb, var(--element-color) 10%, transparent);
}

.formation-element-button.active {
    border-color: color-mix(in srgb, var(--element-color) 80%, transparent);
}

.formation-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.formation-create-button-container {
    display: flex;
    flex: 1;            
    height: 44px;       
    gap: 2px; 
    background-color: #333;
    border: 1px solid #444;
    box-sizing: border-box;
}

.formation-create-amount-button {
    flex: 0 0 35%;         
    height: 100%;
    background-color: #222;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #eee;
    transition: background 0.2s;
}

.formation-create-button {
    flex: 1;            
    height: 100%;
    background-color: #2a2a2a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background 0.2s;
}

.formation-form-button {
    border: 1px solid #444;
    flex: 1.3;            
    height: 44px;       
    background-color: #2a2a2a; 
    color: white;
    cursor: pointer;
    display: flex;      
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    font-size: 0.9rem;  
    letter-spacing: 1px;
    box-sizing: border-box;
    transition: background-color 0.2s;
}

.formation-create-amount-button:hover,
.formation-create-button:hover,
.formation-form-button:hover {
    background-color: #444;
}

.star-cost-display {
    user-select: none;
    font-size: 1.2em;
    margin-bottom: 2vh;
}




.submenu-spellbook[data-visible="true"] {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
    padding: 20px;
    box-sizing: border-box;
}

.spellbook-controls {
    width: 90%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.spellbook-controls div {
    display: flex;
    flex-direction: column;
}

.submenu-player.submenu-spellbook[data-visible="true"] {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    height: calc(100vh - 65px);
    padding: 15px;
    box-sizing: border-box;
    overflow: hidden; 
}


/* 1. Element Tabs */
.spellbook-element-tabs {
    flex-shrink: 0;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 10px;
    border-bottom: 1px solid #333;
    padding-bottom: 12px;
}

.spellbook-element-button {
    display: flex;
    align-items: center;
    justify-content: center; 
    height: 2vw;
    width: 2vw;
    border: 2px solid color-mix(in srgb, var(--element-color) 10%, transparent);
    cursor: pointer;
}

.spellbook-element-button.active {
    border-color: color-mix(in srgb, var(--element-color) 80%, transparent);
}

/* 2. Creation Container */
.spell-creation-container {
    width: 100%;
    height: 35%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between; 
    padding-left: 15px;
    padding-right: 15px;
    box-sizing: border-box;
}

.spell-info-container {
    flex: 0 0 130px;
    display: flex;
    user-select: none;
    flex-direction: column;
    gap: 8px;
    background-color: #1a1a1a;
    padding: 12px;
    border: 1px solid #333;
    color: #eee;
    font-size: 1.1em;
    z-index: 2;
}

.spell-grid-container {
    aspect-ratio: 1 / 1;
    height: 95%; 
    background-color: #151515;
    border: 2px solid #444;
    display: grid;
    box-sizing: border-box;
}

.spell-grid-slot {
    aspect-ratio: 1 / 1;
    background-color: #222;
    border: 1px solid #333;
    position: relative;
    box-sizing: border-box;
    background-clip: padding-box;
}

.spell-grid-slot.active {
    background-color: #4a90e2;
    border-color: #fff;
}

.spell-stat {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    color: #aaa;
}

.spell-stat span {
    color: #fff;
    font-weight: bold;
}

/* 3. Inventory Options */
.spellbook-inventory-options {
    user-select: none;
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: center;
    align-items: center;
}

.inventory-filter-btn  {
    user-select: none;
    height: 44px;
    padding: 0 15px;
    background: #1a1a1a;
    border: 2px solid #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    text-transform: uppercase;
    font-size: 0.9rem;
    font-weight: bold;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.clear-spell-grid-btn {
    user-select: none;
    height: 44px;
    padding: 0 15px;
    background: #1a1a1a;
    border: 2px solid #bbb;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #bbb;
    text-transform: uppercase;
    font-size: 0.9rem;
    font-weight: bold; 
}

.inventory-filter-btn:hover {
    background: #2a2a2a;
    color: #bbb;
}

.inventory-filter-btn.active {
    background: #2a2a2a;
    border-color: #ffd700;
    color: #fff;
}

.spellbook-inventory-container {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    align-content: start;
    gap: 8px;
    width: 100%;
    flex-grow: 1;
    overflow-y: auto; 
    overflow-x: hidden;
    padding: 5px;
    box-sizing: border-box;
}

.spellbook-inventory-container::-webkit-scrollbar {
    width: 6px;
}
.spellbook-inventory-container::-webkit-scrollbar-track {
    background: #222;
}
.spellbook-inventory-container::-webkit-scrollbar-thumb {
    background-color: #555;
}
.spellbook-inventory-container::-webkit-scrollbar-thumb:hover {
    background-color: #777;
}

.spell-inventory-slot {
    position: relative;
    width: 3vw;
    height: 3vw;
    background-color: #252525;
    border: 1px solid #444;
    box-sizing: border-box;
    cursor: grab;
}


.spell-inventory-slot.dragging {
    opacity: 0.6 !important;
}


.spell-grid-slot.drag-over {
    border: none;
}

/* Specific Edge Overrides */
.spell-grid-slot.drag-border-top {
    
    border-top: 2px solid var(--shard-drag-color, #ffffff)  !important;
}
.spell-grid-slot.drag-border-bottom {
    border-bottom: 2px solid var(--shard-drag-color, #ffffff)  !important;
}
.spell-grid-slot.drag-border-left {
    border-left: 2px solid var(--shard-drag-color, #ffffff)  !important;
}
.spell-grid-slot.drag-border-right {
    border-right: 2px solid var(--shard-drag-color, #ffffff) !important;
}

.shard-icon,
.shard-icon use,
.shard-icon rect {
    pointer-events: none !important;
}

.floating-drag-icon {
    position: fixed;
    z-index: 9999;
    pointer-events: none !important;
    transform: translate(-50%, -50%); 
    will-change: transform, top, left;

    --shard-size: 1; 
    --slot-base-size: 3vw;

    width: calc((var(--slot-base-size) * var(--shard-size)) - 3px) !important;
    height: calc((var(--slot-base-size) * var(--shard-size)) - 3px) !important;
}

/* 1. Prevent mobile browser scroll-hijacking on your game zones */
.spellbook-inventory-container,
.spell-grid-container,
.spell-inventory-slot {
    touch-action: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}




.floating-drag-icon.snapped {
    transform: translate(0, 0) !important;
}



.shard-icon {
    opacity: 1;
    width: 2.5vw;
    height: 2.5vw;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}





/* Main Quest Submenu Container */
.submenu-tile.submenu-quest[data-visible="true"] {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 94vh; /* Matches your .submenu-tile height calculation */
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
    user-select: none;
}

/* 1. Details Container (Scrolls internally if text is huge) */
.quest-details-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 20px;
}

/* Individual Panels inside the details container */
.quest-info-panel, 
.quest-rewards-panel, 
.quest-progress-panel {
    background-color: #1a1a1a;
    border: 1px solid #333;
    padding: 15px;
    box-sizing: border-box;
    width: 100%;
}

/* Typography styles matching your design patterns */
.quest-title {
    font-size: 1.4rem;
    color: #fff;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.quest-subtitle {
    font-size: 1.1rem;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.quest-description {
    font-size: 1.1rem;
    color: #ccc;
    line-height: 1.4;
}

.quest-reward-item {
    font-size: 1rem;
    color: #aaa;
    margin-bottom: 4px;
}

.quest-reward-item span {
    color: #fff;
    font-weight: bold;
}

/* Progress Tracker Section */
.quest-progress-panel {
    display: none; /* Hidden by default until player accepts */
}

/* Toggle class for your JavaScript engine to trigger visibility */
.quest-progress-panel.visible {
    display: block;
}

.quest-progress-tracker {
    font-size: 1.2rem;
    color: #eee;
}

/* 2. Actions Row (Mirrors your formation-actions-row structural logic) */
.quest-actions-row {
    user-select: none;
    display: flex;
    flex-direction: row; 
    width: 100%;        
    gap: 10px;          
    flex-shrink: 0;    
    box-sizing: border-box; 
}

/* Base button styles matching your general UI button framework */
.quest-btn {
    font-family: 'nihonium', sans-serif;
    border: 1px solid #444;
    flex: 1;            
    height: 44px;       
    background-color: #2a2a2a; 
    color: white;
    cursor: pointer;
    display: flex;      
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    font-size: 0.9rem;  
    letter-spacing: 1px;
    box-sizing: border-box;
}

.quest-btn:not(:disabled):hover {
    background-color: #444;
}

/* Accept button specific highlight */
.btn-accept:not(:disabled):hover {
    border-color: #4a90e2;
}

/* Disabled/Greved-out State for Claim (or Accept) when prerequisites aren't met */
.quest-btn:disabled {
    background-color: #171717 !important;
    border-color: #222 !important;
    color: #555 !important;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ==========================================================================
   HUNTING SUBMENU LAYOUT
   ========================================================================== */

.submenu-tile.submenu-hunting {
    display: none;
    height: 94vh;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
}

.submenu-tile.submenu-hunting[data-visible="true"] {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
    padding: 15px;
}

/* --- User Selection & Touch Safety Isolation --- */
.submenu-tile.submenu-hunting,
.hunting-usable-spells-container,
.hunting-spell,
.hunting-spell-slots,
.hunting-spell-slot,
.hunting-monster-display {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    touch-action: none !important;
}

/* 1. Monster UI Panels */
.hunting-monster-display {
    width: 90%;
    height: 12vh;
    background-color: #1a1a1a;
    border: 1px solid #333;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    box-sizing: border-box;
}

.hunting-monster-name {
    font-size: 1.2rem;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-align: center;
}

.hunting-monster-health {
    position: relative;
    width: 100%;
    height: 24px;
    background-color: #111;
    border: 1px solid #444;
    overflow: hidden;
    box-sizing: border-box;
}

.hunting-monster-health-fill {
    height: 100%;
    background-color: #d32f2f;
    width: 100%;
}

.hunting-monster-health-text {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #eee;
    font-size: 0.85rem;
    text-shadow: 1px 1px 2px #000;
    pointer-events: none;
    z-index: 3;
}

/* ==========================================================================
   2. SPELL SLOTS & USABLE DECK COMPONENTS
   ========================================================================== */
.hunting-spell-slot-container {
    width: 90%;
    background-color: #151515;
    border: 1px solid #333;
    padding: 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hunting-spell-slots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px; /* Increased slightly to give the arrow perfect breathing room */
    width: 100%;
    min-height: 50px;
    position: relative;
}

.hunting-usable-spells-container {
    width: 90%;
    background-color: #1a1a1a;
    border: 1px solid #333;
    padding: 10px;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    max-height: 140px;
    overflow-y: auto;
}

/* Consolidated Shared Token Box Layout Parameters */
.hunting-spell-slot,
.hunting-spell {
    position: relative; /* REQUIRED: Keeps the absolute arrow attached to the slot */
    overflow: visible !important; /* REQUIRED: Prevents the arrow from being cut off */
    width: 1.6vw;
    height: 1.6vw;
    min-width: 28px;
    min-height: 28px;
    aspect-ratio: 1 / 1;
    border: 1px solid #444;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #252525; /* Default background state when empty */
}

.hunting-spell-slot { cursor: pointer; }
.hunting-spell      { cursor: grab; }

.hunting-spell-slot.drag-over {
    border: 2px solid var(--shard-drag-color, #64dfdf) !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Fallback protection for ghost vector render layers */
.floating-drag-icon svg {
    width: 80% !important;
    height: 80% !important;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}
.floating-drag-icon svg * {
    fill: #eee !important;
    stroke: none !important;
}


.hunting-spell-slot[data-assigned-element]:not(:last-child)::after {
    content: '>';
    position: absolute;
    left: 100%;               
    margin-left: 14px;       
    top: 50%;                 
    transform: translate(-50%, -50%); 
    
    font-family: 'nihonium', sans-serif;
    font-size: 2rem;
    line-height: 1;          
    color: #eee;
    text-shadow: 0 0 2px #000; 
    pointer-events: none !important;
    z-index: 10;
}


.hunting-spell svg,
.hunting-spell-slot svg {
    border-radius: inherit; 
    overflow: hidden; 
    width: 80% !important;
    height: 80% !important;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none !important;
    z-index: 2; /* Forces white SVG paths to float cleanly over color backdrops */
}


/* 3. Action Command Row */
.hunting-action-row {
    display: flex;
    flex-direction: row;
    width: 90%;
    gap: 10px;
    box-sizing: border-box;
    margin-top: auto;
    margin-bottom: 25px;
    flex-shrink: 0;
}


.hunting-action-button {
    color: #eee;
}
.hunting-action-button, 
.hunting-auto-button {
    font-family: 'nihonium', sans-serif;
    border: 1px solid #444;
    height: 44px;
    background-color: #2a2a2a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 1px;
    box-sizing: border-box;
    transition: background-color 0.2s, border-color 0.2s;
}

.hunting-action-button { flex: 1; }

.hunting-auto-button {
    color: #666;
    flex-grow: 0;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
}

.hunting-action-button:hover { background-color: #333; border-color: #444; }
.hunting-auto-button:hover   { background-color: #333; border-color: #444; }

.hunting-auto-button.active {
    color: #eee;
}


/* 4. Secondary Logs & Static Elements */
.hunting-tile-stat-display {
    width: 90%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #888;
    font-size: 0.85rem;
    margin-top: 5px;
}

.tile-even { fill: var(--color-primary, #ffffff); }
.tile-odd  { fill: var(--color-secondary, #000000); }


/* ==========================================================================
   ACTIVE QUEST TRACKER MODULE
   ========================================================================== */

.hunting-tracker-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
}

.tracker-header-title {
    font-size: 0.9rem;
    font-weight: bold;
    color: #eee;
    letter-spacing: 1px;
}

.tracker-tiles-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr); 
    gap: 10px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 4px;
}

.hunting-quest-tile {
    background: rgba(20, 20, 30, 0.7);
    border: 1px solid #eee;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-sizing: border-box;
}

.quest-tile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.quest-tile-coords {
    color: #ffffff;
    font-weight: bold;
}

/* Frame and Status Variant Bars */
.quest-tile-progress-bar {
    position: relative;
    width: 100%;
    height: 20px;
    background: rgba(255, 255, 255, 0.05);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.quest-tile-progress-fill { height: 100%; }
.quest-tile-progress-fill.status-accepted { background-color: #ff1; }
.quest-tile-progress-fill.status-complete { background-color: #1f1; }
.quest-tile-progress-fill.status-claiming { background-color: #64dfdf; }

.quest-tile-progress-text {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
    box-sizing: border-box;
    font-size: 0.75rem;
    color: #222;
    font-weight: bold;
    pointer-events: none;
}

.no-quests-message {
    grid-column: span 2;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.8rem;
    padding: 20px 0;
    font-style: italic;
}