/* =========================================
    BRUTALIST CSS VISUALS
========================================= */
body {
    font-family: 'Host Grotesk', sans-serif;
    background-color: #0a0a0a;
    color: #d0d0d0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    margin: 0;
    min-height: 100vh;
}

h1 {
    margin-top: 0;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* --- Setup Screen & Brutalist Art --- */
#setup-screen {
    text-align: center;
    margin-top: 10vh;
    background: #000;
    padding: 40px;
    border: 2px solid #444;
    max-width: 500px;
}

.brutalist-art {
    font-family: monospace;
    white-space: pre;
    color: #00e5ff;
    font-size: 1.2rem;
    line-height: 1.1;
    margin-bottom: 20px;
    font-weight: bold;
    user-select: none;
}

.blurb {
    font-size: 0.95rem;
    color: #888;
    margin-bottom: 30px;
    line-height: 1.5;
}

/* --- UI Components --- */
.btn {
    background-color: #000;
    color: #fff;
    border: 2px solid #666;
    padding: 8px 16px;
    margin: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-family: 'Host Grotesk', sans-serif;
    font-weight: bold;
    text-transform: uppercase;
    transition: background 0.1s;
}

.btn:hover {
    background-color: #333;
}

.btn.primary {
    border-color: #4CAF50;
    color: #4CAF50;
}

.btn.primary:hover {
    background-color: #4CAF50;
    color: #000;
}

.btn.action {
    border-color: #00e5ff;
    color: #00e5ff;
}

.btn.action:hover {
    background-color: #00e5ff;
    color: #000;
}

select,
input[type="number"],
input[type="file"] {
    background: #000;
    color: white;
    border: 2px solid #444;
    padding: 6px;
    font-family: 'Host Grotesk', sans-serif;
    width: 100%;
    box-sizing: border-box;
}

input[type="range"] {
    width: 100%;
    margin: 8px 0 0 0;
    box-sizing: border-box;
    accent-color: #888;
}

/* --- Layout Grids --- */
#workspace {
    display: grid;
    grid-template-columns: 280px auto 280px;
    gap: 20px;
    max-width: 1300px;
    align-items: start;
}

.center-col {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.side-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* --- Collapsible Panels --- */
details.panel {
    background: #000;
    border: 2px solid #333;
    box-sizing: border-box;
}

details.panel summary {
    font-size: 1.1rem;
    color: #fff;
    padding: 10px;
    cursor: pointer;
    font-weight: bold;
    outline: none;
    user-select: none;
    text-transform: uppercase;
    border-bottom: 2px solid transparent;
}

details.panel[open] summary {
    border-bottom: 2px solid #333;
    background: #111;
}

details.panel .panel-content {
    padding: 15px;
}

/* --- The Camera Viewport --- */
#canvas-wrapper {
    position: relative;
    width: 512px;
    height: 512px;
    margin-bottom: 20px;
    background: #222;
    border: 2px solid #555;
    overflow: hidden;
}

#pan-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: top left;
}

#underlay-image {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    /* Locks image to the bottom */
    transform-origin: top left;
    pointer-events: none;
}

#art-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    /* Locks pixel art above the image */
    image-rendering: pixelated;
    background-color: transparent !important;
}

#ui-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    /* Locks grid/flowmap above everything else */
    pointer-events: none;
}

/* FIX: Added cursor-canvas styles here */
#cursor-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 4;
    /* Locks cursor above the grid to prevent re-rendering the grid on blink */
    pointer-events: none;
}

/* --- Utilities & Controls --- */
.control-group {
    margin-bottom: 15px;
    width: 100%;
}

.control-group label {
    display: block;
    font-size: 0.85rem;
    color: #aaa;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.toggle-row label {
    margin-bottom: 0;
    font-size: 0.95rem;
    color: #ccc;
    cursor: pointer;
}

/* --- Keyboard Diagram & Legend --- */
#keyboard-diagram {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 512px;
}

.kb-row {
    display: flex;
    justify-content: center;
    gap: 2px;
}

.key {
    width: 38px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    color: white;
    border: 2px solid #000;
    text-shadow: 1px 1px 0px #000;
    cursor: pointer;
    user-select: none;
    box-sizing: border-box;
    font-family: monospace;
    transition: border-color 0.1s;
}

.key.selected {
    border-color: #00e5ff;
    box-shadow: inset 0 0 0 2px rgba(0, 229, 255, 0.5);
    z-index: 4;
}

.key:active {
    background-color: #fff !important;
    color: #000;
    text-shadow: none;
}

.key.active-feedback {
    border-color: #fff;
    z-index: 5;
}

#key-legend {
    width: 512px;
    margin-top: 15px;
    padding: 10px;
    border: 2px solid #333;
    background: #000;
    box-sizing: border-box;
    font-size: 0.8rem;
    color: #aaa;
    text-align: center;
    line-height: 1.6;
}

#key-legend span {
    color: #fff;
    font-weight: bold;
}

/* --- Minimap --- */
#minimap-wrapper {
    position: relative;
    width: 240px;
    height: 240px;
    margin: 0 auto 15px auto;
    background: #111;
    border: 2px solid #555;
    overflow: hidden;
    cursor: grab;
}

#minimap-wrapper:active {
    cursor: grabbing;
}

#minimap-bg,
#minimap-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

#minimap-ui {
    pointer-events: none;
}