:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #131a2a;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent-cyan: #06b6d4;
    --accent-pink: #ec4899;
    --accent-purple: #8b5cf6;
    
    --glass-bg: rgba(19, 26, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    --font-ui: 'Outfit', sans-serif;
    --font-mono: 'Fira Code', monospace;
}

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

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(6, 182, 212, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(236, 72, 153, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-ui);
    min-height: 100vh;
    line-height: 1.5;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 3rem;
}

.app-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.app-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Shared Glass Panel Styles */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    box-shadow: var(--glass-shadow);
    padding: 1.5rem;
}

/* Interactive Section */
.interactive-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.canvas-container {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.5);
    aspect-ratio: 1/1;
}

canvas {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Slider Controls */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.slider-header label {
    font-weight: 600;
    font-size: 1.1rem;
}

#nValueDisplay {
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    font-weight: 700;
}

.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #2a3143;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-cyan);
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-cyan);
    transition: transform 0.1s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* Data Section */
.data-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.info-card h2 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    color: #fff;
}

.info-card p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.highlight {
    color: var(--accent-cyan);
    font-weight: 600;
}

.formula-highlight {
    color: var(--accent-pink);
    font-family: var(--font-mono);
    background: rgba(236, 72, 153, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.stat-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-target {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
    font-family: var(--font-mono);
    margin-top: 0.25rem;
}

/* Highlighted Panel for Final Comparison */
.highlighted-panel {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(236, 72, 153, 0.1));
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.resultado-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.resultado-item:last-child {
    text-align: right;
}

.resultado-item h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.resultado-valor {
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 700;
}

.text-cyan { color: var(--accent-cyan); text-shadow: 0 0 10px rgba(6,182,212,0.4); }
.text-pink { color: var(--accent-pink); text-shadow: 0 0 10px rgba(236,72,153,0.4); }

/* Progress / Accuracy Bar */
.progress-container {
    padding: 0 0.5rem;
}

.progress-bar-wrap {
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-pink));
    transition: width 0.3s ease;
}

.accuracy-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    float: right;
}

/* Unroll Section Styles */
.section-divider {
    border: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(236,72,153,0.3), rgba(6,182,212,0.3), transparent);
    margin: 4rem 0;
}

.secondary-header {
    margin-bottom: 2rem;
}

.secondary-header h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.unroll-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.unroll-canvas-box {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.5);
    overflow-x: auto;
    width: 100%;
}

#unrollCanvas {
    width: 100%;
    min-width: 800px;
    height: auto;
    display: block;
}

.unroll-controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.unroll-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
}

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

.modal-content {
    background: var(--bg-secondary);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 2.5rem;
    border: 1px solid var(--accent-purple);
    box-shadow: 0 0 50px rgba(139, 92, 246, 0.2);
    border-radius: 1rem;
}

.close-btn {
    position: absolute;
    top: 1rem; right: 1.5rem;
    background: none; border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover { color: var(--accent-pink); }

/* Math Steps */
.math-steps {
    margin-top: 1rem;
    display: flex; flex-direction: column; gap: 1.5rem;
}
.math-step {
    position: relative;
    padding-left: 3.5rem;
}
.step-num {
    position: absolute;
    left: 0; top: 0;
    width: 2.2rem; height: 2.2rem;
    background: rgba(139, 92, 246, 0.2);
    color: var(--accent-purple);
    border: 1px solid var(--accent-purple);
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    font-weight: bold;
    font-family: var(--font-mono);
}
.math-formula {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    color: var(--accent-cyan);
    margin-top: 0.8rem;
    padding: 1rem;
    background: rgba(0,0,0,0.3);
    border-radius: 0.5rem;
    display: inline-block;
}
.final-step .math-formula {
    color: var(--accent-pink);
    font-size: 1.6rem;
    border: 1px solid rgba(236, 72, 153, 0.3);
}
.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 0.2rem;
}
.fraction .top {
    border-bottom: 2px solid currentColor;
    padding: 0 0.2rem;
}
.fraction .bottom {
    padding: 0 0.2rem;
}
.math-var {
    font-family: var(--font-mono);
    color: #fff;
    font-style: italic;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 1rem;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(236,72,153,0.3);
}

.styled-input {
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 1.2rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    color: var(--text-primary);
    text-align: center;
    font-family: var(--font-mono);
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.styled-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(6,182,212,0.3);
}
.styled-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}
.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}
@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}
