/* ============================================================================
   Grundlagen: Farbtokens, Seitenrahmen, Kopf-/Fußzeile, Modals, Schaltflächen
   Dark-Mode-PCB-Theme aus der ursprünglichen Fassung.
   ========================================================================== */

:root {
    --primary-color: #22d3ee;
    --secondary-color: #10b981;
    --accent-color: #fbbf24;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --card-bg: #16233a;
    --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);

    /* PCB-Leiterbahnen */
    --trace-color: #64748b;
    --trace-glow: #22d3ee;

    --mono: 'Courier New', Courier, monospace;
}

* {
    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:
        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;
    overflow-x: hidden;
}

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

.hidden {
    display: none !important;
}

/* -------------------------------------------------------------- Kopfzeile */

header {
    background-color: var(--surface-color);
    padding: 16px 20px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
}

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

.nav-btn {
    background-color: var(--border-color);
    color: var(--text-primary);
    border: 1px solid var(--trace-color);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-btn:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--trace-glow);
}

.back-btn { grid-column: 1; justify-self: start; }
.tutorial-btn { grid-column: 3; justify-self: end; }

/* ------------------------------------------------------- Abschnittsköpfe */

.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);
}

.panel {
    background-color: var(--surface-color);
    padding: 30px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

/* --------------------------------------------------------- Schaltflächen */

.ghost-btn {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.ghost-btn:hover:not(:disabled) {
    color: var(--text-primary);
    border-color: var(--primary-color);
}

.ghost-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

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

.help-btn:hover,
.help-btn-yes:hover {
    background-color: #67e8f9;
    transform: translateY(-1px);
}

.continue-btn {
    background-color: var(--secondary-color);
    color: #fff;
    display: block;
    margin: 0 auto;
}

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

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

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

/* ------------------------------------------------------- Modul-Schalter */

.values-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 24px 0;
}

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

.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);
}

/* -------------------------------------------------------------- Fußzeile */

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;
}

/* --------------------------------------------------------- Byte-Maskottchen */

.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;
    inset: -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); }
}

/* ----------------------------------------------------------------- Modals */

.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

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

.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: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

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

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

.modal-header .modal-header-with-byte {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.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;
}

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

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

.task-modal,
.help-modal {
    max-width: 480px;
    text-align: center;
}

.help-modal.wide {
    max-width: 640px;
    text-align: left;
}

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

.task-final {
    color: var(--accent-color);
    font-weight: 600;
    margin-bottom: 20px;
}

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

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

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

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

/* ---------------------------------------------------------------- Konfetti */

.confetti-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10000;
    overflow: hidden;
}

.confetti {
    position: absolute;
    top: -20px;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    animation: confetti-fall linear forwards;
}

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

/* ------------------------------------------------------------- Responsive */

@media (max-width: 768px) {
    .container { padding: 15px; }
    h1 { font-size: 1.3rem; }
    header { grid-template-columns: auto 1fr auto; }
    .nav-btn { padding: 8px 12px; font-size: 0.85rem; }
    .panel { padding: 20px 15px; }
    .values-controls { gap: 8px; }
    .byte-mascot,
    .byte-mascot img { width: 70px; height: 70px; }
    .modal-content { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
