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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calculator-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 20px;
    width: 100%;
    max-width: 760px;
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 20px;
}

.calculator-main h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 12px;
    font-size: 22px;
}

.display {
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    text-align: right;
    font-size: 34px;
    font-weight: 300;
    color: #333;
    word-wrap: break-word;
    word-break: break-all;
    min-height: 60px;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
}

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

button {
    padding: 14px;
    font-size: 16px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

button:active {
    transform: scale(0.98);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.number {
    background: #f5f5f5;
    color: #333;
    border: 2px solid #e0e0e0;
}

.number:hover {
    background: #efefef;
}

.operation {
    background: #667eea;
    color: white;
    border: 2px solid #667eea;
}

.operation:hover {
    background: #5568d3;
    border-color: #5568d3;
}

.equals {
    background: #48bb78;
    color: white;
    border: 2px solid #48bb78;
    grid-column: span 2;
}

.equals:hover {
    background: #38a169;
    border-color: #38a169;
}

.clear {
    background: #f56565;
    color: white;
    border: 2px solid #f56565;
    grid-column: span 2;
}

.clear:hover {
    background: #e53e3e;
    border-color: #e53e3e;
}

.decimal {
    background: #f5f5f5;
    color: #333;
    border: 2px solid #e0e0e0;
}

.decimal:hover {
    background: #efefef;
}

.stack-panel {
    border-left: 1px solid #eee;
    padding-left: 12px;
}

.stack-panel h2 {
    color: #667eea;
    margin-bottom: 8px;
}

.stack-list {
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 8px;
    min-height: 200px;
    max-height: 60vh;
    overflow: auto;
}

.stack-item {
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
}

.stack-item:last-child {
    border-bottom: none;
}

.stack-hint {
    font-size: 12px;
    color: #888;
    margin-top: 8px;
}

@media (max-width: 760px) {
    .calculator-container {
        grid-template-columns: 1fr;
        max-width: 380px;
    }

    .stack-panel {
        order: 2;
    }
}
