* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #F9F9F9;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

body.dark-mode {
    background-color: #000000;
}

.calculator-container {
    width: 100%;
    max-width: 400px;
    background-color: #F9F9F9;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

body.dark-mode .calculator-container {
    background-color: #000000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.promo-banner {
    background: linear-gradient(135deg, #A91D3A 0%, #F4B041 100%);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    text-align: center;
}

.promo-text {
    font-size: 16px;
    font-weight: 600;
    color: #FFFFFF;
    margin: 0;
    letter-spacing: 0.5px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.title {
    font-size: 24px;
    font-weight: 600;
    color: #000000;
}

body.dark-mode .title {
    color: #FFFFFF;
}

.settings-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.dark-mode .settings-btn {
    color: #FFFFFF;
}

.display {
    background-color: #FFFFFF;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

body.dark-mode .display {
    background-color: #1C1C1E;
}

.previous-display {
    font-size: 16px;
    color: #8E8E93;
    text-align: right;
    min-height: 24px;
    margin-bottom: 8px;
}

.current-display {
    font-size: 56px;
    font-weight: 700;
    color: #000000;
    text-align: right;
    word-wrap: break-word;
    word-break: break-all;
}

body.dark-mode .current-display {
    color: #FFFFFF;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 20px;
    aspect-ratio: 1;
}

.btn {
    border: none;
    border-radius: 14px;
    font-size: 28px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    min-height: 70px;
    min-width: 70px;
}

.btn:active {
    transform: scale(0.92);
    opacity: 0.75;
}

.number-btn {
    background-color: #E5E5E5;
    color: #000000;
}

body.dark-mode .number-btn {
    background-color: #505050;
    color: #FFFFFF;
}

.operation-btn {
    background-color: #A91D3A;
    color: #FFFFFF;
    font-size: 32px;
    font-weight: 600;
}

.function-btn {
    background-color: #D4D4D4;
    color: #000000;
    font-size: 24px;
}

body.dark-mode .function-btn {
    background-color: #A5A5A5;
    color: #FFFFFF;
}

.btn-zero {
    grid-column: span 2;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.modal-content {
    background-color: #F9F9F9;
    width: 100%;
    max-width: 500px;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

body.dark-mode .modal-content {
    background-color: #1C1C1E;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #000000;
}

body.dark-mode .modal-title {
    color: #FFFFFF;
}

.close-btn, .done-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 8px;
    font-weight: 600;
    color: #A91D3A;
}

.section-title {
    font-size: 17px;
    font-weight: 600;
    margin-top: 16px;
    margin-bottom: 12px;
    color: #000000;
}

body.dark-mode .section-title {
    color: #FFFFFF;
}

.settings-section {
    background-color: #FFFFFF;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 16px;
}

body.dark-mode .settings-section {
    background-color: #1C1C1E;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.setting-label {
    font-size: 17px;
    color: #000000;
}

body.dark-mode .setting-label {
    color: #FFFFFF;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 28px;
    background-color: #D4D4D4;
    border-radius: 14px;
    cursor: pointer;
    border: none;
    padding: 0;
}

.toggle-switch.active {
    background-color: #A91D3A;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    background-color: white;
    border-radius: 12px;
    top: 2px;
    left: 2px;
    transition: left 0.3s ease;
}

.toggle-switch.active::after {
    left: 24px;
}

.avatar-row {
    display: flex;
    justify-content: space-around;
    gap: 12px;
    margin-bottom: 16px;
}

.avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #E5E5E5;
}

body.dark-mode .avatar {
    background-color: #505050;
}

.avatar.selected {
    border-color: #A91D3A;
}

.theme-selector {
    display: flex;
    gap: 8px;
}

.theme-option {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    background-color: #E5E5E5;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #000000;
    transition: all 0.2s ease;
}

.theme-option.active {
    background-color: #A91D3A;
    color: #FFFFFF;
}

body.dark-mode .theme-option {
    background-color: #505050;
    color: #FFFFFF;
}

.stepper {
    display: flex;
    gap: 8px;
}

.stepper-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background-color: #E5E5E5;
    cursor: pointer;
    font-size: 20px;
    font-weight: 600;
    color: #000000;
}

body.dark-mode .stepper-btn {
    background-color: #505050;
    color: #FFFFFF;
}

.stepper-btn:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .calculator-container {
        max-width: 100%;
        padding: 16px;
    }

    .button-grid {
        gap: 8px;
    }

    .btn {
        font-size: 24px;
        min-height: 60px;
        min-width: 60px;
    }

    .operation-btn {
        font-size: 26px;
    }

    .function-btn {
        font-size: 20px;
    }

    .current-display {
        font-size: 40px;
    }

    .promo-text {
        font-size: 14px;
    }
}

@media (max-width: 380px) {
    .btn {
        font-size: 20px;
        min-height: 50px;
        min-width: 50px;
    }

    .current-display {
        font-size: 32px;
    }

    .previous-display {
        font-size: 14px;
    }
}
