:root {
  color-scheme: light;
  --page: #eef2f6;
  --panel: #17202a;
  --screen: #0c1117;
  --text: #f8fafc;
  --muted: #9aa8b8;
  --key: #263241;
  --key-hover: #324052;
  --utility: #d9e2ec;
  --utility-text: #17202a;
  --operator: #2f80ed;
  --operator-hover: #1c6ed8;
  --equals: #18a058;
  --equals-hover: #128449;
  --shadow: 0 24px 70px rgba(21, 32, 43, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top left, rgba(47, 128, 237, 0.16), transparent 34rem),
    linear-gradient(145deg, #f7fafc 0%, var(--page) 48%, #dfe7ef 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.shell {
  width: min(100%, 27rem);
  padding: 1rem;
}

.calculator {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 22%),
    var(--panel);
  box-shadow: var(--shadow);
  padding: 1.1rem;
}

.display {
  min-height: 9.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0.7rem;
  margin-bottom: 1rem;
  padding: 1.4rem;
  border-radius: 20px;
  background: var(--screen);
  overflow: hidden;
}

.expression {
  width: 100%;
  min-height: 1.4rem;
  color: var(--muted);
  font-size: clamp(1rem, 4vw, 1.2rem);
  line-height: 1.3;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result {
  width: 100%;
  color: var(--text);
  font-size: clamp(2.4rem, 13vw, 4.35rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.keys {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
}

.key {
  min-width: 0;
  aspect-ratio: 1;
  border: 0;
  border-radius: 18px;
  background: var(--key);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  transition:
    transform 140ms ease,
    background-color 140ms ease,
    box-shadow 140ms ease;
}

.key:hover {
  background: var(--key-hover);
  transform: translateY(-1px);
}

.key:active,
.key.active {
  transform: translateY(1px) scale(0.98);
}

.key:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.72);
  outline-offset: 2px;
}

.utility {
  background: var(--utility);
  color: var(--utility-text);
}

.utility:hover {
  background: #ecf2f7;
}

.operator {
  background: var(--operator);
}

.operator:hover {
  background: var(--operator-hover);
}

.equals {
  background: var(--equals);
  box-shadow: 0 10px 24px rgba(24, 160, 88, 0.26);
}

.equals:hover {
  background: var(--equals-hover);
}

@media (max-width: 420px) {
  .shell {
    padding: 0.65rem;
  }

  .calculator {
    border-radius: 24px;
    padding: 0.8rem;
  }

  .display {
    min-height: 8.4rem;
    padding: 1rem;
  }

  .keys {
    gap: 0.55rem;
  }

  .key {
    border-radius: 15px;
    font-size: 1.18rem;
  }
}
