:root {
    /* Dark Mode PCB Theme */
    --primary-color: #22d3ee;
    --secondary-color: #10b981;
    --accent-color: #fbbf24;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --switch-off: #475569;
    --switch-on: #10b981;
    --led-off: #64748b;
    --led-on: #10b981;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.3), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* ASCII Character Colors */
    --ascii-control: #a855f7;     /* Purple for control characters (0-31) */
    --ascii-special: #3b82f6;     /* Blue for special characters */
    --ascii-digits: #f59e0b;      /* Orange for digits (48-57) */
    --ascii-letters: #ef4444;     /* Red for letters (65-90, 97-122) */
    --ascii-default: #22d3ee;     /* Cyan for other printable */
    
    /* PCB Traces */
    --trace-color: #64748b;
    --trace-glow: #22d3ee;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background-color: var(--background-color);
    background-image: 
        /* PCB texture points only */
        radial-gradient(circle at 25% 25%, var(--trace-color) 1px, transparent 1px),
        radial-gradient(circle at 75% 75%, var(--trace-color) 1px, transparent 1px);
    background-size: 40px 40px, 40px 40px;
    background-position: 0 0, 20px 20px;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background-color: var(--surface-color);
    padding: 20px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
}

h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 15px;
    text-shadow: 0 0 10px var(--trace-glow);
}

.module-controls {
    display: flex;
    justify-content: center;
    align-items: center;
}

.info-text {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
}

/* Section Headers */
.section-header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
    text-shadow: 0 0 3px var(--trace-glow);
}

/* Local module controls */
.values-controls,
.output-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.values-controls .module-toggle,
.output-controls .module-toggle {
    padding: 8px 12px;
    font-size: 0.9rem;
}

/* Responsive adjustments for local controls */
@media (max-width: 768px) {
    .values-controls,
    .output-controls {
        flex-direction: column;
        gap: 10px;
    }
}

.module-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    padding: 12px 16px;
    border-radius: 8px;
    background-color: var(--border-color);
    border: 1px solid var(--trace-color);
    transition: all 0.2s;
    color: var(--text-primary);
}

.module-toggle:hover {
    background-color: var(--surface-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--trace-glow);
}

.module-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Main Content */
main {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 40px;
    margin-bottom: 40px;
}

/* Bit Display Area */
.bit-display {
    background-color: var(--surface-color);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

/* LEDs */
.leds {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 20px;
    margin-bottom: 15px;
}

.led {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--led-off);
    margin: 0 auto;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    color: #444;
}

.led.on {
    background-color: var(--led-on);
    box-shadow: 0 0 20px var(--led-on), 0 0 40px var(--led-on), inset 0 2px 4px 0 rgb(0 0 0 / 0.3);
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

/* Bit Positions */
.bit-positions {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.bit-position {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Switches */
.switches {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.switch-container {
    display: flex;
    justify-content: center;
}

.switch {
    position: relative;
    display: inline-block;
    width: 80px;
    height: 44px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--switch-off);
    transition: 0.3s;
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.slider:before {
    position: absolute;
    content: "";
    height: 36px;
    width: 36px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px 0 rgb(0 0 0 / 0.2);
}

input:checked + .slider {
    background-color: var(--switch-on);
}

input:checked + .slider:before {
    transform: translateX(36px);
}

.slider:hover {
    box-shadow: var(--shadow-lg);
}

/* Values under switches */
.decimal-values,
.power-values {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 15px; /* Abstand zwischen den Kästen - können Sie anpassen */
    text-align: center;
    position: relative; /* Für absolute Positionierung der Hint-Container */
}

/* WICHTIG: Hidden-Regel muss NACH der Display-Grid-Regel stehen */
.decimal-values.hidden,
.power-values.hidden {
    display: none !important;
}

/* Vertikaler Abstand zwischen den Modulen wenn beide sichtbar sind */
.power-values:not(.hidden) {
    margin-top: 30px; /* Abstand wenn Zweierpotenzen sichtbar sind */
}

/* Zusätzlicher Abstand wenn beide Module gleichzeitig sichtbar sind */
.decimal-values:not(.hidden) + .power-values:not(.hidden) {
    margin-top: 40px; /* Größerer Abstand wenn beide aktiv sind */
}

/* Hint-Container aus dem Grid-Flow herausnehmen */
.decimal-values .module-hint-container,
.power-values .module-hint-container {
    position: absolute;
    left: -45px; /* Links daneben wie bei den anderen Hints */
    top: 50%;
    transform: translateY(-50%);
    grid-column: unset; /* Nicht als Grid-Item behandeln */
}

/* Text bei Module-Hints entfernen */
.module-hint-container span {
    display: none;
}

/* Verstärkte CSS-Regel für decimal/power values */
.bit-display .decimal-values .value,
.bit-display .power-values .value {
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    color: var(--primary-color) !important;
    padding: 8px !important;
    background-color: var(--border-color) !important;
    border-radius: 8px !important;
    width: 80px !important; /* Breite der einzelnen Kästen */
    height: 40px !important; /* Höhe der Kästen */
    margin: 0 auto !important; /* Zentriert die Kästen in ihrer Grid-Zelle */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
}

/* Fallback für ältere Regel */
.decimal-values .value,
.power-values .value {
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    color: var(--primary-color) !important;
    padding: 8px !important;
    background-color: var(--border-color) !important;
    border-radius: 8px !important;
    width: 80px !important; /* Breite der einzelnen Kästen */
    height: 40px !important; /* Höhe der Kästen */
    margin: 0 auto !important; /* Zentriert die Kästen in ihrer Grid-Zelle */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
}

/* Output Area */
.output-area {
    background-color: var(--surface-color);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    min-width: 300px;
}

.ascii-output {
    text-align: center;
    margin-bottom: 30px;
}

.ascii-output .output-label {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.ascii-char {
    font-size: 8rem;
    font-weight: 700;
    color: var(--ascii-default);
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 15px currentColor;
    min-height: 120px;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Fixed dimensions to prevent layout shift */
    width: 150px;
    height: 150px;
    margin: 0 auto;
    border-radius: 12px;
    background-color: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--border-color);
}

/* ASCII Character Type Colors */
.ascii-char.control {
    color: var(--ascii-control);
    font-size: 1.5rem;
    text-shadow: 0 0 10px var(--ascii-control);
}

.ascii-char.special {
    color: var(--ascii-special);
    text-shadow: 0 0 15px var(--ascii-special);
}

.ascii-char.digit {
    color: var(--ascii-digits);
    text-shadow: 0 0 15px var(--ascii-digits);
}

.ascii-char.letter {
    color: var(--ascii-letters);
    text-shadow: 0 0 15px var(--ascii-letters);
}

.additional-outputs {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.binary-output,
.decimal-output,
.grayscale-output {
    text-align: center;
    padding: 20px;
    border-radius: 12px;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

.output-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.output-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
}

/* Spezifische Größe für Dezimalwerte */
#decimal-value {
    font-size: 6rem;
}

.grayscale-box {
    width: 80px;
    height: 80px;
    margin: 10px auto;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    transition: background-color 0.3s ease;
}

.grayscale-info {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
}

.impressum {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.4;
}

.impressum a {
    color: var(--primary-color);
    text-decoration: none;
}

.impressum a:hover {
    text-decoration: underline;
}

/* Hint Bulbs */
.hint-bulb {
    background-color: rgba(34, 211, 238, 0.2);
    border: 2px solid var(--primary-color);
    font-size: 1rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
    position: absolute;
    z-index: 10;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hint-bulb:hover {
    background-color: rgba(34, 211, 238, 0.4);
    transform: scale(1.1);
}

/* Position hint bulbs properly - all on the left */
#bits-hint {
    left: -45px;
    top: 50%;
    transform: translateY(-50%);
}

#switches-hint {
    left: -45px;
    top: 50%;
    transform: translateY(-50%);
}

#output-hint {
    position: absolute;
    left: 10px;
    top: 10px;
}

/* Module hint bulbs - positioned under their sections on the left */
.module-hint {
    position: static;
    margin: 10px 0 5px 0;
}

/* Container for module hints */
.module-hint-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
}

/* Mission Box */
.mission-box {
    background-color: rgba(34, 211, 238, 0.1);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 20px;
    margin-top: 30px;
    animation: pulse 2s infinite;
}

.mission-box h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.mission-content {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 1.1rem;
    margin-bottom: 20px;
}

/* Mission Selector */
.mission-selector {
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
    margin-top: 15px;
}

.mission-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

/* ASCII Table Controls */
.ascii-table-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.ascii-table-btn {
    background-color: var(--accent-color);
    color: var(--background-color);
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.ascii-table-btn:hover {
    background-color: #f59e0b;
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.help-btn {
    background-color: var(--primary-color);
    color: var(--background-color);
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.help-btn:hover {
    background-color: #0891b2;
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.help-btn.hidden {
    display: none;
}

.mission-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background-color: var(--border-color);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    white-space: pre-line;
}

.mission-btn:hover {
    transform: scale(1.1);
}

/* Bessere Tooltip-Darstellung für gelöste Missionen */
.mission-btn.completed:hover {
    z-index: 1000;
}

.mission-btn.completed:hover::after {
    content: attr(title);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-color);
    color: var(--text-primary);
    padding: 20px 24px;
    border-radius: 12px;
    border: 2px solid var(--accent-color);
    font-size: 1.2rem;
    font-weight: 700;
    white-space: pre-line;
    text-align: center;
    min-width: 300px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 30px var(--accent-color);
    z-index: 1001;
    animation: tooltipFadeIn 0.3s ease;
    margin-top: 12px;
    line-height: 1.5;
}

.mission-btn.completed:hover::before {
    content: '';
    position: absolute;
    top: 90%;
    left: 50%;
    transform: translateX(-50%);
    border: 12px solid transparent;
    border-bottom-color: var(--accent-color);
    z-index: 1001;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Mission states */
.mission-btn.completed {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--background-color);
    box-shadow: 0 0 15px var(--primary-color);
}

.mission-btn.completed::before {
    content: '✓';
    font-size: 20px;
    font-weight: bold;
}

.mission-btn.current {
    border-color: var(--accent-color);
    border-width: 3px;
    background-color: rgba(251, 191, 36, 0.2);
    color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
    animation: currentMission 9s infinite alternate;
}

.mission-btn.locked {
    background-color: var(--surface-color);
    border-color: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

@keyframes currentMission {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 5px var(--primary-color); }
    50% { box-shadow: 0 0 20px var(--primary-color); }
}

/* Byte Maskottchen Styles */
.byte-mascot {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: transparent;
    border: 3px solid var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    margin-right: 15px;
    flex-shrink: 0;
}

.byte-mascot::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: rgba(34, 211, 238, 0.1);
    border-radius: 50%;
    z-index: -1;
    animation: mascot-glow 2s ease-in-out infinite;
}

.byte-mascot img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    filter: drop-shadow(0 0 5px rgba(34, 211, 238, 0.3));
}

.byte-mascot.celebrating {
    animation: mascot-bounce 0.6s ease-in-out;
}

@keyframes mascot-glow {
    0%, 100% { opacity: 0.1; transform: scale(1); }
    50% { opacity: 0.2; transform: scale(1.02); }
}

@keyframes mascot-bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-10px) scale(1.1); }
}

/* Modal Header mit Byte */
.modal-header-with-byte {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header-with-byte h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.4rem;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--surface-color);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    max-width: 85vw;
    width: fit-content;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
    margin: 0 auto;
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-50px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.modal-header h3 {
    color: var(--primary-color);
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* ASCII Table Styles */
.ascii-table-container {
    width: fit-content;
    overflow: visible;
    margin: 0 auto;
}

.ascii-table {
    width: 80%;
    border-collapse: collapse;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    table-layout: fixed;
    margin: 0 auto;
}

.ascii-table th,
.ascii-table td {
    padding: 8px 4px;
    text-align: center;
    border: 1px solid var(--border-color);
    width: 8.33%; /* 12 Spalten = 100%/12 */
    line-height: 1.4;
}

.ascii-table th {
    background-color: var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
    position: sticky;
    top: 0;
    font-size: 1.1rem;
    padding: 12px 4px;
}

.ascii-table td {
    color: var(--text-primary);
    font-size: 1.1rem;
    min-height: 36px;
}

/* Spezielle Styling für Dec-Spalten */
.ascii-table .ascii-dec {
    font-weight: bold;
    background-color: var(--card-bg);
    font-size: 1.1rem;
}

/* Spezielle Styling für Bin-Spalten */
.ascii-table .ascii-bin {
    font-family: 'Courier New', monospace;
    background-color: rgba(0, 255, 255, 0.1);
    font-size: 0.95rem;
    color: var(--accent-color);
    font-weight: 600;
}

.ascii-table .ascii-control {
    background-color: rgba(168, 85, 247, 0.2);
    color: var(--ascii-control);
    font-weight: 600;
    font-size: 1.1rem;
}

.ascii-table .ascii-special {
    background-color: rgba(59, 130, 246, 0.2);
    color: var(--ascii-special);
    font-weight: 600;
    font-size: 1.3rem;
}

.ascii-table .ascii-digit {
    background-color: rgba(245, 158, 11, 0.2);
    color: var(--ascii-digits);
    font-weight: 700;
    font-size: 1.4rem;
}

.ascii-table .ascii-letter {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--ascii-letters);
    font-weight: 700;
    font-size: 1.4rem;
}

/* Gruppenabgrenzung: Dickere Ränder zwischen den 3er-Spaltengruppen */
.ascii-table th:nth-child(4),
.ascii-table td:nth-child(4),
.ascii-table th:nth-child(7),
.ascii-table td:nth-child(7),
.ascii-table th:nth-child(10),
.ascii-table td:nth-child(10) {
    border-left: 3px solid var(--accent-color) !important;
}

/* Hint Modal */
.hint-modal {
    max-width: 500px;
}

.hint-content {
    color: var(--text-primary);
    font-size: 1.1rem;
    line-height: 1.6;
}

/* Mission Modal */
.mission-modal {
    max-width: 400px;
    text-align: center;
}

.mission-success h3 {
    color: var(--secondary-color);
    margin-bottom: 20px;
}

.mission-result {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 1.1rem;
    line-height: 1.6;
}

.continue-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
    display: block;
    margin: 0 auto;
}

/* Help Modals */
.help-modal {
    max-width: 450px;
    text-align: center;
}

.help-content {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 1.1rem;
    line-height: 1.6;
}

.help-content p {
    margin-bottom: 15px;
}

.help-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.help-btn-yes, .help-btn-no {
    background-color: var(--primary-color);
    color: var(--background-color);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
}

.help-btn-yes:hover {
    background-color: var(--secondary-color);
}

.help-btn-no {
    background-color: var(--border-color);
    color: var(--text-secondary);
}

.help-btn-no:hover {
    background-color: var(--switch-off);
}

.help-explanation {
    color: var(--text-primary);
    font-size: 1.1rem;
    line-height: 1.6;
    text-align: left;
    max-height: 400px;
    overflow-y: auto;
}

.help-explanation h4 {
    color: var(--accent-color);
    margin: 15px 0 10px 0;
}

.help-explanation .step {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    margin: 10px 0;
}

.help-explanation .step-number {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.2rem;
}

.continue-btn:hover {
    background-color: #059669;
    transform: translateY(-1px);
}

/* Module visibility - verstärkt - höchste Priorität */
.bit-display .decimal-values.module.hidden,
.bit-display .power-values.module.hidden,
#decimal-values-module.hidden,
#power-values-module.hidden,
.module.hidden,
.decimal-values.module.hidden,
.power-values.module.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Zusätzliche Regel für bessere Kontrolle */
.bit-display .module.hidden {
    display: none !important;
}

/* Position adjustments for hint bulbs */
.bit-positions {
    position: relative;
}

.switches {
    position: relative;
}

.ascii-output {
    position: relative;
}

.output-label {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ensure module containers can hold positioned hint bulbs */
.decimal-values,
.power-values {
    position: relative;
}

.binary-output,
.decimal-output,
.grayscale-output {
    position: relative;
}

/* ASCII Mode Toggle */
.ascii-output.hidden {
    display: none;
}

/* Responsive Design */
@media (max-width: 1200px) {
    main {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .output-area {
        min-width: auto;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .switches {
        gap: 15px;
    }
    
    .switch {
        width: 60px;
        height: 34px;
    }
    
    .slider:before {
        height: 26px;
        width: 26px;
    }
    
    input:checked + .slider:before {
        transform: translateX(26px);
    }
    
    .ascii-char {
        font-size: 4rem;
        width: 120px;
        height: 120px;
    }
    
    .output-value {
        font-size: 1.5rem;
    }
    
    #decimal-value {
        font-size: 3rem;
    }
    
    .leds {
        gap: 15px;
    }
    
    .led {
        width: 30px;
        height: 30px;
    }
    
    .values-controls,
    .output-controls {
        flex-direction: column;
        gap: 10px;
    }
}

/* Animation for value changes - Fixed to prevent layout shift */
.ascii-char,
.output-value {
    transition: transform 0.3s ease, text-shadow 0.3s ease;
}

.ascii-char.changed,
.output-value.changed {
    transform: scale(1.02);
    text-shadow: 0 0 20px currentColor;
}

/* Control character display - Fixed dimensions */
.ascii-char.control {
    /* Inherits fixed dimensions from .ascii-char */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
}

/* Improved touch targets for mobile */
@media (hover: none) and (pointer: coarse) {
    .switch {
        width: 90px;
        height: 50px;
    }
    
    .slider:before {
        height: 42px;
        width: 42px;
    }
    
    input:checked + .slider:before {
        transform: translateX(40px);
    }
    
    .preset-btn {
        padding: 16px 24px;
        margin: 8px;
    }
}
