:root {
    --bg-color: #0a0a12;
    --panel-bg: #14141e;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --neon-green: #00ff41;
    --neon-red: #ff3333;
    --neon-blue: #00f3ff;
    --neon-yellow: #ffee00;
    --border-color: #333;
    --font-main: 'Roboto Mono', monospace;
    --font-header: 'Orbitron', sans-serif;
}

* {
    box-sizing: border-box;
    user-select: none;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header / HUD */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--panel-bg);
    border-bottom: 2px solid var(--border-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.game-title {
    font-family: var(--font-header);
    font-size: 1.5rem;
    color: var(--neon-yellow);
    text-shadow: 0 0 10px rgba(255, 238, 0, 0.3);
}

.hud-stats {
    display: flex;
    gap: 2rem;
}

.stat-box {
    text-align: center;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--neon-blue);
}

/* Main Game Area */
main {
    flex: 1;
    display: flex;
    padding: 1rem;
    gap: 1rem;
    height: 100%;
    overflow: hidden;
}

/* Left Panel: Contract & Info */
.panel-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.contract-card {
    background: var(--panel-bg);
    border: 1px solid var(--neon-blue);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.1);
    animation: slideIn 0.5s ease-out;
}

.contract-header {
    font-family: var(--font-header);
    color: var(--neon-blue);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.contract-reqs {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.req-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.req-icon {
    color: var(--neon-yellow);
}

/* Center Panel: Workbench */
.panel-center {
    flex: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #1a1a2e 0%, #0a0a12 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    position: relative;
}

.battery-preview {
    width: 200px;
    height: 300px;
    border: 4px solid #444;
    border-radius: 10px;
    background: #222;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    transition: all 0.3s;
}

.battery-layer {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
    transition: background 0.3s;
}

.layer-anode {
    background: #333;
}

.layer-electrolyte {
    background: #444;
}

.layer-cathode {
    background: #333;
}

.battery-terminal {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 15px;
    background: #888;
    border-radius: 4px 4px 0 0;
}

/* Right Panel: Components */
.panel-right {
    flex: 1;
    background: var(--panel-bg);
    border-left: 2px solid var(--border-color);
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.component-category {
    margin-bottom: 1rem;
}

.category-title {
    font-family: var(--font-header);
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    border-bottom: 1px solid #333;
    padding-bottom: 0.2rem;
}

.component-btn {
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    background: #1a1a24;
    border: 1px solid #333;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.component-btn:hover {
    background: #252530;
    border-color: var(--neon-blue);
}

.component-btn.selected {
    background: rgba(0, 243, 255, 0.1);
    border-color: var(--neon-blue);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.1);
}

.component-cost {
    font-size: 0.8rem;
    color: var(--neon-yellow);
}

/* Actions */
.action-area {
    margin-top: auto;
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 1rem;
}

.main-btn {
    background: transparent;
    color: var(--neon-green);
    border: 2px solid var(--neon-green);
    padding: 1rem 3rem;
    font-family: var(--font-header);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.2);
    text-transform: uppercase;
    border-radius: 4px;
}

.main-btn:hover {
    background: var(--neon-green);
    color: #000;
    box-shadow: 0 0 30px rgba(0, 255, 65, 0.5);
}

.main-btn:disabled {
    border-color: #555;
    color: #555;
    cursor: not-allowed;
    box-shadow: none;
}

/* Educational Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal.visible {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: #14141e;
    border: 1px solid var(--neon-blue);
    padding: 2rem;
    max-width: 600px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 0 50px rgba(0, 243, 255, 0.2);
}

.modal-title {
    font-family: var(--font-header);
    color: var(--neon-blue);
    margin-top: 0;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
}

.learn-link {
    color: var(--neon-yellow);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

/* Animations */
@keyframes slideIn {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.flash-success {
    animation: flashGreen 0.5s;
}

.flash-fail {
    animation: flashRed 0.5s;
}

@keyframes flashGreen {
    0% {
        background-color: rgba(0, 255, 65, 0.5);
    }

    100% {
        background-color: transparent;
    }
}

@keyframes flashRed {
    0% {
        background-color: rgba(255, 51, 51, 0.5);
    }

    100% {
        background-color: transparent;
    }
}

.assistant-line {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--neon-blue);
    color: #fff;
    font-size: 0.9rem;
    text-align: center;
    width: 80%;
    pointer-events: none;
    /* Let clicks pass through if needed, but links need pointer events. Handled by z-index usually */
    pointer-events: auto;
}