:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  background: #000;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  --screen-height: 100dvh;
  --screen-offset: 0px;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; background: #000; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { padding: 0; border: 0; font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus { outline: none; }
button:focus-visible { outline: 2px solid rgba(255,255,255,.8); outline-offset: 3px; }

.calculator {
  --unit: min(100vw, 430px);
  --edge: calc(var(--unit) * .03721);
  --gap: calc(var(--unit) * .02093);
  --key: calc((var(--unit) - 2 * var(--edge) - 3 * var(--gap)) / 4);
  --grid-height: calc(5 * var(--key) + 4 * var(--gap));
  --grid-bottom: max(calc(var(--unit) * .1279), calc(env(safe-area-inset-bottom) + 20px));
  position: relative;
  top: var(--screen-offset);
  width: var(--unit);
  height: var(--screen-height);
  min-height: 620px;
  margin: 0 auto;
  overflow: hidden;
  background: #000;
  isolation: isolate;
}

.status {
  position: absolute;
  z-index: 5;
  top: calc(var(--unit) * .054);
  left: 10.5%;
  right: 7.8%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: calc(var(--unit) * .0419);
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
}
.status-icons { display: flex; align-items: center; gap: 7px; }
.signal { width: 21px; height: 16px; fill: #fff; }
.wifi { width: 23px; height: 18px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; }
.wifi .wifi-dot { fill: #fff; stroke: none; }
.battery { width: 31px; height: 15px; border: 1.5px solid rgba(255,255,255,.78); border-radius: 4px; position: relative; display: grid; place-items: center; }
.battery::before { content: ""; position: absolute; inset: 1.5px; border-radius: 2px; background: #fff; }
.battery::after { content: ""; position: absolute; right: -3.5px; top: 4px; width: 2px; height: 5px; border-radius: 0 2px 2px 0; background: rgba(255,255,255,.6); }
.battery span { position: relative; z-index: 1; color: #000; font-size: 10px; font-weight: 700; line-height: 1; }

.top-actions {
  position: absolute;
  z-index: 3;
  top: calc(var(--unit) * .186);
  left: calc(var(--unit) * .0465);
  right: calc(var(--unit) * .0465);
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.round-action {
  width: calc(var(--unit) * .1116);
  height: calc(var(--unit) * .1116);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #303033 0, #222225 58%, #151517 100%);
  box-shadow: inset 0 1px 1px rgba(255,255,255,.10), 0 1px 2px rgba(255,255,255,.04);
  pointer-events: none;
}
.round-action svg { width: 100%; height: 100%; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.round-action svg .fill { fill: #fff; stroke: none; }
.round-action svg .screen { fill: #fff; stroke: none; }
.secret-reset {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--unit) * .20);
  height: calc(var(--unit) * .14);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: transparent;
}

.display {
  position: absolute;
  z-index: 2;
  left: var(--edge);
  right: var(--edge);
  bottom: calc(var(--grid-bottom) + var(--grid-height) + var(--unit) * .0256);
  display: block;
  height: calc(var(--unit) * .19);
  overflow: hidden;
  text-align: right;
  white-space: nowrap;
  font-size: calc(var(--unit) * .1558);
  font-weight: 200;
  line-height: calc(var(--unit) * .19);
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums lining-nums;
  transform-origin: right center;
}
.display.medium { font-size: calc(var(--unit) * .132); }
.display.small { font-size: calc(var(--unit) * .108); }
.display.tiny { font-size: calc(var(--unit) * .088); }

.keypad {
  position: absolute;
  z-index: 2;
  left: var(--edge);
  right: var(--edge);
  bottom: var(--grid-bottom);
  height: var(--grid-height);
  display: grid;
  grid-template-columns: repeat(4, var(--key));
  grid-template-rows: repeat(5, var(--key));
  gap: var(--gap);
}
.key {
  width: var(--key);
  height: var(--key);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #333;
  font-size: calc(var(--unit) * .093);
  font-weight: 300;
  line-height: 1;
  transition: filter 80ms linear, transform 80ms ease-out, color 120ms linear, background 120ms linear;
  will-change: transform;
}
.key.utility { background: linear-gradient(#6b6b6d, #626264); font-size: calc(var(--unit) * .087); }
.key.operator { background: #ff9500; font-size: calc(var(--unit) * .115); }
.key.operator span { transform: translateY(-2%); }
.key.equals span { transform: translateY(-7%); }
.key.decimal { padding-bottom: 9%; }
.key.sign { font-size: calc(var(--unit) * .079); }
.sign-mark { transform: translateY(-3%); }
.key:active, .key.pressed { filter: brightness(1.65); transform: scale(.965); }
.key.operator.selected { background: #fff; color: #ff9500; }
.backspace { width: 52%; height: 45%; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.cracks { position: absolute; z-index: 20; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; }
.calculator.cracked .cracks { opacity: 1; }
.impact {
  position: absolute;
  z-index: 22;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle, rgba(0,0,0,.92) 0 17%, rgba(255,255,255,.82) 20% 26%, rgba(20,20,20,.9) 29% 39%, rgba(255,255,255,.42) 42% 49%, rgba(0,0,0,.38) 51% 62%, transparent 66%);
  box-shadow: 0 0 2px 1px rgba(255,255,255,.35), inset 1px 1px 2px #000;
  transform: scale(.1) rotate(-18deg);
  pointer-events: none;
}
.calculator.cracked .impact { opacity: 1; transform: scale(1) rotate(-18deg); transition: transform 180ms cubic-bezier(.1,.85,.2,1.35), opacity 40ms; }
.flash { position: absolute; z-index: 21; inset: 0; background: radial-gradient(circle at var(--impact-x,50%) var(--impact-y,50%), rgba(255,255,255,.38), transparent 18%); opacity: 0; pointer-events: none; }
.calculator.breaking .flash { animation: glass-flash 180ms ease-out; }

@keyframes glass-flash { 0% { opacity: .8; } 100% { opacity: 0; } }

html.ios .status { display: none; }

@media (max-height: 760px) {
  .calculator { --grid-bottom: max(16px, env(safe-area-inset-bottom)); }
  .top-actions { top: calc(var(--unit) * .20); }
}
@media (prefers-reduced-motion: reduce) {
  .key, .impact { transition: none; }
  .flash { display: none; }
}
