:root {
  color-scheme: light;
  --bg: #edf1f0;
  --panel: #fbfcfb;
  --panel-border: #cad3d0;
  --text: #16211f;
  --muted: #64706d;
  --key: #ffffff;
  --key-hover: #f2f6f5;
  --utility: #dfe9e5;
  --operator: #11626b;
  --operator-hover: #0d535b;
  --equals: #c7682a;
  --equals-hover: #a9541e;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(17, 98, 107, 0.14), transparent 42%),
    linear-gradient(315deg, rgba(199, 104, 42, 0.13), transparent 38%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  font: inherit;
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.calculator {
  width: min(100%, 380px);
  padding: 16px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 56px rgba(18, 30, 28, 0.18);
}

.screen {
  min-height: 128px;
  display: grid;
  align-content: end;
  gap: 10px;
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid #d7dfdc;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.history {
  min-height: 24px;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.value {
  min-height: 54px;
  color: var(--text);
  font-size: clamp(2rem, 10vw, 3rem);
  font-weight: 750;
  line-height: 1.1;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.key {
  min-width: 0;
  min-height: 62px;
  border: 0;
  border-radius: 8px;
  background: var(--key);
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px #d7dfdc;
  cursor: pointer;
  transition:
    background-color 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
}

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

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

.key:focus-visible {
  outline: 3px solid rgba(17, 98, 107, 0.32);
  outline-offset: 2px;
}

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

.operator {
  background: var(--operator);
  color: #ffffff;
  box-shadow: none;
}

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

.equals {
  background: var(--equals);
  color: #ffffff;
  box-shadow: none;
}

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

.wide {
  grid-column: span 2;
}

@media (max-width: 420px) {
  .page {
    padding: 14px;
  }

  .calculator {
    padding: 12px;
  }

  .key {
    min-height: 58px;
  }
}
