: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,
.message-toast,
.screen-card,
.briefing-card,
.garden-rewards {
  position: absolute;
  z-index: 2;
}

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

.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);
}

.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%;
}

.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: 49%;
  left: 50%;
  width: min(42vw, 320px);
  height: 48px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-75%, -50%) rotate(17deg);
  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));
}

.message-toast {
  bottom: max(26px, env(safe-area-inset-bottom));
  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%;
  }
}

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

  .shield-panel {
    right: 230px;
  }

  .title-card,
  .screen-card {
    top: 57%;
    padding: 19px 26px;
  }

  h1 {
    font-size: 2.35rem;
  }

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

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