:root {
  color-scheme: light;
  --ink: #263238;
  --muted: #66767c;
  --mint: #8edfd0;
  --mint-strong: #35bfa8;
  --cream: #fff4cf;
  --peach: #ffb18a;
  --coral: #f46f6f;
  --blue: #8bbcff;
  --paper: rgba(255, 255, 255, 0.78);
  --line: rgba(38, 50, 56, 0.12);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 244, 207, 0.95) 0 18%, transparent 19%),
    radial-gradient(circle at 84% 12%, rgba(139, 188, 255, 0.42) 0 13%, transparent 14%),
    linear-gradient(160deg, #c6f2e9 0%, #fff7dd 46%, #ffd6c1 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100svh;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(22px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #40736c;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.05;
}

h2 {
  font-size: 22px;
}

h3 {
  margin: 0;
  font-size: 17px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 28px rgba(57, 101, 96, 0.14);
  font-size: 22px;
}

.icon-button.small {
  width: 36px;
  height: 36px;
  font-size: 20px;
}

.hero {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 18px;
  padding-top: 20px;
}

.sky-badge {
  align-self: start;
  padding: 9px 14px;
  border: 1px solid rgba(53, 191, 168, 0.26);
  border-radius: 999px;
  color: #386c64;
  background: rgba(255, 255, 255, 0.58);
  font-size: 14px;
  font-weight: 800;
}

.mascot-stage {
  position: relative;
  width: min(76vw, 330px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.mascot-image {
  position: relative;
  z-index: 2;
  width: 83%;
  height: 83%;
  object-fit: contain;
  animation: floaty 3.4s ease-in-out infinite;
  filter: drop-shadow(0 28px 32px rgba(83, 89, 74, 0.22));
}

.shadow {
  position: absolute;
  bottom: 24px;
  width: 46%;
  height: 18px;
  border-radius: 50%;
  background: rgba(71, 77, 64, 0.18);
  filter: blur(6px);
  animation: shadowPulse 3.4s ease-in-out infinite;
}

.coin {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #8b5b00;
  background: linear-gradient(145deg, #ffe57c, #f5ad27);
  box-shadow: inset 0 -4px 0 rgba(139, 91, 0, 0.18), 0 12px 22px rgba(160, 103, 9, 0.2);
  font-size: 18px;
  font-weight: 900;
}

.lollipop {
  position: absolute;
  z-index: 3;
  width: 52px;
  height: 104px;
  opacity: 0;
  transform: translateY(22px) scale(0.2) rotate(-18deg);
  transform-origin: 50% 100%;
  pointer-events: none;
}

.lollipop::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 23px;
  top: 40px;
  width: 7px;
  height: 64px;
  border-radius: 999px;
  background: linear-gradient(90deg, #fff8df 0%, #f2d08f 48%, #c9974d 100%);
  box-shadow: inset -1px 0 0 rgba(134, 98, 40, 0.24), 0 8px 12px rgba(112, 75, 30, 0.12);
}

.lollipop span {
  position: absolute;
  z-index: 1;
  inset: 0 auto auto 0;
  width: 52px;
  height: 52px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #fff3a2 0 16%, transparent 17%),
    conic-gradient(from 15deg, #ff6e8c 0 20%, #fff6b8 20% 40%, #72d7c7 40% 60%, #8bbcff 60% 80%, #ff9b73 80% 100%);
  box-shadow: 0 10px 18px rgba(159, 89, 94, 0.18);
}

.lollipop-a {
  left: 13%;
  top: 22%;
}

.lollipop-b {
  right: 12%;
  top: 18%;
}

.lollipop-c {
  left: 20%;
  bottom: 20%;
}

.lollipop-d {
  right: 25%;
  bottom: 18%;
}

.coin-a {
  left: 18%;
  top: 26%;
  animation: coinDrift 4.2s ease-in-out infinite;
}

.coin-b {
  right: 16%;
  top: 18%;
  animation: coinDrift 4.8s ease-in-out infinite 0.4s;
}

.coin-c {
  right: 24%;
  bottom: 26%;
  animation: coinDrift 4.6s ease-in-out infinite 0.8s;
}

.balance-panel {
  position: relative;
  overflow: hidden;
  width: 100%;
  text-align: center;
  padding: 20px 18px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.54);
  box-shadow: 0 22px 54px rgba(76, 121, 114, 0.13);
  backdrop-filter: blur(18px);
}

.balance-panel > * {
  position: relative;
  z-index: 1;
}

.balance-panel.candy-mode {
  border-color: rgba(244, 111, 111, 0.22);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.68), rgba(255, 245, 182, 0.72)),
    rgba(255, 255, 255, 0.54);
}

.balance-panel.candy-mode::before {
  content: "";
  position: absolute;
  z-index: 0;
  right: -8px;
  top: -8px;
  width: 150px;
  height: 150px;
  border: 8px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #fff3a2 0 14%, transparent 15%),
    conic-gradient(from 15deg, #ff6e8c 0 20%, #fff6b8 20% 40%, #72d7c7 40% 60%, #8bbcff 60% 80%, #ff9b73 80% 100%);
  box-shadow: 0 16px 30px rgba(159, 89, 94, 0.12);
  opacity: 0.48;
  transform: rotate(18deg);
}

.balance-panel.candy-mode::after {
  content: "";
  position: absolute;
  z-index: 0;
  right: 48px;
  top: 116px;
  width: 13px;
  height: 126px;
  border-radius: 999px;
  background: linear-gradient(90deg, #fff8df 0%, #f2d08f 48%, #c9974d 100%);
  box-shadow: inset -2px 0 0 rgba(134, 98, 40, 0.2);
  opacity: 0.58;
  transform: rotate(18deg);
}

.balance-panel.candy-pop {
  animation: candyPanelPop 640ms cubic-bezier(0.2, 1.4, 0.35, 1);
}

.balance-label {
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

.balance-value {
  margin-top: 8px;
  font-size: clamp(42px, 14vw, 72px);
  line-height: 0.98;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.count-unit {
  margin-left: 8px;
  font-size: 0.48em;
  vertical-align: 0.12em;
}

.balance-note {
  margin-top: 10px;
  color: #4e6b70;
  font-size: 15px;
  font-weight: 750;
}

.primary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.action-button {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px;
  border-radius: 22px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 16px 28px rgba(53, 86, 91, 0.16);
}

.action-button.candy {
  background: linear-gradient(145deg, #fff5b6, #ffcb82);
}

.action-button.ledger {
  background: linear-gradient(145deg, #ffffff, #cde7ff);
}

.button-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.68);
  font-weight: 950;
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.quick-stats article {
  min-height: 82px;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 12px 26px rgba(57, 101, 96, 0.08);
}

.quick-stats span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.quick-stats strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.drawer {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 0;
  width: min(100%, 520px);
  max-height: 76svh;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 -24px 54px rgba(36, 67, 73, 0.22);
  transform: translate(-50%, 105%);
  transition: transform 260ms ease;
  backdrop-filter: blur(18px);
}

.drawer.open {
  transform: translate(-50%, 0);
}

.drawer-handle {
  width: 54px;
  height: 5px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: rgba(38, 50, 56, 0.22);
}

.drawer-header,
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.ledger-list {
  display: grid;
  gap: 10px;
  max-height: 56svh;
  margin-top: 16px;
  overflow: auto;
  padding-bottom: 8px;
}

.ledger-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffdf7;
}

.ledger-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #e3f8f2;
  font-weight: 950;
}

.ledger-copy strong {
  display: block;
  margin-bottom: 3px;
  font-size: 15px;
}

.ledger-copy span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.ledger-amount {
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(25, 50, 54, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: min(100%, 500px);
  max-height: calc(100svh - 36px);
  overflow: auto;
  padding: 18px;
  border-radius: 28px;
  background: #fffdf7;
  box-shadow: 0 28px 70px rgba(31, 54, 58, 0.26);
}

.password-modal {
  align-self: center;
}

.settings-form {
  display: grid;
  gap: 13px;
  margin-top: 18px;
}

.spend-form {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.form-section {
  display: grid;
  gap: 13px;
}

.settings-form label {
  display: grid;
  gap: 7px;
  color: #465a60;
  font-size: 14px;
  font-weight: 850;
}

.settings-form input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: #fff;
  font-size: 18px;
  font-weight: 850;
}

.form-hint {
  color: #4e6b70;
  font-size: 13px;
  font-weight: 850;
}

.form-message {
  min-height: 18px;
  color: #c24b4b;
  font-size: 13px;
  font-weight: 850;
}

.form-message.success {
  color: #278475;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.secondary-button,
.save-button,
.spend-button {
  min-height: 50px;
  border-radius: 17px;
  font-weight: 950;
}

.secondary-button {
  background: #e8f8f5;
  color: #26786d;
}

.save-button {
  background: var(--mint-strong);
  color: #fff;
}

.spend-button {
  width: 100%;
  background: linear-gradient(145deg, #ffb18a, #f46f6f);
  color: #fff;
}

.celebration {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 250, 225, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.celebration.show {
  opacity: 1;
}

.burst {
  position: absolute;
  width: min(82vw, 360px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    conic-gradient(from 10deg, transparent 0 10deg, rgba(255, 184, 77, 0.8) 10deg 18deg, transparent 18deg 36deg),
    radial-gradient(circle, rgba(255, 238, 120, 0.9), transparent 68%);
  animation: burstSpin 900ms ease-out;
}

.celebration-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 260px;
  padding: 26px;
  border-radius: 28px;
  background: #fffdf7;
  box-shadow: 0 26px 62px rgba(62, 81, 72, 0.22);
  animation: popIn 520ms cubic-bezier(0.2, 1.4, 0.4, 1);
}

.celebration-icon {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  color: #8a5b00;
  background: linear-gradient(145deg, #ffe986, #f7b42c);
  font-size: 34px;
  font-weight: 950;
}

.celebration-card strong {
  font-size: 24px;
}

.celebration-card p {
  color: var(--muted);
  font-weight: 800;
}

.mascot-stage.happy .coin {
  animation: coinRain 860ms ease-out;
}

.mascot-stage.happy .mascot-image {
  animation: happyBounce 860ms ease-out;
}

.mascot-stage.candy-mode .coin {
  opacity: 0.18;
  transform: scale(0.82);
  transition: opacity 220ms ease, transform 220ms ease;
}

.mascot-stage.candy-mode .lollipop {
  opacity: 1;
  animation: lollipopFloat 3.4s ease-in-out infinite;
}

.mascot-stage.candy-mode .lollipop-b {
  animation-delay: 0.24s;
}

.mascot-stage.candy-mode .lollipop-c {
  animation-delay: 0.46s;
}

.mascot-stage.candy-mode .lollipop-d {
  animation-delay: 0.68s;
}

.mascot-stage.candy-pop .coin {
  animation: coinToCandy 660ms ease-in forwards;
}

.mascot-stage.candy-pop .lollipop {
  animation: candyBurst 920ms cubic-bezier(0.2, 1.35, 0.35, 1) forwards;
}

.mascot-stage.candy-pop .lollipop-b {
  animation-delay: 70ms;
}

.mascot-stage.candy-pop .lollipop-c {
  animation-delay: 130ms;
}

.mascot-stage.candy-pop .lollipop-d {
  animation-delay: 190ms;
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }
  50% {
    transform: translateY(-10px) rotate(1deg);
  }
}

@keyframes shadowPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(0.82);
    opacity: 0.55;
  }
}

@keyframes coinDrift {
  0%,
  100% {
    transform: translateY(0) rotate(-8deg);
  }
  50% {
    transform: translateY(-16px) rotate(12deg);
  }
}

@keyframes coinRain {
  0% {
    transform: translateY(-90px) scale(0.7) rotate(0deg);
    opacity: 0;
  }
  45% {
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1) rotate(360deg);
  }
}

@keyframes happyBounce {
  0% {
    transform: scale(1) translateY(0);
  }
  38% {
    transform: scale(1.08, 0.94) translateY(14px);
  }
  72% {
    transform: scale(0.96, 1.08) translateY(-18px);
  }
  100% {
    transform: scale(1) translateY(0);
  }
}

@keyframes coinToCandy {
  0% {
    opacity: 1;
    filter: blur(0);
  }
  55% {
    opacity: 0.85;
    transform: translateY(-18px) scale(0.55) rotate(150deg);
    filter: blur(1px);
  }
  100% {
    opacity: 0.12;
    transform: translateY(-34px) scale(0.2) rotate(260deg);
    filter: blur(2px);
  }
}

@keyframes candyBurst {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.2) rotate(-70deg);
  }
  58% {
    opacity: 1;
    transform: translateY(-18px) scale(1.12) rotate(14deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(-8deg);
  }
}

@keyframes lollipopFloat {
  0%,
  100% {
    transform: translateY(0) scale(1) rotate(-8deg);
  }
  50% {
    transform: translateY(-12px) scale(1.03) rotate(10deg);
  }
}

@keyframes candyPanelPop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.035);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes burstSpin {
  from {
    transform: scale(0.4) rotate(-28deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

@keyframes popIn {
  from {
    transform: translateY(18px) scale(0.86);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (max-width: 380px) {
  .app-shell {
    padding-inline: 14px;
  }

  .primary-actions,
  .quick-stats,
  .form-actions {
    grid-template-columns: 1fr;
  }

  .action-button {
    min-height: 56px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
