* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #0d0d1a;
    color: #e0e0e0;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#app {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1600px;
    padding: 10px 20px;
}

header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    width: 100%;
}

header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #f5c542;
    text-shadow: 0 0 20px rgba(245, 197, 66, 0.3);
    letter-spacing: 1px;
}

header .subtitle {
    font-size: 0.85rem;
    color: #888;
    margin-left: 4px;
}

/* ---- Game Row & NN Panel ---- */

#game-row {
    display: flex;
    align-items: stretch;
    justify-content: center;
    width: 100%;
}

#canvas-container {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    max-width: 1200px;
    border: 2px solid #2a2a4a;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5), 0 0 60px rgba(245, 197, 66, 0.05);
    transition: border-radius 0.3s ease;
}

/* Scale PIXI canvas to fill container responsively */
#canvas-container canvas {
    display: block;
    width: 100% !important;
    height: auto !important;
}

#nn-panel {
    max-width: 0;
    overflow: hidden;
    background: #0d0d1a;
    border: 2px solid #2a2a4a;
    border-left: none;
    border-radius: 0 8px 8px 0;
    transition: max-width 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}

#nn-panel.active {
    max-width: 600px;
}

#nn-resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 20;
}

#nn-resize-handle:hover,
#nn-resize-handle.dragging {
    background: rgba(245, 197, 66, 0.3);
}

#nn-panel-header {
    font-size: 0.65rem;
    font-weight: 700;
    color: #555577;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 6px 10px 2px;
    width: 100%;
    text-align: center;
    white-space: nowrap;
}

#nn-canvas {
    display: block;
}

#game-row.nn-open #canvas-container {
    border-radius: 8px 0 0 8px;
    border-right: none;
}

/* ---- Canvas & Overlays ---- */

#celebration-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10;
}

#celebration-text {
    font-size: 4rem;
    font-weight: 900;
    color: #f5c542;
    text-shadow:
        0 0 20px rgba(245, 197, 66, 0.9),
        0 0 60px rgba(245, 197, 66, 0.5),
        0 0 100px rgba(245, 197, 66, 0.3);
    opacity: 0;
    transform: scale(0.3);
    transition: opacity 0.25s ease-out, transform 0.25s cubic-bezier(0.18, 1.2, 0.5, 1);
    letter-spacing: 4px;
}

#celebration-text.active {
    opacity: 1;
    transform: scale(1);
}

#celebration-text.epic {
    font-size: 4.5rem;
    color: #fff;
    text-shadow:
        0 0 30px rgba(255, 255, 255, 0.9),
        0 0 80px rgba(245, 197, 66, 0.8),
        0 0 120px rgba(255, 107, 107, 0.5);
}

#celebration-sub {
    font-size: 1.2rem;
    font-weight: 600;
    color: #ffdd88;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease-out 0.15s, transform 0.3s ease-out 0.15s;
    text-shadow: 0 0 15px rgba(245, 197, 66, 0.5);
}

#celebration-sub.active {
    opacity: 1;
    transform: translateY(0);
}

#screen-flash {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    opacity: 0;
    pointer-events: none;
    z-index: 5;
    transition: opacity 0.4s ease-out;
}

#screen-flash.flash {
    background: radial-gradient(circle at center, rgba(245, 197, 66, 0.5), rgba(255, 255, 255, 0.15));
    opacity: 1;
    transition: opacity 0.02s;
}

#screen-flash.glow {
    background: radial-gradient(circle at center, rgba(78, 205, 196, 0.2), transparent 70%);
    opacity: 1;
    transition: opacity 0.1s ease-in;
}

#gen-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #aaa;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 10px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 8;
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.3s, transform 0.3s;
}

#gen-badge.active {
    opacity: 1;
    transform: translateX(0);
}

#level-toast {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    text-align: center;
    pointer-events: none;
    z-index: 12;
    opacity: 0;
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

#level-toast.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#level-toast-name {
    font-size: 1.4rem;
    font-weight: 800;
    color: #f5c542;
    text-shadow: 0 0 20px rgba(245, 197, 66, 0.6), 0 2px 8px rgba(0, 0, 0, 0.8);
    letter-spacing: 2px;
    text-transform: uppercase;
}

#level-toast-desc {
    font-size: 0.75rem;
    color: #aaa;
    margin-top: 4px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
    max-width: 400px;
}

#goal-counter {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: baseline;
    gap: 4px;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 10px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 8;
}

#goal-counter-value {
    font-size: 1.4rem;
    font-weight: 900;
    color: #f5c542;
    font-variant-numeric: tabular-nums;
    transition: transform 0.2s cubic-bezier(0.18, 1.5, 0.5, 1);
}

#goal-counter-value.bump {
    transform: scale(1.4);
}

#goal-counter-label {
    font-size: 0.7rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Controls ---- */

#controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 0;
    width: 100%;
    max-width: 1200px;
    justify-content: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #1a1a2e;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #2a2a4a;
}

.control-group label {
    font-size: 0.75rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-group .value {
    font-size: 0.9rem;
    font-weight: 600;
    color: #f5c542;
    min-width: 40px;
    text-align: center;
}

button {
    background: #2a2a4a;
    color: #e0e0e0;
    border: 1px solid #3a3a6a;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.15s;
}

button:hover {
    background: #3a3a6a;
    border-color: #f5c542;
    color: #f5c542;
}

button.active {
    background: #f5c54230;
    border-color: #f5c542;
    color: #f5c542;
}

#btn-clear-brains {
    background: #3a2020;
    border-color: #6a3030;
    color: #cc8888;
    font-size: 0.7rem;
    padding: 4px 10px;
}

#btn-clear-brains:hover {
    background: #5a2020;
    border-color: #cc4444;
    color: #ff8888;
}

#save-indicator {
    font-size: 0.7rem;
    color: #4ecdc4;
    opacity: 0;
    transition: opacity 0.3s;
    margin-left: 4px;
}

#save-indicator.active {
    opacity: 1;
}

select {
    background: #2a2a4a;
    color: #e0e0e0;
    border: 1px solid #3a3a6a;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #f5c542;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100px;
    height: 4px;
    background: #3a3a6a;
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #f5c542;
    border-radius: 50%;
    cursor: pointer;
}

/* ---- Stats ---- */

#stats-bar {
    display: flex;
    gap: 20px;
    padding: 6px 0;
    width: 100%;
    max-width: 1200px;
    justify-content: center;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}

.stat-label {
    color: #777;
}

.stat-value {
    color: #f5c542;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

#fitness-graph {
    width: 100%;
    max-width: 600px;
    height: 80px;
    background: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    margin-top: 6px;
}
