
/* =========================================================
   WIRELAB — CIRCUIT MASTER
   VERSION 1.0
========================================================= */


/* =========================================================
   1. GAME PAGE
========================================================= */

.circuit-master {
    width: min(100% - 32px, 1100px);
    margin: 0 auto;
    padding: 32px 0 60px;
    color: var(--wire-text);
}


/* =========================================================
   2. GAME HEADER
========================================================= */

.cm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.cm-heading {
    min-width: 0;
}

.cm-eyebrow {
    margin: 0 0 8px;
    color: var(--wire-accent);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 2px;
}

.cm-header h1 {
    margin: 0 0 8px;
    font-size: 38px;
    font-weight: 300;
}

.cm-heading > p:last-child {
    margin: 0;
    color: var(--wire-text2);
    font-size: 16px;
    line-height: 1.6;
}

.cm-score-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    min-width: 100px;
    min-height: 84px;
    padding: 12px;

    border: 1px solid var(--wire-border);
    border-radius: 12px;

    background: var(--wire-card);
    box-shadow: var(--wire-shadow2);
}

.cm-stat-label {
    color: var(--wire-text3);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
}

.cm-score-panel strong {
    margin-top: 5px;
    color: var(--wire-accent);
    font-size: 28px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}


/* =========================================================
   3. GAME STATUS
========================================================= */

.cm-status-panel {
    display: flex;
    align-items: flex-start;
    gap: 14px;

    margin-bottom: 20px;
    padding: 16px;

    border: 1px solid var(--wire-border);
    border-radius: 12px;

    background: var(--wire-surface);
    transition:
        border-color 0.2s ease,
        background 0.2s ease;
}

.cm-status-indicator {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    margin-top: 5px;

    border-radius: 50%;
    background: var(--wire-text3);
}

.cm-status-content {
    min-width: 0;
}

.cm-status-content strong {
    display: block;
    margin-bottom: 5px;
    font-size: 15px;
    font-weight: 500;
}

.cm-status-content p {
    margin: 0;
    color: var(--wire-text2);
    font-size: 14px;
    line-height: 1.6;
}

.cm-status-panel.is-powered {
    border-color: #54d6a7;
}

.cm-status-panel.is-powered .cm-status-indicator {
    background: #54d6a7;
    box-shadow: 0 0 10px #54d6a780;
}

.cm-status-panel.is-error {
    border-color: #ff727b;
}

.cm-status-panel.is-error .cm-status-indicator {
    background: #ff727b;
}


/* =========================================================
   4. LEVEL INFORMATION
========================================================= */

.cm-level-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    margin-bottom: 16px;
    padding: 16px;

    border: 1px solid var(--wire-border);
    border-radius: 12px;

    background: var(--wire-card);
}

.cm-level-panel h2 {
    margin: 6px 0 0;
    font-size: 20px;
    font-weight: 400;
}

.cm-difficulty {
    flex-shrink: 0;
    padding: 6px 10px;

    border: 1px solid var(--wire-border);
    border-radius: 6px;

    color: var(--wire-accent);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
}


/* =========================================================
   5. CIRCUIT BOARD SECTION
========================================================= */

.cm-board-section {
    overflow: hidden;

    border: 1px solid var(--wire-border);
    border-radius: 12px;

    background: var(--wire-surface);
    box-shadow: var(--wire-shadow);
}

.cm-board-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;

    padding: 16px;

    border-bottom: 1px solid var(--wire-border);
}

.cm-board-heading h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 400;
}

.cm-board-heading > span {
    color: var(--wire-text3);
    font-size: 12px;
}


/* =========================================================
   6. CIRCUIT WORKSPACE
========================================================= */

.cm-board {
    position: relative;

    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: auto auto;
    align-items: start;
    gap: 48px 28px;

    min-height: 440px;
    padding: 24px;

    isolation: isolate;

    background-color: var(--wire-bg);
    background-image:
        radial-gradient(
            var(--wire-border2) 1px,
            transparent 1px
        );
    background-size: 20px 20px;
}


/* =========================================================
   7. SVG WIRE LAYER
========================================================= */

.cm-wire-layer {
    position: absolute;
    inset: 0;
    z-index: 1;

    width: 100%;
    height: 100%;

    overflow: visible;
    pointer-events: none;
}

.cm-wire {
    fill: none;
    stroke: #46cdbb;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cm-wire.is-powered {
    stroke: #54f0bf;
    stroke-width: 4;
    filter: drop-shadow(0 0 4px #54f0bf90);
}

.cm-wire-endpoint {
    fill: #46cdbb;
    stroke: var(--wire-bg);
    stroke-width: 2;
}


/* =========================================================
   8. COMPONENT CARDS
========================================================= */

.cm-component {
    position: relative;
    z-index: 2;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;

    width: 100%;
    min-width: 0;
    max-width: 220px;
    min-height: 170px;

    padding: 20px 14px;

    border: 1px solid var(--wire-border);
    border-radius: 12px;

    background: var(--wire-card);
    color: var(--wire-text);

    box-shadow: var(--wire-shadow2);

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.cm-component-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;

    width: 100%;
    text-align: center;
}

.cm-component-body strong {
    font-size: 15px;
    font-weight: 500;
}

.cm-component-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 42px;

    color: var(--wire-accent);
    font-size: 34px;
    line-height: 1;
}

.cm-component-detail {
    color: var(--wire-text3);
    font-size: 12px;
    letter-spacing: 1px;
}


/* =========================================================
   9. BATTERY POSITION AND APPEARANCE
========================================================= */

.cm-battery {
    grid-column: 1;
    grid-row: 1;

    justify-self: start;
    align-self: start;

    max-width: 170px;
    min-height: 190px;
}

.cm-battery .cm-component-icon {
    color: #e9b95c;
}

.cm-battery .cm-component-detail {
    color: var(--wire-text2);
}


/* =========================================================
   10. BATTERY AND COMPONENT TERMINALS
========================================================= */

.cm-terminal-group {
    position: relative;
    z-index: 5;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;

    width: 100%;
}

.cm-terminal {
    position: relative;
    z-index: 5;

    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    width: 28px;
    height: 28px;
    padding: 0;

    border: 2px solid var(--wire-bg);
    border-radius: 50%;

    background: var(--wire-accent);
    color: #ffffff;

    box-shadow: 0 0 0 1px var(--wire-accent);

    font: inherit;
    font-size: 12px;
    font-weight: 600;

    cursor: crosshair;

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        background 0.15s ease;
}

.cm-terminal:hover {
    transform: scale(1.12);

    box-shadow:
        0 0 0 2px var(--wire-accent),
        0 0 10px var(--wire-accent);
}

.cm-terminal:focus-visible {
    outline: 2px solid var(--wire-accent);
    outline-offset: 4px;
}

.cm-terminal.is-selected {
    transform: scale(1.15);

    box-shadow:
        0 0 0 3px var(--wire-accent),
        0 0 14px var(--wire-accent);
}

.cm-terminal.is-connected {
    background: #46cdbb;
    box-shadow: 0 0 0 1px #46cdbb;
}

.cm-terminal.cm-positive {
    background: #e85b64;
    box-shadow: 0 0 0 1px #e85b64;
}

.cm-terminal.cm-negative {
    background: #5c9df5;
    box-shadow: 0 0 0 1px #5c9df5;
}


/* =========================================================
   11. BATTERY TERMINAL POSITIONING
========================================================= */

.cm-battery-terminals {
    justify-content: space-between;
}

.cm-battery-terminals .cm-positive {
    align-self: flex-start;
}

.cm-battery-terminals .cm-negative {
    align-self: flex-end;
}


/* =========================================================
   12. SWITCH COMPONENT
========================================================= */

.cm-switch {
    grid-column: 2;
    grid-row: 2;

    justify-self: center;
    align-self: start;
}

.cm-switch-terminals {
    justify-content: space-between;
}

.cm-switch.is-closed {
    border-color: #46cdbb;
}

.cm-switch.is-closed .cm-component-icon {
    color: #54d6a7;
}


/* =========================================================
   13. SWITCH CONTROL BUTTON
========================================================= */

.cm-switch-toggle {
    width: 100%;
    min-height: 36px;
    padding: 8px 12px;

    border: 1px solid var(--wire-border2);
    border-radius: 8px;

    background: var(--wire-surface);
    color: var(--wire-text);

    font: inherit;
    font-size: 12px;

    cursor: pointer;

    transition:
        border-color 0.2s ease,
        background 0.2s ease;
}

.cm-switch-toggle:hover {
    border-color: var(--wire-accent);
    background: var(--wire-hover);
}

.cm-switch-toggle:focus-visible {
    outline: 2px solid var(--wire-accent);
    outline-offset: 3px;
}


/* =========================================================
   14. LIGHT BULB COMPONENT
========================================================= */

.cm-bulb {
    grid-column: 3;
    grid-row: 1;

    justify-self: end;
    align-self: start;
}

.cm-bulb-terminals {
    justify-content: space-between;
}

.cm-bulb.is-lit {
    border-color: #e9b95c;

    box-shadow:
        var(--wire-shadow2),
        0 0 18px #e9b95c25;
}

.cm-bulb.is-lit .cm-component-icon {
    color: #ffd76a;

    filter: drop-shadow(0 0 8px #ffd76a90);
}


/* =========================================================
   15. LIGHT BULB GLOW
========================================================= */

.cm-bulb-glow {
    position: absolute;
    top: 55px;
    left: 50%;

    width: 55px;
    height: 55px;

    border-radius: 50%;

    background: #ffd76a;
    opacity: 0;

    filter: blur(25px);
    pointer-events: none;

    transform: translateX(-50%);
    transition: opacity 0.25s ease;
}

.cm-bulb.is-lit .cm-bulb-glow {
    opacity: 0.65;
}


/* =========================================================
   16. CONNECTION HELP
========================================================= */

.cm-connection-help {
    display: flex;
    align-items: flex-start;
    gap: 10px;

    padding: 14px 16px;

    border-top: 1px solid var(--wire-border);

    color: var(--wire-text2);
    font-size: 13px;
    line-height: 1.6;
}

.cm-help-icon {
    flex-shrink: 0;
    color: var(--wire-accent);
}


/* =========================================================
   17. GAME CONTROLS
========================================================= */

.cm-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;

    margin-top: 16px;
    padding: 16px;

    border: 1px solid var(--wire-border);
    border-radius: 12px;

    background: var(--wire-card);
}

.cm-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 42px;
    padding: 10px 16px;

    border: 1px solid var(--wire-border2);
    border-radius: 8px;

    font: inherit;
    font-size: 13px;

    cursor: pointer;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.cm-button:active {
    transform: scale(0.98);
}

.cm-button:focus-visible {
    outline: 2px solid var(--wire-accent);
    outline-offset: 3px;
}

.cm-button-secondary {
    background: var(--wire-surface);
    color: var(--wire-text);
}

.cm-button-secondary:hover {
    border-color: var(--wire-accent);
    background: var(--wire-hover);
}

.cm-button-primary {
    border-color: var(--wire-accent);
    background: var(--wire-accent);
    color: #ffffff;
}

.cm-button-primary:hover {
    filter: brightness(1.08);
}


/* =========================================================
   18. MISSION OBJECTIVE
========================================================= */

.cm-objective {
    display: flex;
    align-items: flex-start;
    gap: 16px;

    margin-top: 20px;
    padding: 20px;

    border: 1px solid var(--wire-border);
    border-radius: 12px;

    background: var(--wire-surface);
}

.cm-objective-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    width: 42px;
    height: 42px;

    border: 1px solid var(--wire-border);
    border-radius: 10px;

    background: var(--wire-card);
    color: var(--wire-accent);
    font-size: 22px;
}

.cm-objective h2 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 400;
}

.cm-objective p {
    margin: 0 0 12px;

    color: var(--wire-text2);
    font-size: 14px;
    line-height: 1.7;
}

.cm-objective ul {
    display: grid;
    gap: 8px;

    margin: 0;
    padding-left: 20px;

    color: var(--wire-text2);
    font-size: 13px;
    line-height: 1.6;
}


/* =========================================================
   19. GAME FEEDBACK
========================================================= */

.cm-feedback {
    margin-top: 16px;
    padding: 14px 16px;

    border: 1px solid var(--wire-border);
    border-radius: 10px;

    background: var(--wire-surface);
    color: var(--wire-text2);

    font-size: 14px;
    line-height: 1.6;
}

.cm-feedback.is-success {
    border-color: #54d6a7;
    color: #54d6a7;
}

.cm-feedback.is-error {
    border-color: #ff727b;
    color: #ff727b;
}

.cm-feedback[hidden] {
    display: none;
}




/* =========================================================
   CIRCUIT MASTER — ZOOM CONTROLS
========================================================= */

.cm-zoom-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.cm-zoom-controls button {
    min-width: 42px;
    height: 38px;
    padding: 0 12px;

    border: 1px solid var(--wire-border);
    border-radius: 8px;

    background: var(--wire-card);
    color: var(--wire-text);

    font: inherit;
    font-size: 18px;

    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.cm-zoom-controls button:hover {
    background: var(--wire-hover);
    border-color: var(--wire-accent);
}

#cm-zoom-reset {
    min-width: 64px;
    font-size: 14px;
}










/* =========================================================
   20. RESPONSIVE LAYOUT
========================================================= */

@media (max-width: 700px) {

    .circuit-master {
        width: calc(100% - 24px);
        padding-top: 24px;
    }

    .cm-header {
        gap: 12px;
    }

    .cm-header h1 {
        font-size: 30px;
    }

    .cm-heading > p:last-child {
        font-size: 14px;
    }

    .cm-score-panel {
        min-width: 76px;
        min-height: 72px;
    }

    .cm-score-panel strong {
        font-size: 24px;
    }

    .cm-board {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 36px 16px;

        min-height: 440px;
        padding: 16px;
    }

    .cm-battery {
        grid-column: 1;
        grid-row: 1;
    }

    .cm-bulb {
        grid-column: 2;
        grid-row: 1;
    }

    .cm-switch {
        grid-column: 1;
        grid-row: 2;
        justify-self: start;
    }

    .cm-component {
        max-width: 190px;
        padding: 16px 10px;
    }

    .cm-terminal-group {
        gap: 12px;
    }

    .cm-controls {
        padding: 12px;
    }

    .cm-button {
        flex: 1 1 auto;
    }
}


@media (max-width: 420px) {

    .cm-board {
        gap: 28px 10px;
        padding: 12px;
    }

    .cm-component {
        min-height: 160px;
        padding: 12px 8px;
    }

    .cm-component-body strong {
        font-size: 13px;
    }

    .cm-component-detail {
        font-size: 11px;
    }

    .cm-terminal {
        width: 25px;
        height: 25px;
    }

    .cm-board-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .cm-objective {
        padding: 14px;
    }
}