:root {
    --bg-primary: #0b0f19;
    --bg-app: #131a2a;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent-cyan: #06b6d4;
    --accent-pink: #ec4899;
    --accent-purple: #8b5cf6;
    
    --font-ui: 'Outfit', sans-serif;
    --font-mono: 'Fira Code', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-ui);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.app-wrapper {
    width: 100%;
    max-width: 400px;
    height: 100vh;
    max-height: 850px;
    background-color: var(--bg-app);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
}

/* Em telas maiores, parece um celular. Em mobile, ocupa tudo. */
@media (min-width: 450px) {
    .app-wrapper {
        height: 90vh;
        border-radius: 30px;
        border: 8px solid #1e293b;
    }
}

.fake-status-bar {
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.status-icons {
    display: flex;
    gap: 8px;
}

.app-header {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.back-btn {
    color: var(--accent-cyan);
    font-size: 1.2rem;
    text-decoration: none;
    padding: 10px;
    margin-left: -10px;
}

.app-header h1 {
    font-size: 1.3rem;
    margin-left: 10px;
    font-weight: 600;
}

.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.instruction p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.4;
    text-align: center;
}

.canvas-container {
    background: #0b0f19;
    border-radius: 16px;
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.05);
}

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

.controls-panel {
    background: rgba(255,255,255,0.03);
    padding: 20px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border: 1px solid rgba(255,255,255,0.05);
}

.slider-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
}

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

.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 10px;
    border-radius: 5px;
    background: #1e293b;
    outline: none;
    margin: 10px 0;
}

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

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-card {
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
}

.resultado-final {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(236, 72, 153, 0.1));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
}

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

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

.resultado-item span {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
}

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

.text-cyan { color: var(--accent-cyan); }
.text-pink { color: var(--accent-pink); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    color: white;
    border: none;
    padding: 15px;
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 1.1rem;
    border-radius: 12px;
    width: 100%;
    margin-top: 10px;
}

.btn-primary:active {
    transform: scale(0.98);
}

/* Modal */
.modal-overlay {
    display: none;
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(11, 15, 25, 0.9);
    backdrop-filter: blur(5px);
    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-app);
    width: 90%;
    padding: 25px;
    border: 1px solid var(--accent-purple);
    border-radius: 16px;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 15px; right: 15px;
    background: none; border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
}

.math-steps {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.math-step {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    text-align: center;
}

.proof-limit { color: var(--text-secondary); }
.final-step {
    color: var(--accent-pink);
    border: 1px solid rgba(236, 72, 153, 0.3);
    font-size: 1.1rem;
}

.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 4px;
}
.fraction .top { border-bottom: 1px solid currentColor; }
