feat: add Turing Complete-style puzzle system

Add progressive puzzle mode alongside the existing sandbox:
- 8 levels from basic gates to 2-bit adder
- Truth table verification with pass/fail feedback
- Gate restrictions per level
- Custom components system (save circuits as reusable chips)
- Save/load circuits as JSON
- Level selection sidebar with difficulty ratings
- Mode toggle: Sandbox (free play) vs Puzzle (guided levels)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jose Luis
2026-03-20 02:06:57 +01:00
parent 0f4fe27396
commit b2e367817c
10 changed files with 1733 additions and 249 deletions

View File

@@ -206,3 +206,399 @@ body {
cursor: ns-resize;
z-index: 91;
}
/* ==================== Mode Toggle ==================== */
.mode-toggle {
display: flex;
gap: 0;
border-radius: 6px;
overflow: hidden;
}
.mode-btn {
padding: 5px 12px;
background: #1a1a2e;
border: 1px solid #2a2a3a;
color: #888;
cursor: pointer;
font-size: 12px;
font-weight: 600;
transition: all 0.15s;
border-radius: 0;
margin: 0 -1px;
}
.mode-btn:first-child { border-radius: 6px 0 0 6px; }
.mode-btn:last-child { border-radius: 0 6px 6px 0; }
.mode-btn:hover {
border-color: #00e599;
color: #fff;
}
.mode-btn.active {
background: #00e59922;
border-color: #00e599;
color: #00e599;
}
/* ==================== Puzzle Panels ==================== */
.puzzle-panel {
display: none;
position: fixed;
top: 48px;
left: 0;
width: 380px;
height: calc(100vh - 48px);
background: #12121a;
border-right: 1px solid #2a2a3a;
z-index: 95;
flex-direction: column;
overflow-y: auto;
box-shadow: 2px 0 10px rgba(0,0,0,0.5);
}
.puzzle-panel.visible {
display: flex;
}
.puzzle-panel.puzzle-info {
top: 48px;
width: 340px;
}
.puzzle-header {
padding: 16px;
background: #0a0a0f;
border-bottom: 1px solid #2a2a3a;
display: flex;
justify-content: space-between;
align-items: flex-start;
flex-shrink: 0;
}
.puzzle-header h2 {
color: #00e599;
font-size: 18px;
margin: 0 0 8px 0;
}
.puzzle-header .close-btn {
background: none;
border: none;
color: #888;
font-size: 20px;
cursor: pointer;
padding: 0;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
transition: color 0.15s;
}
.puzzle-header .close-btn:hover {
color: #ff4444;
}
.close-btn {
background: none;
border: none;
color: #888;
font-size: 20px;
cursor: pointer;
padding: 0;
transition: color 0.15s;
}
.close-btn:hover {
color: #ff4444;
}
/* Level Panel */
.levels-container {
padding: 16px;
overflow-y: auto;
}
.level-category h3 {
color: #ff44aa;
font-size: 14px;
margin: 16px 0 8px 0;
padding: 8px 0;
border-bottom: 1px solid #2a2a3a;
}
.level-card {
background: #1a1a2e;
border: 1px solid #2a2a3a;
border-radius: 8px;
padding: 12px;
margin-bottom: 8px;
cursor: pointer;
transition: all 0.2s;
}
.level-card:hover:not(.locked) {
border-color: #00e599;
background: #1a1a3a;
}
.level-card.locked {
opacity: 0.5;
cursor: not-allowed;
}
.level-card.completed {
border-color: #00e599;
background: #00e59911;
}
.level-card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
}
.level-title {
color: #fff;
font-weight: 600;
font-size: 13px;
}
.level-difficulty {
color: #ff8833;
font-size: 11px;
letter-spacing: 2px;
}
.level-description {
color: #888;
font-size: 12px;
margin-bottom: 8px;
line-height: 1.4;
}
.level-status {
color: #00e599;
font-size: 11px;
font-weight: 600;
text-align: right;
}
.level-card.locked .level-status {
color: #ff8833;
}
/* Puzzle Content */
#puzzle-content {
padding: 16px;
overflow-y: auto;
flex: 1;
}
.puzzle-description {
color: #aaa;
font-size: 13px;
margin-bottom: 16px;
line-height: 1.5;
}
.truth-table-section h3,
.available-gates-section h3 {
color: #ff44aa;
font-size: 13px;
margin: 12px 0 8px 0;
font-weight: 600;
}
/* Truth Table */
.truth-table {
display: grid;
gap: 1px;
margin-bottom: 16px;
background: #0a0a0f;
padding: 8px;
border-radius: 6px;
}
.truth-table-row {
display: grid;
grid-auto-flow: column;
gap: 1px;
}
.truth-table-row.header {
background: #1a1a2e;
margin-bottom: 4px;
}
.truth-cell {
padding: 6px 8px;
font-size: 11px;
font-weight: 600;
background: #0e0e18;
text-align: center;
border-radius: 4px;
min-width: 30px;
}
.truth-table-row.header .truth-cell {
background: #1a1a2e;
color: #00e599;
}
.truth-cell.input-cell {
color: #3388ff;
}
.truth-cell.output-cell {
color: #ff8833;
}
/* Available Gates */
.available-gates-list {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-bottom: 16px;
}
.available-gate-btn {
padding: 6px 10px;
background: #1a1a2e;
border: 1px solid #2a2a3a;
border-radius: 6px;
color: #aaa;
cursor: pointer;
font-size: 11px;
font-weight: 600;
transition: all 0.15s;
white-space: nowrap;
}
.available-gate-btn:hover {
border-color: #00e599;
color: #fff;
background: #1a1a3a;
}
.available-gate-btn:active {
background: #00e59922;
}
/* Puzzle Actions */
.puzzle-actions {
display: flex;
flex-direction: column;
gap: 8px;
margin-top: 16px;
padding-top: 16px;
border-top: 1px solid #2a2a3a;
}
.action-btn.verify-btn {
background: #00e599;
border: none;
color: #000;
font-weight: 600;
padding: 8px 12px;
border-radius: 6px;
cursor: pointer;
transition: all 0.15s;
}
.action-btn.verify-btn:hover {
background: #00ff99;
box-shadow: 0 0 10px #00e59944;
}
.action-btn.hint-btn,
.action-btn.reset-btn {
background: transparent;
border: 1px solid #2a2a3a;
color: #888;
padding: 6px 12px;
border-radius: 6px;
cursor: pointer;
font-size: 12px;
transition: all 0.15s;
}
.action-btn.hint-btn:hover {
border-color: #ff44aa;
color: #ff44aa;
}
.action-btn.reset-btn:hover {
border-color: #ff8833;
color: #ff8833;
}
/* Verification Result */
.verification-result {
margin-top: 16px;
padding: 12px;
border-radius: 6px;
font-size: 12px;
}
.verification-result.success {
background: #00e59922;
border: 1px solid #00e599;
color: #00e599;
}
.verification-result.failure {
background: #ff444422;
border: 1px solid #ff4444;
color: #ff8888;
}
.result-message {
font-weight: 600;
margin-bottom: 8px;
}
.verification-result.success .result-message {
color: #00ff99;
}
.verification-result.failure .result-message {
color: #ff6666;
}
.failed-tests {
margin-top: 8px;
font-size: 11px;
max-height: 120px;
overflow-y: auto;
}
.failed-test {
margin-bottom: 6px;
padding: 6px;
background: rgba(0,0,0,0.3);
border-radius: 4px;
font-family: monospace;
color: #ccc;
}
#next-level-btn {
background: #00e599;
border: none;
color: #000;
font-weight: 600;
padding: 8px 12px;
border-radius: 6px;
cursor: pointer;
margin-top: 8px;
transition: all 0.15s;
}
#next-level-btn:hover {
background: #00ff99;
box-shadow: 0 0 10px #00e59944;
}