:root {
  --night: #1f3a1d;
  --panel: #fbf4e2;
  --ink: #2b2a1f;
  --leaf: #2f6b2c;
  --grass: #8cc761;
  --pink: #ff8fc0;
  --gold: #ffd25a;
  --soil: #6b4a2b;
  --display: "Lilita One", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--night);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- HUD ---------- */

#hud {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(#2c5228, #234320);
  box-shadow: 0 2px 0 #142812, 0 4px 14px rgba(0, 0, 0, 0.35);
  position: relative;
  z-index: 2;
  color: #f4f8e8;
}

.brand {
  font-family: var(--display);
  font-size: 22px;
  color: var(--gold);
  text-shadow: 0 2px 0 #7a4b12;
  white-space: nowrap;
  margin-right: 4px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
  font-family: var(--display);
  font-size: 18px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.stat small {
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.65;
}
.stat.score { margin-left: auto; }
.stat.lives.hit { animation: hit 0.45s ease-out; }
.stat.lives.last span { color: #ff8a7a; }
@keyframes hit { 30% { transform: scale(1.25); background: rgba(220, 60, 50, 0.6); } }

.heart {
  width: 16px; height: 14px;
  background: #ff6f8a;
  clip-path: path("M8 14 L1.5 7.5 A3.6 3.6 0 0 1 8 2.8 A3.6 3.6 0 0 1 14.5 7.5 Z");
}

.claimed #pctLabel { min-width: 2.6em; text-align: right; }
.meter {
  position: relative;
  width: 74px;
  height: 10px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.meter b {
  position: absolute; inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, #7fd36a, var(--pink));
  transition: width 0.3s ease-out;
}
.meter em {
  position: absolute; top: 0; bottom: 0; left: 75%;
  width: 2px;
  background: #fff;
  opacity: 0.85;
}

.turn {
  flex: none;
  width: 44px; height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--panel);
  color: var(--leaf);
  box-shadow: 0 3px 0 #b9ab85;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.turn svg {
  width: 26px; height: 26px;
  fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.15s ease-out;
}
.turn.v svg { transform: rotate(90deg); }
.turn:active { transform: translateY(2px); box-shadow: 0 1px 0 #b9ab85; }

@media (max-width: 620px) {
  .brand { display: none; }
  #hud { gap: 6px; padding: 6px 8px; }
  .stat { padding: 4px 8px; font-size: 16px; }
  .stat small { display: none; }
  .meter { width: 44px; }
}
@media (max-width: 360px) {
  .meter { display: none; }
}

/* ---------- stage ---------- */

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
#game.h { cursor: ew-resize; }
#game.v { cursor: ns-resize; }

/* ---------- overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(18, 34, 16, 0.55);
  backdrop-filter: blur(2px);
  overflow-y: auto;
}
.overlay[hidden] { display: none; }
.overlay:not([hidden]) { animation: fade-in 0.3s ease-out; }
.overlay:not([hidden]) .card { animation: card-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes card-in { from { transform: translateY(14px) scale(0.96); } }

.card {
  width: min(440px, 100%);
  padding: 24px 26px 20px;
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 6px 0 #c9b98f, 0 18px 40px rgba(0, 0, 0, 0.4);
  text-align: center;
}
.card h1, .card h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-weight: 400;
  color: var(--leaf);
  letter-spacing: 0.01em;
}
.card h1 { font-size: 46px; }
.card h2 { font-size: 34px; }
.lede { margin: 0 0 16px; font-size: 17px; }

.rules {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  text-align: left;
  display: grid;
  gap: 10px;
  font-size: 15px;
  line-height: 1.35;
}
.rules li { display: flex; gap: 12px; align-items: center; }
.ico { flex: none; width: 34px; height: 34px; border-radius: 9px; background: var(--grass); position: relative; }
.ico.hedge::after { content: ""; position: absolute; left: 13px; top: 2px; bottom: 2px; width: 8px; border-radius: 4px; background: var(--leaf); }
.ico.bunny::after {
  content: ""; position: absolute; left: 8px; top: 13px; width: 18px; height: 13px; border-radius: 50%; background: #f4efe6;
  box-shadow: 9px -6px 0 -2px #f4efe6;
}
.ico.bunny::before { content: ""; position: absolute; left: 17px; top: 3px; width: 4px; height: 11px; border-radius: 3px; background: #f4efe6; transform: rotate(-12deg); }
.ico.bloom { background: #4f8f3e; }
.ico.bloom::after {
  content: ""; position: absolute; left: 7px; top: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--pink);
  box-shadow: 12px 4px 0 var(--gold), 4px 13px 0 #fff, 15px 15px 0 #c79bff;
}

.primary {
  font-family: var(--display);
  font-size: 22px;
  padding: 10px 40px;
  border: 0;
  border-radius: 14px;
  background: var(--leaf);
  color: #fff;
  box-shadow: 0 4px 0 #1a3f18;
  cursor: pointer;
}
.primary:hover { filter: brightness(1.1); }
.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #1a3f18; }

.keys { margin: 14px 0 0; font-size: 13px; opacity: 0.7; line-height: 1.4; }

.results {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 18px;
  margin: 10px 0 18px;
  font-size: 17px;
  text-align: left;
}
.results dt { opacity: 0.75; }
.results dd { margin: 0; font-family: var(--display); font-size: 20px; text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  margin: 0 0 4px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--gold);
  font-family: var(--display);
  font-size: 16px;
}
.badge[hidden] { display: none; }
