:root {
    --red: #e53e3e;
    --blue: #3182ce;
    --green: #38a169;
    --light-gray: #edf2f7;
    --dark-gray: #2d3748;
    --border-color: #e2e8f0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f0f2f5;
    padding: 20px;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 400px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 0 20px;
    width: 100%;
}

header h1 {
    color: #2d3748;
    font-size: 2.5rem;
    margin-bottom: 10px;
}

header p {
    color: #4a5568;
    font-size: 1.1rem;
    max-width: 500px;
    margin: 0 auto;
}

.calculator {
    background-color: #f8f9fa;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    width: 100%;
    max-width: 350px;
    border: 1px solid var(--border-color);
}

.tabs {
    display: flex;
    background-color: #f8f9fa;
    border-bottom: 1px solid var(--border-color);
}

.tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    background-color: #e2e8f0;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: #4a5568;
    transition: all 0.3s ease;
    font-size: 14px;
}

.tab:hover {
    background-color: #cbd5e0;
}

.tab.active {
    background-color: #f8f9fa;
    color: var(--blue);
    font-weight: 600;
}

.display {
    padding: 15px;
}

#output {
    width: 100%;
    height: 60px;
    background-color: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-align: right;
    padding: 0 15px;
    font-size: 24px;
    font-weight: bold;
    color: var(--dark-gray);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tab-content {
    display: none;
    padding: 15px;
    padding-top: 0;
}

.tab-content.active {
    display: block;
}

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

.button {
    height: 60px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.button:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.button:active {
    transform: translateY(0);
}

.button.number {
    background-color: var(--light-gray);
    color: var(--dark-gray);
}

.button.operator {
    background-color: var(--blue);
    color: white;
}

.button.function {
    background-color: var(--blue);
    color: white;
    font-size: 16px;
}

.button.unit {
    background-color: var(--green);
    color: white;
    font-size: 14px;
}

.button.clear {
    background-color: var(--red);
    color: white;
}

#output:focus {
    outline: 2px solid #3182ce;
    outline-offset: 2px;
}

.button:focus {
    outline: 2px solid #3182ce;
    outline-offset: 2px;
    position: relative;
    z-index: 1;
}

footer {
    margin-top: 40px;
    padding: 20px;
    text-align: center;
    color: #4a5568;
    font-size: 0.9rem;
    width: 100%;
}

.footer-content {
    max-width: 500px;
    margin: 0 auto;
}

.links {
    margin-top: 10px;
}

.links a {
    color: #3182ce;
    text-decoration: none;
    margin: 0 10px;
    transition: opacity 0.3s;
}

.links a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

@media (max-width: 480px) {
    header h1 {
        font-size: 2rem;
    }
    
    header p {
        font-size: 0.9rem;
    }
    
    footer {
        font-size: 0.8rem;
    }
    
    .links a {
        display: block;
        margin: 5px 0;
    }
}

@media (max-width: 400px) {
    .button {
        height: 50px;
        font-size: 16px;
    }
    
    .button.unit {
        font-size: 12px;
    }
}