@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/poppins-800.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/inter-500.woff2") format("woff2");
}

:root {
  --canopy: #132e1f;
  --moss: #1c2119;
  --moss-press: #242c20;
  --lime: #85d65e;
  --ink: #f5f2e8;
  --charcoal: #1a1a1a;
  --sage: #a9b3a2;
  --olive: #4b5d3f;
  --r-key: 20px;
  --r-card: 28px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background: var(--canopy);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body {
  min-height: 100dvh;
  min-height: 100svh;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:focus { outline: none; }
button:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}

.app {
  position: relative;
  width: min(430px, 100%);
  min-height: 100dvh;
  min-height: 100svh;
  margin: 0 auto;
  padding:
    calc(12px + env(safe-area-inset-top, 0px))
    20px
    calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.clear {
  position: absolute;
  top: calc(4px + env(safe-area-inset-top, 0px));
  right: 8px;
  z-index: 1;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sage);
  padding: 10px 12px;
  min-height: 44px;
  min-width: 44px;
}
@media (hover: hover) {
  .clear:hover { color: var(--ink); }
}
.clear[hidden] { display: none; }

.check {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-right: 72px;
}
.amount {
  margin: 0;
  font-family: Poppins, ui-sans-serif, sans-serif;
  font-weight: 800;
  font-size: clamp(2.6rem, 12vw, 3.6rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.amount.is-empty { color: var(--sage); }
.label {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sage);
}

.pcts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.pct {
  min-height: 88px;
  padding: 12px 10px 14px;
  border-radius: var(--r-card);
  background: var(--moss);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 180ms var(--ease), color 180ms var(--ease), transform 120ms var(--ease);
}
.pct-n {
  font-family: Poppins, ui-sans-serif, sans-serif;
  font-weight: 800;
  font-size: 2rem;
  letter-spacing: -0.04em;
  line-height: 1;
}
.pct-sign {
  font-size: 0.55em;
  letter-spacing: 0;
}
.pct-amt {
  font-family: Inter, ui-sans-serif, sans-serif;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0;
  line-height: 1.1;
  color: var(--sage);
  font-variant-numeric: tabular-nums;
  min-height: 1.1em;
  opacity: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pcts.has-amt .pct-amt { opacity: 1; }
.pct[aria-pressed="true"] {
  background: var(--lime);
  color: var(--charcoal);
}
.pct[aria-pressed="true"] .pct-amt { color: var(--charcoal); }
.pct:active { transform: scale(0.98); }
@media (hover: hover) {
  .pct:hover:not([aria-pressed="true"]) { background: var(--moss-press); }
}

.sum {
  display: flex;
  flex-direction: column;
}
.sum .row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
}
.sum .row + .row {
  border-top: 1px solid var(--olive);
}
.sum .label {
  margin: 0;
}
.sum .val {
  font-family: Poppins, ui-sans-serif, sans-serif;
  font-weight: 800;
  font-size: 1.65rem;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.sum .total .val {
  font-size: clamp(2rem, 8vw, 2.4rem);
}

.pad {
  margin-top: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
  min-height: 240px;
  max-height: 420px;
  flex: 1 1 auto;
}
.key {
  border-radius: var(--r-key);
  background: var(--moss);
  font-family: Poppins, ui-sans-serif, sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.03em;
  min-height: 52px;
  display: grid;
  place-items: center;
  transition: background 120ms var(--ease), transform 120ms var(--ease);
}
.key:active {
  background: var(--moss-press);
  transform: scale(0.97);
}
@media (hover: hover) {
  .key:hover { background: var(--moss-press); }
}
.key-back svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-height: 720px) {
  .app { gap: 10px; }
  .pct { min-height: 72px; padding: 10px 8px 12px; }
  .pct-n { font-size: 1.7rem; }
  .pct-amt { font-size: 13px; }
  .amount { font-size: 2.5rem; }
  .sum .val { font-size: 1.4rem; }
  .sum .total .val { font-size: 1.85rem; }
  .pad { min-height: 200px; gap: 6px; }
  .key { font-size: 1.4rem; min-height: 48px; }
}

@media (min-width: 720px) {
  body {
    display: flex;
    align-items: stretch;
    justify-content: center;
  }
  .app {
    min-height: 100dvh;
  }
}
