:root {
    --bg-color: #0c0c14;
    --card-bg: rgba(255, 255, 255, 0.05);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --accent-color: #00f2ff;
    --accent-glow: rgba(0, 242, 255, 0.3);
    --matrix-white: #ffffff;
    --matrix-black: #000000;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(80px);
}

.blob {
    position: absolute;
    width: 50vw;
    height: 50vw;
    border-radius: 50%;
    opacity: 0.15;
}

.blob-1 {
    top: -10%;
    right: -10%;
    background-color: var(--accent-color);
    animation: move 20s infinite alternate;
}

.blob-2 {
    bottom: -10%;
    left: -10%;
    background-color: #7000ff;
    animation: move 25s infinite alternate-reverse;
}

@keyframes move {
    from {
        transform: translate(0, 0);
    }

    to {
        transform: translate(100px, 100px);
    }
}

.app-container {
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 32px;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-shrink: 0;
}

.matrix-section {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
    min-height: 0;
}

.main-display {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 1rem;
    min-height: 0;
}

.display-tabs {
    display: flex;
    gap: 1rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    flex-shrink: 0;
}

.tab-content {
    display: none;
    flex: 1;
    min-height: 0;
}

.tab-content.active {
    display: flex;
}

.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Custom Scrollbar */
.controls-panel::-webkit-scrollbar {
    width: 6px;
}

.controls-panel::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    body {
        overflow-y: auto;
        height: auto;
        align-items: flex-start;
        padding: 1rem 0;
    }

    .app-container {
        width: 95%;
        height: auto;
        padding: 1.5rem;
        border-radius: 20px;
        overflow: visible;
    }

    .matrix-section {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .controls-panel {
        overflow-y: visible;
        padding-right: 0;
    }

    .decoder-container {
        grid-template-columns: 1fr;
        position: relative;
    }

    .camera-preview {
        aspect-ratio: 4/3;
        height: min(400px, 60vh);
    }

    .processing-view {
        position: absolute;
        top: 1rem;
        right: 1rem;
        width: 120px;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        padding: 0.5rem;
        z-index: 10;
        pointer-events: none;
    }

    .processing-view h3 {
        display: none;
    }

    #processingCanvas {
        width: 100%;
        margin-bottom: 0;
    }

    #matrixCanvas {
        width: 320px;
        height: 320px;
    }

    #latencyDisplay {
        font-size: 3rem;
    }
}

@media (max-width: 480px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    #matrixCanvas {
        width: 260px;
        height: 260px;
    }

    .processing-view {
        flex-direction: column;
        gap: 1rem;
    }
}

.data-card,
.settings-card {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.data-card.highlighted {
    background: linear-gradient(135deg, rgba(0, 242, 255, 0.1) 0%, rgba(0, 0, 0, 0.3) 100%);
    border-color: rgba(0, 242, 255, 0.2);
}

.data-card.decoded-success {
    background: rgba(0, 255, 149, 0.15);
    border-color: var(--accent-color);
    box-shadow: 0 0 20px rgba(0, 255, 149, 0.3);
    animation: success-pulse 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes success-pulse {
    0% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-5px) scale(1.02);
    }

    100% {
        transform: translateY(0) scale(1);
    }
}

.latency-value-hero {
    display: flex;
    align-items: baseline;
    justify-content: center;
    margin: 1rem 0;
}

#latencyDisplay {
    font-size: 4rem;
    font-weight: 600;
    color: var(--accent-color);
    text-shadow: 0 0 30px var(--accent-glow);
}

.latency-value-hero small {
    font-size: 1.5rem;
    margin-left: 0.5rem;
    color: var(--text-secondary);
}

h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.data-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.mono {
    font-family: 'JetBrains Mono', monospace;
}

.value {
    font-size: 1.1rem;
    color: var(--accent-color);
}

.control-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

select {
    width: 100%;
    background: var(--bg-color);
    color: white;
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: 10px;
    outline: none;
    font-size: 0.9rem;
}

.btn {
    width: 100%;
    padding: 0.75rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    margin-bottom: 0.5rem;
}

.btn-primary {
    background: var(--accent-color);
    color: black;
}

.btn-primary:hover {
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: white;
}

.btn-secondary:hover {
    background: white;
    color: black;
}

.hidden {
    display: none !important;
}

.footer-info {
    margin-top: auto;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 1rem 0;
}

.footer-info a {
    color: var(--accent-color);
    text-decoration: none;
}

/* Custom Swtich */
.toggle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.slider {
    position: relative;
    width: 40px;
    height: 20px;
    background-color: #334155;
    border-radius: 20px;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
}

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

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

input {
    display: none;
}