:root {
    --bg-deep: #05070a;
    --bg-panel: rgba(20, 25, 40, 0.7);
    --neon-cyan: #00f3ff;
    --neon-purple: #bc13fe;
    --text-primary: #e0e6ed;
    --text-secondary: #8b9bb4;
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Rajdhani', sans-serif;
    background-color: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Fondo espacial animado */
.stars, .twinkling {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    display: block;
}
.stars {
    background: #000 url('http://www.script-tutorials.com/demos/360/images/stars.png') repeat top center;
    z-index: -2;
}
.twinkling {
    background: transparent url('http://www.script-tutorials.com/demos/360/images/twinkling.png') repeat top center;
    z-index: -1;
    animation: move-twink-back 200s linear infinite;
}
@keyframes move-twink-back {
    from {background-position:0 0;}
    to {background-position:-10000px 5000px;}
}

/* Contenedor Principal */
.calculator-container {
    width: 90%;
    max-width: 450px;
    background: var(--bg-panel);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.15), inset 0 0 20px rgba(188, 19, 254, 0.05);
}

.calc-header {
    text-align: center;
    margin-bottom: 15px;
}
.calc-header h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    letter-spacing: 2px;
    color: var(--text-primary);
}
.highlight { color: var(--neon-cyan); text-shadow: 0 0 10px var(--neon-cyan); }
.subtitle {
    font-size: 0.85rem;
    color: var(--neon-purple);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Pantalla Auto-expandible */
.screen-container {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--neon-cyan);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    min-height: 120px;
    max-height: 40vh; /* Se expande hasta el 40% de la pantalla */
    overflow-y: auto; /* Scroll interno si el proceso es muy largo */
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    box-shadow: inset 0 0 15px rgba(0, 243, 255, 0.1);
}

/* Scrollbar personalizado */
.screen-container::-webkit-scrollbar { width: 6px; }
.screen-container::-webkit-scrollbar-thumb { background: var(--neon-purple); border-radius: 3px; }

.process-display {
    font-size: 1rem;
    color: var(--text-secondary);
    text-align: right;
    white-space: pre-wrap; /* Respeta saltos de línea de la IA */
    word-wrap: break-word;
    margin-bottom: 10px;
    line-height: 1.4;
}
.placeholder { font-style: italic; opacity: 0.5; }

.result-display {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    color: var(--neon-cyan);
    text-align: right;
    word-wrap: break-word;
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.5);
}

/* Input de IA */
.ai-input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
#ai-prompt {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary);
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    outline: none;
    transition: 0.3s;
}
#ai-prompt:focus {
    border-color: var(--neon-purple);
    box-shadow: 0 0 10px rgba(188, 19, 254, 0.3);
}
.ai-btn {
    background: linear-gradient(135deg, var(--neon-purple), #8a00c2);
    border: none;
    border-radius: 8px;
    color: white;
    min-width: 48px;
    padding: 0 12px;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ai-btn.reset-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.ai-btn:disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}
.ai-btn:hover { transform: scale(1.05); box-shadow: 0 0 15px var(--neon-purple); }

/* Teclado */
.keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}
.btn:active { transform: scale(0.95); }
.btn.func { color: #ff5e5e; }
.btn.operator { color: var(--neon-cyan); font-size: 1.4rem; }
.btn.equals {
    grid-column: span 2;
    background: linear-gradient(135deg, var(--neon-cyan), #00a8b3);
    color: #000;
    font-weight: bold;
}
.btn.equals:hover { box-shadow: 0 0 20px var(--neon-cyan); }
.btn.zero { grid-column: span 2; }

/* Responsividad para móviles muy pequeños */
@media (max-width: 380px) {
    .calculator-container { width: 95%; padding: 15px; }
    .btn { padding: 12px; font-size: 1rem; }
    .result-display { font-size: 2rem; }
}