:root {
    --btn-size: 80px;
    --radius: 16px;
    --border: #e5e7eb;
    --bg-panel: rgb(39 39 42 / 0.5);
    --mood-color: rgb(255, 200, 100);
    --mood-bg: transparent;
}

/* =====================
   Base
===================== */

body {
    background-color: #18181b;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
                 Roboto, "Helvetica Neue", Arial, sans-serif;
    color: white;
    margin: 0;
}

/* =====================
   Page Layout
===================== */

.page-container {
    display: grid;
    justify-content: center;
    justify-items: stretch;
    gap: 30px;
    padding: 40px;
    grid-template-columns: max-content;
}

/* =====================
   Title Block
===================== */

.calc-name-field {
    background-color: var(--bg-panel);
    color: rgb(205, 205, 205);
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-align: center;
    width: 0;
    min-width: 100%;
    box-sizing: border-box;
    min-height: 180px;
}

#title {
    font-size: 28px;
    margin: 0;
}

#title-p {
    font-size: 18px;
    margin: 0;
}

#title-p2 {
    font-size: 16px;
    margin: 0;
}

#face {
    font-size: 32px;
    font-family: monospace;
    margin-bottom: 4px;
    transition: transform 0.2s ease;
}

#commentary {
    font-size: 14px;
    font-style: italic;
    color: var(--mood-color);
    margin: 8px 0 0 0;
    min-height: 2.5em;
    transition: color 0.3s ease;
}

/* =====================
   Mood States
===================== */

.mood-neutral { --mood-color: rgb(255, 200, 100); }
.mood-happy { --mood-color: rgb(100, 255, 150); }
.mood-impressed { --mood-color: rgb(255, 215, 0); }
.mood-concerned { --mood-color: rgb(255, 150, 100); }
.mood-angry { --mood-color: rgb(255, 80, 80); }
.mood-confused { --mood-color: rgb(180, 150, 255); }
.mood-existential { --mood-color: rgb(100, 200, 255); }
.mood-amused { --mood-color: rgb(255, 150, 200); }

/* =====================
   Animations
===================== */

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes glitch {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(2px, -2px); }
    60% { transform: translate(-2px, -2px); }
    80% { transform: translate(2px, 2px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

.pulse {
    animation: pulse 0.4s ease-in-out;
}

.glitch {
    animation: glitch 0.3s ease-in-out infinite;
}

.typing-cursor::after {
    content: '|';
    animation: blink 0.7s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* =====================
   Hyperspace Effect
===================== */

#hyperspace {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

/* =====================
   Calculator Shell
===================== */

.calculator-container {
    background-color: var(--bg-panel);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    width: fit-content;
}

/* =====================
   Display
===================== */

.calculator-head {
    background-color: rgba(86, 86, 86, 0.45);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-sizing: border-box;
    width: 0;
    min-width: 100%;
}

.current-operation {
    all: unset;
    font-size: 22px;
    color: rgb(160, 159, 159);
    text-align: right;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.current-input {
    all: unset;
    font-size: 36px;
    color: white;
    text-align: right;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* =====================
   Calculator Body
===================== */

.calculator-body {
    display: flex;
    gap: 10px;
}

/* Number grid container */
.calculator-numbers {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Number rows (rendered dynamically) */
.calculator-numbers > div {
    display: grid;
    grid-template-columns: repeat(3, var(--btn-size));
    gap: 10px;
}

/* Operator column */
.calculator-operators {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* =====================
   Buttons
===================== */

button {
    all: unset;
    width: var(--btn-size);
    height: var(--btn-size);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.1s ease;
}

/* Universal hover (works for AC and =) */
button:hover {
    filter: brightness(0.9);
}

/* Press feedback */
button:active {
    transform: scale(0.96);
}

/* =====================
   Button Types
===================== */

.calculator-number {
    background-color: white;
    color: black;
}

.calculator-operator {
    background-color: orange;
    color: black;
}

/* Special buttons */
#clear {
    background-color: rgb(255, 39, 39);
    color: white;
}

#equals {
    background-color: rgb(74, 194, 74);
    color: black;
}

/* =====================
   Mobile Responsive
===================== */

@media screen and (max-width: 480px) {
    :root {
        --btn-size: 60px;
        --radius: 12px;
    }

    .page-container {
        padding: 20px 15px;
        gap: 20px;
    }

    .calc-name-field {
        padding: 12px;
        min-height: 160px;
    }

    #face {
        font-size: 26px;
    }

    #title {
        font-size: 22px;
    }

    #title-p {
        font-size: 14px;
    }

    #title-p2 {
        font-size: 12px;
    }

    #commentary {
        font-size: 12px;
        min-height: 2.8em;
    }

    .calculator-container {
        padding: 16px;
    }

    .calculator-head {
        padding: 10px 12px;
        margin-bottom: 15px;
    }

    .current-operation {
        font-size: 16px;
    }

    .current-input {
        font-size: 28px;
    }

    .calculator-body {
        gap: 8px;
    }

    .calculator-numbers {
        gap: 8px;
    }

    .calculator-numbers > div {
        gap: 8px;
    }

    .calculator-operators {
        gap: 8px;
    }

    button {
        font-size: 20px;
    }
}

/* =====================
   Achievement Notifications
===================== */

.achievement-notification {
    position: fixed;
    top: 20px;
    right: -400px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.95) 0%, rgba(255, 180, 50, 0.95) 100%);
    color: #1a1a2e;
    padding: 16px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 8px 32px rgba(255, 215, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.2);
    z-index: 10000;
    transition: right 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    max-width: 320px;
}

.achievement-notification.show {
    right: 20px;
}

.achievement-icon {
    font-size: 36px;
    flex-shrink: 0;
}

.achievement-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.achievement-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
}

.achievement-name {
    font-size: 18px;
    font-weight: 700;
}

.achievement-desc {
    font-size: 12px;
    opacity: 0.9;
}

/* =====================
   Philosophical Mode Overlay
===================== */

.philosophical-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 20, 0.95) 100%);
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    transition: opacity 2s ease;
}

.philosophical-overlay.active {
    opacity: 1;
}

.philosophical-text {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(100, 200, 255, 0.8);
    font-size: 16px;
    font-style: italic;
    text-align: center;
    max-width: 90%;
    opacity: 0;
    transition: opacity 1s ease;
    z-index: 101;
    pointer-events: none;
    text-shadow: 0 0 20px rgba(100, 200, 255, 0.5);
    padding: 12px 20px;
    background: rgba(0, 0, 20, 0.7);
    border-radius: 8px;
}

.philosophical-text.active {
    opacity: 1;
}

/* Extra small screens (iPhone SE, etc) */
@media screen and (max-width: 375px) {
    :root {
        --btn-size: 52px;
        --radius: 10px;
    }

    .page-container {
        padding: 15px 10px;
        gap: 15px;
    }

    .calc-name-field {
        padding: 10px;
        min-height: 145px;
    }

    #face {
        font-size: 22px;
    }

    #title {
        font-size: 18px;
    }

    #title-p {
        font-size: 12px;
    }

    #title-p2 {
        font-size: 11px;
    }

    #commentary {
        font-size: 11px;
    }

    .calculator-container {
        padding: 12px;
    }

    .calculator-head {
        padding: 8px 10px;
        margin-bottom: 12px;
    }

    .current-operation {
        font-size: 14px;
    }

    .current-input {
        font-size: 24px;
    }

    .calculator-body {
        gap: 6px;
    }

    .calculator-numbers {
        gap: 6px;
    }

    .calculator-numbers > div {
        gap: 6px;
    }

    .calculator-operators {
        gap: 6px;
    }

    button {
        font-size: 18px;
    }
}
