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

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family:
    "Segoe UI",
    -apple-system,
    BlinkMacSystemFont,
    Roboto,
    sans-serif;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  padding: 20px;
}

.calculator {
  width: 100%;
  max-width: 360px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 24px;
  box-shadow:
    0 25px 60px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.calculator-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 0 4px;
}

.brand {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.status {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.display {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 20px 18px;
  margin-bottom: 20px;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  overflow: hidden;
}

.expression {
  color: rgba(255, 255, 255, 0.5);
  font-size: 1rem;
  min-height: 1.4em;
  word-break: break-all;
  text-align: right;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.result {
  color: #ffffff;
  font-size: 2.6rem;
  font-weight: 300;
  line-height: 1.2;
  word-break: break-all;
  text-align: right;
  max-width: 100%;
  overflow-wrap: anywhere;
  transition: font-size 0.15s ease;
}

.result.small {
  font-size: 1.8rem;
}

.result.error {
  color: #ff6b6b;
}

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

.btn {
  border: none;
  outline: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 1.35rem;
  font-weight: 500;
  height: 62px;
  border-radius: 16px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition:
    transform 0.1s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0) scale(0.96);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.btn-number {
  background: rgba(255, 255, 255, 0.1);
}

.btn-operator {
  background: rgba(99, 102, 241, 0.35);
  color: #c7d2fe;
  font-size: 1.5rem;
}

.btn-operator:hover {
  background: rgba(99, 102, 241, 0.55);
}

.btn-function {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.1rem;
}

.btn-function:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-equals {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  font-size: 1.6rem;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.btn-equals:hover {
  background: linear-gradient(135deg, #818cf8, #a78bfa);
  box-shadow: 0 10px 28px rgba(99, 102, 241, 0.55);
}

.btn-zero {
  grid-column: span 2;
}

footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
}

footer p {
  line-height: 1.6;
}

footer a {
  color: #a5b4fc;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

footer a:hover {
  color: #c7d2fe;
  text-decoration: underline;
}

.heart {
  color: #f472b6;
}

@media (max-width: 400px) {
  .calculator {
    padding: 18px;
    border-radius: 20px;
  }

  .btn {
    height: 56px;
    font-size: 1.2rem;
    border-radius: 14px;
  }

  .result {
    font-size: 2.2rem;
  }
}
