/**
 * @fileoverview Core styling for the game shell.
 */

:root {
    --bg-color: #050510;
    --neon-blue: #00f3ff;
    --neon-red: #ff003c;
    --neon-green: #00ff66;
    --neon-yellow: #ffee00;
    --neon-purple: #ff7b9a;
    --text-color: #e0e0e0;
    --panel-bg: rgba(5, 5, 16, 0.85);
    --panel-border: rgba(0, 243, 255, 0.3);
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Courier New', Courier, monospace; /* Placeholder retro font */
}

/* Attract Mode Background canvases */
#attract-canvas, #rain-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
#attract-canvas { z-index: 1; }
#rain-canvas { z-index: 2; }

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    isolation: isolate;
}

#game-canvas {
    display: block;
    background-color: var(--bg-color);
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
    max-height: none;
    contain: none;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through to canvas by default */   
}

/* Diagnostics Panel */
#diagnostics-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    padding: 10px;
    border-radius: 4px;
    pointer-events: auto;
    font-size: 12px;
    color: var(--neon-green);
    text-shadow: 0 0 5px var(--neon-green);
}

/* Debug Console */
#debug-console {
    position: absolute;
    bottom: 220px;
    left: 10px;
    width: 400px;
    height: 200px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    padding: 10px;
    border-radius: 4px;
    pointer-events: auto;
    overflow-y: auto;
    font-size: 12px;
    color: var(--text-color);
    z-index: 220;
}

.hidden {
    display: none !important;
}

.defense-service-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    color: #f3fbff;
    background:
        linear-gradient(180deg, rgba(0, 243, 255, 0.045), transparent 12%),
        repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 4px),
        linear-gradient(180deg, rgba(6, 14, 28, 0.96), rgba(2, 8, 18, 0.96));
    border: 1px solid rgba(0, 243, 255, 0.34);
    border-radius: 8px;
    box-shadow:
        0 0 24px rgba(0, 243, 255, 0.12),
        0 18px 40px rgba(0, 0, 0, 0.42),
        inset 0 0 28px rgba(0, 243, 255, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    contain: layout paint style;
    will-change: transform;
}

.defense-service-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background:
        linear-gradient(90deg, rgba(0, 243, 255, 0.11), transparent 16%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 18%);
    pointer-events: none;
}

.defense-service-panel::after {
    content: '';
    position: absolute;
    inset: 10px;
    border: 1px solid rgba(0, 243, 255, 0.08);
    border-radius: 4px;
    pointer-events: none;
}

.defense-service-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 243, 255, 0.14);
    position: relative;
}

.defense-service-title-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.defense-service-eyebrow {
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(0, 243, 255, 0.75);
    text-shadow: 0 0 8px rgba(0, 243, 255, 0.35);
}

.defense-service-title {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.05;
    color: #fbfcff;
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.18), 2px 2px 0 rgba(0, 0, 0, 0.65);
}

.defense-service-meta {
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(170, 209, 224, 0.72);
}

.defense-service-header-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.defense-service-chip {
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid rgba(0, 243, 255, 0.26);
    background: linear-gradient(180deg, rgba(0, 243, 255, 0.1), rgba(0, 243, 255, 0.04));
    color: #dffaff;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: inset 0 0 10px rgba(0, 243, 255, 0.08);
}

.defense-service-chip-ore {
    border-color: rgba(255, 184, 77, 0.28);
    background: linear-gradient(180deg, rgba(255, 184, 77, 0.12), rgba(255, 184, 77, 0.04));
    color: #ffd88a;
    box-shadow: inset 0 0 10px rgba(255, 184, 77, 0.08);
}

.defense-service-status {
    min-height: 20px;
    padding: 10px 12px;
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(0, 243, 255, 0.05), transparent 36%),
        linear-gradient(180deg, rgba(5, 18, 31, 0.9), rgba(3, 12, 22, 0.96));
    border: 1px solid rgba(0, 243, 255, 0.18);
    font-size: 12px;
    line-height: 1.45;
    box-shadow: inset 0 0 16px rgba(0, 243, 255, 0.04);
}

.defense-service-section {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(0, 243, 255, 0.14);
    background:
        linear-gradient(180deg, rgba(0, 243, 255, 0.03), transparent 30%),
        linear-gradient(180deg, rgba(4, 12, 23, 0.82), rgba(2, 8, 16, 0.94));
    box-shadow: inset 0 0 18px rgba(0, 243, 255, 0.03);
}

.defense-service-tracks {
    max-height: min(60vh, 860px);
    overflow: auto;
}

.defense-service-tracks > div:first-child {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(0, 243, 255, 0.85);
    text-shadow: 0 0 8px rgba(0, 243, 255, 0.28);
}

.defense-service-tracks > div:nth-child(2) {
    font-size: 12px;
    line-height: 1.5;
    color: rgba(215, 228, 235, 0.78);
}

.defense-service-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 243, 255, 0.12);
}

.defense-service-group-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(115, 255, 208, 0.95);
    text-shadow: 0 0 8px rgba(0, 255, 170, 0.18);
}

.defense-service-group-description {
    font-size: 12px;
    line-height: 1.45;
    color: rgba(209, 220, 228, 0.72);
}

.defense-service-track-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(0, 243, 255, 0.12);
    background:
        linear-gradient(180deg, rgba(0, 243, 255, 0.04), transparent 26%),
        rgba(1, 10, 19, 0.56);
    box-shadow: inset 0 0 14px rgba(0, 243, 255, 0.025);
}

.defense-service-track-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.defense-service-track-label {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.05;
    text-shadow: 0 0 8px rgba(0, 243, 255, 0.12);
}

.defense-service-track-level {
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(0, 243, 255, 0.14);
    background: rgba(0, 243, 255, 0.06);
    color: rgba(218, 248, 255, 0.92);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.defense-service-track-description {
    font-size: 12px;
    line-height: 1.45;
    color: rgba(213, 224, 231, 0.82);
}

.defense-service-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding-top: 2px;
}

.defense-service-button {
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(0, 243, 255, 0.28);
    background:
        linear-gradient(180deg, rgba(0, 243, 255, 0.12), rgba(0, 243, 255, 0.03)),
        rgba(4, 20, 32, 0.92);
    color: #eafaff;
    text-align: left;
    font: inherit;
    line-height: 1.35;
    transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
    box-shadow: inset 0 0 14px rgba(0, 243, 255, 0.07);
}

.defense-service-button:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: rgba(0, 243, 255, 0.6);
    background:
        linear-gradient(180deg, rgba(0, 243, 255, 0.18), rgba(0, 243, 255, 0.06)),
        rgba(4, 20, 32, 0.96);
    box-shadow:
        0 0 18px rgba(0, 243, 255, 0.18),
        inset 0 0 18px rgba(0, 243, 255, 0.12);
    text-shadow: 0 0 6px rgba(0, 243, 255, 0.28);
}

.defense-service-button:disabled {
    border-color: rgba(0, 243, 255, 0.12);
    background:
        linear-gradient(180deg, rgba(0, 243, 255, 0.04), rgba(0, 243, 255, 0.02)),
        rgba(4, 16, 24, 0.86);
    color: rgba(194, 211, 220, 0.62);
    box-shadow: inset 0 0 10px rgba(0, 243, 255, 0.03);
}

.defense-service-track-button {
    min-height: 40px;
}

.defense-service-logistics {
    font-size: 12px;
    line-height: 1.5;
}

@media (max-width: 720px) {
    .defense-service-header {
        flex-direction: column;
    }

    .defense-service-header-stats {
        justify-content: flex-start;
    }

    .defense-service-track-label {
        font-size: 18px;
    }

    .defense-service-actions {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Reusable Neon Text / Buttons for future UI */
.neon-text-blue {
    color: var(--neon-blue);
    text-shadow: 0 0 5px var(--neon-blue);
}
.neon-button {
    background: transparent;
    border: 1px solid var(--neon-blue);
    color: var(--neon-blue);
    padding: 8px 16px;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: bold;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2) inset;
}
.neon-button:hover {
    background: rgba(0, 243, 255, 0.1);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4) inset, 0 0 15px rgba(0, 243, 255, 0.4);
}

.neon-button-green {
    border-color: var(--neon-green);
    color: var(--neon-green);
    box-shadow: 0 0 10px rgba(0, 255, 102, 0.2) inset;
}
.neon-button-green:hover {
    background: rgba(0, 255, 102, 0.1);
    box-shadow: 0 0 15px rgba(0, 255, 102, 0.4) inset, 0 0 15px rgba(0, 255, 102, 0.4);
}

.neon-button-yellow {
    border-color: var(--neon-yellow);
    color: var(--neon-yellow);
    box-shadow: 0 0 10px rgba(255, 238, 0, 0.2) inset;
}
.neon-button-yellow:hover {
    background: rgba(255, 238, 0, 0.1);
    box-shadow: 0 0 15px rgba(255, 238, 0, 0.4) inset, 0 0 15px rgba(255, 238, 0, 0.4);
}

/* --- Runtime HUD Shell --- */
.hud-shell {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none; /* let clicks pass through to canvas */
    z-index: 10;
}

.hud-cluster {
    background: rgba(5, 5, 16, 0.6);
    border: 1px solid rgba(0, 243, 255, 0.2);
    border-radius: 4px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    pointer-events: none; /* Let clicks pass through to canvas by default */
}

.hud-cluster button,
.hud-cluster .clickable {
    pointer-events: auto; /* Allow children to be clickable if needed */
}

#hud-utility {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    font-size: 12px;
}

.hud-row {
    display: flex;
    gap: 6px;
    align-items: baseline;
}

.hud-label {
    color: rgba(255, 255, 255, 0.6);
    font-weight: bold;
    text-transform: uppercase;
}

.hud-value {
    color: var(--text-color);
    font-weight: bold;
}

.hud-value.secondary {
    color: rgba(255, 255, 255, 0.5);
    font-weight: normal;
}

#hud-wave-state {
    align-items: flex-start;
    gap: 6px;
}

#hud-wave-state .hud-value {
    min-width: 84px;
}

.hud-separator {
    color: rgba(0, 243, 255, 0.3);
    margin: 0 4px;
}

.hud-help {
    color: rgba(255, 255, 255, 0.4);
    margin-top: 4px;
    font-style: italic;
}

/* Common neon overrides for values */
.neon-text-yellow {
    color: var(--neon-yellow);
    text-shadow: 0 0 5px var(--neon-yellow);
    font-size: 16px;
}

.neon-text-red {
    color: var(--neon-red);
    text-shadow: 0 0 5px var(--neon-red);
}

#ui-game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(20, 0, 5, 0.85); /* darkened backdrop with slight red tint */
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    pointer-events: auto;
}

#ui-game-over .start-panel {
    border-color: var(--neon-red);
    box-shadow: 0 0 20px rgba(255, 0, 60, 0.2);
}

#ui-game-over .start-title {
    color: var(--neon-red);
    text-shadow: 0 0 10px var(--neon-red);
}

/* Reusable Start Overlay Classes */
.start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(5, 5, 16, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    pointer-events: auto;
}

.start-panel {
    background: rgba(5, 5, 16, 0.95);
    border: 2px solid var(--neon-blue);
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.2);
    padding: 40px;
    border-radius: 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 400px;
}

.start-title {
    margin: 0;
    font-size: 32px;
    color: var(--neon-blue);
    text-shadow: 0 0 10px var(--neon-blue);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.start-summary {
    margin: 0;
    font-size: 16px;
    color: var(--text-color);
    line-height: 1.5;
}

.start-controls {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.start-btn {
    background: transparent;
    border: 2px solid var(--neon-blue);
    color: var(--neon-blue);
    padding: 12px 24px;
    font-size: 18px;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: bold;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2) inset;
    font-family: inherit;
    letter-spacing: 1px;
}

.start-btn:hover {
    background: rgba(0, 243, 255, 0.1);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.5) inset, 0 0 15px rgba(0, 243, 255, 0.5);
    text-shadow: 0 0 5px var(--neon-blue);
}

.start-hint {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    animation: start-pulse 1.5s infinite;
}

@keyframes start-pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

/* --- Shop Surface --- */
#shop-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    max-width: 750px;
    height: 85vh;
    max-height: 600px;
    background: var(--panel-bg);
    border: 2px solid var(--neon-blue);
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.2), inset 0 0 20px rgba(0, 243, 255, 0.2);
    display: none;
    flex-direction: column;
    pointer-events: auto;
    z-index: 100;
}

#shop-panel.active {
    display: flex;
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--panel-border);
}

.shop-header h2 {
    margin: 0;
    color: var(--neon-blue);
    text-shadow: 0 0 8px var(--neon-blue);
    text-transform: uppercase;
    font-size: 20px;
}

#shop-close-btn {
    background: transparent;
    border: none;
    color: var(--neon-red);
    font-size: 24px;
    cursor: pointer;
    text-shadow: 0 0 8px var(--neon-red);
}

.shop-tabs {
    display: flex;
    border-bottom: 2px solid var(--panel-border);
    background: rgba(0, 0, 0, 0.5);
}

.shop-section-tabs {
    display: flex;
    border-bottom: 1px solid rgba(0, 243, 255, 0.18);
    background: linear-gradient(180deg, rgba(0, 243, 255, 0.08), rgba(0, 0, 0, 0.45));
}

.shop-section-tabs .shop-tab-btn {
    flex: 1;
    padding: 10px 0;
    letter-spacing: 0.08em;
}

.shop-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-right: 1px solid var(--panel-border);
    color: var(--text-color);
    padding: 12px 0;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    text-transform: uppercase;
    transition: all 0.2s;
}

.shop-tab-btn:last-child {
    border-right: none;
}

.shop-tab-btn:hover {
    background: rgba(0, 243, 255, 0.1);
}

.shop-tab-btn.active {
    color: var(--neon-blue);
    border-bottom: 3px solid var(--neon-blue);
    background: rgba(0, 243, 255, 0.05);
    text-shadow: 0 0 5px var(--neon-blue);
}

.shop-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.shop-card {
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.shop-card:hover:not(.disabled) {
    border-color: var(--neon-green);
    box-shadow: 0 0 10px rgba(0, 255, 102, 0.3) inset;
    transform: translateY(-2px);
}

.shop-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: var(--neon-red);
}

.shop-card-title {
    font-weight: bold;
    color: var(--neon-blue);
    margin-bottom: 8px;
    font-size: 14px;
}

.shop-card-desc {
    font-size: 11px;
    color: #999;
    margin-bottom: 12px;
    flex: 1;
}

.shop-card-cost {
    font-weight: bold;
    color: var(--neon-yellow);
    text-shadow: 0 0 5px var(--neon-yellow);
    font-size: 16px;
    margin-bottom: 10px;
}

.shop-card-buy-btn {
    width: 100%;
    padding: 6px;
    background: transparent;
    border: 1px solid var(--neon-green);
    color: var(--neon-green);
    cursor: pointer;
    text-transform: uppercase;
    font-weight: bold;
    font-family: inherit;
    transition: all 0.2s;
}

.shop-card:not(.disabled) .shop-card-buy-btn:hover {
    background: rgba(0, 255, 102, 0.2);
    box-shadow: 0 0 8px rgba(0, 255, 102, 0.5);
}

.shop-card.disabled .shop-card-buy-btn {
    border-color: var(--neon-red);
    color: var(--neon-red);
    cursor: not-allowed;
}

/* --- Cinematic Menu Atmosphere --- */
.menu-atmosphere {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100; /* Under the menu, but covering the canvas */
    overflow: hidden;
}

/* Base state based on the element itself having hidden */
#cinematic-overlay.hidden {
    display: none;
}

/* Force shown when menu is not hidden */
#main-menu:not(.hidden) ~ #cinematic-overlay {
    display: block !important;
}

/* Hide clutter */
#main-menu:not(.hidden) ~ #runtime-hud,
#main-menu:not(.hidden) ~ #diagnostics-panel,
#main-menu:not(.hidden) ~ #debug-console,
#main-menu:not(.hidden) ~ div:not([id]),
#main-menu:not(.hidden) ~ #shop-panel,
#main-menu:not(.hidden) ~ #ui-game-over {
    display: none !important;
}

.vignette-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, transparent 30%, rgba(0, 5, 10, 0.85) 100%);
    box-shadow: inset 0 0 150px rgba(0,0,0,0.9);
}

.rain-layer {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    background-image:
        linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(100, 200, 255, 0.14) 50%, rgba(255,255,255,0) 100%),
        linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(0, 243, 255, 0.06) 50%, rgba(255,255,255,0) 100%);
    background-size: 14px 140px, 100% 100%;
    background-position: 0 0, 0 0;
    opacity: 0.2;
    transform: rotate(15deg);
    filter: blur(0.15px);
}

/* --- Blueprint Lab Surface --- */
#blueprint-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(1260px, calc(100vw - 40px));
    height: min(820px, calc(100vh - 40px));
    background:
        radial-gradient(circle at top right, rgba(0, 243, 255, 0.09), transparent 30%),
        radial-gradient(circle at bottom left, rgba(255, 123, 154, 0.06), transparent 28%),
        linear-gradient(180deg, rgba(4, 10, 18, 0.96), rgba(2, 6, 12, 0.92));
    border: 1px solid rgba(0, 243, 255, 0.18);
    border-radius: 20px;
    box-shadow: 0 0 36px rgba(0, 243, 255, 0.08), inset 0 0 30px rgba(0, 243, 255, 0.05), 0 0 100px rgba(0,0,0,0.7);
    display: none;
    flex-direction: column;
    pointer-events: auto;
    z-index: 260; /* Above the main menu shell so it stays in front of the enemy sheet */
    backdrop-filter: blur(12px);
    overflow: hidden;
}

#blueprint-panel.active {
    display: flex;
}

.blueprint-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid rgba(0, 243, 255, 0.14);
}

.blueprint-header h2 {
    margin: 0;
    color: var(--neon-blue);
    text-shadow: 0 0 12px rgba(0, 243, 255, 0.28);
    text-transform: uppercase;
    font-size: 22px;
    letter-spacing: 1.3px;
}

#blueprint-close-btn {
    background: transparent;
    border: none;
    color: var(--neon-red);
    font-size: 24px;
    cursor: pointer;
    text-shadow: 0 0 8px var(--neon-red);
}

.blueprint-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.blueprint-sidebar {
    width: 230px;
    border-right: 1px solid rgba(0, 243, 255, 0.12);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(0, 0, 0, 0.28);
}

.blueprint-sidebar h3 {
    margin: 0;
    color: var(--neon-yellow);
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

#blueprint-list {
    flex: 1;
    overflow-y: auto;
    display: grid;
    gap: 10px;
    min-height: 0;
}

.blueprint-list-item {
    padding: 12px;
    border: 1px solid rgba(0, 243, 255, 0.14);
    border-radius: 14px;
    cursor: pointer;
    color: var(--text-color);
    font-size: 12px;
    background: rgba(255, 255, 255, 0.03);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.blueprint-list-item:hover {
    background: rgba(0, 243, 255, 0.09);
}

.blueprint-list-item.active {
    border-color: rgba(0, 243, 255, 0.38);
    color: var(--neon-blue);
    background: linear-gradient(135deg, rgba(0, 243, 255, 0.12), rgba(255, 123, 154, 0.04));
}

.blueprint-list-item-name {
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.blueprint-list-item-body {
    min-width: 0;
    display: grid;
    gap: 6px;
}

.blueprint-list-item-meta {
    color: rgba(255, 255, 255, 0.58);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.blueprint-list-preview {
    width: 88px;
    height: 64px;
    border: 1px solid rgba(0, 243, 255, 0.14);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.44);
    box-shadow: inset 0 0 16px rgba(0, 243, 255, 0.04);
    flex: 0 0 auto;
}

.blueprint-list-empty {
    padding: 14px;
    border: 1px dashed rgba(0, 243, 255, 0.18);
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.56);
    font-size: 12px;
    line-height: 1.5;
    background: rgba(255, 255, 255, 0.02);
}

.blueprint-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 18px 22px;
    min-width: 0;
    min-height: 0;
    overflow: auto;
}

#blueprint-editor-canvas {
    background: #000;
    border: 1px solid rgba(0, 243, 255, 0.18);
    border-radius: 16px;
    box-shadow: 0 0 16px rgba(0, 243, 255, 0.08);
    cursor: crosshair;
    max-width: none;
    width: auto;
    height: auto;
    flex: 0 0 auto;
}

.blueprint-status-card {
    width: min(100%, 680px);
    padding: 12px 14px;
    border: 1px solid rgba(0, 243, 255, 0.14);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    box-sizing: border-box;
}

.blueprint-status-card[data-tone='warn'] {
    border-color: rgba(255, 204, 0, 0.24);
    background: rgba(255, 204, 0, 0.06);
}

.blueprint-status-label {
    margin-bottom: 6px;
    color: rgba(0, 243, 255, 0.72);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.6px;
    text-transform: uppercase;
}

.blueprint-status-text {
    color: #d7f6ff;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-line;
}

.blueprint-status-card[data-tone='warn'] .blueprint-status-text {
    color: #ffcf9d;
}

.blueprint-name-input {
    width: min(100%, 680px);
    box-sizing: border-box;
}

.blueprint-editor-hint {
    width: min(100%, 680px);
    color: rgba(255, 255, 255, 0.58);
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}

.blueprint-zoom-controls {
    width: min(100%, 680px);
    display: flex;
    justify-content: center;
    gap: 10px;
}

.blueprint-zoom-button {
    min-width: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.blueprint-zoom-readout {
    min-width: 92px;
}

.blueprint-zoom-value {
    font-size: 12px;
    letter-spacing: 1px;
}

.blueprint-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    width: min(100%, 680px);
    padding-bottom: 6px;
    flex: 0 0 auto;
}

.blueprint-controls .neon-button:disabled {
    opacity: 0.4;
    cursor: default;
    box-shadow: none;
}

.blueprint-palette {
    width: 240px;
    border-left: 1px solid rgba(0, 243, 255, 0.12);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(0, 0, 0, 0.28);
    overflow-y: auto;
}

.blueprint-palette-heading {
    color: var(--neon-green);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

.blueprint-palette-copy {
    color: rgba(255, 255, 255, 0.58);
    font-size: 12px;
    line-height: 1.5;
}

.blueprint-palette-grid {
    display: grid;
    gap: 10px;
}

.palette-item {
    border: 1px solid rgba(0, 243, 255, 0.14);
    padding: 10px 12px;
    cursor: pointer;
    font-size: 12px;
    text-transform: uppercase;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
}

.palette-item:hover {
    background: rgba(0, 255, 102, 0.1);
}

.palette-item.active {
    border-color: var(--neon-green);
    color: var(--neon-green);
    background: rgba(0, 255, 102, 0.08);
}

.blueprint-palette-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.blueprint-palette-name {
    text-align: left;
}

/* --- Skill Tree Surface --- */
#skill-tree-panel {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 28px;
    box-sizing: border-box;
    background: rgba(5, 8, 16, 0.74);
    backdrop-filter: blur(12px);
    z-index: 260;
}

#skill-tree-panel.active {
    display: flex;
}

#skill-tree-panel.collapsed {
    align-items: flex-start;
    justify-content: flex-start;
    padding: 16px;
    background: transparent;
    backdrop-filter: none;
}

.skill-tree-shell {
    width: min(1360px, calc(100vw - 56px));
    height: min(840px, calc(100vh - 56px));
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px;
    box-sizing: border-box;
    border: 1px solid rgba(0, 243, 255, 0.18);
    border-radius: 20px;
    background:
        radial-gradient(circle at top right, rgba(0, 243, 255, 0.09), transparent 30%),
        radial-gradient(circle at bottom left, rgba(255, 123, 154, 0.06), transparent 28%),
        linear-gradient(180deg, rgba(4, 10, 18, 0.96), rgba(2, 6, 12, 0.92));
    box-shadow: 0 0 36px rgba(0, 243, 255, 0.08), inset 0 0 30px rgba(0, 243, 255, 0.05);
    overflow: hidden;
}

.skill-tree-shell.collapsed {
    width: min(420px, calc(100vw - 32px));
    height: auto;
    gap: 8px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(4, 10, 18, 0.92);
}

.skill-tree-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.skill-tree-header-lead {
    display: grid;
    gap: 6px;
}

.skill-tree-kicker {
    color: rgba(0, 243, 255, 0.72);
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.skill-tree-title {
    margin: 0;
    color: var(--neon-blue);
    text-shadow: 0 0 14px rgba(0, 243, 255, 0.28);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-size: 28px;
}

.skill-tree-header-action {
    align-self: center;
}

.skill-tree-summary,
.skill-tree-help {
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
    line-height: 1.5;
}

.skill-tree-help {
    color: rgba(255, 255, 255, 0.56);
}

.skill-tree-body {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 18px;
    min-height: 0;
    flex: 1;
}

.skill-tree-sidebar {
    display: grid;
    gap: 14px;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

.skill-tree-sidebar-card {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid rgba(0, 243, 255, 0.14);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.3);
}

.skill-tree-sidebar-label {
    color: rgba(0, 243, 255, 0.72);
    font-size: 11px;
    letter-spacing: 1.8px;
    text-transform: uppercase;
}

.skill-tree-sidebar-metric {
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
}

.skill-tree-sidebar-copy {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    line-height: 1.5;
}

.skill-tree-branch-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
}

.skill-tree-branch-row.active {
    border: 1px solid rgba(0, 243, 255, 0.22);
    background: linear-gradient(90deg, rgba(0, 243, 255, 0.12), rgba(255, 123, 154, 0.05));
}

.skill-tree-branch-name {
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.skill-tree-branch-value {
    color: rgba(255, 255, 255, 0.62);
    font-size: 12px;
    text-align: right;
}

.skill-tree-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    min-height: 0;
}

.skill-tree-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.skill-tree-tab {
    border: 1px solid rgba(0, 243, 255, 0.24);
    background: rgba(0, 243, 255, 0.05);
    color: rgba(255, 255, 255, 0.74);
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 12px;
}

.skill-tree-tab:hover {
    background: rgba(0, 243, 255, 0.12);
}

.skill-tree-tab.active {
    color: var(--neon-blue);
    border-color: rgba(0, 243, 255, 0.5);
    background: rgba(0, 243, 255, 0.16);
    box-shadow: 0 0 18px rgba(0, 243, 255, 0.12);
}

.skill-tree-board-viewport {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 24px;
    border: 1px solid rgba(0, 243, 255, 0.14);
    border-radius: 18px;
    background:
        linear-gradient(rgba(0, 243, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 243, 255, 0.03) 1px, transparent 1px),
        radial-gradient(circle at top right, rgba(0, 243, 255, 0.05), transparent 34%),
        linear-gradient(180deg, rgba(0, 0, 0, 0.48), rgba(2, 6, 12, 0.82));
    background-size: 28px 28px, 28px 28px, 100% 100%, 100% 100%;
    box-sizing: border-box;
}

.skill-tree-board {
    position: relative;
    min-height: 100%;
}

.skill-tree-connections {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.skill-tree-link {
    fill: none;
    stroke: rgba(0, 243, 255, 0.22);
    stroke-width: 3;
}

.skill-tree-link.is-ready {
    stroke: rgba(0, 243, 255, 0.42);
}

.skill-tree-link.is-pending {
    stroke: rgba(255, 204, 0, 0.54);
}

.skill-tree-link.is-unlocked {
    stroke: rgba(0, 255, 102, 0.58);
}

.skill-tree-link.is-locked {
    stroke: rgba(255, 0, 60, 0.38);
}

.skill-tree-lane-header {
    position: absolute;
    top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    box-sizing: border-box;
    border: 1px solid rgba(0, 243, 255, 0.16);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.34);
    color: rgba(255, 255, 255, 0.74);
    font-size: 11px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
}

.skill-tree-card {
    position: absolute;
    width: 228px;
    min-height: 214px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    box-sizing: border-box;
    border: 1px solid rgba(0, 243, 255, 0.14);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(8, 14, 22, 0.96), rgba(3, 8, 14, 0.96));
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.24), inset 0 0 22px rgba(0, 243, 255, 0.03);
}

.skill-tree-card[data-state='ready'] {
    border-color: rgba(0, 243, 255, 0.34);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.24), inset 0 0 24px rgba(0, 243, 255, 0.08);
}

.skill-tree-card[data-state='pending'] {
    border-color: rgba(255, 204, 0, 0.34);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.24), inset 0 0 24px rgba(255, 204, 0, 0.06);
}

.skill-tree-card[data-state='unlocked'] {
    border-color: rgba(0, 255, 102, 0.34);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.24), inset 0 0 24px rgba(0, 255, 102, 0.08);
}

.skill-tree-card[data-state='locked'],
.skill-tree-card[data-state='no-points'] {
    border-color: rgba(255, 0, 60, 0.2);
}

.skill-tree-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.skill-tree-card-title-group {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.skill-tree-card-branch,
.skill-tree-card-status {
    align-self: flex-start;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 10px;
    letter-spacing: 1.1px;
    text-transform: uppercase;
}

.skill-tree-card-branch {
    color: rgba(255, 255, 255, 0.64);
    background: rgba(255, 255, 255, 0.05);
}

.skill-tree-card-status {
    color: rgba(255, 255, 255, 0.86);
    background: rgba(0, 243, 255, 0.12);
}

.skill-tree-card[data-state='pending'] .skill-tree-card-status {
    background: rgba(255, 204, 0, 0.12);
}

.skill-tree-card[data-state='unlocked'] .skill-tree-card-status {
    background: rgba(0, 255, 102, 0.14);
}

.skill-tree-card[data-state='locked'] .skill-tree-card-status,
.skill-tree-card[data-state='no-points'] .skill-tree-card-status {
    background: rgba(255, 0, 60, 0.12);
}

.skill-tree-card-title {
    margin: 0;
    color: #fff;
    font-size: 16px;
    line-height: 1.2;
}

.skill-tree-card-body {
    color: rgba(255, 255, 255, 0.72);
    font-size: 13px;
    line-height: 1.5;
    flex: 1;
}

.skill-tree-card-meta {
    display: grid;
    gap: 6px;
}

.skill-tree-card-meta-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.9px;
}

.skill-tree-card-meta-label {
    color: rgba(255, 255, 255, 0.45);
}

.skill-tree-card-meta-value {
    color: rgba(255, 255, 255, 0.86);
    text-align: right;
}

.skill-tree-card-reqs {
    max-width: 122px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.skill-tree-card-button {
    border: 1px solid rgba(0, 243, 255, 0.28);
    background: rgba(0, 243, 255, 0.08);
    color: var(--neon-blue);
    border-radius: 12px;
    padding: 10px 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.skill-tree-card-button:hover:not(:disabled) {
    background: rgba(0, 243, 255, 0.16);
    box-shadow: 0 0 16px rgba(0, 243, 255, 0.12);
}

.skill-tree-card-button:disabled {
    opacity: 0.6;
    cursor: default;
}

.skill-tree-card-button[data-state='pending'] {
    border-color: rgba(255, 204, 0, 0.32);
    color: var(--neon-yellow);
    background: rgba(255, 204, 0, 0.08);
}

.skill-tree-card-button[data-state='unlocked'] {
    border-color: rgba(0, 255, 102, 0.3);
    color: var(--neon-green);
    background: rgba(0, 255, 102, 0.08);
}

.skill-tree-card-button[data-state='locked'],
.skill-tree-card-button[data-state='no-points'] {
    border-color: rgba(255, 0, 60, 0.22);
    color: rgba(255, 255, 255, 0.62);
    background: rgba(255, 0, 60, 0.06);
}

.skill-tree-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}
/* --- Blueprint Lab Surface --- */


/* --- Main Menu Shell --- */
.main-menu-shell {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    pointer-events: none;
    display: flex;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.46), rgba(0, 0, 0, 0.06) 36%, rgba(0, 0, 0, 0.34)),
        radial-gradient(circle at top right, rgba(0, 243, 255, 0.08), transparent 34%);
}

.main-menu-shell.hidden {
    display: none !important;
}

.menu-panel-left {
    width: clamp(340px, 37vw, 500px);
    height: 100%;
    background:
        linear-gradient(180deg, rgba(3, 8, 14, 0.94), rgba(0, 0, 0, 0.9)),
        radial-gradient(circle at top left, rgba(0, 243, 255, 0.08), transparent 36%);
    border-right: 1px solid rgba(0, 243, 255, 0.2);
    box-shadow: 0 0 28px rgba(0, 243, 255, 0.12), inset -8px 0 32px rgba(0, 243, 255, 0.06);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 22px;
    padding: 42px 38px 32px;
    pointer-events: auto;
    box-sizing: border-box;
    overflow-y: auto;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.menu-panel-right {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 40px 36px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    box-sizing: border-box;
    pointer-events: auto;
    background:
        radial-gradient(circle at top right, rgba(0, 243, 255, 0.1), transparent 30%),
        radial-gradient(circle at bottom left, rgba(255, 123, 154, 0.06), transparent 24%),
        linear-gradient(180deg, rgba(5, 5, 16, 0.86), rgba(0, 0, 0, 0.72));
    overflow-y: auto;
}

.enemy-sheet-shell {
    width: min(100%, 360px);
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
    border: 1px solid rgba(0, 243, 255, 0.16);
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(2, 6, 12, 0.78), rgba(0, 0, 0, 0.68)),
        radial-gradient(circle at top right, rgba(0, 243, 255, 0.08), transparent 34%);
    box-shadow: 0 0 28px rgba(0, 243, 255, 0.08), inset 0 0 24px rgba(0, 243, 255, 0.05);
    backdrop-filter: blur(12px);
    transition:
        width 180ms ease,
        padding 180ms ease,
        gap 180ms ease,
        background 180ms ease,
        box-shadow 180ms ease,
        transform 180ms ease;
}

.enemy-sheet-shell.expanded {
    width: min(100%, 1080px);
    gap: 18px;
    padding: 26px;
    background:
        linear-gradient(180deg, rgba(2, 6, 12, 0.84), rgba(0, 0, 0, 0.76)),
        radial-gradient(circle at top right, rgba(0, 243, 255, 0.08), transparent 34%);
    box-shadow: 0 0 34px rgba(0, 243, 255, 0.08), inset 0 0 24px rgba(0, 243, 255, 0.05);
}

.enemy-sheet-shell.collapsed {
    transform: translateY(10px);
}

.enemy-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
}

.enemy-sheet-heading {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.enemy-sheet-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    flex: 0 0 auto;
}

.enemy-sheet-count {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(0, 243, 255, 0.2);
    background: rgba(0, 243, 255, 0.08);
    color: rgba(255, 255, 255, 0.78);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    white-space: nowrap;
}

.enemy-sheet-toggle {
    min-width: 136px;
}

.enemy-sheet-shell.collapsed .menu-enemy-copy {
    max-width: 34ch;
}

.enemy-sheet-shell.collapsed .enemy-sheet-grid {
    display: none;
}

.menu-section-label {
    color: var(--neon-blue);
    text-transform: uppercase;
    letter-spacing: 2.5px;
    font-size: 12px;
    font-weight: 700;
}

.menu-enemy-copy {
    margin: 0;
    max-width: 70ch;
    color: rgba(255, 255, 255, 0.72);
    font-size: 13px;
    line-height: 1.6;
}

.enemy-sheet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.enemy-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: start;
    padding: 14px;
    border: 1px solid rgba(0, 243, 255, 0.18);
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.7), rgba(0, 243, 255, 0.05));
    box-shadow: inset 0 0 20px rgba(0, 243, 255, 0.04);
}

.enemy-card-icon {
    --enemy-color: var(--neon-blue);
    --enemy-accent: #ffffff;
    width: 68px;
    height: 68px;
    position: relative;
    flex: 0 0 auto;
    background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.14), transparent 65%);
    filter: drop-shadow(0 0 10px var(--enemy-color));
    overflow: hidden;
}

.enemy-card-icon::before,
.enemy-card-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.enemy-card-icon::before {
    background: var(--enemy-color);
    opacity: 0.09;
    border: 1px solid var(--enemy-color);
    box-shadow: 0 0 14px var(--enemy-color);
}

.enemy-card-icon::after {
    background: var(--enemy-accent);
    opacity: 0.07;
}

.enemy-card-svg {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: block;
}

.enemy-card-icon[data-shape='circle'] {
    border-radius: 50%;
}

.enemy-card-icon[data-shape='circle']::before,
.enemy-card-icon[data-shape='circle']::after {
    border-radius: 50%;
}

.enemy-card-icon[data-shape='square'] {
    border-radius: 16px;
}

.enemy-card-icon[data-shape='square']::before,
.enemy-card-icon[data-shape='square']::after {
    border-radius: 16px;
}

.enemy-card-icon[data-shape='hexagon'] {
    clip-path: polygon(25% 6%, 75% 6%, 98% 50%, 75% 94%, 25% 94%, 2% 50%);
}

.enemy-card-icon[data-shape='hexagon']::before,
.enemy-card-icon[data-shape='hexagon']::after {
    clip-path: inherit;
}

.enemy-card-icon[data-shape='triangle'] {
    clip-path: polygon(50% 4%, 96% 90%, 4% 90%);
}

.enemy-card-icon[data-shape='triangle']::before,
.enemy-card-icon[data-shape='triangle']::after {
    clip-path: inherit;
}

.enemy-card-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.enemy-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.enemy-card-name {
    margin: 0;
    color: #fff;
    font-size: 16px;
    letter-spacing: 0.4px;
}

.enemy-card-badge {
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(0, 243, 255, 0.22);
    color: var(--neon-blue);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    white-space: nowrap;
}

.enemy-card-summary {
    margin: 0;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    line-height: 1.5;
}

.enemy-card-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
}

.enemy-stat {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.enemy-stat-label {
    color: rgba(255, 255, 255, 0.5);
}

.enemy-stat-value {
    color: var(--enemy-accent);
    font-weight: 700;
    text-shadow: 0 0 8px var(--enemy-accent);
}

.menu-title {
    margin: 0;
    font-size: 46px;
    font-weight: 900;
    color: var(--neon-blue);
    text-shadow: 0 0 20px var(--neon-blue), 2px 2px 0px rgba(0,0,0,0.8);
    text-transform: uppercase;
    letter-spacing: 2.4px;
    text-align: left;
    line-height: 1.1;
}

.menu-subtitle {
    margin: -6px 0 4px;
    color: var(--neon-green);
    font-size: 14px;
    letter-spacing: 4px;
    text-shadow: 0 0 10px var(--neon-green), 1px 1px 0px rgba(0,0,0,0.8);
    text-transform: uppercase;
    text-align: left;
}

.menu-copy {
    margin: 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: 14px;
    line-height: 1.6;
    max-width: 42ch;
    text-wrap: balance;
}

.menu-actions {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 14px;
    padding: 18px;
    border: 1px solid rgba(0, 243, 255, 0.14);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
    box-shadow: inset 0 0 24px rgba(0, 243, 255, 0.03);
    box-sizing: border-box;
}

.menu-field-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.menu-field-label {
    color: rgba(255, 255, 255, 0.62);
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.menu-join-label {
    padding-left: 2px;
}

.neon-input {
    border: 1px solid rgba(0, 243, 255, 0.35);
    border-radius: 6px;
    background: rgba(0, 10, 20, 0.72);
    color: #00f3ff;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    padding: 12px 14px;
    outline: none;
    box-shadow: inset 0 0 10px rgba(0, 243, 255, 0.08);
}

.neon-input:focus {
    background: rgba(0, 20, 40, 0.9);
    box-shadow: inset 0 0 10px rgba(0, 243, 255, 0.15), 0 0 14px rgba(0, 243, 255, 0.14);
}

.menu-join-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: 1px solid rgba(0, 243, 255, 0.24);
    border-radius: 12px;
    padding: 12px;
    overflow: hidden;
    margin-top: 4px;
    background: rgba(0, 10, 20, 0.34);
}

.menu-join-group .neon-input {
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(0, 243, 255, 0.2);
    border-radius: 0;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.menu-join-group .neon-input::placeholder {
    color: rgba(0, 243, 255, 0.35);
    letter-spacing: 1px;
}

.menu-join-group .neon-input:focus {
    background: rgba(0, 20, 40, 0.9);
    box-shadow: inset 0 0 10px rgba(0, 243, 255, 0.15), 0 0 14px rgba(0, 243, 255, 0.14);
}

.menu-join-group .neon-button {
    border-radius: 0;
    padding: 10px 16px;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 700;
}

.menu-lobby-card {
    display: grid;
    gap: 8px;
    padding: 12px;
    margin-top: 6px;
    border: 1px solid rgba(0, 243, 255, 0.25);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(0, 243, 255, 0.08), rgba(255, 123, 154, 0.06));
}

.menu-lobby-heading {
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    letter-spacing: 1.8px;
    text-transform: uppercase;
}

.menu-lobby-code-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.menu-lobby-code {
    flex: 1;
    font-size: 20px;
    font-weight: 700;
    color: var(--neon-yellow);
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(255, 238, 0, 0.35);
    word-break: break-all;
}

.menu-lobby-note {
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
    line-height: 1.45;
}

.menu-copy-button,
.hud-copy-button {
    border: 1px solid rgba(0, 243, 255, 0.35);
    background: rgba(0, 243, 255, 0.08);
    color: var(--neon-blue);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 11px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-copy-button:hover,
.hud-copy-button:hover {
    background: rgba(0, 243, 255, 0.16);
    box-shadow: 0 0 14px rgba(0, 243, 255, 0.22);
}

.primary-btn {
    font-size: 18px;
    padding: 15px;
    font-weight: bold;
    border-width: 2px;
    width: 100%;
    box-sizing: border-box;
    letter-spacing: 1px;
}

.secondary-btn {
    border-color: var(--neon-purple);
    color: var(--neon-purple);
    width: 100%;
    box-sizing: border-box;
    letter-spacing: 1px;
}

.secondary-btn:hover {
    background: rgba(255, 123, 154, 0.1);
    box-shadow: 0 0 15px rgba(255, 123, 154, 0.4) inset, 0 0 15px rgba(255, 123, 154, 0.4);
}

.menu-divider {
    width: 100%;
    border: none;
    border-top: 1px dashed var(--panel-border);
    margin: 10px 0;
}

.menu-status {
    margin-top: 0;
    padding: 12px;
    color: var(--neon-purple);
    font-size: 14px;
    text-align: left;
    border: 1px solid rgba(255, 123, 154, 0.18);
    border-radius: 12px;
    background: rgba(255, 123, 154, 0.04);
}

.menu-status[data-tone='info'] {
    color: var(--neon-blue);
    border-color: rgba(0, 243, 255, 0.22);
    background: rgba(0, 243, 255, 0.06);
}

.menu-status[data-tone='warn'] {
    color: var(--neon-yellow);
    border-color: rgba(255, 204, 0, 0.24);
    background: rgba(255, 204, 0, 0.05);
}

.menu-status[data-tone='error'] {
    color: var(--neon-red);
    border-color: rgba(255, 0, 60, 0.25);
    background: rgba(255, 0, 60, 0.06);
}

.menu-copy-button:disabled,
.hud-copy-button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

#ui-skip-wave-break {
    padding: 4px 10px;
    font-size: 11px;
    line-height: 1;
}

#ui-visual-mode-toggle {
    padding: 4px 10px;
    font-size: 11px;
    line-height: 1;
}

.shop-summary {
    padding: 12px 20px;
    border-bottom: 1px solid var(--panel-border);
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
    line-height: 1.5;
    background: linear-gradient(90deg, rgba(0, 243, 255, 0.08), rgba(255, 123, 154, 0.04));
}

/* --- Responsive Layout --- */
@media (max-width: 850px) {
    #blueprint-panel {
        width: 95%;
        height: 95%;
        flex-direction: column;
    }
    .blueprint-body {
        flex-direction: column;
        overflow-y: auto;
    }
    .blueprint-sidebar, .blueprint-palette {
        width: 100%;
        height: auto;
        border: none;
        border-bottom: 1px solid var(--panel-border);
    }
    .blueprint-palette {
        border-top: 1px solid var(--panel-border);
        border-bottom: none;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }
    .palette-item {
        margin-bottom: 0;
    }
    .blueprint-status-card,
    .blueprint-name-input,
    .blueprint-editor-hint,
    .blueprint-controls,
    .blueprint-zoom-controls {
        width: 100%;
    }

    .skill-tree-shell {
        width: calc(100vw - 24px);
        height: calc(100vh - 24px);
        padding: 18px;
    }

    .skill-tree-body {
        grid-template-columns: 1fr;
    }

    .skill-tree-sidebar {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        overflow: visible;
        padding-right: 0;
    }
}

@media (max-width: 650px) {
    .main-menu-shell {
        flex-direction: column;
    }
    .menu-panel-left {
        width: 100%;
        max-width: none;
        min-width: 0;
        padding: 0 20px;
        background: rgba(5, 5, 16, 0.95); /* more solid for small screens */
    }
    .menu-panel-right {
        width: 100%;
        padding: 18px 20px 24px;
        border-top: 1px solid rgba(0, 243, 255, 0.18);
    }
    .enemy-sheet-shell {
        width: 100%;
        padding: 18px;
        border-radius: 14px;
        transform: none;
    }
    .enemy-sheet-shell.expanded {
        width: 100%;
        padding: 18px;
    }
    .enemy-sheet-grid {
        grid-template-columns: 1fr;
    }
    .enemy-sheet-header,
    .enemy-sheet-actions {
        align-items: stretch;
    }
    .enemy-sheet-header {
        flex-direction: column;
        gap: 14px;
    }
    .menu-copy {
        max-width: none;
        margin-bottom: 20px;
    }
    .menu-lobby-code-row {
        flex-direction: column;
        align-items: stretch;
    }
    .menu-copy-button {
        width: 100%;
    }
    #shop-panel {
        width: 95%;
        height: 95%;
    }
    .menu-title {
        font-size: 36px;
    }
    .start-panel {
        min-width: 90%;
        padding: 20px;
    }

    #skill-tree-panel {
        padding: 12px;
    }

    .skill-tree-shell {
        width: 100%;
        height: 100%;
        border-radius: 16px;
        padding: 16px;
    }

    .skill-tree-header {
        flex-direction: column;
        align-items: stretch;
    }

    .skill-tree-header-action {
        align-self: flex-start;
    }

    .skill-tree-board-viewport {
        padding: 16px;
    }
}

/* === TOUCH CONTROLS === */
/* Virtual joystick and action buttons for iPad/iPhone. Hidden on non-touch devices. */

#touch-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

#touch-controls.hidden {
    display: none;
}

/* --- Virtual Joystick (left side) --- */
.touch-joystick-area {
    position: absolute;
    bottom: env(safe-area-inset-bottom, 20px);
    left: env(safe-area-inset-left, 20px);
    width: 140px;
    height: 140px;
    margin-bottom: 20px;
    margin-left: 20px;
    pointer-events: auto;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.touch-joystick-base {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 2px solid rgba(0, 243, 255, 0.35);
    background: rgba(0, 243, 255, 0.06);
    box-shadow: inset 0 0 20px rgba(0, 243, 255, 0.08);
}

.touch-joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(0, 243, 255, 0.6);
    background: rgba(0, 243, 255, 0.15);
    box-shadow: 0 0 12px rgba(0, 243, 255, 0.3);
}

/* --- Action Buttons (right side) --- */
.touch-action-area {
    position: absolute;
    bottom: env(safe-area-inset-bottom, 20px);
    right: env(safe-area-inset-right, 20px);
    margin-bottom: 20px;
    margin-right: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 180px;
    justify-content: flex-end;
    pointer-events: auto;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.touch-action-btn {
    min-width: 52px;
    min-height: 52px;
    border: 2px solid rgba(0, 243, 255, 0.45);
    border-radius: 10px;
    background: rgba(0, 10, 20, 0.7);
    color: var(--neon-blue);
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    padding: 6px 10px;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.15) inset;
    -webkit-tap-highlight-color: transparent;
}

.touch-action-btn:active {
    background: rgba(0, 243, 255, 0.25);
    box-shadow: 0 0 18px rgba(0, 243, 255, 0.5) inset;
    border-color: var(--neon-blue);
}

#touch-btn-place {
    border-color: rgba(0, 255, 102, 0.5);
    color: var(--neon-green);
    box-shadow: 0 0 10px rgba(0, 255, 102, 0.15) inset;
}

#touch-btn-place:active {
    background: rgba(0, 255, 102, 0.25);
    box-shadow: 0 0 18px rgba(0, 255, 102, 0.5) inset;
}

#touch-btn-shop {
    border-color: rgba(255, 238, 0, 0.45);
    color: var(--neon-yellow);
    box-shadow: 0 0 10px rgba(255, 238, 0, 0.12) inset;
}

#touch-btn-shop:active {
    background: rgba(255, 238, 0, 0.2);
    box-shadow: 0 0 18px rgba(255, 238, 0, 0.4) inset;
}

/* --- Mobile touch-friendly overrides --- */
@media (pointer: coarse) {
    /* Ensure minimum 44px touch targets on all interactive elements */
    .neon-button,
    .shop-tab-btn,
    .shop-card-buy-btn,
    .palette-item,
    .blueprint-list-item,
    #shop-close-btn,
    #blueprint-close-btn,
    .hud-copy-button,
    .menu-copy-button {
        min-height: 44px;
        min-width: 44px;
    }

    #shop-close-btn,
    #blueprint-close-btn {
        font-size: 32px;
        padding: 8px 14px;
    }

    /* Prevent text selection on long-press */
    body {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }

    /* Allow text selection in actual inputs */
    input, textarea {
        -webkit-user-select: auto;
        user-select: auto;
    }

    /* Compact HUD for mobile */
    .hud-shell {
        top: env(safe-area-inset-top, 10px);
        left: env(safe-area-inset-left, 10px);
        margin-top: 10px;
        margin-left: 10px;
        max-width: 50vw;
    }

    .hud-cluster {
        padding: 6px 8px;
        font-size: 11px;
    }

    .hud-help {
        display: none;
    }

    /* Fit game-over overlay to safe area */
    #ui-game-over .start-panel {
        min-width: 80%;
        padding: 20px;
    }
}
