:root {
  color-scheme: light;
  --bg: #f8efe0;
  --ink: #251b13;
  --muted: #78685a;
  --line: rgba(37, 27, 19, 0.14);
  --panel: #fff8ed;
  --panel-strong: #fff1d6;
  --gold: #f7b733;
  --gold-dark: #bf7420;
  --green: #55b77a;
  --green-dark: #2d7d51;
  --blue: #5ea8ff;
  --red: #e15d5d;
  --shadow: 0 18px 48px rgba(58, 41, 25, 0.18);
  --radius: 24px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  min-height: 100dvh;
  margin: 0;
  display: grid;
  place-items: center;
  touch-action: none;
  background:
    radial-gradient(circle at top left, rgba(247, 183, 51, 0.25), transparent 28rem),
    linear-gradient(145deg, #f8efe0, #ead8bb);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.phone {
  width: min(100dvw, 430px);
  height: min(100dvh, 920px);
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 1.7fr);
  gap: clamp(5px, 1dvh, 10px);
  padding: clamp(8px, 1.5dvh, 16px);
  background: rgba(255, 250, 241, 0.9);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.scoreboard,
.zone {
  border: 1px solid var(--line);
  background: rgba(255, 248, 237, 0.88);
  backdrop-filter: blur(14px);
}

.scoreboard {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: clamp(7px, 1.2dvh, 12px) clamp(10px, 3vw, 16px);
  border-radius: var(--radius);
}

.title-block {
  min-width: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, min(7vw, 4.8dvh), 3rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
}

h2 {
  font-size: clamp(0.82rem, min(3.3vw, 2.1dvh), 1rem);
  letter-spacing: -0.03em;
}

.eyebrow,
.stat-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.zone {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
}

.zone::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
  background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.7), transparent 12rem);
}

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

.zone--presents {
  display: grid;
  grid-template-rows: 1fr;
  background: linear-gradient(180deg, #fff8ed, #ffe9ef);
}

.present-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: minmax(0, 1fr);
  gap: clamp(5px, 1dvh, 8px);
  align-content: center;
  height: 100%;
  min-height: 0;
  padding: 0 clamp(8px, 2.5vw, 14px) clamp(6px, 1dvh, 12px);
}

.present {
  min-height: 0;
  border: 1px solid rgba(151, 73, 93, 0.2);
  border-radius: 18px;
  background:
    linear-gradient(90deg, transparent 44%, rgba(255, 255, 255, 0.45) 45%, rgba(255, 255, 255, 0.45) 55%, transparent 56%),
    linear-gradient(0deg, transparent 44%, rgba(255, 255, 255, 0.45) 45%, rgba(255, 255, 255, 0.45) 55%, transparent 56%),
    linear-gradient(135deg, #ff7d9b, #c95dcf);
  box-shadow: inset 0 -8px 16px rgba(98, 44, 75, 0.13);
  display: grid;
  place-items: center;
  font-size: clamp(1.05rem, min(7vw, 5dvh), 1.8rem);
  transition:
    transform 160ms ease,
    filter 160ms ease;
}

.present:not(.is-open):hover,
.present.is-targeted {
  filter: brightness(1.04);
  transform: translateY(-2px);
}

.present.is-open {
  background: #fff;
  border-color: rgba(37, 27, 19, 0.1);
  box-shadow: inset 0 -8px 16px rgba(37, 27, 19, 0.06);
}

.present.is-revealing {
  background: #fff;
  border-color: rgba(37, 27, 19, 0.1);
  box-shadow: inset 0 -8px 16px rgba(37, 27, 19, 0.06);
}

.present-reveal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  pointer-events: none;
}

.present-reveal__stage {
  position: absolute;
  left: var(--origin-x);
  top: var(--origin-y);
  width: var(--source-width);
  height: var(--source-height);
  display: grid;
  place-items: center;
  filter: drop-shadow(0 24px 38px rgba(58, 41, 25, 0.3));
  transform-origin: center;
  animation: present-reveal-flight 4000ms cubic-bezier(0.2, 0.88, 0.2, 1) forwards;
}

.present-reveal__gift,
.present-reveal__emoji {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 18px;
  font-size: clamp(1.05rem, min(7vw, 5dvh), 1.8rem);
  line-height: 1;
}

.present-reveal__gift {
  border: 1px solid rgba(151, 73, 93, 0.2);
  background:
    linear-gradient(90deg, transparent 44%, rgba(255, 255, 255, 0.45) 45%, rgba(255, 255, 255, 0.45) 55%, transparent 56%),
    linear-gradient(0deg, transparent 44%, rgba(255, 255, 255, 0.45) 45%, rgba(255, 255, 255, 0.45) 55%, transparent 56%),
    linear-gradient(135deg, #ff7d9b, #c95dcf);
  box-shadow: inset 0 -8px 16px rgba(98, 44, 75, 0.13);
  animation: present-gift-pop 4000ms ease forwards;
}

.present-reveal__emoji {
  border: 1px solid rgba(37, 27, 19, 0.1);
  background: #fff;
  box-shadow: inset 0 -8px 16px rgba(37, 27, 19, 0.06);
  opacity: 0;
  animation: present-emoji-reveal 4000ms cubic-bezier(0.2, 0.88, 0.2, 1) forwards;
}

.present-reveal__confetti-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
}

.present-reveal__confetti {
  position: absolute;
  left: 0;
  top: 0;
  width: clamp(4px, 1.6vw, 8px);
  height: clamp(8px, 2.6vw, 14px);
  border-radius: 2px;
  background: var(--confetti-color);
  opacity: 0;
  transform-origin: center;
  animation: present-confetti-burst 4000ms ease-out var(--confetti-delay, 0ms) forwards;
}

@keyframes present-reveal-flight {
  0% {
    transform: translate(-50%, -50%) translate(0, 0) scale(1);
  }

  18%,
  74% {
    transform: translate(-50%, -50%) translate(var(--move-x), var(--move-y)) scale(var(--front-scale));
  }

  100% {
    transform: translate(-50%, -50%) translate(0, 0) scale(1);
  }
}

@keyframes present-gift-pop {
  0%,
  18% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }

  20%,
  26%,
  32%,
  38%,
  44% {
    opacity: 1;
    transform: scale(1.02) translateX(-1px) rotate(-3deg);
  }

  22%,
  28%,
  34%,
  40%,
  46% {
    opacity: 1;
    transform: scale(1.02) translateX(1px) rotate(3deg);
  }

  24%,
  30%,
  36%,
  42% {
    opacity: 1;
    transform: scale(1.01) translateY(-1px) rotate(0deg);
  }

  48% {
    opacity: 1;
    transform: scale(1.14) rotate(-5deg);
  }

  56%,
  100% {
    opacity: 0;
    transform: scale(1.72) rotate(18deg);
  }
}

@keyframes present-emoji-reveal {
  0%,
  45% {
    opacity: 0;
    transform: scale(0.42) rotate(-8deg);
  }

  56% {
    opacity: 1;
    transform: scale(1.12) rotate(4deg);
  }

  68%,
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes present-confetti-burst {
  0%,
  42% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2) rotate(0deg);
  }

  48% {
    opacity: 1;
  }

  82% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--confetti-x)), calc(-50% + var(--confetti-y))) scale(1) rotate(var(--confetti-rotate));
  }
}

.playfield {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(0, clamp(74px, 13dvh, 100px)) minmax(0, 1fr);
  gap: clamp(5px, 1dvh, 10px);
  min-height: 0;
}

.playfield,
.zone--purse,
.zone--bank,
.zone--robot {
  min-height: 0;
}

.zone--purse {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: linear-gradient(160deg, #fff6df, #ffe3b2);
}

.purse-reserve {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 2px;
  min-height: 12px;
  padding: clamp(3px, 0.6dvh, 5px) clamp(5px, 1.5vw, 8px) clamp(2px, 0.4dvh, 4px);
  border-bottom: 1px solid rgba(37, 27, 19, 0.08);
}

.purse-reserve-coin {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border: 1px solid #c7841f;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, #ffeaa5 0 28%, transparent 29%),
    radial-gradient(circle, #ffd85f, var(--gold) 62%, var(--gold-dark));
  box-shadow: inset 0 -1px 1px rgba(115, 66, 7, 0.22);
}

.zone--bank {
  grid-row: 1 / 3;
  grid-column: 2;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  clip-path: polygon(50% 0%, 100% 20%, 100% 100%, 0% 100%, 0% 20%);
}

.zone--bank::before {
  display: none;
}

.zone--bank.is-theme-tree {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 24% 23%, rgba(255, 247, 166, 0.32), transparent 18%),
    radial-gradient(circle at 76% 77%, rgba(255, 247, 166, 0.22), transparent 18%),
    linear-gradient(160deg, #bfe6a4, #75b95d);
  clip-path: none;
}

.zone--bank.is-theme-tree::before {
  display: block;
}

.zone--robot {
  display: grid;
  grid-template-rows: 1fr;
  background: linear-gradient(160deg, #edf4ff, #cfe2ff);
}

.bank-summary {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 6px;
  justify-items: center;
  align-content: end;
  min-height: clamp(72px, 13dvh, 104px);
  padding:
    clamp(26px, 4dvh, 40px) clamp(20px, 6vw, 32px)
    clamp(8px, 1.2dvh, 12px);
  background: #2f6f4a;
  color: #fff8ed;
}

.zone--bank.is-theme-tree .bank-summary {
  min-height: 0;
  align-content: start;
  background: transparent;
  color: var(--ink);
  padding: clamp(7px, 1.2dvh, 12px) clamp(8px, 2.5vw, 14px) clamp(5px, 0.8dvh, 8px);
}

.bank-summary__label {
  display: grid;
  justify-items: center;
  gap: 0.12em;
  text-align: center;
  font-size: clamp(1.32rem, min(5.6vw, 3.3dvh), 1.64rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.bank-summary__label strong {
  font-size: 1em;
  font-weight: 900;
}

.bank-summary__label span {
  display: block;
  font-size: 0.72em;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.92;
}

.interest-progress {
  width: min(68%, 8.5rem);
  height: clamp(5px, 0.85dvh, 8px);
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 248, 237, 0.28);
}

.zone--bank.is-theme-tree .interest-progress {
  width: 100%;
  height: clamp(6px, 1dvh, 9px);
  background: rgba(45, 125, 81, 0.18);
}

.interest-progress span {
  --progress: 0;
  display: block;
  width: calc(var(--progress) * 100%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #9be4b4, #fff8ed);
  transition: width 120ms linear;
}

.zone--bank.is-theme-tree .interest-progress span {
  background: linear-gradient(90deg, var(--green), var(--green-dark));
}

.bank-wall {
  position: relative;
  z-index: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr;
  background-color: #f3e2d2;
}

.zone--bank.is-theme-tree .bank-wall {
  background: transparent;
}

.bank-bricks {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.zone--bank.is-theme-tree .bank-bricks {
  display: none;
}

.brick {
  position: absolute;
  box-sizing: border-box;
  background: #d4896f;
  border: 1.5px solid #8a4536;
  border-radius: 1px;
  box-shadow: inset 0 1px 0 rgba(255, 232, 220, 0.35);
}

.coin-tray {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  gap: clamp(3px, 1vw, 7px);
  min-height: 0;
  padding: clamp(3px, 0.7dvh, 6px) clamp(7px, 2vw, 12px) clamp(5px, 0.9dvh, 10px);
  overflow: hidden;
}

#purse-coins {
  align-items: center;
  align-content: center;
  flex-wrap: nowrap;
  overflow: visible;
}

.coin-tray--particles .coin {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  transform: translate(-50%, -50%) scale(var(--scale));
}

.coin-tray--bank {
  position: relative;
  z-index: 1;
  align-content: start;
  max-height: 100%;
  overflow: hidden;
  padding: 0;
}

.coin-tray--tree {
  isolation: isolate;
  padding: 0;
}

.coin-tray--tree::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: calc(var(--radius) - 6px);
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(58, 113, 48, 0.24) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(0deg, transparent calc(33.333% - 1px), rgba(58, 113, 48, 0.2) calc(33.333% - 1px) calc(33.333% + 1px), transparent calc(33.333% + 1px)),
    linear-gradient(0deg, transparent calc(66.666% - 1px), rgba(58, 113, 48, 0.2) calc(66.666% - 1px) calc(66.666% + 1px), transparent calc(66.666% + 1px)),
    radial-gradient(circle at 24% 23%, rgba(255, 255, 255, 0.2), transparent 12%),
    radial-gradient(circle at 76% 23%, rgba(255, 255, 255, 0.16), transparent 12%),
    radial-gradient(circle at 24% 50%, rgba(255, 255, 255, 0.16), transparent 12%),
    radial-gradient(circle at 76% 50%, rgba(255, 255, 255, 0.16), transparent 12%),
    radial-gradient(circle at 24% 77%, rgba(255, 255, 255, 0.16), transparent 12%),
    radial-gradient(circle at 76% 77%, rgba(255, 255, 255, 0.16), transparent 12%);
  box-shadow: inset 0 0 0 1px rgba(58, 113, 48, 0.18);
  content: "";
  pointer-events: none;
}

.coin-tray--bank .coin {
  width: clamp(18px, min(7vw, 4.4dvh), 32px);
  height: clamp(18px, min(7vw, 4.4dvh), 32px);
  font-size: clamp(0.62rem, min(3vw, 2dvh), 1rem);
}

.coin {
  --scale: 1;
  position: relative;
  width: clamp(24px, min(8.8vw, 5.7dvh), 42px);
  height: clamp(24px, min(8.8vw, 5.7dvh), 42px);
  border: 2px solid #c7841f;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, #ffeaa5 0 19%, transparent 20%),
    radial-gradient(circle, #ffd85f, var(--gold) 62%, var(--gold-dark));
  box-shadow:
    inset 0 -5px 8px rgba(115, 66, 7, 0.18),
    0 4px 10px rgba(89, 54, 12, 0.18);
  color: #704704;
  display: grid;
  flex: 0 0 auto;
  font-size: clamp(0.8rem, min(4vw, 2.8dvh), 1.25rem);
  font-weight: 900;
  line-height: 1;
  place-items: center;
  touch-action: none;
  transform: scale(var(--scale));
  transition:
    opacity 120ms ease,
    transform 120ms ease;
  user-select: none;
}

.coin::after {
  content: "$";
}

.coin:hover {
  transform: scale(calc(var(--scale) * 1.06));
}

.coin-tray--particles .coin:hover {
  transform: translate(-50%, -50%) scale(calc(var(--scale) * 1.06));
}

.coin.is-source {
  opacity: 0.22;
}

.coin.is-dropping {
  z-index: 4;
  pointer-events: none;
  transition: none;
}

.coin-tray--particles .coin.is-dropping {
  transform: translate(-50%, -50%) scale(calc(var(--scale) * var(--drop-sx, 1)), calc(var(--scale) * var(--drop-sy, 1)));
}

.coin-tray--particles .coin.is-dropping:hover {
  transform: translate(-50%, -50%) scale(calc(var(--scale) * var(--drop-sx, 1)), calc(var(--scale) * var(--drop-sy, 1)));
}

.coin.is-bottom {
  box-shadow:
    inset 0 -5px 8px rgba(115, 66, 7, 0.18),
    0 0 0 4px rgba(247, 183, 51, 0.25),
    0 4px 10px rgba(89, 54, 12, 0.18);
}

.coin.is-splitting {
  overflow: visible;
  z-index: 2;
  transition: none;
}

.coin.is-splitting::before {
  position: absolute;
  inset: -18%;
  z-index: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 234, 165, 0.9) 0 18%, transparent 19%),
    radial-gradient(circle, rgba(255, 216, 95, 0.55), rgba(247, 183, 51, 0.2) 58%, transparent 72%);
  content: "";
  filter: blur(1.5px);
  opacity: 0.55;
  pointer-events: none;
}

.coin.is-splitting::after {
  position: relative;
  z-index: 2;
}

.coin-tray--particles .coin.is-splitting,
.coin-tray--particles .split-child-particle.is-splitting-child {
  --split-angle: 0rad;
  --split-along: 1;
  --split-across: 1;
  transform:
    translate(-50%, -50%)
    rotate(var(--split-angle))
    scale(calc(var(--scale) * var(--split-along)), calc(var(--scale) * var(--split-across)))
    rotate(calc(var(--split-angle) * -1));
}

.coin-tray--particles .coin.is-splitting:hover,
.coin-tray--particles .split-child-particle.is-splitting-child:hover {
  transform:
    translate(-50%, -50%)
    rotate(var(--split-angle))
    scale(calc(var(--scale) * var(--split-along) * 1.04), calc(var(--scale) * var(--split-across) * 1.04))
    rotate(calc(var(--split-angle) * -1));
}

.split-goo-bridge {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 1;
  width: var(--length);
  height: var(--thickness);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 30%, #ffeaa5 0 16%, transparent 18%),
    radial-gradient(ellipse at center, #ffd85f 0 42%, var(--gold) 68%, var(--gold-dark));
  box-shadow:
    inset 0 -2px 4px rgba(115, 66, 7, 0.16),
    0 1px 3px rgba(89, 54, 12, 0.12);
  opacity: calc(var(--goo-fade, 1) * 0.96);
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(var(--angle)) scaleY(calc(0.55 + var(--waist) * 0.45));
  filter: blur(0.35px);
}

.split-goo-bridge::before {
  position: absolute;
  inset: 18% 8%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255, 244, 196, 0.55), transparent 70%);
  content: "";
  transform: scaleY(calc(0.35 + var(--waist) * 0.9));
}

.split-goo-bridge::after {
  position: absolute;
  inset: 28% 22%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, var(--gold-dark), transparent 72%);
  content: "";
  opacity: calc((1 - var(--waist)) * 0.55);
  transform: scaleY(0.55);
}

.coin--tree {
  z-index: 3;
  box-shadow:
    inset 0 -5px 8px rgba(115, 66, 7, 0.18),
    0 0 0 3px rgba(255, 247, 166, 0.42),
    0 4px 10px rgba(89, 54, 12, 0.18);
}

.coin.is-sprouting {
  pointer-events: auto;
}

.tree-branch {
  position: absolute;
  left: var(--from-x);
  top: var(--from-y);
  z-index: 1;
  width: var(--branch-length);
  height: var(--branch-width);
  border-radius: 999px;
  background: linear-gradient(90deg, #5e381e, #7d4e2b 72%, #3f8f45);
  box-shadow: 0 1px 2px rgba(48, 29, 12, 0.16);
  pointer-events: none;
  transform: rotate(var(--branch-angle)) scaleX(var(--progress));
  transform-origin: left center;
}

.tree-base {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 2;
  width: clamp(20px, min(8vw, 5dvh), 30px);
  height: clamp(16px, min(6vw, 4dvh), 24px);
  pointer-events: none;
  transform: translate(-50%, -42%);
}

.tree-base::before,
.tree-base::after {
  position: absolute;
  content: "";
}

.tree-base::before {
  left: 50%;
  bottom: 26%;
  width: 28%;
  height: 82%;
  border-radius: 999px 999px 4px 4px;
  background: linear-gradient(90deg, #5e381e, #8b5a2e 55%, #5e381e);
  box-shadow: inset -2px 0 3px rgba(46, 25, 10, 0.22);
  transform: translateX(-50%);
}

.tree-base::after {
  right: 2%;
  bottom: 0;
  left: 2%;
  height: 42%;
  border-radius: 50%;
  background: linear-gradient(180deg, #7bc665, #4f8e40);
  box-shadow:
    inset 0 3px 5px rgba(255, 255, 255, 0.18),
    0 2px 3px rgba(48, 81, 36, 0.18);
}

.tree-bloom-coin {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 2;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(var(--scale));
}

.coin-tray--tree .coin:hover {
  transform: translate(-50%, -50%) scale(calc(var(--scale) * 1.06));
}

.split-child-particle {
  z-index: 1;
  opacity: 0.96;
  pointer-events: none;
  transition: none;
}

.coin-ghost {
  position: fixed;
  z-index: 50;
  overflow: visible;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.15);
}

.coin-ghost.is-splitting {
  transform:
    translate(-50%, -50%)
    rotate(var(--split-angle, 0rad))
    scale(calc(1.15 * var(--split-along, 1)), calc(1.15 * var(--split-across, 1)))
    rotate(calc(var(--split-angle, 0rad) * -1));
}

.drag-split-child {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  opacity: 0.92;
  transform:
    translate(calc(-50% + var(--drag-child-x, 0px)), calc(-50% + var(--drag-child-y, 0px)))
    rotate(var(--split-angle, 0rad))
    scale(calc(var(--scale, 1) * var(--split-along, 1)), calc(var(--scale, 1) * var(--split-across, 1)))
    rotate(calc(var(--split-angle, 0rad) * -1));
}

.drag-split-bridge {
  left: 50%;
  top: 50%;
  transform:
    translate(calc(-50% + var(--drag-child-x, 0px)), calc(-50% + var(--drag-child-y, 0px)))
    rotate(var(--angle))
    scaleY(calc(0.55 + var(--waist) * 0.45));
}

.robot {
  --robot-body-width: clamp(68px, min(26vw, 17dvh), 112px);
  --robot-body-padding: clamp(4px, 0.7dvh, 6px);
  --robot-coin-size: clamp(16px, min(7vw, 4.2dvh), 30px);
  --robot-neck-height: 10px;
  --robot-neck-width: 24px;
  --robot-stack-gap: clamp(1px, 0.45dvh, 3px);
  --robot-head-font-size: 54px;
  --robot-stack-height: 129px;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: center;
  justify-items: center;
  gap: 0;
  height: 100%;
  min-height: 0;
  padding: 0 clamp(6px, 2vw, 12px) clamp(6px, 1dvh, 14px);
}

.robot-head {
  width: var(--robot-body-width);
  aspect-ratio: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-size: var(--robot-head-font-size);
  line-height: 0.86;
  filter: drop-shadow(0 6px 8px rgba(58, 105, 160, 0.2));
}

.robot-neck {
  width: var(--robot-neck-width);
  height: var(--robot-neck-height);
  border-radius: 999px 999px 0 0;
  background: var(--blue);
  box-shadow: inset 0 -4px 7px rgba(44, 65, 88, 0.18);
}

.robot-body {
  width: var(--robot-body-width);
  min-height: 0;
  height: auto;
  max-height: none;
  padding: var(--robot-body-padding);
  border: 3px solid #5d86ba;
  border-radius: 16px 16px 24px 24px;
  background: linear-gradient(180deg, #eaf5ff, #83b5ef);
}

.robot-stack {
  position: relative;
  height: var(--robot-stack-height);
  overflow: hidden;
}

.robot-stack .coin {
  position: absolute;
  left: 50%;
  bottom: var(--robot-bottom, 0px);
  width: var(--robot-coin-size);
  height: var(--robot-coin-size);
  font-size: clamp(0.6rem, 2.8vw, 1rem);
  pointer-events: none;
  transform: translateX(-50%) scale(var(--scale));
}

.start-overlay,
.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: clamp(18px, 5vw, 34px);
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 240, 194, 0.82), transparent 18rem),
    rgba(37, 27, 19, 0.32);
  backdrop-filter: blur(5px);
  animation: result-overlay-fade 480ms ease forwards;
}

.start-overlay[hidden],
.result-overlay[hidden] {
  display: none;
}

.start-card {
  width: min(92vw, 390px);
  display: grid;
  gap: clamp(14px, 2.2dvh, 22px);
  padding: clamp(22px, 6vw, 34px);
  border: 3px solid rgba(37, 27, 19, 0.12);
  border-radius: 34px;
  background: rgba(255, 250, 241, 0.96);
  color: var(--ink);
  box-shadow: 0 28px 70px rgba(37, 27, 19, 0.32);
  text-align: center;
  transform-origin: center;
  animation: result-card-pop 900ms cubic-bezier(0.18, 1.2, 0.22, 1) forwards;
}

.start-goal {
  font-size: clamp(1.15rem, min(5.4vw, 3.2dvh), 1.65rem);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.result-card {
  width: min(92vw, 390px);
  display: grid;
  gap: clamp(8px, 1.4dvh, 14px);
  padding: clamp(22px, 6vw, 34px);
  border: 3px solid rgba(37, 27, 19, 0.12);
  border-radius: 34px;
  background: rgba(255, 250, 241, 0.96);
  color: var(--ink);
  box-shadow: 0 28px 70px rgba(37, 27, 19, 0.32);
  text-align: center;
  transform-origin: center;
  animation: result-card-pop 900ms cubic-bezier(0.18, 1.2, 0.22, 1) forwards;
}

.result-card.is-lost {
  background: linear-gradient(180deg, #fff8ed, #ffe9e6);
}

.result-card.is-won {
  background: linear-gradient(180deg, #fffaf1, #fff0c2);
}

.result-kicker {
  color: var(--muted);
  font-size: clamp(0.72rem, min(3.3vw, 1.9dvh), 0.9rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.result-title {
  font-size: clamp(2.45rem, min(15vw, 8.5dvh), 4.7rem);
  line-height: 0.86;
  letter-spacing: -0.08em;
}

.result-card.is-lost .result-title {
  color: #a43d36;
  animation: result-title-shake 820ms ease-in-out 260ms both;
}

.result-card.is-won .result-title {
  color: #8a5d00;
  animation: result-title-bounce 1200ms ease-in-out 220ms both;
}

.result-message {
  font-size: clamp(1.08rem, min(5vw, 3dvh), 1.55rem);
  font-weight: 900;
  line-height: 1.05;
}

.result-detail {
  color: var(--muted);
  font-size: clamp(0.86rem, min(3.6vw, 2dvh), 1rem);
  font-weight: 800;
  line-height: 1.25;
}

.result-button {
  min-height: 48px;
  margin-top: clamp(4px, 1dvh, 10px);
  border: 0;
  border-radius: 18px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(37, 27, 19, 0.22);
}

@keyframes result-overlay-fade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes result-card-pop {
  0% {
    opacity: 0;
    transform: translateY(28px) scale(0.82) rotate(-2deg);
  }

  62% {
    opacity: 1;
    transform: translateY(-5px) scale(1.04) rotate(1deg);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

@keyframes result-title-shake {
  0%,
  100% {
    transform: translateX(0);
  }

  20%,
  60% {
    transform: translateX(-5px) rotate(-1deg);
  }

  40%,
  80% {
    transform: translateX(5px) rotate(1deg);
  }
}

@keyframes result-title-bounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  35% {
    transform: translateY(-8px) scale(1.05);
  }

  70% {
    transform: translateY(2px) scale(0.98);
  }
}

.control-button,
.secondary-button,
.preset-button,
.icon-button {
  min-height: 44px;
  border: 0;
  border-radius: 16px;
  font-weight: 900;
}

.control-button {
  background: var(--ink);
  color: #fff;
}

.secondary-button,
.preset-button {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.icon-button {
  width: 42px;
  min-height: 42px;
  background: #f6ead8;
  color: var(--ink);
}

.app-menu {
  position: relative;
  flex: 0 0 auto;
}

.app-menu summary {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1;
  list-style: none;
}

.app-menu summary::-webkit-details-marker {
  display: none;
}

.menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 142px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffaf1;
  box-shadow: 0 14px 30px rgba(58, 41, 25, 0.22);
}

.menu-panel button {
  min-height: 38px;
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.settings-dialog {
  width: min(92vw, 410px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: auto;
  touch-action: pan-y;
}

.settings-dialog::backdrop {
  background: rgba(37, 27, 19, 0.34);
  backdrop-filter: blur(4px);
}

.settings-form {
  display: grid;
  gap: clamp(10px, 1.6dvh, 16px);
  padding: clamp(12px, 2dvh, 18px);
}

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

.preset-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(8px, 1.2dvh, 12px);
}

.settings-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.settings-grid .settings-check {
  grid-column: 1 / -1;
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--ink);
}

.settings-grid input,
.settings-grid select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font-weight: 800;
}

.settings-grid input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--ink);
}

.settings-grid input:disabled {
  color: var(--muted);
  background: #f3eadc;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 10px;
  margin: 0;
  padding: 0;
}

[data-drop].is-drop-target {
  outline: 4px solid rgba(85, 183, 122, 0.35);
  outline-offset: -5px;
}

@media (max-width: 370px) {
  .phone {
    padding: 8px;
    gap: 5px;
  }
}

@media (max-height: 650px) {
  .robot-head {
    border-width: 2px;
  }

  .robot-body {
    border-width: 2px;
  }
}
