:root {
    --bg-dark: #37344D;      /* off-black, for bg and text */
    --primary: #cfb220;  /* sidebar */
    --secondary: #B84B63;    /* main content boxes, also works as accent */
    --accent: #643B75;  /* sub boxes within main content boxes */
    --text-white: #f8f8ee;   /* off-white, for text and borders*/
}

/* Basic Reset */
body {
    font-family: sans-serif;
    margin: 0;
    background-color: #3C3C53; /* Soft grey-blue background */
    color: var(--text-white);
}

#game-container {
    display: flex;
    /* Remove 'height: 100vh' if you want the container to grow with your content */
    min-height: 100vh; 
}

#main-content {
    flex-grow: 1;
    padding: 40px;
}

button {
    padding: 10px 15px;
    margin: 5px;
    cursor: pointer;
    border-radius: 5px;
    border: none;
    background-color: var(--secondary);
    color: var(--text-white);
}

/* #region +++ SIDE BAR +++ */

#pet-sidebar {
    position: sticky;
    top: 0;
    width: 20%;
    max-width: 250px;
    min-width: 150px;
    height: 100vh;
    align-self: flex-start;
    
    box-sizing: border-box; 
    
    background-color: var(--primary);
    border-right: 4px solid var(--text-white); /* White borders pop against dark bg */
    color: var(--bg-dark); /* Dark text for readability on gold */
    /* outline: 8px solid rgba(218, 189, 47, 0.4); */
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    
    /* Ensure the content inside can scroll if it gets too long */
    overflow-y: auto; 
    z-index: 10;
}

#pet-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)); /* Fixes overflow */
    grid-template-rows: auto auto;
    /* Centering logic */
    width: 90%;               /* Increased from 50% to fit the text + stroke */
    margin: 0 auto;           /* Centers the box itself in the sidebar */
    place-items: center;      /* Centers text horizontally & vertically in cells */
    
    background-color: var(--accent); /* Dark purple stats box */
    border: 3px solid var(--text-white);
    letter-spacing: 0.1em;
    border-radius: 10px;
    padding: 10px;
    font-family: Impact;

    -webkit-text-stroke-width: 4px;
    -webkit-text-stroke-color: var(--text-white);
    paint-order: stroke fill;
    text-align: center;

    gap: 0.3em 0.5em; /* Tightened row gap slightly */
}

/* Make numbers bigger */
.stat-value {
    font-size: clamp(1.5rem, 1.5rem + 1vw, 3rem);
}

/* Match colors for both value and label */
#val-vigor, #label-vigor { color: #ff9d00; }
#val-chaos, #label-chaos { color: #a200ff; }
#val-flux, #label-flux { color: #00cd93; }

/* General label styling */
.stat-label {
    font-size: clamp(0.1rem, 0.5rem + 1vw, 1rem);
    text-transform: uppercase;
}


/* Make the Progress Bars visible */
.progress-bar {
    width: 100%;
    height: 20px;
    border: 2px solid var(--text-white);
    background-color: var(--bg-dark);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
}

#energy-fill { background-color: #9de12f; height: 100%; transition: width 0.3s; }
#bond-fill { background-color: #3082fd; height: 100%; transition: width 0.3s; }



#pet-avatar {

    width: 100%;
    min-width: 0;          /* Removes the "intrinsic size" floor */
    flex-shrink: 1;        /* Explicitly allows the image to shrink */
    aspect-ratio: 1 / 1;          
    box-sizing: border-box; 
    object-fit: contain;    
    background: var(--text-white);    
    border: 8px solid var(--secondary); /* Swapped from outline */
    border-radius: 10px;
    padding: 10px;
}

/* Centers the image and name in the sidebar */
#pet-display {
    text-align: center;
    margin-bottom: 20px;
}

/* Styling the scrollbar for Chrome, Edge, and Safari */
#pet-sidebar::-webkit-scrollbar {
    width: 8px; /* Makes it nice and thin */
}

#pet-sidebar::-webkit-scrollbar-track {
    background: var(--primary); /* Matches your sidebar background */
}

#pet-sidebar::-webkit-scrollbar-thumb {
    background-color: var(--text-white); /* The moving part - matches your border */
    border-radius: 10px;       /* Makes it rounded/pill-shaped */
    border: 2px solid var(--primary); /* Adds a little space around the thumb */
}

/* Styling for Firefox */
#pet-sidebar {
    scrollbar-width: thin;
    scrollbar-color: var(--text-white) var(--primary);
}
/* #endregion */

/* #region +++ INVENTORY STYLES +++ */

/* --- SHARED MODULAR PANEL STYLES --- */
.side-panel {
    position: fixed;
    top: 0;
    left: 0.5%; /* Sidebar width */
    width: 20%;
    max-width: 250px;
    min-width: 150px;
    height: 100vh;
    background-color: var(--primary);
    border-right: 4px solid var(--text-white);
    box-sizing: border-box;
    padding: 15px;
    z-index: 5; 
    
    /* Animation logic */
    transform: translateX(0.5%); 
    transition: transform 0.1s ease-in-out;
}

.side-panel.open {
    z-index: 3;
    transform: translateX(100%);
}

/* The clickable tab on the edge */
.panel-tab {
    position: absolute;
    left: 100%; 
    height: 9%;
    aspect-ratio: 1/3;
    max-width: 30px;
    max-height: 80px;
    font-size: clamp(0.1rem, 3vh, 1.5rem);
    background-color: var(--primary);
    color: var(--bg-dark);
    border: 4px solid var(--text-white);
    border-left: none;
    border-radius: 0 8px 8px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    cursor: pointer;
    font-weight: bold;
    z-index: 100;
}

/* --- SPECIFIC PANEL TWEAKS --- */

/* Inventory Tab Position */
#inventory-tab { top: 10%; }

/* Pet Details Tab Position (Lower so they don't overlap) */
#pet-details-tab { top: 20%; }

/* Scrollable area inside panels */
.panel-content {
    height: 100%;
    overflow-y: auto;
    margin-top: 10px;
}

/* Container for the items */
#inventory-list {
    display: flex;
    flex-direction: column;
    gap: 12px; /* Space between each item box */
    margin-top: 15px;
}

/* Individual item box */
.inventory-item {
    background-color: var(--secondary);
    padding: 12px;
    border-radius: 8px; /* Slightly rounded edges */
    display: flex;
    align-items: center;
    gap: 15px;
    transition: background-color 0.2s;
    cursor: pointer;
}

.inventory-item:hover {
    background-color: var(--accent); /* Darkens on hover */
}

/* Small image for the item */
.item-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/* Item details text */
.item-info h4 { margin: 0; font-size: 14px; color: var(--text-white); }
.item-info p { margin: 0; font-size: 12px; color: var(--text-white); }

.item-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
    
    /* ADD THESE FOR FALLBACKS */
    background-color: var(--bg-dark); /* A dark gray background */
    border-radius: 50%;        /* Makes it a circle */
    border: 2px solid var(--text-white);
}

.bio-card {
    background: rgba(255, 255, 255, 0.15);
    padding: 12px;
    border-radius: 8px;
    border: 2px solid var(--text-white);
    color: var(--text-white);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    margin: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-row span:last-child {
    font-weight: bold;
    color: var(--bg-dark); /* Makes the actual number stand out */
}

/* #endregion */

/* #region +++ SELECTION SCREEN +++ */

/* creature selection screen */
#selection-screen {
    text-align: center;
    padding: 50px;
}

.creature-grid {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.creature-grid img {
    width: 150px;           /* Set a specific width */
    height: 150px;          /* Set a specific height */
    object-fit: contain;    /* This prevents squishing by scaling the image to fit */
    background: var(--text-white);       /* Optional: adds a background for better visibility */
    border: 4px solid var(--accent);
    border-radius: 10px;
    padding: 10px;
}

.creature-grid img:hover {
    transform: scale(1.1);
    border-color: var(--primary);
}

.selected-creature {
    border: 4px solid var(--secondary) !important;
    transform: scale(1.1);
}

#pet-name-input {
    color: var(--text-white);
    padding: 10px;
    font-size: 16px;
    border-radius: 5px;
    background-color: var(--bg-dark);
    border: 2px solid var(--text-white);
}
/* #endregion */

/* #region +++ MARKET STYLES +++ */

.market-view {
    background-color: var(--secondary); /* The Light Gray */
    border: 4px solid var(--text-white);
    border-radius: 15px;
    padding: 30px;
    color: var(--text-white);
}

.market-header {
    font-family: Impact;
    font-size: clamp(1rem, 0.8rem + 1vw, 2rem);
    color: var(--bg-dark);
    -webkit-text-stroke: 4px var(--text-white);
    paint-order: stroke fill;
    margin-top: 0;
    letter-spacing: 0.1em;
}

.market-balance {
    font-family: Impact;
    font-size: 1.2rem;
    letter-spacing: 1px;
}

.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.shop-card {
    background-color: var(--primary);
    border: 3px solid var(--text-white);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    transition: transform 0.1s;
}

.shop-card:hover {
    transform: translateY(-5px);
}

.item-icon-wrapper {
    background: var(--bg-dark);
    border: 2px solid var(--text-white);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
}

.shop-item-icon {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.shop-card h4 {
    margin: 10px 0 5px 0;
    font-family: Impact;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bg-dark);
    -webkit-text-stroke-width: 2px;
    -webkit-text-stroke-color: var(--text-white);
    paint-order: stroke fill;
}

.shop-price {
    font-family: Impact;
    color: #186c3e;
    font-size: 1.1rem;
    margin: 10px 0;
}

.buy-btn {
    background-color: var(--secondary); /* Gold buttons like the sidebar theme */
    color: var(--text-white);
    font-weight: bold;
    border: 2px solid var(--text-white);
    width: 100%;
    transition: background 0.2s;
}

.buy-btn:hover {
    background-color: var(--accent);
}

/* #endregion */

/* #region +++ EVOLUTION SCREEN STYLES */

#evolution-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(55, 52, 77, 0.9); /* --bg-dark with transparency */
    z-index: 1000;
    display: flex; justify-content: center; align-items: center;
}

#evolution-modal {
    background-color: var(--secondary);
    border: 6px solid var(--text-white);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
}

#evo-choices-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
}

.evo-choice-card {
    background: var(--accent);
    border: 3px solid var(--text-white);
    padding: 20px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative;
    text-align: center;
}

.evo-choice-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    border-color: var(--primary); /* Gold border on hover */
}

.evo-choice-card::after {
    content: "CHOOSE PATH";
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-family: Impact;
    color: var(--primary);
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.evo-choice-card:hover::after {
    opacity: 1;
}

#cancel-evo-btn {
    background: transparent;
    color: var(--text-white);
    border: 1px solid var(--text-white);
    margin-top: 15px;
}

.evo-card img {
    width: 140px;           /* Control the width */
    height: 140px;          /* Control the height */
    object-fit: contain;    /* Prevents squishing/stretching */
    background: var(--text-white); /* Optional: matches your sidebar avatar look */
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 15px;
    border: 2px solid var(--ui-border);
}

/* #endregion */

/* #region +++ DEBUG CONSOLE +++ */

#debug-console {
    position: fixed;
    bottom: 0; left: 0;
    width: 100%;
    background: var(--bg-dark);
    border-top: 3px solid var(--primary);
    padding: 10px;
    z-index: 2000;
    font-family: monospace;
}

#debug-log {
    color: var(--primary);
    font-size: 0.8rem;
    margin-bottom: 5px;
    max-height: 50px;
    overflow-y: auto;
}

#debug-input {
    width: 98%;
    background: #000;
    color: #0f0; /* Classic green terminal text */
    border: 1px solid var(--text-white);
    padding: 5px;
    outline: none;
}

#debug-suggestions {
    background: var(--bg-dark);
    border: 1px solid var(--primary);
    border-bottom: none;
    max-height: 150px;
    overflow-y: auto;
    display: none; /* Hidden by default */
}

.suggestion-item {
    padding: 5px 10px;
    color: var(--text-white);
    cursor: pointer;
    font-size: 0.8rem;
}

.suggestion-item.selected {
    background: var(--primary);
    color: var(--bg-dark);
    font-weight: bold;
}


/* #endregion */

/* #region +++ Match Game +++ */

#match-grid-container {
    position: relative; /* Necessary for absolute children */
    width: 380px;  /* 6 cols * 60px + margins */
    height: 320px; /* 5 rows * 60px + margins */
    background: var(--bg-dark);
    padding: 10px;
    border: 4px solid var(--text-white);
    border-radius: 10px;
    display: inline-block;
    user-select: none; /* Prevents text highlighting while dragging */
}

.grid-row { display: flex; }

.orb {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%; 
    background-size: contain; /* Ensures the art fits the circle */
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3); /* Adds some depth to the art */
    will-change: left, top;
    transform: translateZ(0); /* Forces GPU rendering */
    transition: left 0.1s ease-out, top 0.1s ease-out; /* Smooth shifting */
}

/* Orb Colors */
.red { background-image: url('../assets/orbs/red-orb-sml.png'); }
.blue { background-image: url('../assets/orbs/blue-orb-sml.png'); }
.green { background-image: url('../assets/orbs/green-orb-sml.png'); }
.yellow { background-image: url('../assets/orbs/yellow-orb-sml.png'); }
.purple { background-image: url('../assets/orbs/purple-orb-sml.png'); }
.pink { background-image: url('../assets/orbs/pink-orb-sml.png'); }
.food { background-image: url('../assets/orbs/orb-food.png');}
.toy { background-image: url('../assets/orbs/orb-toy.png');}

.orb.dragging {
    transition: none; /* Disable transition while active dragging */
    opacity: 0.8;
    transform: scale(1.2);
    box-shadow: 0 0 15px var(--primary); /* Glowing gold glow */
    z-index: 100;
    cursor: grabbing;
    pointer-events: none; /* Allows the 'elementFromPoint' to see the orbs BELOW */
}

#combo-log {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 40px;
    margin-bottom: 10px;
}

.combo-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-family: Impact;
    font-size: 0.9rem;
    color: white;
    border: 2px solid rgba(255,255,255,0.3);
    text-shadow: 1px 1px 2px black;
}

/* Colors for the badges */
.badge-red { background: #a30000; }
.badge-blue { background: #004da3; }
.badge-pink { background: #a3005a; }
.badge-purple { background: #6d00a3; }
.badge-yellow { background: #a39b00; }

#timer-container {
    width: 380px; /* Matches grid width (6 orbs * 60px + margins) */
    height: 6px;
    background: rgba(0, 0, 0, 0.3);
    margin: 10px auto;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--ui-border);
}

#timer-fill {
    width: 100%;
    height: 100%;
    background: var(--primary); /* Gold */
    transition: width 0.1s linear;
}

/* Optional: Make the bar turn red when low */
#timer-fill.warning {
    background: #ff4d4d;
    box-shadow: 0 0 10px #ff0000;
}

/* Container for both HP boxes */
#battle-ui {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    margin: 0 auto 20px auto;
    gap: 20px;
}

.hp-box {
    flex: 1;
    text-align: center;
    color: var(--text-white);
    font-family: Impact, sans-serif;
    text-transform: uppercase;
    font-size: 0.8rem;
}

/* The grey background of the bar */
.hp-bar-bg {
    width: 100%;
    height: 14px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--ui-border);
    border-radius: 7px;
    overflow: hidden;
    margin: 5px 0;
    position: relative;
}

/* The actual colored fill */
#player-hp-fill, #enemy-hp-fill {
    height: 100%;
    width: 100%; /* Default to full */
    transition: width 0.4s ease-out; /* Smooth shrinking animation */
}

/* Player is Green/Teal, Enemy is Red/Orange */
#player-hp-fill {
    background: linear-gradient(to right, #2ecc71, #27ae60);
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.5);
}

#enemy-hp-fill {
    background: linear-gradient(to right, #e74c3c, #c0392b);
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.5);
}

/* HP Numbers below the bar */
.hp-box span {
    font-size: 0.75rem;
    letter-spacing: 1px;
}

.orb.exploding {
    animation: orb-explode 0.5s ease-out forwards;
    z-index: 200;
}

@keyframes orb-explode {
    0% { transform: scale(1); opacity: 1; filter: brightness(2); }
    100% { transform: scale(2); opacity: 0; filter: brightness(5); }
}

/* Ensure new orbs falling in look smooth */
.orb.falling {
    transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Slight bounce */
}

/* #endregion */

/* #region +++ TOAST +++ */
#toast-container {
    position: fixed;
    top: 20px; right: 20px;
    z-index: 3000;
    display: flex; flex-direction: column; gap: 10px;
}

.toast {
    background: var(--secondary);
    color: var(--text-white);
    border: 2px solid var(--primary);
    padding: 12px 20px;
    border-radius: 8px;
    width: 15vw;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    animation: toast-in 0.3s ease-out forwards;
}

#notification-log {
    position: fixed;
    top: 55px; /* Keeps it below your History tab */
    right: 15px;
    width: 20%;
    
    /* FIX: Limit height to 70% of the screen height */
    max-height: 70vh; 
    
    /* FIX: Allow internal scrolling when content is too long */
    overflow-y: auto; 
    
    background: var(--bg-dark);
    border: 3px solid var(--primary);
    border-radius: 12px;
    padding: 15px;
    z-index: 3001;
    display: none; /* Controlled by JS toggleLog */
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}

#notification-log::-webkit-scrollbar {
    width: 6px;
}
#notification-log::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

#log-content {
    overflow-y: auto;
    max-height: 300px;
    margin-top: 10px;
    font-size: 0.8rem;
}

.log-entry {
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding: 8px 0;
}

@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

#ui-top-right {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

#history-tab {
    background: var(--secondary);
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 5px 12px;
    border-radius: 20px;
    font-family: Impact;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

#history-tab:hover {
    background: var(--primary);
    color: var(--bg-dark);
}

/* Position the log relative to the tab */
#notification-log {
    position: fixed;
    top: 55px; /* Sits right under the tab */
    right: 15px;
    width: 20%;
    max-height: 350px;
    background: var(--bg-dark);
    border: 2px solid var(--primary);
    border-radius: 10px;
    padding: 10px;
    z-index: 3001;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    display: none; /* Controlled by JS */
    flex-direction: column;
}

.log-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--primary);
    padding-bottom: 5px;
    font-family: Impact;
    color: var(--primary);
}


/* #endregion */
