@font-face {
    font-family: 'PixelSans'; /* The name you will use in your CSS */
    src: url('fonts/PixelifySans-Regular.woff2') format('woff2'), /* Primary format */
         url('fonts/PixelifySans-VariableFont_wght.ttf') format('truetype'); /* Fallback */
    font-weight: normal;
    font-style: normal;
    font-display: swap; /* Improves performance by showing fallback text first */
  }

  body {
    background-color: #121212;
    color: #dddddd;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: 'PixelSans', 'Courier New', monospace; /* Updated */
    padding: 20px;
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

/* Ensure the canvas doesn't break small screens */
canvas {
    max-width: 100%;
    height: auto;
}

#canvas-container {
    border: 3px solid #333;
    background: black;
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.2);
}

#ritual-container {
    position: relative;
    width: 500px;
    height: 500px;
    margin: 20px auto;
    background: black;
    /* This ensures the canvases don't spill out */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Force both canvases to stack on top of each other and FILL the square */
#summonCanvas, #spriteCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* This keeps the text and buttons underneath the circle */
#hash-display, #button-row, .name-input-container {
    position: relative;
    z-index: 10;
    margin-top: 10px;
}

button {
    margin-top: 15px;
    padding: 10px 25px;
    cursor: pointer;
    background: transparent;
    color: #ff4444;
    border: 2px solid #ff4444;
    font-weight: bold;
    transition: 0.3s;
}
button:hover {
    background: #ff4444;
    color: black;
}

/* Ensure the sprite (Hashling) is centered and doesn't stretch */
#spriteCanvas {
    z-index: 2;
    pointer-events: none; /* So you can draw "under" it */
    /* Scale the sprite down so it fits in the center of the circle */
    transform: scale(0.25); 
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    
    /* This adds the glow back using the browser's GPU (very fast) */
    filter: drop-shadow(0 0 0px currentColor);
}

.hashling-sprite {
    width: 200px; 
    height: 200px;
    image-rendering: pixelated; 
    image-rendering: crisp-edges;
}

#gallery-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    width: 80vw;         /* 80% of screen width on mobile */
    max-width: 300px;    /* But caps at 300px on desktop */
    background: #0a0a0a;
    border-right: 1px solid #333;
    transition: transform 0.3s ease;
    z-index: 100;
    padding: 20px;
    color: white;
    display: flex;
    flex-direction: column;
}

.sidebar-closed {
    transform: translateX(-320px);
}

#toggleGallery {
    position: absolute;
    /* Position it exactly on the right edge of the sidebar */
    right: -65px; 
    top: 20px;
    
    /* Visual styles */
    background: #1a1a1a;
    border: 1px solid #333;
    border-left: none; /* Looks like a tab sticking out */
    padding: 10px;
    font-size: 12px;
    z-index: 2001;
}

#hashling-list {
    height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-top: 20px;
    align-items: center;
}

/* The "Black Square" Entry */
.hashling-card {
    position: relative;
    background: black;
    border: 1px solid white;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 20px;

    /* --- THE BULLETPROOF SQUARE FIX --- */
    width: 200px;           /* Set a fixed width or 100% of the sidebar */
    height: 200px;          /* Match the width exactly */
    flex-shrink: 0;         /* Prevent the sidebar from squishing the height */
    box-sizing: border-box; /* Ensures padding doesn't add to the size */
    /* ---------------------------------- */

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* The Ritual Circle Background */
.card-circle-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    
    min-width: 100%; 
    min-height: 100%;
    
    object-fit: contain; /* This keeps the circle from stretching into an oval */
    opacity: 0.5;
    pointer-events: none;
    z-index: 1;
}

/* The Sprite Foreground */
.card-sprite {
    position: relative;
    z-index: 2; /* Sits above the circle */
    width: 50px;
    height: 50px;
    image-rendering: pixelated;
    margin-bottom: 8px;
}

.hashling-card img {
    width: 80px; /* Mini sprite size */
    height: 80px;
    image-rendering: pixelated;
    margin-bottom: 8px;
}

/* The Name Text */
.hashling-card span {
    position: relative;
    z-index: 2; /* Sits above the circle */
    display: block;
    font-size: 0.85em;
    font-family: monospace;
    color: #ffffff;
    text-shadow: 0px 0px 5px black; /* Ensures readability over the circle */
}

/* Layout Wrapper */
#summoning-layout {
    display: flex;
    flex-direction: row-reverse; /* Puts toolbar on the RIGHT of canvas */
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 20px auto;
    width: fit-content;
    justify-content: center;
}

/* Toolbar Style */
#toolbar {
    display: flex;
    flex-direction: column; /* Vertical on Desktop */
    gap: 20px;
    background: #1a1a1a;
    padding: 20px;
    border: 1px solid #333;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
}

.tool-btn {
    margin-top: 0 !important; /* Override your general button margin */
    padding: 8px 15px !important;
    font-size: 12px;
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: #dddddd;
    font-size: 12px;
    font-family: 'PixelSans', monospace;
}

#sliceSlider {
    cursor: pointer;
    accent-color: #ff4444; /* Matches your button color */
}

/* --- Hamburger Icon Styling --- */
.hamburger {
    display: none; /* Hidden on desktop */
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    z-index: 5000;
}

.hamburger span {
    width: 25px;
    height: 2px;
    background-color: #00ffcc;
    transition: 0.3s;
}

.main-nav {
    width: 100%;
    height: 80px; /* Increased from 60px */
    background: #0a0a0a;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 3000;
}

/* --- Logo --- */
.nav-logo {
    font-family: 'Pixelify Sans', sans-serif;
    color: white;
    letter-spacing: 2px;
    font-size: 1.5rem; /* Bigger logo */
    flex: 1; /* Takes up equal space on the left */
}

/* --- Center Menu Section --- */
.nav-menu-container {
    flex: 2; /* Takes up more space in the middle */
    display: flex;
    justify-content: center;
}

.nav-links {
    display: flex;
    gap: 30px;
}

/* .nav-link {
    text-decoration: none;
    color: #fff;
    font-family: 'Pixelify Sans', sans-serif;
    font-size: 1.1rem;
    transition: color 0.2s;
    white-space: nowrap;
} */

.nav-link:hover {
    color: #00ffcc;
}

/* --- Auth Section --- */
.nav-auth-group {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1; /* Takes up equal space on the right */
    justify-content: flex-end;
}

.nav-btn {
    background: transparent;
    border: 1px solid #444;
    color: #ccc;
    padding: 10px 20px; /* Larger buttons */
    font-size: 1.2rem;
    cursor: pointer;
    font-family: 'Pixelify Sans', sans-serif;
    transition: 0.2s;
    white-space: nowrap;
}

/* --- Mobile Hamburger --- */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
}

.hamburger span {
    width: 30px;
    height: 3px;
    background: #00ffcc;
    transition: 0.3s;
}


@media (max-width: 800px) {
    body {
        padding: 10px;
        display: block;
        min-height: 100vh;
        overflow-y: auto; /* Allow scrolling if the phone is small */
    }

    /* 1. THE RITUAL CONTAINER: This is the primary fix */
    #ritual-container {
        width: 90vw !important;        /* Use almost full screen width */
        max-width: 500px;              /* Don't exceed original design size */
        height: auto !important;       /* Let aspect ratio handle height */
        aspect-ratio: 1 / 1;           /* Force a perfect square */
        margin: 10px auto 20px auto;   /* Center it with some breathing room */
        touch-action: none;            /* Essential: Stops the page from scrolling while drawing */
        
    }

    /* 2. CANVASES: Ensure they fill the 95vw container exactly */
    #summonCanvas, #spriteCanvas {
        position: absolute;
        top: 0;
        left: 0;
        width: 100% !important;
        height: 100% !important;
        image-rendering: pixelated; /* Keeps it sharp on high-res displays */
    }

    /* 3. SPRITE SCALING: Make sure the monster stays centered */
    #spriteCanvas {
        /* On mobile, we keep the 0.25 scale so it stays in the "portal" */
        transform: scale(0.25); 
    }

    /* 4. UI ELEMENTS: Stack them neatly below the ritual */
    #hash-display {
        width: 95%;
        margin: 0 auto;
        font-size: 10px;        /* Smaller font to prevent hash overflow */
        word-break: break-all;  /* Force the long hash to wrap if needed */
        text-align: center;
        background: rgba(0,0,0,0.5);
        padding: 5px;
    }

    /* Buttons stack vertically on mobile */
    #button-row {
        display: flex;
        width: 95%;
        margin: 15px auto;
        justify-content: center;
    }

    button {
        width: 100%;
        margin-top: 0;
        padding: 15px 5px; 
        font-size: 12px;
    }

    /* 4. Fix the LOGS button position */
    #toggleGallery {
        left: 0; /* Keep it tucked to the side */
        top: 10px;
        transform: none;
        font-size: 10px;
        padding: 5px 10px;
        align-items: start;
    }

    #hashling-list {
        display: grid; /* Use a grid for mobile logs */
        grid-template-columns: 1fr 1fr; /* Two columns of squares! */
        gap: 15px;
        padding: 10px;
    }

    .hashling-card {
        width: 100% !important; /* Let the grid handle the width */
        aspect-ratio: 1 / 1;    /* Force the 1:1 ratio */
        height: auto !important; /* Clear any fixed heights */
        padding: 5px;
        margin-bottom: 0 !important;
    }

    .hashling-card img {
        width: 60px; /* Scale down the preview sprite for small squares */
        height: 60px;
    }

    /* The naming UI needs to be clear */
    #naming-ui {
        width: 95%;
        margin: 0 auto;
    }

    #summoning-layout {
        flex-direction: column; /* Toolbar moves ABOVE canvas */
        width: 95vw;
    }

    #toolbar {
        flex-direction: row; /* Horizontal on mobile */
        width: 100%;
        justify-content: space-between;
        align-items: center;
        padding: 10px 15px;
        box-sizing: border-box;
    }

    .slider-group {
        flex-direction: row;
        align-items: center;
    }


}