:root {
  --umbrella: #ffd54a;
  --umbrella-dark: #f4b400;
  --ink: #2b2116;
  --paper: #fff7e6;
  --sky-top: #152038;
  --sky-mid: #243656;
  --sky-bot: #31485a;
  --ground: #1c3326;
  --danger: #ff7043;
  --good: #8bc34a;
  --shake: 0deg;
  --lean: 0deg;
  --wind-x: 1;
  --sway: 8deg;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #070b14;
  color: var(--paper);
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#app {
  position: relative;
  width: min(100%, 430px);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 0%, #3a5278 0%, transparent 52%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 46%, var(--sky-bot) 72%, #1a2c28 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

#weather {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

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

.cloud {
  position: absolute;
  background: rgba(176, 190, 214, 0.42);
  border-radius: 40px;
  filter: blur(1px);
  animation: cloud-move 18s linear infinite;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.cloud.c1 {
  width: 160px;
  height: 44px;
  top: 9%;
  left: -20%;
  animation-duration: 22s;
}
.cloud.c1::before {
  width: 70px;
  height: 70px;
  top: -38px;
  left: 24px;
}
.cloud.c1::after {
  width: 90px;
  height: 56px;
  top: -28px;
  right: 18px;
}

.cloud.c2 {
  width: 210px;
  height: 50px;
  top: 16%;
  left: 10%;
  animation-duration: 16s;
  animation-delay: -6s;
  opacity: 0.8;
}
.cloud.c2::before {
  width: 86px;
  height: 86px;
  top: -48px;
  left: 36px;
}
.cloud.c2::after {
  width: 70px;
  height: 70px;
  top: -34px;
  right: 30px;
}

.cloud.c3 {
  width: 120px;
  height: 34px;
  top: 22%;
  left: 50%;
  animation-duration: 26s;
  animation-delay: -12s;
  opacity: 0.55;
}
.cloud.c3::before {
  width: 50px;
  height: 50px;
  top: -26px;
  left: 16px;
}

.cloud.c4 {
  width: 180px;
  height: 40px;
  top: 6%;
  left: 40%;
  animation-duration: 19s;
  animation-delay: -3s;
  opacity: 0.7;
}
.cloud.c4::before {
  width: 64px;
  height: 64px;
  top: -32px;
  left: 40px;
}

@keyframes cloud-move {
  from {
    transform: translateX(calc(var(--wind-x) * -80px));
  }
  to {
    transform: translateX(calc(var(--wind-x) * 520px));
  }
}

.lightning {
  position: absolute;
  inset: 0;
  background: rgba(210, 230, 255, 0.38);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

.lightning.flash {
  animation: flash 0.18s ease-out;
}

@keyframes flash {
  0% {
    opacity: 0.7;
  }
  100% {
    opacity: 0;
  }
}

.top-bar {
  position: relative;
  z-index: 8;
  padding: calc(10px + env(safe-area-inset-top)) 16px 0;
  text-align: center;
}

.game-title {
  margin: 0;
  color: #fff8e7;
  font-size: clamp(28px, 8vw, 36px);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow: 0 3px 0 #10182a, 0 8px 18px rgba(0, 0, 0, 0.35);
  transform: rotate(-1.5deg);
}

.title-lead {
  margin: 10px 12px 0;
  font-size: 15px;
  font-weight: 700;
  color: #ffe082;
  text-shadow: 0 2px 0 #1b2438;
}

.hud {
  margin-top: 8px;
  text-align: left;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.stat {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.25;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

.stat.best {
  margin-top: 2px;
  font-size: 16px;
  color: #ffe082;
}

.durability {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  font-size: 15px;
  font-weight: 800;
}

.gauge {
  height: 18px;
  border: 3px solid #f3e5c4;
  border-radius: 999px;
  background: #1b2436;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #dce775, #9ccc65);
  transform-origin: left center;
  transition: background 0.2s linear;
}

.gauge-fill.warn {
  background: linear-gradient(90deg, #ffcc80, #ff9800);
}

.gauge-fill.danger {
  background: linear-gradient(90deg, #ff8a65, #e53935);
}

.wind-banner {
  position: relative;
  z-index: 7;
  margin: 10px 0 0;
  height: 52px;
  overflow: hidden;
  background: rgba(8, 12, 24, 0.62);
  border-top: 2px solid rgba(255, 255, 255, 0.18);
  border-bottom: 2px solid rgba(255, 255, 255, 0.18);
}

.wind-track {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  display: flex;
  align-items: center;
  white-space: nowrap;
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #fff;
  text-shadow: 0 0 12px rgba(255, 241, 118, 0.95);
  animation: wind-scroll 1.2s linear infinite;
}

@keyframes wind-scroll {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(calc(var(--wind-x) * 80px));
  }
}

.gust-banner,
.bekon,
.end-title {
  position: absolute;
  left: 50%;
  z-index: 18;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  width: max-content;
  max-width: 92%;
  white-space: nowrap;
  transform: translate(-50%, -50%) scale(0.8);
}

.gust-banner {
  top: 34%;
  padding: 8px 22px;
  border-radius: 16px;
  background: #ff7043;
  color: #fff;
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 0.08em;
  box-shadow: 0 8px 0 #bf360c;
}

.gust-banner.show,
.bekon.show,
.end-title.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
  transition: transform 0.12s ease-out, opacity 0.12s ease-out;
}

.bekon {
  top: 32%;
  font-size: 48px;
  font-weight: 900;
  color: #fff176;
  text-shadow:
    0 4px 0 #e65100,
    0 10px 0 #bf360c,
    0 16px 24px rgba(0, 0, 0, 0.45);
  animation: none;
}

.bekon.show {
  animation: bekon-pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes bekon-pop {
  0% {
    transform: translate(-50%, -50%) scale(0.4) rotate(-8deg);
  }
  60% {
    transform: translate(-50%, -50%) scale(1.18) rotate(4deg);
  }
  100% {
    transform: translate(-50%, -50%) scale(1) rotate(-2deg);
  }
}

.end-title {
  top: 30%;
  font-size: clamp(36px, 11vw, 52px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 4px 0 #10182a, 0 12px 24px rgba(0, 0, 0, 0.45);
}

.scene {
  position: absolute;
  inset: 0 0 150px;
  z-index: 5;
}

.trees {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18%;
  display: flex;
  justify-content: space-between;
  padding: 0 2px;
  pointer-events: none;
}

.tree {
  width: 86px;
  height: 150px;
  transform-origin: 50% 100%;
  animation: tree-sway 1.4s ease-in-out infinite;
}

.tree-right {
  width: 100px;
  height: 170px;
  animation-duration: 1.7s;
  animation-delay: -0.4s;
}

@keyframes tree-sway {
  0%,
  100% {
    transform: rotate(calc(var(--sway) * var(--wind-x) * -0.35));
  }
  50% {
    transform: rotate(calc(var(--sway) * var(--wind-x)));
  }
}

.actor {
  position: absolute;
  left: 50%;
  bottom: 8%;
  width: min(78vw, 320px);
  transform: translateX(-50%) rotate(var(--lean));
  transform-origin: 50% 100%;
}

.umbrella {
  width: 100%;
  transform: rotate(calc(var(--angle, 0deg) + var(--shake)));
  transform-origin: 50% 86%;
  filter: drop-shadow(0 10px 0 rgba(0, 0, 0, 0.18));
}

.umbrella.critical {
  animation: rattle 0.08s linear infinite;
}

@keyframes rattle {
  0%,
  100% {
    translate: 0 0;
  }
  25% {
    translate: -3px 2px;
  }
  50% {
    translate: 3px -2px;
  }
  75% {
    translate: -2px -1px;
  }
}

.umbrella-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.canopy-fill {
  fill: var(--umbrella);
  stroke: var(--ink);
  stroke-width: 5;
  stroke-linejoin: round;
}

.canopy-fill.flipped {
  fill: var(--umbrella-dark);
}

.canopy-line,
.rib {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linecap: round;
  opacity: 0.55;
}

.shaft,
.handle {
  stroke: #5d4037;
  stroke-width: 8;
  stroke-linecap: round;
  fill: none;
}

.plastic-bag {
  position: absolute;
  top: 18%;
  left: 54%;
  width: 72px;
  z-index: 2;
  transform: rotate(18deg);
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.15));
  animation: bag-flap 0.35s ease-in-out infinite;
}

.plastic-bag svg {
  width: 100%;
  height: auto;
}

@keyframes bag-flap {
  0%,
  100% {
    transform: rotate(14deg) translateY(0);
  }
  50% {
    transform: rotate(26deg) translateY(4px);
  }
}

.person {
  width: 42%;
  margin: -18% auto 0;
  position: relative;
  z-index: 1;
}

.person svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.hand {
  fill: #ffcc80;
  stroke: var(--ink);
  stroke-width: 3;
}

.head,
.body {
  fill: #ffcc80;
  stroke: var(--ink);
  stroke-width: 4;
}

.body {
  fill: #5c6bc0;
}

.eye {
  fill: var(--ink);
}

.brow,
.mouth,
.arm {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3.5;
  stroke-linecap: round;
}

.leg {
  fill: #3949ab;
  stroke: var(--ink);
  stroke-width: 3;
}

.shoe {
  fill: #4e342e;
  stroke: var(--ink);
  stroke-width: 3;
}

.shadow {
  fill: rgba(0, 0, 0, 0.28);
}

.ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 118px;
  height: 90px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(90, 140, 110, 0.35), transparent 55%),
    linear-gradient(#2e5a3c, #1a3324);
  border-top: 4px solid #0f2418;
  z-index: 4;
  clip-path: ellipse(85% 100% at 50% 100%);
}

.result {
  position: absolute;
  inset: 0;
  z-index: 14;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 20px 120px;
  background: rgba(8, 12, 22, 0.42);
  text-align: center;
}

.result-end {
  margin: 0 0 18px;
  font-size: clamp(42px, 12vw, 58px);
  font-weight: 900;
  text-shadow: 0 4px 0 #10182a;
}

.result-line {
  margin: 4px 0;
  font-size: 24px;
  font-weight: 800;
}

.new-best {
  margin-top: 14px;
  padding: 6px 16px;
  border-radius: 999px;
  background: #ffd54a;
  color: #3e2723;
  font-size: 22px;
  font-weight: 900;
  animation: best-pop 0.45s ease-out;
}

@keyframes best-pop {
  0% {
    transform: scale(0.6) rotate(-8deg);
  }
  70% {
    transform: scale(1.12) rotate(3deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

.bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  padding: 0 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.start-btn,
.retry-btn,
.ctrl {
  appearance: none;
  border: 4px solid #2b2116;
  font-family: inherit;
  font-weight: 900;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.start-btn,
.retry-btn {
  width: 100%;
  height: 72px;
  border-radius: 22px;
  background: #ffd54a;
  color: #2b2116;
  font-size: 32px;
  box-shadow: 0 8px 0 #c49000;
}

.start-btn:active,
.retry-btn:active,
.ctrl:active,
.ctrl.held {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #c49000;
}

.ctrl.held {
  filter: brightness(0.96);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.ctrl {
  height: 86px;
  border-radius: 24px;
  background: #eceff1;
  color: #263238;
  font-size: 42px;
  box-shadow: 0 8px 0 #90a4ae;
}

.ctrl:active,
.ctrl.held {
  box-shadow: 0 4px 0 #90a4ae;
}

.disclaimer {
  margin: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 247, 230, 0.72);
}

#app.gusty .wind-track {
  color: #fff;
  text-shadow: 0 0 16px #fff59d;
}

#app.gusty .umbrella {
  filter: drop-shadow(0 12px 0 rgba(0, 0, 0, 0.2));
}

@media (min-width: 720px) {
  body {
    background:
      radial-gradient(circle at 50% 40%, #18233a, #070b14 70%);
  }

  #app {
    border-radius: 28px;
    height: min(100dvh, 920px);
    margin-top: calc((100dvh - min(100dvh, 920px)) / 2);
    box-shadow:
      0 0 0 8px #121826,
      0 24px 80px rgba(0, 0, 0, 0.45);
  }
}

@media (max-height: 700px) {
  .game-title {
    font-size: 26px;
  }

  .stat {
    font-size: 17px;
  }

  .ctrl {
    height: 72px;
  }

  .start-btn,
  .retry-btn {
    height: 62px;
    font-size: 28px;
  }

  .ground {
    bottom: 104px;
    height: 70px;
  }
}
