:root {
  color: #214538;
  background: #f4fafc;
  font-family: "Avenir Next Rounded", "Nunito", "Avenir Next", ui-rounded, system-ui, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 0;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: linear-gradient(145deg, #f4fafc 10%, #ddf3ff 58%, #fef9e7 100%);
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 4px solid #214538;
  outline-offset: 3px;
}

#game-shell {
  position: relative;
  isolation: isolate;
  width: 100vw;
  min-height: 100svh;
  overflow: hidden;
  background: linear-gradient(180deg, #ddf3ff 0%, #f4fafc 48%, #ddf4d8 100%);
}

#game-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

.game-hud,
.guide-line,
.tap-coach,
.movement-cue,
.message-toast,
.screen-card,
.briefing-card,
.garden-rewards {
  position: absolute;
  z-index: 2;
}

.game-hud {
  inset: 0;
  pointer-events: none;
}

.hud-card,
.tool-button {
  transition: opacity 180ms ease, transform 180ms ease;
}

#game-shell.is-title .progress-panel,
#game-shell.is-title .timer-panel,
#game-shell.is-title .shield-panel,
#game-shell.is-title #pause-button {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.96);
}

#game-shell.is-title .timer-panel {
  transform: translate(-50%, -8px) scale(0.96);
}

.hud-card {
  position: absolute;
  display: grid;
  gap: 5px;
  min-height: 54px;
  padding: 9px 12px;
  border: 1px solid rgba(33, 69, 56, 0.13);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 26px rgba(53, 111, 97, 0.11);
  backdrop-filter: blur(10px);
}

.progress-panel {
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
}

.timer-panel {
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  min-height: 0;
  padding: 5px;
  transform: translateX(-50%);
  border-radius: 50%;
}

.shield-panel {
  top: max(14px, env(safe-area-inset-top));
  right: 92px;
}

.hud-kicker,
.eyebrow,
.tiny-note {
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.hud-kicker {
  font-size: clamp(0.62rem, 1.2vw, 0.75rem);
  color: #37715c;
}

.petal-row,
.shield-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.petal {
  width: 23px;
  height: 23px;
  border: 2px solid #247a45;
  border-radius: 52% 48% 52% 48%;
  background: #fff;
  transform: rotate(45deg);
  transition: background 170ms ease, box-shadow 170ms ease, transform 170ms ease;
}

.petal.is-filled {
  background: #ffc94f;
  box-shadow: 0 0 0 3px rgba(255, 201, 79, 0.25);
  transform: rotate(45deg) scale(1.08);
}

.petal.is-filled.is-rewarding {
  animation: feed-petal-pop 700ms cubic-bezier(0.18, 0.86, 0.25, 1) both;
}

.petal.is-filled.is-rewarding-static {
  outline: 3px solid rgba(255, 246, 173, 0.96);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(255, 201, 79, 0.3);
}

@keyframes feed-petal-pop {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 201, 79, 0.62);
    transform: rotate(45deg) scale(0.58);
  }

  38% {
    box-shadow: 0 0 0 9px rgba(255, 201, 79, 0.3);
    transform: rotate(45deg) scale(1.42);
  }

  68% {
    box-shadow: 0 0 0 5px rgba(255, 201, 79, 0.18);
    transform: rotate(45deg) scale(0.98);
  }

  100% {
    box-shadow: 0 0 0 3px rgba(255, 201, 79, 0.25);
    transform: rotate(45deg) scale(1.08);
  }
}

.timer-ring {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#72d8f4 var(--timer-angle), #e5f0ec 0deg);
  box-shadow: inset 0 0 0 2px rgba(33, 69, 56, 0.11);
}

.timer-ring::before {
  grid-area: 1 / 1;
  width: 51px;
  height: 51px;
  border-radius: inherit;
  background: #fff;
  content: "";
}

.timer-ring span {
  z-index: 1;
  grid-area: 1 / 1;
  width: 43px;
  color: #214538;
  font-size: 0.63rem;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
}

.shield-row {
  gap: 7px;
}

.shield-leaf {
  width: 22px;
  height: 16px;
  border: 2px solid #247a45;
  border-radius: 100% 0 100% 0;
  background: #4dbb5b;
  box-shadow: inset -3px 2px 0 rgba(255, 255, 255, 0.3);
  transform: rotate(-25deg);
  transition: opacity 170ms ease, filter 170ms ease, transform 170ms ease;
}

.shield-leaf.is-lost {
  opacity: 0.24;
  filter: grayscale(1);
  transform: rotate(-25deg) scale(0.82);
}

.toolbar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.tool-button {
  width: 64px;
  min-width: 64px;
  height: 64px;
  min-height: 64px;
  padding: 4px;
  border: 2px solid rgba(33, 69, 56, 0.21);
  border-radius: 20px;
  color: #214538;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 7px 18px rgba(53, 111, 97, 0.12);
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1.05;
  transition: transform 140ms ease, background 140ms ease;
}

.tool-button[aria-pressed="true"] {
  background: #d7f1de;
}

.tool-button:active,
.primary-button:active,
.replay-button:active {
  transform: translateY(2px) scale(0.98);
}

.screen-card,
.briefing-card {
  left: 50%;
  width: min(440px, calc(100vw - 32px));
  padding: clamp(24px, 4vw, 34px);
  border: 1px solid rgba(33, 69, 56, 0.13);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 60px rgba(57, 111, 94, 0.2);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -45%) scale(0.96);
  transition: opacity 180ms ease, transform 180ms ease;
}

.screen-card {
  top: 52%;
}

.screen-card.is-visible,
.briefing-card.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.title-card {
  top: 55%;
}

.visual-rule {
  display: grid;
  grid-template-columns: 1fr 1px 0.72fr;
  align-items: center;
  gap: 18px;
  width: min(340px, 100%);
  min-height: 88px;
  margin: 2px auto 14px;
  padding: 12px 16px;
  border: 1px solid rgba(33, 69, 56, 0.12);
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(229, 249, 220, 0.86), rgba(255, 248, 212, 0.9));
  box-shadow: inset 0 -4px 0 rgba(54, 126, 76, 0.07);
}

.rule-catch,
.rule-avoid {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
}

.rule-divider {
  width: 1px;
  height: 58px;
  background: rgba(33, 69, 56, 0.14);
}

.rule-fly,
.rule-wrong-bug {
  position: relative;
  display: block;
  width: 24px;
  height: 36px;
  border-radius: 50% 50% 44% 44%;
  box-shadow: 0 3px 0 rgba(33, 69, 56, 0.15);
}

.rule-fly {
  z-index: 2;
  border: 3px solid #7d5c13;
  background: #ffc94f;
  transform: rotate(-18deg);
  box-shadow: 0 0 0 8px rgba(114, 216, 244, 0.2), 0 3px 0 rgba(33, 69, 56, 0.15);
}

.rule-fly::before,
.rule-fly::after,
.rule-wrong-bug::before,
.rule-wrong-bug::after {
  position: absolute;
  content: "";
}

.rule-fly::before,
.rule-fly::after {
  top: 5px;
  width: 22px;
  height: 15px;
  border: 2px solid #458ca0;
  border-radius: 70% 30% 70% 30%;
  background: rgba(173, 237, 249, 0.95);
}

.rule-fly::before {
  right: 15px;
  transform: rotate(24deg);
}

.rule-fly::after {
  left: 15px;
  transform: scaleX(-1) rotate(24deg);
}

.rule-arrow {
  width: 34px;
  height: 8px;
  margin: 0 8px 0 14px;
  border-radius: 999px;
  background: #e0ad2f;
}

.rule-arrow::after {
  display: block;
  width: 15px;
  height: 15px;
  margin: -4px 0 0 20px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 12px solid #e0ad2f;
  content: "";
}

.rule-trap {
  position: relative;
  display: block;
  width: 54px;
  height: 52px;
  transform: rotate(-5deg);
}

.rule-trap::before,
.rule-trap::after {
  position: absolute;
  left: 1px;
  width: 52px;
  height: 24px;
  border: 5px solid #2b9148;
  background: #f36f9f;
  content: "";
}

.rule-trap::before {
  top: 1px;
  border-radius: 70% 70% 20% 20%;
  transform: rotate(-8deg);
}

.rule-trap::after {
  bottom: 1px;
  border-radius: 20% 20% 70% 70%;
  transform: rotate(8deg);
}

.rule-avoid {
  gap: 8px;
}

.rule-wrong-bug {
  width: 25px;
  height: 31px;
  border: 3px solid #5c416c;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.22), 0 3px 0 rgba(33, 69, 56, 0.15);
}

.rule-wrong-bug-purple {
  width: 32px;
  height: 24px;
  border-radius: 52% 52% 43% 43%;
  background: #9d78d6;
  transform: rotate(-14deg);
}

.rule-wrong-bug-coral {
  width: 22px;
  height: 35px;
  border-radius: 54% 54% 62% 62% / 40% 40% 70% 70%;
  background: #f28b73;
  transform: rotate(14deg);
}

.rule-wrong-bug::before {
  top: -11px;
  left: 50%;
  width: 22px;
  height: 15px;
  border-right: 3px solid #5c416c;
  border-left: 3px solid #5c416c;
  border-radius: 50% 50% 0 0;
  transform: translateX(-50%);
}

.rule-wrong-bug::after {
  top: 3px;
  left: -10px;
  width: calc(100% + 20px);
  height: calc(100% - 2px);
  background:
    linear-gradient(28deg, transparent 43%, #5c416c 44% 51%, transparent 52%) 0 0 / 50% 50% no-repeat,
    linear-gradient(-28deg, transparent 43%, #5c416c 44% 51%, transparent 52%) 100% 0 / 50% 50% no-repeat,
    linear-gradient(-28deg, transparent 43%, #5c416c 44% 51%, transparent 52%) 0 100% / 50% 50% no-repeat,
    linear-gradient(28deg, transparent 43%, #5c416c 44% 51%, transparent 52%) 100% 100% / 50% 50% no-repeat;
}

.rule-no {
  position: absolute;
  inset: 3px 8px;
  z-index: 2;
  border: 5px solid #d9514b;
  border-radius: 50%;
  filter: drop-shadow(0 2px 0 white);
}

.rule-no::after {
  position: absolute;
  top: 21px;
  left: -1px;
  width: 56px;
  height: 5px;
  border-radius: 999px;
  background: #d9514b;
  content: "";
  transform: rotate(-42deg);
  transform-origin: center;
}

.title-rule-copy strong {
  color: #17663d;
}

.compact-card {
  max-width: 390px;
}

.briefing-card {
  top: 22%;
  width: min(330px, calc(100vw - 32px));
  padding: 14px 20px;
  border-radius: 22px;
  box-shadow: 0 12px 32px rgba(57, 111, 94, 0.14);
}

.eyebrow {
  margin: 0 0 8px;
  color: #247a45;
  font-size: 0.73rem;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  color: #214538;
  letter-spacing: -0.035em;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.35rem, 6vw, 4.25rem);
  line-height: 0.92;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.75rem, 4vw, 2.45rem);
  line-height: 0.98;
}

.screen-card p:not(.eyebrow):not(.tiny-note),
.briefing-card p:not(.eyebrow) {
  margin-bottom: 20px;
  color: #376253;
  font-size: clamp(1rem, 2vw, 1.13rem);
  font-weight: 650;
  line-height: 1.42;
}

.tiny-note {
  margin: 14px 0 0;
  color: #578373;
  font-size: 0.67rem;
}

.primary-button,
.replay-button {
  min-width: min(300px, 100%);
  min-height: 68px;
  padding: 13px 26px;
  border: 0;
  border-radius: 22px;
  color: #214538;
  background: linear-gradient(135deg, #ffc94f, #ffd978);
  box-shadow: 0 8px 0 #d69d23, 0 16px 28px rgba(214, 157, 35, 0.23);
  font-size: clamp(1.06rem, 2.3vw, 1.22rem);
  font-weight: 900;
  transition: transform 140ms ease, filter 140ms ease;
}

.primary-button:hover,
.replay-button:hover {
  filter: brightness(1.04);
}

.guide-line {
  top: 0;
  left: 0;
  width: 0;
  height: 48px;
  opacity: 0;
  pointer-events: none;
  transform-origin: 0 0;
  transition: opacity 180ms ease;
}

.guide-line.is-visible {
  opacity: 1;
}

.guide-line span {
  display: block;
  width: 100%;
  height: 100%;
  border-top: 5px dotted rgba(255, 201, 79, 0.88);
  filter: drop-shadow(0 2px 0 rgba(33, 69, 56, 0.12));
}

.tap-coach {
  top: 0;
  left: 0;
  width: 84px;
  height: 84px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 160ms ease;
}

.tap-coach.is-visible {
  opacity: 1;
}

.tap-coach-ring {
  position: absolute;
  inset: 5px;
  border: 5px solid rgba(255, 222, 84, 0.95);
  border-radius: 50%;
  box-shadow: 0 0 0 7px rgba(114, 216, 244, 0.28), 0 5px 16px rgba(33, 69, 56, 0.18);
  animation: tap-coach-pulse 760ms ease-in-out infinite;
}

.tap-coach-pointer {
  position: absolute;
  right: 2px;
  bottom: -4px;
  width: 24px;
  height: 42px;
  border: 4px solid #214538;
  border-radius: 15px 15px 18px 18px;
  background: #fff4d2;
  box-shadow: 0 4px 0 rgba(33, 69, 56, 0.18);
  transform: rotate(-28deg);
  animation: tap-coach-press 760ms ease-in-out infinite;
}

@keyframes tap-coach-pulse {
  0%, 100% { transform: scale(1); opacity: 0.78; }
  52% { transform: scale(0.78); opacity: 1; }
}

@keyframes tap-coach-press {
  0%, 100% { transform: translate(4px, 8px) rotate(-28deg); }
  52% { transform: translate(-5px, -5px) rotate(-28deg); }
}

.movement-cue {
  bottom: max(22px, env(safe-area-inset-bottom));
  left: max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 11px;
  max-width: min(360px, calc(100vw - 118px));
  padding: 9px 14px 9px 10px;
  border: 1px solid rgba(33, 69, 56, 0.16);
  border-radius: 19px;
  color: #214538;
  background: rgba(255, 255, 255, 0.91);
  box-shadow: 0 10px 26px rgba(53, 111, 97, 0.15);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.97);
  transition: opacity 180ms ease, transform 180ms ease;
}

.movement-cue.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.movement-cue.is-demonstrated {
  opacity: 0;
  transform: translateY(8px) scale(0.96);
}

.movement-cue-keys {
  display: flex;
  gap: 4px;
}

.movement-cue-keys b {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 2px solid #2d7653;
  border-radius: 10px;
  color: #1f6647;
  background: #e4f6dc;
  box-shadow: 0 3px 0 rgba(33, 69, 56, 0.2);
  font-size: 1rem;
  line-height: 1;
  transition: color 110ms ease, background 110ms ease, box-shadow 110ms ease, transform 110ms ease;
}

.movement-cue-keys b.is-input-active {
  color: #214538;
  background: #ffd865;
  box-shadow: 0 1px 0 rgba(33, 69, 56, 0.28), 0 0 0 4px rgba(255, 201, 79, 0.24);
  transform: translateY(2px) scale(0.95);
}

.movement-cue strong,
.movement-cue small {
  display: block;
}

.movement-cue strong {
  font-size: 0.82rem;
  line-height: 1.1;
}

.movement-cue small {
  margin-top: 2px;
  color: #37715c;
  font-size: 0.67rem;
  font-weight: 750;
  line-height: 1.15;
}

.message-toast {
  bottom: max(84px, calc(env(safe-area-inset-bottom) + 76px));
  left: 50%;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  color: #214538;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 20px rgba(53, 111, 97, 0.12);
  font-weight: 850;
  opacity: 0;
  transform: translate(-50%, 14px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.message-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.garden-rewards {
  right: 20px;
  bottom: 18px;
  display: flex;
  gap: 9px;
  pointer-events: none;
}

.garden-flower {
  position: relative;
  width: 27px;
  height: 27px;
  border: 2px solid #247a45;
  border-radius: 50%;
  background: #fff;
  opacity: 0.42;
  transition: background 180ms ease, opacity 180ms ease, transform 180ms ease;
}

.garden-flower::before,
.garden-flower::after {
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: #f05a9a;
  content: "";
}

.garden-flower::after {
  inset: 10px;
  background: #ffc94f;
}

.garden-flower.is-earned {
  background: #72d8f4;
  opacity: 1;
  transform: scale(1.12);
}

.replay-buttons {
  display: grid;
  gap: 12px;
}

.replay-button {
  min-width: 0;
  min-height: 58px;
  border-radius: 18px;
  box-shadow: 0 6px 0 #d69d23, 0 10px 20px rgba(214, 157, 35, 0.18);
  font-size: 1rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 620px) {
  .progress-panel {
    width: 126px;
    padding: 8px 9px;
  }

  .petal {
    width: 18px;
    height: 18px;
  }

  .shield-panel {
    top: 89px;
    right: 14px;
  }

  .timer-panel {
    top: 89px;
    left: 14px;
    transform: none;
  }

  .timer-ring {
    width: 58px;
    height: 58px;
  }

  .timer-ring::before {
    width: 43px;
    height: 43px;
  }

  .timer-ring span {
    font-size: 0.56rem;
  }

  .guide-line {
    top: 54%;
  }

  .movement-cue {
    max-width: calc(100vw - 102px);
    padding: 7px 10px 7px 8px;
  }

  .movement-cue-keys b {
    width: 26px;
    height: 26px;
  }

  .movement-cue small {
    font-size: 0.61rem;
  }
}

@media (max-width: 620px) and (orientation: portrait) {
  .timer-panel {
    top: max(14px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
  }

  .shield-panel {
    top: max(82px, calc(env(safe-area-inset-top) + 68px));
    right: auto;
    left: max(14px, env(safe-area-inset-left));
  }

  .movement-cue {
    max-width: calc(100vw - 144px);
  }

  .movement-cue small {
    display: none;
  }

  .message-toast {
    bottom: max(96px, calc(env(safe-area-inset-bottom) + 88px));
    width: max-content;
    max-width: calc(100vw - 36px);
    text-align: center;
  }

  .garden-rewards {
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .toolbar {
    flex-direction: row;
  }

  .shield-panel {
    right: 230px;
  }

  .title-card,
  .screen-card {
    top: 58%;
    padding: 15px 24px 17px;
  }

  .title-card h1 {
    margin-bottom: 8px;
    font-size: clamp(1.9rem, 5.2vw, 2.2rem);
    line-height: 1;
  }

  .title-card p:not(.eyebrow):not(.tiny-note) {
    margin-bottom: 13px;
    font-size: 0.98rem;
    line-height: 1.28;
  }

  .visual-rule {
    min-height: 66px;
    margin-bottom: 8px;
    padding: 6px 12px;
  }

  .rule-catch,
  .rule-avoid {
    min-height: 50px;
    transform: scale(0.86);
  }

  .title-card .tiny-note {
    margin-top: 11px;
  }

  .primary-button {
    min-height: 58px;
  }

  .movement-cue {
    bottom: max(10px, env(safe-area-inset-bottom));
    max-width: 310px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }

  .movement-cue-keys b.is-input-active {
    transform: none;
  }

  .petal.is-filled.is-rewarding {
    animation: none;
  }
}

.game-shell.is-reduced-motion .petal.is-filled.is-rewarding {
  animation: none;
}
