:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --ink: #183045;
  --paper: rgba(255, 255, 255, 0.92);
  --line: rgba(24, 48, 69, 0.16);
  --red: #d93c32;
  --yellow: #ffc52f;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #66c6ee;
  touch-action: none;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 360px;
  overflow: hidden;
  isolation: isolate;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
  touch-action: none;
}

#game.is-aiming {
  cursor: grabbing;
}

.hud {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 82px;
  padding: max(14px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
  pointer-events: none;
  background: linear-gradient(180deg, rgba(16, 48, 69, 0.28), transparent);
}

.brand,
.scoreboard,
.toolbar {
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: white;
  filter: drop-shadow(0 2px 0 rgba(20, 50, 64, 0.25));
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.88);
  border-radius: 50%;
  background: var(--red);
  color: white;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  transform: rotate(-7deg);
}

.brand-copy {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0;
}

.scoreboard {
  justify-self: center;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 7px 24px rgba(28, 91, 118, 0.14);
  color: var(--ink);
  backdrop-filter: blur(10px);
}

.score-label {
  color: #577183;
  font-size: 12px;
  font-weight: 700;
}

.scoreboard strong {
  min-width: 65px;
  font-size: 21px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

#targets {
  min-width: 14px;
}

.score-divider {
  width: 1px;
  height: 21px;
  margin: 0 3px;
  background: var(--line);
}

.toolbar {
  display: flex;
  gap: 8px;
}

.icon-btn,
.power-btn {
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: white;
  background: rgba(24, 48, 69, 0.4);
  box-shadow: 0 5px 16px rgba(20, 55, 72, 0.12);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, opacity 150ms ease;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.icon-btn svg,
.power-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.5;
}

.icon-btn:hover,
.power-btn:hover {
  transform: translateY(-2px);
  background: rgba(24, 48, 69, 0.58);
}

.icon-btn:active,
.power-btn:active {
  transform: translateY(0) scale(0.95);
}

.icon-btn:focus-visible,
.power-btn:focus-visible,
.primary-btn:focus-visible {
  outline: 3px solid white;
  outline-offset: 3px;
}

.bird-tray {
  position: absolute;
  z-index: 4;
  left: max(20px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  text-shadow: 0 2px 2px rgba(24, 48, 69, 0.34);
  pointer-events: none;
}

.bird-tray-label {
  font-size: 12px;
  font-weight: 800;
}

.bird-lives {
  display: flex;
  gap: 3px;
}

.bird-life {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 2px 1px rgba(24, 48, 69, 0.24));
  transition: opacity 180ms ease, transform 180ms ease;
}

.bird-life.used {
  opacity: 0.24;
  transform: scale(0.74);
  filter: grayscale(1);
}

.power-btn {
  position: absolute;
  z-index: 5;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: #f4ad20;
  color: #503400;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.74);
}

.power-btn.is-ready {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
  animation: power-pulse 1.1s ease-in-out infinite alternate;
}

.power-btn.is-used {
  opacity: 0;
  pointer-events: none;
}

.hint {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 7px;
  background: rgba(24, 48, 69, 0.42);
  color: white;
  font-size: 13px;
  font-weight: 700;
  backdrop-filter: blur(8px);
  transform: translateX(-50%);
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none;
}

.hint.is-hidden {
  opacity: 0;
  transform: translate(-50%, 8px);
}

.hint-hand {
  display: grid;
  place-items: center;
}

.hint-hand svg {
  width: 17px;
  height: 17px;
}

.result[hidden] {
  display: none;
}

.result {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(21, 43, 56, 0.4);
  backdrop-filter: blur(7px);
  animation: result-in 260ms ease-out both;
}

.result-panel {
  width: min(390px, calc(100vw - 40px));
  padding: 34px 32px 30px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 64px rgba(18, 51, 68, 0.28);
  color: var(--ink);
  text-align: center;
}

.stars {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 4px;
  height: 58px;
  margin-bottom: 8px;
}

.stars svg {
  width: 45px;
  height: 45px;
  color: #bec8ce;
  fill: #e4e8ea;
  stroke-width: 1.5;
}

.stars svg:nth-child(2) {
  width: 58px;
  height: 58px;
}

.stars svg.is-earned {
  color: #f0a800;
  fill: #ffc52f;
  animation: star-pop 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.stars svg:nth-child(2).is-earned {
  animation-delay: 120ms;
}

.stars svg:nth-child(3).is-earned {
  animation-delay: 240ms;
}

.result-eyebrow {
  margin: 0 0 5px;
  color: #718593;
  font-size: 12px;
  font-weight: 800;
}

.result h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.2;
  letter-spacing: 0;
}

.final-score {
  margin: 13px 0 24px;
  color: #607786;
}

.final-score strong {
  color: var(--red);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.primary-btn {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 22px;
  border: 0;
  border-radius: 7px;
  background: var(--red);
  box-shadow: 0 5px 0 #a82924;
  color: white;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 0 #a82924;
}

.primary-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #a82924;
}

.primary-btn svg {
  width: 19px;
  height: 19px;
}

.rotate-notice {
  display: none;
}

@keyframes power-pulse {
  from { box-shadow: 0 5px 16px rgba(20, 55, 72, 0.12), 0 0 0 0 rgba(255, 197, 47, 0.42); }
  to { box-shadow: 0 5px 16px rgba(20, 55, 72, 0.12), 0 0 0 10px rgba(255, 197, 47, 0); }
}

@keyframes result-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes star-pop {
  0% { transform: scale(0.35) rotate(-18deg); }
  70% { transform: scale(1.16) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}

@media (max-width: 720px) {
  .hud {
    min-height: 66px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .brand-copy,
  .score-label,
  .score-divider,
  .fullscreen-control {
    display: none;
  }

  .brand-mark,
  .icon-btn {
    width: 38px;
    height: 38px;
  }

  .brand-mark {
    font-size: 21px;
  }

  .scoreboard {
    min-height: 38px;
    padding: 7px 11px;
  }

  .scoreboard strong {
    min-width: 57px;
    font-size: 18px;
  }

  #targets {
    display: none;
  }

  .hint {
    bottom: max(58px, calc(env(safe-area-inset-bottom) + 46px));
    font-size: 12px;
  }

  .bird-tray {
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .bird-tray-label {
    display: none;
  }

  .bird-life {
    width: 24px;
    height: 24px;
  }

  .power-btn {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    width: 50px;
    height: 50px;
  }
}

@media (orientation: portrait) and (max-width: 600px) {
  .rotate-notice {
    position: absolute;
    z-index: 6;
    top: 74px;
    left: 50%;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border-radius: 6px;
    background: rgba(24, 48, 69, 0.45);
    color: white;
    font-size: 12px;
    font-weight: 700;
    transform: translateX(-50%);
    pointer-events: none;
  }

  .rotate-notice svg {
    width: 15px;
    height: 15px;
    transform: rotate(90deg);
  }
}

@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;
  }
}
