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

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    min-height: 100vh;
    display: block;
    padding: 40px 20px;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.15) 2px, transparent 2px);
    background-size: 30px 30px;
    z-index: 1;
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    opacity: 0.1;
    animation: float 20s infinite ease-in-out;
    z-index: 1;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0) 70%);
    top: -150px;
    left: -150px;
    animation-delay: 0s;
    pointer-events: none;
}

.bg-circle {
    position: fixed;
    border-radius: 50%;
    opacity: 0.1;
    animation: float 25s infinite ease-in-out;
    z-index: 1;
    pointer-events: none;
}

.bg-circle-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0) 70%);
    bottom: -100px;
    right: -100px;
    animation-delay: 5s;
}

.bg-circle-2 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 70%);
    top: 50%;
    right: -100px;
    animation-delay: 3s;
}

.bg-circle-3 {
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 70%);
    bottom: 30%;
    left: 10%;
    animation-delay: 7s;
}

@keyframes float {
    0%,
    100% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }

    25% {
        transform: translate(30px, -30px) scale(1.1) rotate(90deg);
    }

    50% {
        transform: translate(60px, 20px) scale(0.9) rotate(180deg);
    }

    75% {
        transform: translate(-20px, 40px) scale(1.05) rotate(270deg);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.calculator-container {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 28px;
    padding: 35px;
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.3),
        0 15px 30px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    max-width: 500px;
    width: 100%;
    position: relative;
    z-index: 10;
    animation: slideIn 0.6s ease-out;
    border: 1px solid rgba(255, 255, 255, 0.5);
    margin: 0 auto;
}

h1 {
    text-align: center;
    color: #1f2937;
    margin-bottom: 35px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.formula-container {
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f1ff 100%);
    border-radius: 22px;
    padding: 28px;
    margin-bottom: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid rgba(102, 126, 234, 0.15);
    box-shadow: inset 0 2px 10px rgba(102, 126, 234, 0.05);
}

.formula-line {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 18px;
    font-size: 18px;
    color: #333;
    width: 100%;
}

.percentage {
    font-weight: 700;
    color: #667eea;
    font-size: 20px;
    margin-bottom: 5px;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 14px;
    padding: 16px 20px;
    box-shadow:
        0 4px 16px rgba(102, 126, 234, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 1);
    width: 280px;
    max-width: 90%;
    border: 2px solid rgba(102, 126, 234, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.input-label {
    position: absolute;
    left: 20px;
    top: -11px;
    background: white;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 700;
    color: #667eea;
    border-radius: 8px;
    opacity: 0.95;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.input-wrapper:focus-within {
    border-color: #667eea;
    box-shadow:
        0 8px 24px rgba(102, 126, 234, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 1);
    transform: translateY(-3px);
}

.input-wrapper.error {
    border-color: #ef4444;
    animation: shake 0.5s;
}

input[type="number"],
.fixed-value {
    border: none;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    width: 100%;
    text-align: right;
    background: transparent;
}

input[type="number"] {
    outline: none;
}

input[type="number"]::placeholder {
    color: #d1d5db;
    font-weight: 400;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.currency {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    margin-right: 8px;
    font-size: 16px;
}

.operator {
    font-size: 26px;
    font-weight: 700;
    color: #6b7280;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.button-group {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.calculate-btn,
.clear-btn {
    padding: 18px 20px;
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}

.calculate-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.35);
}

.clear-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35);
}

.calculate-btn::before,
.clear-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.calculate-btn:hover::before,
.clear-btn:hover::before {
    left: 100%;
}

.calculate-btn:hover,
.clear-btn:hover {
    transform: translateY(-4px);
}

.calculate-btn:hover {
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.45);
}

.clear-btn:hover {
    box-shadow: 0 12px 32px rgba(239, 68, 68, 0.45);
}

.calculate-btn:active,
.clear-btn:active {
    transform: translateY(-2px);
}

.calculate-btn:focus,
.clear-btn:focus {
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

.calculate-btn.calculating {
    animation: pulse 0.6s infinite;
}

.result-container {
    background: #f8f9fa;
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    transition: all 0.4s ease;
    border: 2px solid #e5e7eb;
    position: relative;
    overflow: hidden;
}

.result-container.debt {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border-color: #dc2626;
    transform: scale(1.02);
}

.result-container.no-debt {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-color: #059669;
    transform: scale(1.02);
}

.result-container.neutral {
    background: #f8f9fa;
    color: #6b7280;
}

.result-label {
    font-size: 13px;
    margin-bottom: 12px;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.result-value {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -1px;
}

.result-value.animate {
    animation: fadeIn 0.5s ease-out;
}

.message-container {
    margin-top: 20px;
    padding: 15px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s ease;
}

.message-container.show {
    opacity: 1;
    transform: translateY(0);
}

.message-container.error {
    background: #fee2e2;
    color: #991b1b;
    border: 2px solid #fecaca;
}

.message-container.success {
    background: #d1fae5;
    color: #065f46;
    border: 2px solid #a7f3d0;
}

.message-container.warning {
    background: #fed7aa;
    color: #92400e;
    border: 2px solid #fcd34d;
}

.message-container.info {
    background: #dbeafe;
    color: #1e40af;
    border: 2px solid #bfdbfe;
}

@media (max-width: 767px) {
    body {
        padding: 20px 15px;
    }

    .calculator-container {
        padding: 25px;
    }

    body::before {
        background-size: 20px 20px;
    }
}

@media (min-width: 768px) {
    .calculator-container {
        padding: 55px;
        max-width: 620px;
    }

    h1 {
        font-size: 32px;
        margin-bottom: 40px;
    }

    .formula-container {
        padding: 38px;
    }

    .formula-line {
        gap: 22px;
        font-size: 20px;
    }

    .percentage {
        font-size: 22px;
    }

    .input-wrapper {
        padding: 18px 22px;
        width: 300px;
    }

    .input-label {
        font-size: 13px;
    }

    input[type="number"],
    .fixed-value {
        font-size: 20px;
    }

    .currency {
        font-size: 18px;
    }

    .operator {
        font-size: 30px;
    }

    .calculate-btn,
    .clear-btn {
        padding: 20px 24px;
        font-size: 17px;
    }

    .result-label {
        font-size: 14px;
    }

    .result-value {
        font-size: 46px;
    }

    .message-container {
        font-size: 15px;
        padding: 16px 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    body::after,
    .bg-circle {
        animation: none !important;
    }
}
