:root {
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
  --font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  --bg: #1f2f66;
  --ink: #183a26;
  --muted: #4f6b5a;
  --panel: #ffffff;
  --panel-edge: #2f7d3f;
  --shadow: #1f5a2c;
  --title-shadow: #f4cfd5;
  --small-frog: #fdecee;
  --big-frog: #e4f3e6;
  --accent: #d7263d;
  --accent-edge: #9b1628;
  --accent-ink: #ffffff;
  --good: #23863a;
  --bad: #c43a2f;
  --hud-bg: #ffffff;
  --hud-ink: #183a26;
  --scrim: rgba(8, 14, 40, 0.38);
  --sky-top: #1f2f66;
  --sky-bottom: #7f8fd2;
  --hill: #dbe6f4;
  --grass-top: #f7fbff;
  --grass-bottom: #cddbee;
  --tuft: #b7c9e2;
  --water: #bfe2f3;
  --water-shine: rgba(255, 255, 255, 0.9);
  --pad: #8fb9d4;
  --cloud: rgba(225, 232, 255, 0.35);
  --sun: #f7f3da;
  --sun-glow: rgba(247, 243, 218, 0.28);
  --sun-glow-end: rgba(247, 243, 218, 0);
  --text-stroke: #ffffff;
  --night: 1;
  --tree: #1f5f3d;
  --tree-dark: #164a2f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #070b24;
    --ink: #eef0ff;
    --muted: #aab2d8;
    --panel: #1d2346;
    --panel-edge: #74d184;
    --shadow: #090d22;
    --title-shadow: #0c1129;
    --small-frog: rgba(215, 38, 61, 0.16);
    --big-frog: rgba(63, 157, 85, 0.2);
    --accent: #ff5a6e;
    --accent-edge: #a3182c;
    --accent-ink: #ffffff;
    --good: #82e08f;
    --bad: #ff8f84;
    --hud-bg: #1d2346;
    --hud-ink: #eef0ff;
    --scrim: rgba(5, 8, 25, 0.45);
    --sky-top: #070b24;
    --sky-bottom: #2b2a5e;
    --hill: #a9bad6;
    --grass-top: #cfdbee;
    --grass-bottom: #95a9c9;
    --tuft: #8aa0c2;
    --water: #86aed0;
    --water-shine: rgba(235, 245, 255, 0.65);
    --pad: #6f94b8;
    --cloud: rgba(180, 190, 235, 0.2);
    --sun: #f4f0d6;
    --sun-glow: rgba(244, 240, 214, 0.2);
    --sun-glow-end: rgba(244, 240, 214, 0);
    --text-stroke: #10142e;
    --night: 1;
    --tree: #174c31;
    --tree-dark: #103a25;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070b24;
  --ink: #eef0ff;
  --muted: #aab2d8;
  --panel: #1d2346;
  --panel-edge: #74d184;
  --shadow: #090d22;
  --title-shadow: #0c1129;
  --small-frog: rgba(215, 38, 61, 0.16);
  --big-frog: rgba(63, 157, 85, 0.2);
  --accent: #ff5a6e;
  --accent-edge: #a3182c;
  --accent-ink: #ffffff;
  --good: #82e08f;
  --bad: #ff8f84;
  --hud-bg: #1d2346;
  --hud-ink: #eef0ff;
  --scrim: rgba(5, 8, 25, 0.45);
  --sky-top: #070b24;
  --sky-bottom: #2b2a5e;
  --hill: #a9bad6;
  --grass-top: #cfdbee;
  --grass-bottom: #95a9c9;
  --tuft: #8aa0c2;
  --water: #86aed0;
  --water-shine: rgba(235, 245, 255, 0.65);
  --pad: #6f94b8;
  --cloud: rgba(180, 190, 235, 0.2);
  --sun: #f4f0d6;
  --sun-glow: rgba(244, 240, 214, 0.2);
  --sun-glow-end: rgba(244, 240, 214, 0);
  --text-stroke: #10142e;
  --night: 1;
  --tree: #174c31;
  --tree-dark: #103a25;
}

html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* HUD */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) calc(env(safe-area-inset-right, 0px) + 12px) 0 calc(env(safe-area-inset-left, 0px) + 12px);
  pointer-events: none;
}
.pill {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  background: var(--hud-bg);
  color: var(--hud-ink);
  border: 2px solid var(--panel-edge);
  box-shadow: 0 3px 0 var(--shadow);
  font-family: var(--font);
  font-weight: 800;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}
.pill .lbl { font-size: 14px; font-weight: 500; color: var(--muted); }
#timePill { margin-left: auto; }
.timebar { width: 56px; height: 8px; border-radius: 4px; background: rgba(127, 127, 127, 0.22); overflow: hidden; }
.timebar i { display: block; width: 100%; height: 100%; background: var(--good); transform-origin: left center; }
#timePill.warn { color: var(--bad); border-color: var(--bad); }
#timePill.warn .timebar i { background: var(--bad); }
#timePill.warn #timeNum { display: inline-block; animation: pulse 0.5s ease-in-out infinite alternate; }
#mute {
  pointer-events: auto;
  width: 40px;
  padding: 0;
  justify-content: center;
  font-family: var(--emoji);
  font-size: 17px;
  cursor: pointer;
  touch-action: manipulation;
}
#mute:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--shadow); }
#mute:focus-visible, .btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: flex;
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) calc(env(safe-area-inset-right, 0px) + 16px) calc(env(safe-area-inset-bottom, 0px) + 16px) calc(env(safe-area-inset-left, 0px) + 16px);
  background: var(--scrim);
  touch-action: manipulation;
}
.overlay[hidden] { display: none; }
.card {
  margin: auto;
  width: min(400px, 100%);
  box-sizing: border-box;
  background: var(--panel);
  color: var(--ink);
  border: 3px solid var(--panel-edge);
  border-radius: 28px;
  box-shadow: 0 6px 0 var(--shadow);
  padding: 22px 18px 18px;
  text-align: center;
  animation: pop 0.4s cubic-bezier(0.2, 1.5, 0.4, 1);
}
h1 {
  margin: 0;
  font-size: clamp(38px, 11vw, 50px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--panel-edge);
  text-shadow: 0 4px 0 var(--title-shadow);
}
.lead { margin: 12px auto 16px; max-width: 30ch; font-size: 17px; line-height: 1.4; color: var(--muted); }
.frogs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.frog { border-radius: 20px; padding: 8px 6px 12px; }
.frog.small { background: var(--small-frog); }
.frog.big { background: var(--big-frog); }
.thumb { display: block; width: 64px; height: 64px; margin: 0 auto 2px; }
.frog h3 { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.tag { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); }
.tag.bad { color: var(--bad); }
.emo { margin: 0; font-family: var(--emoji); font-size: 22px; line-height: 1.3; letter-spacing: 1px; }
.emo img { height: 28px; width: auto; max-width: 32px; object-fit: contain; vertical-align: middle; margin: 2px 1px 0; }
.ico img { height: 1.35em; width: auto; vertical-align: -0.35em; }
.rules { margin: 0 auto 16px; max-width: 34ch; font-size: 14px; line-height: 1.45; color: var(--muted); }
.btn {
  appearance: none;
  display: block;
  width: 100%;
  font-family: var(--font);
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: 22px;
  padding: 14px 20px;
  box-shadow: 0 5px 0 var(--accent-edge);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.06s, box-shadow 0.06s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--accent-edge); }
.btn:disabled { opacity: 0.6; }
.btn.secondary {
  margin-top: 12px;
  background: var(--panel);
  color: var(--panel-edge);
  border: 3px solid var(--panel-edge);
  box-shadow: 0 5px 0 var(--shadow);
  font-size: 19px;
}
.btn[hidden] { display: none; }
.btn.secondary:active { box-shadow: 0 1px 0 var(--shadow); }
.linkbtn {
  appearance: none; border: 0; background: none; padding: 0 0 0 6px;
  font-family: var(--font); font-size: 15px; font-weight: 700; color: var(--accent);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; touch-action: manipulation;
}
.linkbtn[hidden] { display: none; }
#shareScreen { z-index: 4; }
.share-img {
  display: block; width: auto; max-width: 100%; max-height: 56vh; margin: 14px auto 6px;
  border-radius: 16px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto;
}
.best { margin: 12px 0 0; font-size: 15px; color: var(--muted); }
.best b { color: var(--ink); font-weight: 800; }
h2 { margin: 0; font-size: 34px; font-weight: 800; color: var(--panel-edge); }
.score-big { margin-top: 6px; font-size: 76px; font-weight: 800; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.score-lbl { font-size: 16px; color: var(--muted); }
.newbest {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  animation: wobble 0.6s ease-in-out 2;
}
.newbest[hidden] { display: none; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.stat { font-size: 14px; line-height: 1.4; color: var(--muted); }
.stat .thumb { width: 52px; height: 52px; }
.stat b { color: var(--ink); font-size: 18px; font-weight: 800; }

.edition { margin: 6px 0 0; font-size: 18px; font-weight: 700; color: var(--accent); }
.x2 { display: inline-block; padding: 1px 7px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 14px; font-weight: 800; animation: pulse 0.4s ease-in-out infinite alternate; }
.x2[hidden] { display: none; }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { to { transform: scale(1.12); } }
@keyframes wobble { 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }

@media (max-height: 560px) {
  h1 { font-size: 32px; }
  .lead { font-size: 15px; margin: 8px auto 10px; }
  .thumb { width: 48px; height: 48px; }
  .rules { margin-bottom: 10px; }
  .btn { padding: 10px 20px; font-size: 20px; }
  .score-big { font-size: 52px; }
  .stats { margin: 10px 0; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .newbest, #timePill.warn #timeNum, .x2 { animation: none; }
}
