@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Space+Grotesk:wght@400;500;700&display=swap');

:root {
    --space-cadet: #25344F;
    --slate-gray: #617891;
    --tan: #D5B893;
    --coffee: #6F4D38;
    --caput-mortuum: #632024;
    --white: #ffffff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--space-cadet);
    color: var(--space-cadet);
    font-family: "Space Grotesk", sans-serif;
    overflow-x: hidden;
}

button,
a {
    font: inherit;
}

.top-nav {
    min-height: 76px;
    padding: 16px 24px;
    background: var(--coffee);
    border-bottom: 4px solid #5f3f2b;
    box-shadow: 4px 4px 0 #5f3f2b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--tan);
}

.brand,
.brand-mark,
.footer strong {
    font-family: "Space Mono", monospace;
    font-weight: 700;
    letter-spacing: -1px;
}

.brand {
    font-size: 32px;
}

.top-nav a {
    color: var(--tan);
    text-decoration: none;
    border-bottom: 2px solid var(--tan);
    font-family: "Space Mono", monospace;
    font-weight: 700;
}

.nav-actions {
    display: flex;
    gap: 16px;
}

.nav-actions button {
    background: none;
    border: 0;
    color: var(--tan);
    font-size: 24px;
    cursor: pointer;
}

.main-content {
    min-height: calc(100vh - 150px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px 32px 100px;
}

.calculator {
    position: relative;
    width: 400px;
    padding: 24px;
    background: var(--tan);
    border: 4px solid #5f3f2b;
    box-shadow: 4px 4px 0 #5f3f2b;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.duck-mascot {
    position: absolute;
    top: -48px;
    right: 24px;
    width: 48px;
    height: 48px;
    z-index: 2;
    pointer-events: none;
}

#duck-head {
    transform-origin: 4px 4px;
    transition: transform .15s ease-in-out;
}

.screw {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #5f3f2b;
}

.screw-tl {
    top: 8px;
    left: 8px;
}

.screw-tr {
    top: 8px;
    right: 8px;
}

.screw-bl {
    bottom: 8px;
    left: 8px;
}

.screw-br {
    bottom: 8px;
    right: 8px;
}

.brand-mark {
    width: 100%;
    text-align: center;
    font-size: 32px;
}

.pixel-lines {
    display: flex;
    justify-content: space-between;
    padding: 0 8px;
    margin-bottom: 8px;
}

.pixel-lines span {
    width: 32px;
    height: 8px;
    background: #5f3f2b;
}

.display {
    height: 96px;
    padding: 16px;
    margin-bottom: 16px;
    background: var(--space-cadet);
    border-top: 4px solid var(--slate-gray);
    border-left: 4px solid var(--slate-gray);
    border-bottom: 4px solid var(--white);
    border-right: 4px solid var(--white);
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
}

#display-value {
    color: var(--tan);
    font: 700 48px/1.1 "Space Mono", monospace;
    letter-spacing: -2px;
    overflow: hidden;
    max-width: 100%;
}

.keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.calc-button {
    height: 48px;
    border: 4px solid #5f3f2b;
    box-shadow: 4px 4px 0 #5f3f2b;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tan);
    font: 700 18px/1 "Space Mono", monospace;
    cursor: pointer;
    transition: transform .05s ease-in-out, box-shadow .05s ease-in-out;
}

.calc-button:active,
.calc-button.pressed {
    box-shadow: 0 0 0 #5f3f2b;
    transform: translate(4px, 4px);
}

.number {
    background: var(--coffee);
}

.utility {
    background: var(--slate-gray);
}

.operator {
    background: var(--caput-mortuum);
}

.zero {
    grid-column: span 2;
}

.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    min-height: 54px;
    padding: 8px 24px;
    background: #cbdafd;
    border-top: 4px solid #7f756b;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    font-size: 12px;
}

.footer div {
    display: flex;
    align-items: center;
    gap: 16px;
}

.footer a {
    color: #4d453c;
    text-decoration: underline;
}

@media (max-width: 600px) {
    .main-content {
        padding: 48px 16px 90px;
    }

    .calculator {
        width: min(400px, 100%);
        padding: 18px;
    }

    .keypad {
        gap: 12px;
    }

    .footer {
        display: none;
    }

    .top-nav {
        padding: 12px 16px;
    }

    .brand {
        font-size: 24px;
    }
}

/* ================================
   NAVBAR DROPDOWNS
================================ */

.nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-panel-wrapper {
    position: relative;
}

.nav-icon-button {
    background: none;
    border: none;
    color: var(--tan);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
}

.nav-dropdown {
    position: absolute;
    top: calc(100% + 18px);
    right: 0;
    width: 280px;
    padding: 16px;
    background: var(--tan);
    border: 4px solid #5f3f2b;
    box-shadow: 4px 4px 0 #5f3f2b;
    color: var(--space-cadet);
    z-index: 100;
    display: none;
}

.nav-dropdown.open {
    display: block;
}

.dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    margin-bottom: 14px;
    border-bottom: 3px solid #5f3f2b;
    font-family: "Space Mono", monospace;
    font-weight: 700;
}

.dropdown-close {
    border: none;
    background: transparent;
    color: var(--space-cadet);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    font-family: "Space Mono", monospace;
    font-size: 13px;
    font-weight: 700;
}

.pixel-toggle {
    min-width: 52px;
    padding: 6px 8px;
    border: 3px solid #5f3f2b;
    background: var(--slate-gray);
    color: var(--tan);
    box-shadow: 3px 3px 0 #5f3f2b;
    font-family: "Space Mono", monospace;
    font-weight: 700;
    cursor: pointer;
}

.pixel-toggle.active {
    background: var(--caput-mortuum);
}

.dropdown-action {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    border: 3px solid #5f3f2b;
    background: var(--coffee);
    color: var(--tan);
    box-shadow: 3px 3px 0 #5f3f2b;
    font-family: "Space Mono", monospace;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.history-list {
    max-height: 240px;
    overflow-y: auto;
    font-family: "Space Mono", monospace;
    font-size: 12px;
}

.history-list p {
    margin: 8px 0;
    color: var(--slate-gray);
}

.history-entry {
    padding: 10px 0;
    border-bottom: 2px dashed var(--slate-gray);
}

.history-expression {
    display: block;
    margin-bottom: 4px;
}

.history-result {
    display: block;
    color: var(--caput-mortuum);
    font-weight: 700;
}

@media (max-width: 600px) {
    .nav-dropdown {
        position: fixed;
        top: 76px;
        right: 12px;
        width: min(280px, calc(100vw - 24px));
    }
}

.footer-left,
.footer-links {
    display: flex;
    align-items: center;
    gap: 16px;
}

.footer-links a {
    color: #4d453c;
    text-decoration: underline;
}