* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', sans-serif;
}

body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
}

.container {
    display: flex;
    flex-direction: column; 
    gap: 20px;
    padding: 20px;
    width: 100%;
}

.calculator {
    background: #16213e;
    border-radius: 20px;
    padding: 20px;
    width: 320px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
.calculator {
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
}
.display {
    background: #0f3460;
    border-radius: 12px;
    padding: 20px;
    text-align: right;
    margin-bottom: 16px;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

#expression {
    color: #fff;
    font-size: 2rem;
    font-weight: 300;
    word-break: break-all;
}


.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

button {
    padding: 18px;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    background: #1a1a2e;
    color: #fff;
}

button:hover {
    transform: scale(1.05);
    background: #0f3460;
}

button:active {
    transform: scale(0.95);
}

/* OPERATOR BUTTONS */
.buttons button:nth-child(4n) {
    background: #e94560;
    color: #fff;
}

.buttons button:nth-child(4n):hover {
    background: #c73652;
}

/* CLEAR AND DELETE */
.buttons button:nth-child(1),
.buttons button:nth-child(2) {
    background: #0f3460;
}

/* EQUALS BUTTON */
.buttons button:last-child {
    background: #e94560;
    font-size: 1.3rem;
}

.buttons button:last-child:hover {
    background: #c73652;
}

/* HISTORY */
.history {
    background: #16213e;
    border-radius: 20px;
    padding: 20px;
    width: 260px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 500px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-header h3 {
    color: #fff;
    font-size: 1rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.history-header button {
    background: #e94560;
    color: #fff;
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
}

.history {
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
}

.history-header button:hover {
    background: #c73652;
}

/* HISTORY LIST */
#historyList {
    list-style: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#historyList li {
    background: #0f3460;
    padding: 10px 14px;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease;
}

#historyList li:hover {
    background: #e94560;
}

#historyList .expression {
    font-size: 0.8rem;
    color: #aaa;
}

#historyList .result {
    font-size: 1.1rem;
    font-weight: bold;
}

/* SCROLLBAR */
#historyList::-webkit-scrollbar {
    width: 4px;
}

#historyList::-webkit-scrollbar-track {
    background: transparent;
}

#historyList::-webkit-scrollbar-thumb {
    background: #e94560;
    border-radius: 10px;
}

@media (min-width: 700px) {
    .container {
        flex-direction: row; /* side by side on desktop */
    }
}
