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

html, body { 
    scrollbar-width: none; 
    -ms-overflow-style: none; 
}

html::-webkit-scrollbar, body::-webkit-scrollbar { 
    display: none; 
}

body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: #000;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px;
    -webkit-font-smoothing: antialiased;
}

/* ── Calculator shell ── */
.calc-wrapper {
    width: 100%;
    max-width: 380px;
}

.calc {
    background: #000;
    overflow: hidden;
    user-select: none;
}

/* ── Display ── */
.calc-display {
    padding: 24px 24px 16px;
    text-align: right;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.calc-expression {
    font-size: 18px;
    color: #888;
    margin-bottom: 8px;
    min-height: 24px;
    font-family: 'SF Mono', 'Helvetica Neue', Helvetica, monospace;
    word-break: break-all;
}

.calc-screen {
    font-size: 64px;
    font-weight: 300;
    color: #fff;
    line-height: 1.1;
    word-break: break-all;
    transition: font-size 0.15s;
}

.calc-screen.small { font-size: 48px; }
.calc-screen.xsmall { font-size: 36px; }

/* ── Button grid ── */
.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 0 12px 16px;
}

.calc-btn {
    aspect-ratio: 1;
    border: none;
    border-radius: 50%;
    font-size: 28px;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-weight: 400;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.calc-btn:active { filter: brightness(1.4); }

.calc-btn.num {
    background: #333;
    color: #fff;
}

.calc-btn.func {
    background: #a5a5a5;
    color: #000;
    font-size: 22px;
}

.calc-btn.op {
    background: #ff9f0a;
    color: #fff;
    font-size: 32px;
}

.calc-btn.op.active-op {
    background: #fff;
    color: #ff9f0a;
}

.calc-btn.zero {
    grid-column: span 2;
    border-radius: 40px;
    aspect-ratio: auto;
    padding: 0 28px;
    justify-content: flex-start;
}

/* ── Branding ── */
.calc-brand {
    text-align: center;
    padding: 24px 0 0;
}

.calc-brand-name {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #555;
}

.calc-brand-tag {
    font-size: 10px;
    color: #333;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* ── Terminal overlay ── */
.terminal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: #0a0a0a;
    overflow-y: auto;
    scrollbar-width: none;
}
.terminal-overlay::-webkit-scrollbar { display: none; }

.terminal {
    color: #33ff33;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Courier New', monospace;
    font-size: 13px;
    padding: 24px;
    line-height: 1.7;
}

.terminal-line {
    white-space: pre-wrap;
    word-break: break-all;
    opacity: 0;
    animation: tFade .08s forwards;
}
@keyframes tFade { to { opacity: 1; } }

.t-ok    { color: #33ff33; }
.t-warn  { color: #facc15; }
.t-err   { color: #f87171; }
.t-info  { color: #60a5fa; }
.t-dim   { color: #555; }
.t-bold  { font-weight: 700; }
.t-white { color: #e0e0e0; }

/* ── Result overlay ── */
.result-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: #000;
    overflow-y: auto;
}

.result-inner {
    max-width: 480px;
    margin: 0 auto;
    padding: 48px 24px;
}

.result-kicker {
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 24px;
}

.result-banner {
    background: #111;
    border-left: 4px solid #33ff33;
    padding: 32px;
    text-align: center;
    margin-bottom: 32px;
}

.result-icon {
    font-size: 32px;
    color: #33ff33;
    margin-bottom: 8px;
}

.result-expr {
    font-size: 16px;
    color: #888;
    font-family: 'SF Mono', 'Monaco', monospace;
    margin-bottom: 8px;
}

.result-val {
    font-size: 72px;
    font-weight: 700;
    color: #fff;
    font-family: 'SF Mono', 'Monaco', monospace;
    line-height: 1.1;
    padding: 16px 0;
}

.result-note {
    font-size: 10px;
    color: #555;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

@keyframes glitchIn {
    0%   { opacity: 0; transform: scale(0.8) skewX(-5deg); filter: blur(8px); }
    40%  { opacity: 1; transform: scale(1.05) skewX(2deg); filter: blur(0); }
    60%  { transform: scale(0.98) skewX(-1deg); }
    80%  { transform: scale(1.01) skewX(0.5deg); }
    100% { transform: scale(1) skewX(0); }
}
.glitch-in { animation: glitchIn 0.6s ease-out forwards; }

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 32px;
}

.result-stat {
    text-align: center;
    padding: 14px 8px;
    border: 1px solid #222;
}

.result-stat-value {
    font-family: 'SF Mono', 'Monaco', monospace;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2px;
}

.result-stat-label {
    font-size: 9px;
    color: #555;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.result-back {
    display: block;
    width: 100%;
    padding: 16px;
    background: #333;
    color: #fff;
    border: none;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    font-family: inherit;
    border-radius: 12px;
    transition: background 0.2s;
}

.result-back:hover { background: #444; }

@media (max-width: 420px) {
    body { padding: 12px; }
    .calc-display { padding: 16px 16px 12px; }
    .calc-screen { font-size: 52px; }
    .calc-screen.small { font-size: 40px; }
    .calc-screen.xsmall { font-size: 30px; }
    .calc-buttons { gap: 10px; padding: 0 10px 12px; }
    .calc-btn { font-size: 24px; }
    .calc-btn.op { font-size: 28px; }
    .calc-btn.func { font-size: 20px; }
    .result-val { font-size: 48px; }
}