:root {
    color-scheme: light dark;
    font-family: "Inter", "Segoe UI", sans-serif;
}

body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at top, #0f172a 0%, #1e293b 45%, #0f172a 100%);
    color: #f8fafc;
    min-height: 100vh;
}

.nixie-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 40px 20px 80px;
}

.app-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 40px;
    text-align: left;
}

.app-header .header-main {
    flex: 1 1 320px;
}

.app-header h1 {
    margin: 0 0 12px;
    font-size: 2.5rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #f97316;
    text-shadow: 0 0 10px rgba(249, 115, 22, 0.6);
}

.app-header .tagline {
    color: #cbd5f5;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
}

.auto-advance-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    background: rgba(148, 163, 184, 0.15);
    border-radius: 999px;
    padding: 6px 16px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    cursor: pointer;
    color: #e2e8f0;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.35);
}

.auto-advance-toggle input {
    transform: scale(1.2);
}

.auto-advance-toggle input:focus-visible {
    outline: 2px solid #f97316;
    outline-offset: 2px;
}

.auto-advance-toggle span {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.challenge-section {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: 0 15px 40px rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(8px);
}

.challenge-section h2 {
    margin-top: 0;
    color: #fbbf24;
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
}

canvas {
    display: block;
    margin: 20px auto;
    background: transparent;
}

canvas.segment-canvas {
    display: block;
    margin: 20px auto;
}

.decimal-value {
    text-align: center;
    font-size: 1.25rem;
    margin-bottom: 16px;
    color: #f8fafc;
}

.bit-inputs {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 20px;
}

.bit-inputs label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #e2e8f0;
    font-weight: 600;
}

.bit-inputs input[type="checkbox"] {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    appearance: none;
    position: relative;
    background: linear-gradient(90deg, #1f2937, #0f172a);
    border: 1px solid rgba(148, 163, 184, 0.4);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.bit-inputs input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #94a3b8;
    transition: transform 0.2s ease, background 0.2s ease;
}

.bit-inputs input[type="checkbox"]:checked {
    border-color: rgba(248, 113, 113, 0.7);
    background: linear-gradient(90deg, #fb923c, #f97316);
}

.bit-inputs input[type="checkbox"]:checked::after {
    transform: translateX(18px);
    background: #fff7ed;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
}

button {
    padding: 10px 18px;
    border-radius: 999px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    background: linear-gradient(135deg, #f97316, #fb923c);
    color: #0f172a;
    box-shadow: 0 10px 20px rgba(249, 115, 22, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 24px rgba(249, 115, 22, 0.3);
}

a.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.8);
    color: #e2e8f0;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

a.secondary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(148, 163, 184, 0.3);
}

.feedback {
    text-align: center;
    min-height: 24px;
    font-weight: 600;
}

.feedback.correct {
    color: #4ade80;
}

.feedback.incorrect {
    color: #f87171;
}

.binary-display {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 24px 0;
}

.bit-card {
    background: rgba(30, 41, 59, 0.8);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    width: 90px;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.bit-card h3 {
    margin: 0 0 8px;
    color: #fbbf24;
    font-size: 1.1rem;
}

.bit-value {
    display: block;
    font-size: 2rem;
    color: #f8fafc;
}

.decimal-answer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}

.decimal-answer input {
    width: 120px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.7);
    color: #f8fafc;
    font-size: 1.1rem;
    text-align: center;
}

.resources {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.35);
}

.resources ul {
    margin: 0;
    padding-left: 20px;
    color: #cbd5f5;
}

.resources li {
    margin-bottom: 8px;
}

.resources a {
    color: #fbbf24;
    text-decoration: underline;
}

.resources a:hover {
    color: #facc15;
}

.instructor-links {
    margin-top: 18px;
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.instructor-links a {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: #e2e8f0;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.instructor-links a:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(148, 163, 184, 0.3);
}

.addition-section .addition-problem {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 28px auto;
    max-width: 420px;
}

.binary-add-row {
    display: grid;
    grid-template-columns: 48px 1fr 80px;
    align-items: center;
    gap: 14px;
    font-size: 1.4rem;
}

.binary-add-row.header-row {
    margin-bottom: -6px;
    font-size: 0.85rem;
    color: #cbd5f5;
    letter-spacing: 0.05em;
}

.operand-label {
    width: 48px;
    text-align: right;
    font-weight: 600;
    color: #fbbf24;
}

.binary-add-row.header-row .operand-label {
    color: #fbbf24;
    visibility: hidden;
}

.bit-strip {
    display: grid;
    grid-template-columns: repeat(4, 48px);
    gap: 12px;
    align-items: center;
}

.binary-add-row.header-row .bit-strip {
    justify-items: center;
}

.binary-add-row.header-row .decimal-summary {
    text-align: left;
}

.bit-strip.header-strip {
    font-weight: 600;
    justify-items: center;
}

.bit-strip .bit-display {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: #f8fafc;
    font-weight: 700;
    font-size: 1.3rem;
}

.bit-strip .bit-display.blank {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.bit-strip .bit-pos {
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    text-align: center;
    width: 48px;
}

.bit-strip .sum-input {
    width: 48px;
    height: 48px;
    text-align: center;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.7);
    color: #f8fafc;
    font-size: 1.3rem;
    font-weight: 700;
}

.bit-strip .sum-input:focus {
    outline: none;
    border-color: rgba(251, 146, 60, 0.9);
    box-shadow: 0 0 0 2px rgba(251, 146, 60, 0.35);
}

.binary-input-grid {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-bottom: 20px;
}

.binary-input-grid label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: #cbd5f5;
    font-weight: 600;
}

.conversion-bit {
    width: 52px;
    height: 52px;
    text-align: center;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.75);
    color: #f8fafc;
    font-size: 1.4rem;
    font-weight: 700;
}

.conversion-bit:focus {
    outline: none;
    border-color: rgba(251, 146, 60, 0.9);
    box-shadow: 0 0 0 2px rgba(251, 146, 60, 0.35);
}

.hex-input {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: 20px 0;
}

.hex-input input {
    width: 80px;
    height: 56px;
    text-align: center;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(248, 250, 252, 0.85);
    color: #1f2937;
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
}

.hex-input input:focus {
    outline: none;
    border-color: rgba(244, 63, 94, 0.9);
    box-shadow: 0 0 0 2px rgba(244, 63, 94, 0.35);
}

.decimal-summary {
    min-width: 64px;
    text-align: left;
    font-size: 1rem;
    color: #fbbf24;
}

.score-display {
    text-align: center;
    margin-top: -4px;
    margin-bottom: 12px;
    font-weight: 600;
    color: #fbbf24;
}

.addition-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.score-block {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    color: #fbbf24;
}

.next-spinner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #fcd34d;
    font-size: 0.9rem;
}

.next-spinner[hidden] {
    display: none;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(252, 211, 77, 0.4);
    border-top-color: #facc15;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.tabbed-card .tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.tab-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.75);
    color: #e2e8f0;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.tab-btn-link {
    text-decoration: none;
}

.tab-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(148, 163, 184, 0.25);
}

.tab-btn.active {
    background: linear-gradient(135deg, #f97316, #fb923c);
    color: #0f172a;
    border-color: transparent;
    box-shadow: 0 10px 20px rgba(249, 115, 22, 0.25);
}

.tab-panels {
    width: 100%;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.section-header h2 {
    margin: 0;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-title .tab-btn {
    padding: 6px 14px;
}

.tab-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tab-actions .secondary-btn {
    padding: 8px 16px;
}

@media (max-width: 720px) {
    .bit-inputs,
    .binary-display,
    .controls {
        flex-direction: column;
        align-items: center;
    }

    button {
        width: 100%;
    }

    .binary-add-row {
        grid-template-columns: 48px 1fr;
        grid-template-rows: auto auto;
        gap: 8px;
    }

    .binary-add-row .decimal-summary {
        grid-column: 2 / -1;
        text-align: left;
    }

    .binary-add-row.header-row {
        display: none;
    }

    .operand-label {
        width: auto;
        text-align: center;
    }

    .bit-strip {
        grid-template-columns: repeat(4, 1fr);
    }

    .bit-strip .bit-display,
    .bit-strip .sum-input {
        width: 44px;
        height: 44px;
    }

    .decimal-summary {
        min-width: auto;
    }
}


