:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-block-size: 100vh;
  min-block-size: 100dvh;
  margin: 0;
  background: #10192e;
  color: #151515;
}

main {
  display: grid;
  min-block-size: inherit;
  place-items: center;
  padding: 1rem;
}

.calculator-stage {
  position: relative;
  inline-size: min(100%, 20rem);
  isolation: isolate;
}

.calculator {
  position: relative;
  z-index: 2;
  inline-size: min(100%, 20rem);
  padding: 1rem;
  border: 1px solid #dfdfda;
  border-radius: 1.25rem;
  background: #ffffff;
  box-shadow: 0 1rem 2.5rem rgb(0 0 0 / 7%);
}

.calculator-cover {
  display: none;
}

html.cover-ready .calculator-cover {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  inline-size: 100%;
  block-size: 100%;
  padding: 1.25rem;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 1.25rem;
  background: #18243f;
  box-shadow: 0 1.25rem 3rem rgb(0 0 0 / 24%);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  transform: translateY(0) scale(1);
  transform-origin: center;
  transition: transform 620ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 620ms ease;
  will-change: transform;
}

html.cover-ready .calculator-cover:hover {
  box-shadow: 0 1.45rem 3.25rem rgb(0 0 0 / 30%);
}

html.cover-ready .calculator-cover:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 4px;
}

html.cover-ready .calculator-cover.is-lifting {
  transform: translateY(calc(-100% - 1.25rem)) scale(0.985);
}

html.cover-ready .calculator-cover.is-tucked {
  z-index: 1;
  pointer-events: none;
  transform: translateY(-1.35rem) scale(0.965);
  box-shadow: 0 0.55rem 1.5rem rgb(0 0 0 / 18%);
  transition-duration: 460ms;
}

.calculator-cover__brand {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.calculator-cover__hint {
  color: rgb(255 255 255 / 68%);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.display {
  display: flex;
  min-block-size: 5.5rem;
  align-items: center;
  justify-content: flex-end;
  overflow-x: auto;
  padding: 0.75rem 1rem;
  border-radius: 0.8rem;
  background: #171716;
  color: #ffffff;
  font-size: clamp(2rem, 9vw, 3rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: end;
  white-space: nowrap;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin-block-start: 0.75rem;
}

.key {
  min-block-size: 3.75rem;
  border: 0;
  border-radius: 0.8rem;
  background: #efefeb;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 1.2rem;
  transition: background-color 120ms ease, transform 120ms ease;
}

.key:hover {
  background: #e4e4df;
}

.key:active {
  transform: scale(0.97);
}

.key:focus-visible {
  outline: 3px solid #3578e5;
  outline-offset: 2px;
}

.function {
  background: #dfe0da;
}

.function:hover {
  background: #d2d3cc;
}

.operator,
.equals {
  background: #171716;
  color: #ffffff;
}

.operator:hover,
.equals:hover {
  background: #33332f;
}

.zero {
  grid-column: span 2;
}

@media (prefers-reduced-motion: reduce) {
  html.cover-ready .calculator-cover,
  html.cover-ready .calculator-cover.is-tucked {
    transition-duration: 1ms;
  }
}

@media (max-width: 360px) {
  .calculator {
    padding: 0.75rem;
    border-radius: 1rem;
  }

  html.cover-ready .calculator-cover {
    border-radius: 1rem;
  }

  .key {
    min-block-size: 3.35rem;
  }
}
