:root {
  color-scheme: light dark;
  --canvas: #ffe9ce;
  --surface: #ffffff;
  --text: #000000;
  --outline: #000000;
  --field: #ffffff;
  --field-text: #000000;
  --ink: #000000;
  --card: #ffd80c;
  --bubble: #ffffff;
  --blob: #8a53ff;
  --fill-a: #fd4b38;
  --fill-b: #3ccb09;
  --fill-c: #8a53ff;
  --alert: #fd4b38;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0a1d4b;
    --surface: #162d67;
    --text: #fcf6ea;
    --outline: #fcf6ea;
    --field: #0a1d4b;
    --field-text: #ffffff;
    --ink: #0a1d4b;
    --card: #9c8bf9;
    --bubble: #fcf6ea;
    --blob: #68dacb;
    --fill-a: #ffb8d9;
    --fill-b: #68dacb;
    --fill-c: #fbc333;
    --alert: #ffb8d9;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--canvas);
  color: var(--text);
  font-family: ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

.app {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.top-bar {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 12px;
  padding: 4px 0;
}

.logo {
  display: block;
  grid-row: 1 / span 2;
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.tagline {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.card {
  background-color: var(--surface);
  color: var(--text);
  border: 3px solid var(--outline);
  border-radius: 26px 18px 30px 22px;
  padding: 24px 20px;
}

.caption {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

output {
  display: block;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.results {
  position: relative;
  background-color: var(--card);
  color: var(--ink);
  border-radius: 22px 32px 18px 28px;
  padding: 30px 24px 30px;
  text-align: center;
  transform: rotate(-2deg);
}

.sticker {
  position: absolute;
  display: block;
  pointer-events: none;
  overflow: visible;
}

.sticker-shape {
  stroke: var(--outline);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.sticker-star {
  top: -12px;
  left: -10px;
  width: 38px;
  height: 38px;
  transform: rotate(-14deg);
}

.sticker-star .sticker-shape {
  fill: var(--fill-a);
}

.sticker-squiggle {
  top: -10px;
  right: -10px;
  width: 58px;
  height: 26px;
  transform: rotate(10deg);
}

.sticker-squiggle .sticker-shape {
  fill: var(--fill-b);
}

.sticker-sparkle {
  bottom: -12px;
  right: -10px;
  width: 36px;
  height: 36px;
}

.sticker-sparkle .sticker-shape {
  fill: var(--fill-c);
}

#share {
  margin: 4px 0 22px;
  font-size: 64px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.bubble {
  position: relative;
  padding: 10px 12px;
  background-color: var(--bubble);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 18px 24px 16px 22px;
}

.bubble::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 22px;
  width: 16px;
  height: 16px;
  background-color: var(--bubble);
  color: var(--ink);
  border-top: 3px solid var(--ink);
  border-left: 3px solid var(--ink);
  border-radius: 4px 0 0 0;
  transform: rotate(45deg);
}

.bubble + .bubble::before {
  left: auto;
  right: 22px;
}

.bubble output {
  margin-top: 2px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.inputs {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

label {
  display: block;
  font-size: 15px;
  font-weight: 800;
}

.icon {
  display: block;
  flex: none;
  width: 26px;
  height: 26px;
  overflow: visible;
}

.icon path {
  stroke: currentColor;
  stroke-width: 2px;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.icon .icon-detail {
  fill: none;
}

.icon-receipt .icon-body {
  fill: var(--fill-b);
}

.icon-coin .icon-body {
  fill: var(--fill-c);
}

.icon-buddies .icon-body {
  fill: var(--fill-a);
}

input, button {
  min-height: 44px;
  font: inherit;
}

input {
  width: 100%;
  padding: 0 14px;
  border: 3px solid var(--outline);
  border-radius: 14px 18px 12px 16px;
  background-color: var(--field);
  color: var(--field-text);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper input {
  flex: 1;
  min-width: 0;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.blob {
  flex: none;
  min-width: 44px;
  padding: 0;
  border: none;
  border-radius: 16px;
  background-color: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.blob-art {
  display: block;
  width: 52px;
  height: 52px;
  overflow: visible;
}

.blob-ledge {
  fill: var(--outline);
}

.blob-top {
  fill: var(--blob);
  stroke: var(--outline);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.blob-mark {
  fill: var(--ink);
}

.blob-top, .blob-mark {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transition: transform 100ms ease;
}

.blob:active .blob-top, .blob:active .blob-mark {
  transform: translateY(3px) scale(1.06, 0.9);
}

:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 3px;
}

.error-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 0 4px;
}

#error {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.icon-warning {
  order: -1;
}

.icon-warning .icon-body {
  fill: var(--alert);
  stroke: var(--outline);
}

.icon-warning .icon-detail {
  stroke: var(--ink);
  stroke-width: 2.5px;
}

#error:empty + .icon-warning {
  display: none;
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.14) rotate(-3deg);
  }
  100% {
    transform: scale(1);
  }
}

#share.pop {
  animation: pop 280ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .blob-top, .blob-mark {
    transition: none;
  }

  .blob:active .blob-top, .blob:active .blob-mark {
    transform: none;
  }

  #share.pop {
    animation: none;
  }
}
