:root { color-scheme: dark; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: #000; color: #fff; overflow: hidden; overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }

#calc {
  position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: flex-end;
  padding: env(safe-area-inset-top) 0 max(env(safe-area-inset-bottom), 10px);
  background: #000; transition: opacity .22s ease;
  --gap: 12px;
  --k: min(calc((100vw - 5 * var(--gap)) / 4), calc((100dvh - 140px - env(safe-area-inset-top) - 6 * var(--gap)) / 5), 92px);
}
#calc.away { opacity: 0; pointer-events: none; }

.screen { display: flex; justify-content: flex-end; align-items: flex-end; padding: 0 calc(var(--gap) * 2) 4px; min-height: 90px; }
.out { font-weight: 300; line-height: 1.05; letter-spacing: -1px; white-space: nowrap; font-size: 88px; font-variant-numeric: tabular-nums; }

.keys {
  display: grid; grid-template-columns: repeat(4, var(--k)); grid-auto-rows: var(--k);
  gap: var(--gap); justify-content: center; padding: 0 var(--gap);
}
.k {
  border: 0; border-radius: 999px; background: #333336; color: #fff; font: inherit; font-size: calc(var(--k) * .42);
  display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; touch-action: manipulation;
  transition: filter .08s ease, background-color .25s ease, color .25s ease;
}
.k:active, .k.down { filter: brightness(1.6); transition-duration: 0s; }
.k.fn { background: #a5a5a8; color: #000; }
.k.fn:active, .k.fn.down { filter: brightness(1.25); }
.k.op { background: #ff9f0a; font-size: calc(var(--k) * .56); }
.k.op:active, .k.op.down { filter: brightness(1.2); }
/* a tap that doesn't change the screen (0 when it already says 0) still shows that it landed */
.out.tick { animation: tick .16s ease-out; } @keyframes tick { from { opacity: .3; } to { opacity: 1; } }
.k.op.sel { background: #fff; color: #ff9f0a; transition-duration: 0s; }
.k.zero { grid-column: span 2; justify-content: flex-start; padding-left: calc(var(--k) * .38); }

#app-root { position: fixed; inset: 0; }

@media (max-height: 520px) and (orientation: landscape) {
  #calc { --k: min(calc((100vw - 5 * var(--gap)) / 4), calc((100dvh - 70px - 6 * var(--gap)) / 5), 70px); }
  .out { font-size: 48px !important; }
  .screen { min-height: 56px; }
}
