:root {
  color-scheme: light;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", system-ui, sans-serif;
  color: #17364b;
  background: #f2f8fa;
  --ink: #17364b;
  --soft-ink: #567282;
  --paper: #f9fcfb;
  --line: rgba(23, 54, 75, 0.18);
  --sky-top: #ccecff;
  --sky-bottom: #eaf7fa;
  --green: #8eb99e;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 14% 8%, rgba(255, 255, 255, 0.95) 0 14rem, transparent 32rem),
    linear-gradient(145deg, #f6fbfc 0%, #e9f3f4 100%);
}

button,
a {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.page-shell {
  width: min(100% - 32px, 840px);
  margin: 0 auto;
  padding: 22px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  margin-bottom: 18px;
  color: var(--soft-ink);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
}

.topbar p {
  margin: 0;
}

.back-link {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--ink);
}

.game-shell {
  width: min(100%, 680px);
  margin: 0 auto;
}

.game-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 0 4px 14px;
}

.eyebrow,
.overlay-kicker {
  margin: 0 0 5px;
  color: var(--soft-ink);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
}

.game-heading h1 {
  margin: 0;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(2rem, 7vw, 3.35rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1;
}

.scoreboard {
  display: flex;
  gap: 22px;
  padding-bottom: 2px;
  text-align: right;
}

.scoreboard > div {
  display: grid;
  gap: 2px;
}

.score-label {
  color: var(--soft-ink);
  font-size: 0.68rem;
}

.scoreboard strong {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.game-board {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-height: 720px;
  overflow: hidden;
  aspect-ratio: 4 / 5;
  border: 1px solid rgba(67, 112, 133, 0.2);
  border-radius: 28px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02)),
    linear-gradient(180deg, var(--sky-top) 0%, #d9f0fb 56%, var(--sky-bottom) 100%);
  box-shadow:
    0 28px 65px rgba(55, 91, 105, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.game-board::after {
  position: absolute;
  z-index: 9;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 70px rgba(87, 146, 169, 0.08);
  content: "";
  pointer-events: none;
}

.sun-glow {
  position: absolute;
  top: -12%;
  right: -7%;
  width: 48%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 252, 215, 0.82) 0 18%, rgba(255, 255, 255, 0) 68%);
}

.cloud {
  position: absolute;
  z-index: 1;
  width: 20%;
  height: 4.2%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  filter: blur(0.2px);
  opacity: 0.78;
}

.cloud::before,
.cloud::after {
  position: absolute;
  bottom: 8%;
  border-radius: 50%;
  background: inherit;
  content: "";
}

.cloud::before {
  left: 19%;
  width: 34%;
  aspect-ratio: 1;
}

.cloud::after {
  right: 17%;
  width: 45%;
  aspect-ratio: 1;
}

.cloud-one {
  top: 23%;
  left: 8%;
}

.cloud-two {
  top: 38%;
  right: 6%;
  width: 24%;
  opacity: 0.62;
}

.cloud-three {
  top: 57%;
  left: -6%;
  width: 17%;
  opacity: 0.48;
}

.safe-sky {
  position: absolute;
  z-index: 2;
  top: 14%;
  left: 0;
  width: 100%;
  border-top: 1px dashed rgba(39, 93, 121, 0.2);
}

.safe-sky span {
  position: absolute;
  top: -19px;
  left: 50%;
  padding: 2px 8px;
  color: rgba(34, 79, 103, 0.48);
  background: rgba(214, 240, 252, 0.74);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.56rem;
  letter-spacing: 0.16em;
  transform: translateX(-50%);
}

.bird-layer,
.balloon-layer {
  position: absolute;
  z-index: 4;
  inset: 0;
  pointer-events: none;
}

.balloon-layer {
  z-index: 5;
}

.ground {
  position: absolute;
  z-index: 3;
  right: -4%;
  bottom: -5%;
  left: -4%;
  height: 17%;
  border-radius: 50% 50% 0 0 / 28% 28% 0 0;
  background:
    radial-gradient(circle at 32% 12%, rgba(255, 255, 255, 0.16) 0 2px, transparent 3px),
    linear-gradient(180deg, #a9c9ad 0%, #86ae94 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35);
}

.grass {
  position: absolute;
  top: -9px;
  width: 1px;
  height: 14px;
  background: #759e84;
  transform: rotate(12deg);
  transform-origin: bottom;
}

.grass::after {
  position: absolute;
  left: 4px;
  width: 1px;
  height: 11px;
  background: inherit;
  content: "";
  transform: rotate(-28deg);
  transform-origin: bottom;
}

.grass-one { left: 12%; }
.grass-two { left: 29%; }
.grass-three { left: 53%; }
.grass-four { left: 71%; }
.grass-five { left: 88%; }

.balloon {
  position: absolute;
  width: clamp(56px, 10vw, 72px);
  height: 128px;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -31px);
  transform-origin: 50% 31px;
  transition: filter 160ms ease;
}

.balloon:disabled {
  opacity: 1;
  cursor: default;
}

.balloon:not(:disabled):hover {
  filter: brightness(1.04) saturate(1.05);
}

.balloon--tethered {
  animation: balloon-arrive 180ms ease-out both;
}

.balloon:not(:disabled):focus-visible .balloon-body {
  outline: 3px solid rgba(22, 77, 105, 0.55);
  outline-offset: 5px;
}

.balloon-body {
  position: absolute;
  top: 0;
  left: 50%;
  width: clamp(41px, 7.2vw, 52px);
  height: clamp(53px, 9.2vw, 66px);
  border: 1px solid rgba(31, 92, 125, 0.17);
  border-radius: 51% 49% 47% 47% / 45% 45% 55% 55%;
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 255, 255, 0.72) 0 7%, transparent 17%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.28), transparent 45%),
    var(--balloon-color);
  box-shadow:
    inset -8px -9px 15px rgba(38, 115, 155, 0.14),
    0 9px 18px rgba(60, 121, 147, 0.14);
  transform: translateX(-50%);
}

.balloon-knot {
  position: absolute;
  top: clamp(50px, 8.7vw, 63px);
  left: 50%;
  width: 11px;
  height: 9px;
  background: var(--balloon-color);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  transform: translateX(-50%);
}

.balloon-string {
  position: absolute;
  top: clamp(58px, 10vw, 70px);
  left: 50%;
  width: 1px;
  height: 67px;
  background: linear-gradient(rgba(72, 91, 101, 0.58), rgba(72, 91, 101, 0.24));
  transform: translateX(-50%);
  transform-origin: top;
  transition: height 220ms ease;
}

.balloon-string::after {
  position: absolute;
  right: -3px;
  bottom: -1px;
  width: 7px;
  height: 3px;
  border-radius: 50%;
  background: rgba(68, 96, 78, 0.35);
  content: "";
}

.balloon--rising .balloon-string,
.balloon--saved .balloon-string {
  height: 38px;
  transform: translateX(-50%) rotate(3deg);
}

.balloon--rising {
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.balloon--rising .balloon-string::after,
.balloon--saved .balloon-string::after {
  display: none;
}

.balloon--rising .balloon-body,
.balloon--saved .balloon-body {
  animation: balloon-breathe 2.4s ease-in-out infinite;
}

.balloon--grace .balloon-body {
  box-shadow:
    0 0 0 7px rgba(255, 255, 255, 0.34),
    0 9px 18px rgba(60, 121, 147, 0.14);
}

.balloon--held {
  z-index: 2;
  cursor: grabbing;
}

.balloon--held::before {
  position: absolute;
  z-index: 2;
  top: -18px;
  left: 50%;
  padding: 3px 7px;
  border: 1px solid rgba(31, 84, 108, 0.2);
  border-radius: 999px;
  color: #315e73;
  background: rgba(247, 253, 254, 0.9);
  content: "HOLD";
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.52rem;
  letter-spacing: 0.12em;
  pointer-events: none;
  transform: translateX(-50%);
}

.balloon--held .balloon-body {
  animation: none;
  box-shadow:
    0 0 0 7px rgba(255, 255, 255, 0.52),
    0 0 0 9px rgba(42, 105, 133, 0.18),
    0 9px 18px rgba(60, 121, 147, 0.14);
  transform: translateX(-50%) scale(0.96);
}

.balloon--saved .balloon-body {
  box-shadow:
    0 0 0 6px rgba(255, 255, 255, 0.19),
    0 10px 22px rgba(60, 121, 147, 0.15);
}

.balloon--popped {
  pointer-events: none;
}

.balloon--popped .balloon-body,
.balloon--popped .balloon-knot,
.balloon--popped .balloon-string {
  animation: balloon-pop 420ms ease-out forwards;
}

.balloon--popped::before,
.balloon--popped::after {
  position: absolute;
  top: 23px;
  left: 50%;
  width: 48px;
  height: 2px;
  background: rgba(56, 120, 151, 0.55);
  content: "";
  animation: pop-lines 520ms ease-out forwards;
  transform: translateX(-50%);
}

.balloon--popped::after {
  transform: translateX(-50%) rotate(90deg);
}

.bird {
  position: absolute;
  width: clamp(48px, 9vw, 64px);
  aspect-ratio: 2 / 1;
  color: #436879;
  opacity: 0.88;
  transform: translate(-50%, -50%);
  transition: opacity 150ms ease;
}

.bird svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 4px 4px rgba(55, 95, 111, 0.12));
}

.bird--left svg {
  transform: scaleX(-1);
}

.bird-wing {
  animation: wing-flap 420ms ease-in-out infinite alternate;
  transform-box: fill-box;
  transform-origin: 75% 70%;
}

.bird--warning {
  width: clamp(38px, 7vw, 50px);
  opacity: 0.64;
  animation: warning-pulse 720ms ease-in-out infinite alternate;
}

.bird--warning::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 145%;
  aspect-ratio: 1;
  border: 1px solid rgba(44, 93, 116, 0.35);
  border-radius: 50%;
  content: "";
  transform: translate(-50%, -50%);
}

.overlay {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, rgba(218, 242, 252, 0.62), rgba(232, 246, 246, 0.76));
  backdrop-filter: blur(6px);
}

.overlay[hidden] {
  display: none;
}

.overlay-card {
  width: min(100%, 410px);
  padding: clamp(28px, 7vw, 46px);
  border: 1px solid rgba(52, 99, 119, 0.16);
  border-radius: 24px;
  background: rgba(249, 253, 251, 0.88);
  box-shadow: 0 24px 55px rgba(50, 91, 109, 0.13);
  text-align: center;
}

.overlay-card h2 {
  margin: 8px 0 15px;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(1.65rem, 6vw, 2.55rem);
  font-weight: 500;
  letter-spacing: 0.07em;
}

.overlay-card > p:not(.overlay-kicker):not(.result-score) {
  margin: 0;
  color: var(--soft-ink);
  font-size: clamp(0.82rem, 2.7vw, 0.96rem);
  line-height: 1.9;
}

.primary-button {
  min-width: 178px;
  margin-top: 25px;
  padding: 13px 22px;
  border: 1px solid #244f65;
  border-radius: 999px;
  color: #f8fcfc;
  background: #244f65;
  box-shadow: 0 8px 18px rgba(36, 79, 101, 0.16);
  cursor: pointer;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  transition: background 150ms ease, transform 150ms ease;
}

.primary-button:hover {
  background: #173f54;
  transform: translateY(-1px);
}

.primary-button:disabled {
  color: rgba(248, 252, 252, 0.78);
  background: #6d8794;
  cursor: default;
  transform: none;
}

.primary-button:focus-visible {
  outline: 3px solid rgba(36, 79, 101, 0.28);
  outline-offset: 4px;
}

.result-score {
  margin: 3px 0 0;
  color: #2e6986;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(2.8rem, 13vw, 5.2rem);
  font-weight: 300;
  letter-spacing: -0.08em;
  line-height: 1;
}

#result-panel {
  cursor: pointer;
}

#result-panel.overlay--locked {
  cursor: default;
}

.result-hint {
  margin-top: 13px !important;
  color: rgba(86, 114, 130, 0.72) !important;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.62rem !important;
  letter-spacing: 0.08em;
}

.game-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  min-height: 58px;
  padding: 14px 5px 0;
  color: var(--soft-ink);
  font-size: 0.78rem;
  line-height: 1.6;
}

.game-footer p {
  margin: 0;
}

.game-status {
  max-width: 68%;
}

.game-tools {
  display: grid;
  flex: 0 0 auto;
  justify-items: end;
  gap: 6px;
}

.control-hint {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-align: right;
}

.reset-score-button {
  padding: 2px 0;
  border: 0;
  border-bottom: 1px solid rgba(86, 114, 130, 0.35);
  color: var(--soft-ink);
  background: transparent;
  cursor: pointer;
  font-size: 0.67rem;
}

.reset-score-button:hover,
.reset-score-button:focus-visible {
  color: var(--ink);
  border-bottom-color: rgba(23, 54, 75, 0.62);
}

.reset-score-button:focus-visible {
  outline: 2px solid rgba(36, 79, 101, 0.24);
  outline-offset: 3px;
}

.reset-score-button:disabled {
  color: rgba(86, 114, 130, 0.42);
  border-bottom-color: transparent;
  cursor: default;
}

@keyframes balloon-breathe {
  from { transform: translateX(-50%) rotate(-1.3deg); }
  50% { transform: translateX(-50%) translateY(-2px) rotate(1.3deg); }
  to { transform: translateX(-50%) rotate(-1.3deg); }
}

@keyframes balloon-arrive {
  from { opacity: 0; transform: translate(-50%, -22px) scale(0.88); }
  to { opacity: 1; transform: translate(-50%, -31px) scale(1); }
}

@keyframes balloon-pop {
  0% { opacity: 1; transform: translateX(-50%) scale(1); }
  35% { opacity: 1; transform: translateX(-50%) scale(1.14); }
  100% { opacity: 0; transform: translateX(-50%) scale(0.08); }
}

@keyframes pop-lines {
  from { opacity: 0.8; clip-path: inset(0 44%); }
  to { opacity: 0; clip-path: inset(0 0); transform: translateX(-50%) scale(1.8); }
}

@keyframes wing-flap {
  from { transform: rotate(-8deg); }
  to { transform: rotate(13deg); }
}

@keyframes warning-pulse {
  from { opacity: 0.38; transform: translate(-50%, -50%) scale(0.94); }
  to { opacity: 0.8; transform: translate(-50%, -50%) scale(1.04); }
}

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 20px, 680px);
    padding-top: 12px;
  }

  .topbar {
    margin-bottom: 10px;
  }

  .game-heading {
    padding-inline: 3px;
  }

  .scoreboard {
    gap: 14px;
  }

  .game-board {
    border-radius: 21px;
  }

  .balloon {
    height: 110px;
    transform: translate(-50%, -27px);
  }

  .balloon--tethered {
    animation-name: balloon-arrive-mobile;
  }

  .balloon-string {
    height: 47px;
  }

  .game-footer {
    display: block;
  }

  .game-status {
    max-width: none;
    min-height: 40px;
  }

  .control-hint {
    margin-top: 5px !important;
    text-align: left;
  }

  .game-tools {
    justify-items: start;
  }
}

@keyframes balloon-arrive-mobile {
  from { opacity: 0; transform: translate(-50%, -19px) scale(0.88); }
  to { opacity: 1; transform: translate(-50%, -27px) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
