* {
  box-sizing: border-box;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: #172026;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 12% 18%, rgba(255, 209, 102, 0.36), transparent 28%), radial-gradient(circle at 84% 12%, rgba(77, 150, 255, 0.2), transparent 26%), linear-gradient(135deg, #fff8ea 0%, #e6f6f2 52%, #eef3ff 100%);
  overscroll-behavior: none;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.game-shell {
  width: min(1180px, 100%);
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}
.topbar h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4.7rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 7px;
  color: #6d4b3e;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 500px;
}
.stats span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(23, 32, 38, 0.1);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.65);
  box-shadow: 0 10px 26px rgba(22, 32, 38, 0.07);
  font-size: 0.9rem;
  white-space: nowrap;
}

.stage-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 18px;
  align-items: stretch;
}

.stage {
  position: relative;
  min-height: 640px;
  overflow: hidden;
  border: 1px solid rgba(23, 32, 38, 0.12);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(223, 245, 255, 0.96), rgba(255, 244, 220, 0.9) 56%, rgba(215, 241, 209, 0.95) 56%), #fffaf1;
  box-shadow: 0 22px 70px rgba(22, 32, 38, 0.18);
  outline: none;
  touch-action: none;
  user-select: none;
}
.stage::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 96px;
  background: linear-gradient(90deg, rgba(66, 184, 131, 0.2), rgba(255, 209, 102, 0.22), rgba(77, 150, 255, 0.15)), repeating-linear-gradient(90deg, rgba(23, 32, 38, 0.08) 0 1px, transparent 1px 50px);
}
.stage.hit {
  animation: stage-hit 0.24s ease;
}

.skyline {
  position: absolute;
  inset: auto 0 94px;
  height: 150px;
  pointer-events: none;
}
.skyline span {
  position: absolute;
  bottom: 0;
  width: 120px;
  border-radius: 8px 8px 0 0;
  background: rgba(67, 97, 107, 0.14);
}
.skyline span:nth-child(1) {
  left: 7%;
  height: 84px;
}
.skyline span:nth-child(2) {
  left: 28%;
  height: 126px;
  width: 92px;
}
.skyline span:nth-child(3) {
  right: 27%;
  height: 96px;
  width: 142px;
}
.skyline span:nth-child(4) {
  right: 7%;
  height: 118px;
}

.brief {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 360px;
  border: 1px solid rgba(23, 32, 38, 0.12);
  border-radius: 8px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 22px 70px rgba(22, 32, 38, 0.18);
}
.brief h2 {
  margin: 0;
  font-size: 1.15rem;
}
.brief p {
  min-height: 90px;
  margin: 0;
  color: #415057;
  line-height: 1.55;
}

.progress {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(23, 32, 38, 0.1);
}
.progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f45b69, #ffd166, #42b883);
  transition: width 0.2s ease;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.controls button {
  min-height: 46px;
  border-radius: 8px;
  color: #fff;
  background: #172026;
  box-shadow: 0 10px 20px rgba(23, 32, 38, 0.15);
}
.controls button:active {
  transform: translateY(1px);
}

.primary-btn {
  min-height: 48px;
  border-radius: 8px;
  padding: 0 22px;
  color: #fff;
  background: #f45b69;
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(244, 91, 105, 0.34);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(255, 250, 241, 0.62);
  backdrop-filter: blur(8px);
}
.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.panel {
  width: min(520px, 100%);
  border: 1px solid rgba(23, 32, 38, 0.12);
  border-radius: 8px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 22px 70px rgba(22, 32, 38, 0.18);
}
.panel h2 {
  margin: 0 0 12px;
  font-size: clamp(1.6rem, 5vw, 3.2rem);
  line-height: 1;
  letter-spacing: 0;
}
.panel p {
  margin: 0 0 20px;
  color: #415057;
  line-height: 1.55;
}
.panel span {
  display: block;
  margin: 5px 0;
}

.drop {
  position: absolute;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 8px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
  line-height: 1.05;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  box-shadow: 0 12px 24px rgba(22, 32, 38, 0.16);
  user-select: none;
}
.drop.good {
  background: linear-gradient(135deg, #42b883, #4d96ff);
}
.drop.cake, .drop.win {
  background: linear-gradient(135deg, #f45b69, #ffd166);
}
.drop.citation, .drop.nap {
  background: linear-gradient(135deg, #7c5cff, #4d96ff);
}
.drop.agenda {
  background: linear-gradient(135deg, #172026, #42b883);
}
.drop.flow {
  background: linear-gradient(135deg, #4d96ff, #ffd166);
}
.drop.bad {
  background: linear-gradient(135deg, #2f3437, #f45b69);
}
.drop.spreadsheet, .drop.mail {
  background: linear-gradient(135deg, #2f3437, #7c5cff);
}
.drop.ping, .drop.blocker {
  background: linear-gradient(135deg, #f45b69, #172026);
}

.player {
  position: absolute;
  z-index: 20;
  width: 74px;
  height: 154px;
  transform-origin: 50% 100%;
  transition: filter 0.15s ease;
}
.player.happy {
  filter: drop-shadow(0 0 16px rgba(255, 209, 102, 0.95));
}

.hair-back {
  position: absolute;
  left: 8px;
  top: 0;
  width: 58px;
  height: 92px;
  border-radius: 30px 30px 24px 24px;
  background: #4b281a;
  box-shadow: inset -9px -12px 0 rgba(0, 0, 0, 0.16);
}

.head {
  position: absolute;
  left: 15px;
  top: 11px;
  width: 44px;
  height: 52px;
  border-radius: 48% 48% 45% 45%;
  background: #f5c6a5;
  box-shadow: inset -4px -7px 0 rgba(199, 134, 99, 0.24);
}

.bangs {
  position: absolute;
  left: -3px;
  top: -2px;
  width: 50px;
  height: 20px;
  border-radius: 28px 28px 12px 12px;
  background: #4b281a;
}
.bangs::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 10px;
  width: 14px;
  height: 20px;
  border-radius: 0 0 12px 12px;
  background: #4b281a;
}

.glasses {
  position: absolute;
  left: 6px;
  top: 23px;
  display: flex;
  align-items: center;
  gap: 1px;
}
.glasses span {
  width: 14px;
  height: 11px;
  border: 2px solid #263238;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}
.glasses i {
  width: 5px;
  height: 2px;
  background: #263238;
}

.smile {
  position: absolute;
  left: 17px;
  top: 39px;
  width: 10px;
  height: 5px;
  border-bottom: 2px solid #7a3f37;
  border-radius: 0 0 12px 12px;
}

.neck {
  position: absolute;
  left: 31px;
  top: 59px;
  width: 12px;
  height: 13px;
  background: #e8a984;
}

.torso {
  position: absolute;
  left: 24px;
  top: 70px;
  width: 26px;
  height: 48px;
  border-radius: 15px 15px 8px 8px;
  background: linear-gradient(180deg, #fffaf1, #4d96ff);
  box-shadow: inset 0 -18px 0 #2c6ecb;
}

.arm {
  position: absolute;
  top: 75px;
  width: 9px;
  height: 48px;
  border-radius: 999px;
  background: #f5c6a5;
}
.arm.arm-left {
  left: 16px;
  transform: rotate(10deg);
}
.arm.arm-right {
  right: 16px;
  transform: rotate(-10deg);
}

.leg {
  position: absolute;
  top: 116px;
  width: 10px;
  height: 38px;
  border-radius: 999px;
  background: #1d2730;
}
.leg.leg-left {
  left: 27px;
}
.leg.leg-right {
  right: 27px;
}

.confetti {
  position: absolute;
  top: -20px;
  z-index: 40;
  width: 9px;
  height: 16px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

.firework {
  position: absolute;
  z-index: 45;
  width: 8px;
  height: 8px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 10px rgba(255, 209, 102, 0.85));
}
.firework::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #fff4d6;
  animation: firework-flash 0.72s ease-out forwards;
}
.firework .spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 14px;
  border-radius: 999px;
  background: var(--spark-color);
  box-shadow: 0 0 14px var(--spark-color);
  transform-origin: 50% 50%;
  animation: firework-spark 1.12s cubic-bezier(0.08, 0.82, 0.25, 1) forwards;
}

@keyframes confetti-fall {
  to {
    top: 110%;
    transform: translateX(70px) rotate(520deg);
  }
}
@keyframes firework-flash {
  0% {
    opacity: 1;
    transform: scale(0.4);
  }
  55% {
    opacity: 0.95;
    transform: scale(2.5);
  }
  100% {
    opacity: 0;
    transform: scale(5);
  }
}
@keyframes firework-spark {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(var(--angle)) translateY(0) scaleY(0.4);
  }
  74% {
    opacity: 0.92;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--angle)) translateY(calc(-1 * var(--distance))) scaleY(0.08);
  }
}
@keyframes stage-hit {
  0%,
  100% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(-7px);
  }
  70% {
    transform: translateX(7px);
  }
}
@media (max-width: 900px) {
  .app {
    align-items: start;
    padding: 14px;
  }
  .topbar {
    align-items: start;
    flex-direction: column;
  }
  .stats {
    justify-content: flex-start;
  }
  .stage-wrap {
    grid-template-columns: 1fr;
  }
  .stage {
    height: min(62svh, 560px);
    min-height: 440px;
  }
  .brief {
    min-height: auto;
  }
}
@media (max-width: 900px) and (hover: none) {
  .app {
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
  }
  .controls {
    position: fixed;
    z-index: 60;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    gap: 8px;
    margin: 0;
    padding: 8px;
    border: 1px solid rgba(23, 32, 38, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 14px 34px rgba(22, 32, 38, 0.18);
    backdrop-filter: blur(10px);
  }
  .app:not(.is-playing) .controls {
    display: none;
  }
  .controls button {
    min-height: 58px;
    font-weight: 800;
  }
}
@media (max-width: 900px) and (orientation: landscape) {
  .app {
    padding-top: 8px;
  }
  .topbar {
    align-items: end;
    flex-direction: row;
    margin-bottom: 8px;
  }
  .topbar h1 {
    font-size: clamp(1.7rem, 5vw, 2.8rem);
  }
  .stats span {
    min-height: 28px;
    padding: 4px 8px;
    font-size: 0.76rem;
  }
  .stage {
    height: calc(100svh - 128px);
    min-height: 240px;
  }
}
@media (max-width: 560px) {
  .app {
    min-height: 100svh;
    padding: 10px 10px calc(92px + env(safe-area-inset-bottom));
  }
  .game-shell {
    width: 100%;
  }
  .topbar {
    gap: 10px;
    margin-bottom: 10px;
  }
  .topbar h1 {
    font-size: clamp(2rem, 12vw, 2.45rem);
  }
  .eyebrow {
    margin-bottom: 4px;
    font-size: 0.7rem;
  }
  .stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 6px;
  }
  .stats span {
    width: 100%;
    justify-content: center;
    min-height: 30px;
    padding: 5px 8px;
    font-size: 0.78rem;
  }
  .stats span:last-child {
    grid-column: 1/-1;
  }
  .stage-wrap {
    gap: 10px;
  }
  .stage {
    height: min(58svh, 470px);
    min-height: 360px;
    border-radius: 8px;
  }
  .skyline {
    height: 118px;
  }
  .brief {
    gap: 10px;
    padding: 14px;
  }
  .brief h2 {
    font-size: 1rem;
  }
  .brief p {
    min-height: auto;
    font-size: 0.92rem;
    line-height: 1.35;
  }
  .panel {
    padding: 18px;
  }
  .panel h2 {
    font-size: clamp(1.45rem, 9vw, 2.4rem);
  }
}
