/* =========================================================
   BEES — stylesheet
   Structure:
   1. Design tokens (colours, fonts, spacing, radii, shadows)
   2. Reset & base
   3. Reusable utility classes (layout, typography, spacing)
   4. Reusable components (buttons, cards, modals)
   5. Page layout (header, main, footer)
   6. HUD (level, honey pot, hearts)
   7. Game scene (sky, hills, ground, flowers, bees, cursor)
   8. Animations
   9. Responsive & reduced-motion tweaks
   ========================================================= */

/* ---------- 1. DESIGN TOKENS ---------- */
:root {
  /* Colours */
  --color-sky-top: #bfe4ff;
  --color-sky-bottom: #fff1d6;
  --color-sun: #ffe08a;
  --color-sun-glow: rgba(255, 224, 138, 0.45);
  --color-cloud: #ffffff;
  --color-hill-back: #cde9a6;
  --color-hill-front: #a9d77f;
  --color-grass-light: #9fd170;
  --color-grass-dark: #6fb04c;
  --color-honey: #f6b93b;
  --color-honey-dark: #d98e04;
  --color-cream: #fff8e7;
  --color-paper: #fffdf7;
  --color-ink: #4a3b2a;
  --color-ink-soft: #7a6650;
  --color-pink: #ff9ec4;
  --color-danger: #e85d5d;
  --color-focus: #6b8cff;

  /* Typography */
  --font-display: "Fredoka", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, sans-serif;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.75rem;
  --fs-xxl: clamp(2rem, 5vw, 3rem);
  --lh-tight: 1.1;
  --lh-body: 1.5;

  /* Spacing scale (used for margin, padding and gaps) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Shape & depth */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 28px;
  --radius-pill: 999px;
  --shadow-soft: 0 6px 18px rgba(122, 90, 40, 0.15);
  --shadow-pop: 0 4px 0 var(--color-honey-dark), 0 10px 20px rgba(217, 142, 4, 0.3);

  /* Motion */
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-fast: 150ms ease;

  /* Layout */
  --container-max: 1100px;
  --horizon: 42%; /* where the ground starts inside the game scene */
}

/* ---------- 2. RESET & BASE ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  color-scheme: light;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  color: var(--color-ink);
  background: radial-gradient(circle at top, var(--color-cream), #fbe9c4);
  -webkit-font-smoothing: antialiased;
}

ul {
  list-style: none;
}

/* Make sure the hidden attribute always wins over display rules */
[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
}

/* One clear focus style everywhere for keyboard users */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}

/* ---------- 3. UTILITY CLASSES ---------- */

/* Layout: flexbox helpers */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

/* Gaps (work for both flex and grid) */
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

/* "Stack": evenly spaces children vertically */
.stack > * + * {
  margin-top: var(--space-4);
}

/* Centered, max-width wrapper with side gutters */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

/* Typography helpers */
.font-display { font-family: var(--font-display); line-height: var(--lh-tight); }
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-md { font-size: var(--fs-md); }
.text-lg { font-size: var(--fs-lg); }
.text-xl { font-size: var(--fs-xl); }
.text-xxl { font-size: var(--fs-xxl); }
.text-soft { color: var(--color-ink-soft); }
.text-center { text-align: center; }
.text-left { text-align: left; }
.upper { text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; }

/* Hide visually but keep available to screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- 4. COMPONENTS ---------- */

/* Card: soft paper panel used by the HUD and dialogs */
.card {
  background: var(--color-paper);
  border: 3px solid #f3dfb4;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: var(--space-4) var(--space-5);
}

/* Button base + variants */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-md);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn:active {
  transform: translateY(3px);
}

.btn--primary {
  background: var(--color-honey);
  color: var(--color-ink);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-lg);
}

.btn--primary:hover {
  transform: translateY(-2px);
}

/* A button waiting on something (e.g. "Saving…") */
.btn:disabled {
  opacity: 0.7;
  cursor: progress;
  transform: none;
}

.btn--ghost {
  background: var(--color-paper);
  border: 2px solid #f3dfb4;
}

.btn--ghost:hover {
  background: var(--color-cream);
}

/* Sound toggle icon: honey-coloured speaker with soft rounded strokes */
.sound-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.sound-icon__speaker {
  fill: var(--color-honey);
  stroke: var(--color-honey-dark);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.sound-icon__wave {
  fill: none;
  stroke: var(--color-honey-dark);
  stroke-width: 2;
  stroke-linecap: round;
}

/* Show the "on" or "off" icon depending on the button's pressed state */
[aria-pressed="true"] .sound-icon--off,
[aria-pressed="false"] .sound-icon--on {
  display: none;
}

/* Generic button icon (trophy, full screen) in the same honey style */
.btn-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.btn-icon__fill {
  fill: var(--color-honey);
  stroke: var(--color-honey-dark);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.btn-icon__line {
  fill: none;
  stroke: var(--color-honey-dark);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Round icon-only button */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 2px solid #f3dfb4;
  border-radius: 50%;
  background: rgba(255, 253, 247, 0.85);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.icon-btn:hover {
  transform: scale(1.08);
}

/* Form fields */
.label {
  display: block;
  font-weight: 800;
  font-size: var(--fs-sm);
}

.input {
  flex: 1;
  min-width: 0;
  padding: var(--space-3) var(--space-4);
  font: inherit;
  color: var(--color-ink);
  background: var(--color-cream);
  border: 2px solid #f0d9a8;
  border-radius: var(--radius-pill);
}

.input:focus-visible {
  border-color: var(--color-focus);
}

/* Name form on the game-over screen */
.score-form {
  padding: var(--space-4);
  background: var(--color-cream);
  border-radius: var(--radius-md);
}

.score-form > * + * {
  margin-top: var(--space-2);
}

.new-high {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  color: var(--color-honey-dark);
  animation: pop-in 400ms var(--ease-bounce);
}

.new-high .icon {
  width: 26px;
  height: 26px;
}

/* Leaderboard table */
.board {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.board th,
.board td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
}

.board th {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-ink-soft);
  border-bottom: 2px dashed #f0d9a8;
}

/* Number columns line up on the right */
.board .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.board tbody tr:nth-child(odd) {
  background: var(--color-cream);
}

/* Gold, silver and bronze medals for the top three */
.board .rank {
  width: 2.5rem;
  font-family: var(--font-display);
  font-weight: 700;
}

/* The score you just saved */
.board tr.is-new {
  background: #ffe7a8;
  font-weight: 800;
}

/* Personal best line on the game-over screen */
.personal-best {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  color: var(--color-honey-dark);
}

.personal-best .icon {
  width: 24px;
  height: 24px;
}

.personal-best:empty {
  display: none;
}

/* "Your best ever" strip in the leaderboard dialog */
.personal-best-card {
  padding: var(--space-3) var(--space-4);
  background: #ffe7a8;
  border-radius: var(--radius-md);
}

.board-empty {
  padding: var(--space-5);
  background: var(--color-cream);
  border-radius: var(--radius-md);
}

/* Skip link: hidden until focused */
.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--color-ink);
  color: var(--color-paper);
  border-radius: var(--radius-sm);
  transform: translateY(-200%);
  z-index: 1000;
}

.skip-link:focus {
  transform: none;
}

/* ---- Chapter intro screen ---- */

/* The new bee and its threat at the top of the chapter intro */
.chapter-art {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
}

.chapter-art svg {
  width: 72px;
  height: 64px;
  overflow: visible;
}

/* Bee / Flowers / Challenge facts as a neat two-column list.
   The label column is as wide as its longest label; values wrap if needed. */
.chapter-facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--space-1) var(--space-3);
  padding: var(--space-3);
  background: var(--color-cream);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
}

/* Each <div> groups a dt/dd pair; "contents" lets them join the list's grid */
.chapter-facts > div {
  display: contents;
}

.chapter-facts dt {
  font-weight: 800;
  color: var(--color-ink-soft);
}

/* ---- Chapters journey map ----
   A tall map inside a scrolling box. Every piece is placed by game.js
   with `bottom` (px) and `left` (%), so level 1 sits at the bottom. */

/* The journey dialog is tall and narrow, like a phone game map */
.modal.modal--journey {
  width: min(94vw, 560px);
  height: min(90dvh, 900px);
  padding: var(--space-4);
}

.modal--journey[open] {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.journey-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border-radius: var(--radius-md);
  background: var(--color-cream);
  overscroll-behavior: contain;
}

.journey {
  position: relative;
  overflow: hidden;
}

.journey__chapters,
.journey-levels {
  list-style: none;
}

/* The road: a wide soft path, with the trail drawn on top */
.journey__path {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.journey__road,
.journey__trail {
  fill: none;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke; /* keeps line widths even though the SVG is stretched */
}

.journey__road { stroke: rgba(255, 255, 255, 0.75); stroke-width: 22; }
.journey__trail--todo { stroke: rgba(122, 102, 80, 0.35); stroke-width: 4; stroke-dasharray: 2 10; }
.journey__trail--done { stroke: var(--color-honey); stroke-width: 6; }

/* Each chapter's little world: a coloured band behind its stops */
.journey-chapter__bg {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 0;
}

.journey-chapter--1 .journey-chapter__bg { background: linear-gradient(#cdeaa8, #a9d77f); }
.journey-chapter--2 .journey-chapter__bg { background: linear-gradient(#f4d6ff, #ffd1e6); }
.journey-chapter--3 .journey-chapter__bg { background: linear-gradient(#ffe7a3, #ffd36b); }
.journey-chapter--4 .journey-chapter__bg {
  /* Night: a few stars over a deep blue */
  background:
    radial-gradient(2px 2px at 20% 20%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 70% 35%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 40% 70%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 85% 80%, #fff 50%, transparent 51%),
    linear-gradient(#1d2550, #3b4183);
}
.journey-chapter--5 .journey-chapter__bg { background: linear-gradient(#d7f0ff, #e9dcff, #ffe3f0); }

/* Locked worlds are faded until you reach them */
.journey-chapter.is-locked .journey-chapter__bg {
  filter: grayscale(0.7);
  opacity: 0.6;
}

/* Decorative flowers along the edges of each world */
.journey-flower {
  position: absolute;
  width: 34px;
  height: 76px;
  transform: translateX(-50%);
}

.journey-flower svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Signpost at the start of each chapter */
.journey-sign {
  position: absolute;
  left: 50%;
  z-index: 3;
  width: min(80%, 300px);
  padding: var(--space-3) var(--space-4);
  transform: translateX(-50%);
  background: var(--color-paper);
  border: 3px solid #f3dfb4;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.journey-sign__art {
  display: flex;
  justify-content: center;
  gap: var(--space-1);
}

.journey-sign__art svg {
  width: 44px;
  height: 38px;
  overflow: visible;
}

.journey-sign__label {
  color: var(--color-ink-soft);
}

.journey-sign__status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  margin-top: var(--space-1);
  font-weight: 800;
}

.journey-chapter.is-locked .journey-sign__art svg {
  filter: brightness(0);
  opacity: 0.25;
}

/* Level stops: round honey buttons along the path */
.journey-node {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-weight: 700;
  border: 3px solid #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
}

.journey-node.is-done {
  background: var(--color-honey);
  color: var(--color-ink);
}

.journey-node.is-current {
  width: 58px;
  height: 58px;
  background: #ffe7a8;
  color: var(--color-ink);
  border-color: var(--color-honey);
  box-shadow: 0 0 0 6px rgba(246, 185, 59, 0.35), 0 4px 0 rgba(0, 0, 0, 0.15);
  animation: node-pulse 1.8s ease-in-out infinite;
}

.journey-node.is-locked {
  background: #e9e1d2;
  color: #9a8b78;
}

/* Reached levels are buttons that fill the whole circle */
.journey-node__btn {
  position: absolute;
  inset: 0;
  border: none;
  border-radius: 50%;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.journey-node:has(.journey-node__btn):hover {
  transform: translateX(-50%) scale(1.08);
}

/* The level you picked to start from */
.journey-node.is-selected {
  box-shadow: 0 0 0 5px var(--color-paper), 0 0 0 9px var(--color-focus), 0 4px 0 rgba(0, 0, 0, 0.15);
  animation: none;
}

.journey-actions {
  flex-wrap: wrap;
}

/* Little badge on the corner of a stop: a tick or a lock */
.journey-node__badge {
  position: absolute;
  right: -6px;
  bottom: -4px;
  display: flex;
}

.journey-node__badge:empty {
  display: none;
}

/* Your bee hovering over the stop you've reached */
.journey-node__bee {
  position: absolute;
  bottom: 100%;
  left: 50%;
  width: 52px;
  height: 46px;
  transform: translateX(-50%);
  animation: hover-bob 2.4s ease-in-out infinite;
}

.journey-node__bee svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* "More chapters coming soon" cloud at the very top */
.journey-soon {
  position: absolute;
  left: 50%;
  z-index: 3;
  width: min(80%, 300px);
  padding: var(--space-3) var(--space-4);
  transform: translateX(-50%);
  background: var(--color-paper);
  border: 3px dashed #f0d9a8;
  border-radius: var(--radius-pill);
}

/* Small status icons (lock, tick, pin, sprout) */
.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.icon--large {
  width: 34px;
  height: 34px;
}

.icon__dot { fill: var(--color-honey-dark); }
.icon__lid { fill: var(--color-honey-dark); }
.icon__drip { fill: #ffd56b; }
.icon__shine { fill: none; stroke: #fff6d6; stroke-width: 1.6; stroke-linecap: round; }
.icon__petal { fill: var(--color-pink); stroke: #e2729e; stroke-width: 1; }
.icon__burst { fill: #ff8a6b; stroke: var(--color-danger); stroke-width: 1.2; stroke-linejoin: round; }
.icon__crown { fill: #ffd700; stroke: var(--color-ink); stroke-width: 1.4; stroke-linejoin: round; }
.icon__minibee ellipse { fill: #ffd23f; stroke: var(--color-ink); stroke-width: 1.3; }
.icon__minibee path { stroke: var(--color-ink); stroke-width: 1.8; }
.icon__ribbon { fill: #7fb2e8; stroke: #5a8ccc; stroke-width: 1; stroke-linejoin: round; }
.icon__medal { stroke-width: 1.4; }
.icon__rank { font-family: var(--font-display); font-size: 8px; font-weight: 700; fill: var(--color-ink); }

/* Medal colours */
.icon--gold .icon__medal { fill: #ffd34d; stroke: #d99e00; }
.icon--silver .icon__medal { fill: #e3e8ee; stroke: #9aa6b2; }
.icon--bronze .icon__medal { fill: #f0b27a; stroke: #b97440; }
.board .rank .icon { width: 26px; height: 26px; vertical-align: middle; }

/* The honeybee artwork used as an icon */
.icon--bee {
  display: inline-block;
  width: 50px;
  height: 44px;
}

.icon--bee svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.logo-mark .icon--bee {
  width: 100%;
  height: 100%;
}

/* Icons sit nicely inside floating text, banners and chips */
.float-text .icon { width: 22px; height: 22px; }
.level-banner__sub .icon { width: 22px; height: 22px; }
.level-chip .icon { width: 14px; height: 14px; }
.icon__tick { fill: none; stroke: var(--color-ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.icon__leaf { fill: #8fcf6a; stroke: #5a9b3c; stroke-width: 1.5; }

/* Modal dialogs */
.modal {
  margin: auto;
  width: min(92vw, 440px);
  color: var(--color-ink);
}

.modal::backdrop {
  background: rgba(74, 59, 42, 0.35);
  backdrop-filter: blur(4px);
}

.modal[open] {
  animation: pop-in 350ms var(--ease-bounce);
}

/* Row of icons at the top of a dialog */
.modal__icons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-2);
}

.modal__icons .icon {
  width: 44px;
  height: 44px;
}

.rules {
  padding: var(--space-4);
  background: var(--color-cream);
  border-radius: var(--radius-md);
}

.rules li {
  padding-left: var(--space-5);
  position: relative;
}

/* Small flower bullet for the rules list */
.rules li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.2em;
  width: 1.1em;
  height: 1.1em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='%23ff9ec4'%3E%3Ccircle cx='12' cy='6.5' r='3.6'/%3E%3Ccircle cx='17.2' cy='10.3' r='3.6'/%3E%3Ccircle cx='15.2' cy='16.5' r='3.6'/%3E%3Ccircle cx='8.8' cy='16.5' r='3.6'/%3E%3Ccircle cx='6.8' cy='10.3' r='3.6'/%3E%3C/g%3E%3Ccircle cx='12' cy='12' r='3' fill='%23f6b93b'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* ---------- 5. PAGE LAYOUT ---------- */

/* Header / main / footer stacked with grid so the footer sits at the bottom */
.page {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100dvh;
}

.site-header {
  padding-block: var(--space-4);
  flex-wrap: wrap;
}

.title {
  color: var(--color-honey-dark);
  text-shadow: 0 3px 0 #fff;
}

.logo-mark {
  display: inline-block;
  width: 56px;
  height: 50px;
  animation: hover-bob 2.4s ease-in-out infinite;
}

/* Header buttons wrap onto a second row on narrow screens */
.header-actions {
  flex-wrap: wrap;
}

.site-main {
  padding-block: var(--space-2) var(--space-5);
}

.site-footer {
  padding-block: var(--space-5);
  border-top: 2px dashed #f0d9a8;
}

/* ---------- 6. HUD ---------- */

/* Three columns: level | pot | stings */
.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-4);
}

.pot {
  width: 64px;
  height: 64px;
  overflow: visible;
}

.pot__body {
  fill: #fff4dc;
  stroke: var(--color-honey-dark);
  stroke-width: 2.5;
}

.pot__honey {
  fill: var(--color-honey);
  transform-box: fill-box;
  transform-origin: bottom;
  transform: scaleY(0);
  transition: transform 450ms var(--ease-bounce);
}

.pot__rim {
  fill: var(--color-honey-dark);
}

.pot__label {
  font-family: var(--font-display);
  font-size: 7px;
  font-weight: 700;
  fill: var(--color-ink);
  opacity: 0.6;
}

/* Wobble the pot when honey is added */
.pot.is-filling {
  animation: wobble 400ms ease;
}

.hearts li {
  width: 26px;
  height: 26px;
  transition: transform 300ms var(--ease-bounce), opacity 300ms ease, filter 300ms ease;
}

.hearts svg {
  width: 100%;
  height: 100%;
  fill: var(--color-pink);
  stroke: #e2729e;
  stroke-width: 1.5;
}

/* A heart that has been used up by a sting */
.hearts li.is-lost {
  opacity: 0.35;
  filter: grayscale(1);
  transform: scale(0.8);
}

/* ---------- 7. GAME SCENE ---------- */

.game {
  position: relative;
  width: 100%;
  height: clamp(380px, 62vh, 620px);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft), inset 0 0 0 4px rgba(255, 255, 255, 0.6);
  background: linear-gradient(var(--color-sky-top), var(--color-sky-bottom) 45%);
  cursor: none; /* replaced by our custom net cursor */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* Every background layer fills the game area */
.scene,
.field {
  position: absolute;
  inset: 0;
}

.sun {
  position: absolute;
  top: 8%;
  right: 10%;
  width: 90px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--color-sun);
  box-shadow: 0 0 0 18px var(--color-sun-glow), 0 0 80px 30px var(--color-sun-glow);
  transition: background 600ms ease, box-shadow 600ms ease;
}

/* Fluffy clouds made of one box + two pseudo-element bumps */
.cloud {
  position: absolute;
  width: 120px;
  height: 36px;
  background: var(--color-cloud);
  border-radius: var(--radius-pill);
  opacity: 0.9;
  animation: drift linear infinite;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: var(--color-cloud);
  border-radius: 50%;
}

.cloud::before { width: 50px; height: 50px; top: -26px; left: 18px; }
.cloud::after { width: 64px; height: 64px; top: -36px; left: 48px; }

.cloud--one { top: 14%; animation-duration: 70s; animation-delay: -10s; }
.cloud--two { top: 26%; transform: scale(0.7); animation-duration: 95s; animation-delay: -50s; }
.cloud--three { top: 8%; transform: scale(0.5); animation-duration: 120s; animation-delay: -80s; opacity: 0.7; }

.hills {
  position: absolute;
  left: 0;
  width: 100%;
  bottom: calc(100% - var(--horizon) - 4%);
  height: 30%;
}

.hills__back { fill: var(--color-hill-back); }
.hills__front { fill: var(--color-hill-front); }

/* Ground: lighter at the horizon, darker up close for depth */
.ground {
  position: absolute;
  inset: var(--horizon) 0 0 0;
  background:
    radial-gradient(ellipse at 30% 80%, rgba(255, 255, 255, 0.15), transparent 50%),
    linear-gradient(var(--color-grass-light), var(--color-grass-dark));
}

/* ---- Flowers ---- */
/* Each flower is anchored at its stem base; --z (0 far → 1 near) sets height & size */
.flower {
  position: absolute;
  top: calc(var(--horizon) + var(--z) * (100% - var(--horizon)) * 0.95);
  left: var(--x);
  width: 40px;
  height: 90px;
  transform: translate(-50%, -100%) scale(var(--scale));
  transform-origin: bottom center;
  pointer-events: none;
}

.flower svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  transform-origin: bottom center;
  animation: sway ease-in-out infinite alternate;
  animation-duration: var(--sway, 4s);
}

.flower__stem { stroke: #5a9b3c; stroke-width: 3; fill: none; stroke-linecap: round; }
.flower__leaf { fill: #6fb04c; }
.flower__petal { fill: var(--petal); }
.flower__center { fill: #ffd45c; stroke: #e9a92a; stroke-width: 1.5; }

/* Chapter flowers: tulips, sunflowers and bluebells */
.flower__cup,
.flower__bell { stroke: rgba(0, 0, 0, 0.12); stroke-width: 1; }
.flower__stem--thick { stroke-width: 4.5; }
.flower__stem--thin { stroke-width: 1.5; }
.flower__ray { fill: var(--petal); stroke: #e8a317; stroke-width: 0.8; }
.flower__seeds { fill: #7a4a1e; stroke: #5a3412; stroke-width: 1.5; }

/* Sunflowers stand a little taller than the rest */
.flower--sunflower { height: 100px; }

/* ---- Bees ---- */
/* Bees are real <button>s so they can be focused and caught by keyboard */
.bee {
  position: absolute;
  top: 0;
  left: 0;
  width: 64px;
  height: 56px;
  padding: 0;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: none;
  will-change: transform;
}

.bee__art {
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: scaleX(var(--facing, 1));
  transition: filter 200ms ease;
}

.bee__body { fill: #ffd23f; stroke: var(--color-ink); stroke-width: 2; }
.bee__stripe { fill: var(--color-ink); }
.bee__stinger { fill: var(--color-ink); }
.bee__eye { fill: var(--color-ink); }
.bee__shine { fill: #fff; }
.bee__blush { fill: var(--color-pink); opacity: 0.8; }
.bee__smile,
.bee__antenna { fill: none; stroke: var(--color-ink); stroke-width: 2; stroke-linecap: round; }
.bee__antenna-tip { fill: var(--color-ink); }
.bee__wing {
  fill: rgba(255, 255, 255, 0.75);
  stroke: #9fc7e8;
  stroke-width: 1.5;
  transform-box: fill-box;
  transform-origin: bottom center;
  animation: flap 120ms ease-in-out infinite alternate;
}
.bee__wing--back { animation-delay: -60ms; }

/* Angry bee: warns the player it is about to sting */
.bee.is-angry .bee__art {
  filter: hue-rotate(-40deg) saturate(2.2) drop-shadow(0 0 6px rgba(232, 93, 93, 0.9));
  animation: jitter 90ms linear infinite;
}

/* Caught bee: shrinks and spins away */
.bee.is-caught {
  pointer-events: none;
}

.bee.is-caught .bee__art {
  animation: caught 450ms ease-in forwards;
}

/* Soft oval shadow on the ground beneath each bee (sells the 2.5D look) */
.bee-shadow {
  position: absolute;
  top: 0;
  left: 0;
  width: 46px;
  height: 12px;
  border-radius: 50%;
  background: rgba(40, 70, 20, 0.28);
  filter: blur(2px);
  pointer-events: none;
  z-index: 1;
}

/* Floating "+1" text when a bee is caught */
.float-text {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-lg);
  color: var(--color-honey-dark);
  text-shadow: 0 2px 0 #fff;
  pointer-events: none;
  z-index: 300;
  animation: float-up 900ms ease-out forwards;
}

/* ---- Chapter bees, wasps, the queen and her soldiers ---- */

/* Bumblebee & carpenter bee fluff: a dashed outline reads as fuzz */
.bee__body--fuzzy { stroke-dasharray: 1.5 2.5; stroke-width: 3; stroke-linecap: round; }
.bee__tail { fill: #fff6e6; }
.bee__body--dark { fill: #34303f; }
.bee__gloss { fill: #ffffff; opacity: 0.35; }
.bee__body--glow { fill: #fff6c2; }
.bee__stripe--soft { fill: #6b5a8e; }
.bee__body--queen { fill: #ffc94a; }
.bee__stripe--royal { fill: #7b3fa0; }
.bee__crown { fill: #ffd700; stroke: var(--color-ink); stroke-width: 1.5; stroke-linejoin: round; }
.bee__body--soldier { fill: #ff8a6b; }
.bee__brow { fill: none; stroke: var(--color-ink); stroke-width: 2.2; stroke-linecap: round; }

/* Glow bees shine softly (so you can find them in the dark) */
.bee--glow .bee__art {
  filter: drop-shadow(0 0 6px rgba(255, 240, 150, 0.95));
}

/* Wasps get slimmer, darker wings */
.bee--wasp .bee__wing { fill: rgba(220, 230, 255, 0.6); stroke: #8aa0c8; }

/* The queen's royal glow */
.bee--queen .bee__art {
  filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.7));
}

/* The queen can't be caught, so clicks pass through her to the bees behind */
.bee--queen {
  pointer-events: none;
}

/* Soldiers aren't buttons, but you can still bump into them */
.bee--soldier {
  cursor: none;
}

/* ---- Darkness (chapter 4) ----
   A dark layer with a warm hole cut around the lantern (the net).
   --lx / --ly are set by game.js every frame. */
.darkness {
  position: absolute;
  inset: 0;
  z-index: 150; /* above flowers, below insects (which game.js lifts above it) */
  pointer-events: none;
  opacity: 0;
  transition: opacity 800ms ease;
  background: radial-gradient(
    circle 150px at var(--lx, 50%) var(--ly, 60%),
    rgba(255, 214, 140, 0.16) 0%,
    rgba(12, 14, 44, 0.4) 55%,
    rgba(8, 10, 32, 0.86) 100%
  );
}

.game.is-dark .darkness {
  opacity: 1;
}

/* ---- Level banner: "Level 12 · Sweet level!" ---- */
.level-banner {
  position: absolute;
  top: 26%;
  left: 50%;
  z-index: 550;
  width: max-content;
  max-width: 90%;
  padding: var(--space-3) var(--space-6);
  text-align: center;
  background: rgba(255, 253, 247, 0.92);
  border: 3px solid #f3dfb4;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%);
}

.level-banner.is-showing {
  animation: banner 2.6s ease forwards;
}

.level-banner__title {
  font-size: var(--fs-xl);
  color: var(--color-honey-dark);
}

.level-banner__sub {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-weight: 800;
}

/* Small "Sweet level" / "Swarm level" tag in the HUD */
.level-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  font-size: var(--fs-xs);
  font-weight: 800;
  border-radius: var(--radius-pill);
  background: #ffe7a8;
  white-space: nowrap;
}

.level-chip[data-type="swarm"] {
  background: #ffd3c4;
}

/* ---- Custom cursor (bee net) ---- */
.cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 56px;
  height: 56px;
  pointer-events: none; /* clicks pass through to bees */
  z-index: 500;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.cursor.is-visible { opacity: 1; }

.cursor__art {
  width: 100%;
  height: 100%;
  overflow: visible;
  transform-origin: 20px 20px;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.2));
}

.cursor__handle { stroke: #b07a3c; stroke-width: 5; stroke-linecap: round; }
.cursor__mesh-bg { fill: rgba(255, 255, 255, 0.45); }
.cursor__mesh { stroke: rgba(255, 255, 255, 0.9); stroke-width: 1; }
.cursor__hoop { fill: none; stroke: var(--color-honey-dark); stroke-width: 3.5; }

.cursor.is-swinging .cursor__art { animation: swing 220ms ease-out; }
.cursor.is-stung .cursor__art { animation: stung 500ms ease-out; }
.cursor.is-stung .cursor__hoop { stroke: var(--color-danger); }

/* Full-scene red flash on sting */
.sting-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle, transparent 40%, rgba(232, 93, 93, 0.45));
  opacity: 0;
  z-index: 400;
}

.sting-flash.is-active { animation: flash 450ms ease-out; }

.game.is-shaking { animation: shake 350ms ease; }

/* The meadow is focused by script (not Tab), so it doesn't need a focus ring */
.game:focus { outline: none; }

/* ---- Full screen ---- */
.fullscreen-btn {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 600; /* above the bees and the net */
}

/* Show the "enter" or "exit" icon depending on the pressed state */
.fullscreen-btn[aria-pressed="true"] .fs-icon--enter,
.fullscreen-btn[aria-pressed="false"] .fs-icon--exit {
  display: none;
}

/* In full screen (real or fallback), the HUD sits on top and the meadow fills the rest.
   JavaScript adds .is-fullscreen in both cases. */
.play-area.is-fullscreen {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: var(--space-4);
  width: 100%;
  height: 100%;
  padding: var(--space-4);
  background: radial-gradient(circle at top, var(--color-cream), #fbe9c4);
  overflow: hidden;
}

.play-area.is-fullscreen > * + * {
  margin-top: 0; /* grid gap handles spacing instead of .stack */
}

.play-area.is-fullscreen .game {
  height: 100%;
}

/* Fallback: pin the play area over the whole browser window */
.play-area.is-fullscreen-fallback {
  position: fixed;
  inset: 0;
  height: 100dvh;
  z-index: 900;
}

/* Stop the page behind from scrolling while in fallback full screen */
.no-scroll {
  overflow: hidden;
}

/* ---- Scenes: each level gets its own look ----
   The scene layers above only use colour tokens, so a scene is
   just a new set of token values on the game element. */

.game[data-scene="sunset"] {
  --color-sky-top: #ff9f80;
  --color-sky-bottom: #ffe0b0;
  --color-sun: #ff7b54;
  --color-sun-glow: rgba(255, 140, 90, 0.4);
  --color-cloud: #ffd9c7;
  --color-hill-back: #e8c27c;
  --color-hill-front: #c9b45e;
  --color-grass-light: #b9c467;
  --color-grass-dark: #869c45;
}

.game[data-scene="lavender"] {
  --color-sky-top: #cfc6ff;
  --color-sky-bottom: #fbe8ff;
  --color-sun: #fff4b8;
  --color-sun-glow: rgba(255, 244, 184, 0.5);
  --color-cloud: #fdf7ff;
  --color-hill-back: #c8b6ef;
  --color-hill-front: #a993dd;
  --color-grass-light: #a9cf86;
  --color-grass-dark: #77a65c;
}

.game[data-scene="night"] {
  --color-sky-top: #1d2550;
  --color-sky-bottom: #4b4f8e;
  --color-sun: #f6f1d3; /* the moon */
  --color-sun-glow: rgba(246, 241, 211, 0.18);
  --color-cloud: #6a6fa8;
  --color-hill-back: #33476b;
  --color-hill-front: #2a3f5c;
  --color-grass-light: #3f6e55;
  --color-grass-dark: #284a3a;
}

.game[data-scene="blossom"] {
  --color-sky-top: #ffd1e6;
  --color-sky-bottom: #fff4f8;
  --color-sun: #fff0a8;
  --color-sun-glow: rgba(255, 240, 168, 0.45);
  --color-cloud: #ffffff;
  --color-hill-back: #f6c3d7;
  --color-hill-front: #b8dc8c;
  --color-grass-light: #a6d67e;
  --color-grass-dark: #74b356;
}

/* Night: the sun becomes a smaller moon with a shaded edge */
.game[data-scene="night"] .sun {
  width: 64px;
  box-shadow: inset -14px -6px 0 0 #e2dcb4, 0 0 60px 20px var(--color-sun-glow);
}

/* Stars: dots drawn with gradients, only visible at night */
.stars {
  position: absolute;
  inset: 0 0 50% 0;
  opacity: 0;
  background-image:
    radial-gradient(2px 2px at 10% 20%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 22% 60%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 35% 12%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 48% 40%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 58% 18%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 66% 55%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 74% 30%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 90% 65%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 5% 70%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40% 75%, #fff 50%, transparent 51%);
  transition: opacity 600ms ease;
}

.game[data-scene="night"] .stars {
  opacity: 1;
  animation: twinkle 3s ease-in-out infinite alternate;
}

/* Falling petals: only visible in the blossom scene */
.falling-petals span {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 9px;
  border-radius: 80% 0 80% 0;
  background: #ffb3cf;
  opacity: 0;
  z-index: 260;
}

.game[data-scene="blossom"] .falling-petals span {
  opacity: 0.9;
  animation: petal-fall linear infinite;
}

/* Spread the petals out: different start positions, speeds and delays */
.falling-petals span:nth-child(1)  { left: 5%;  animation-duration: 9s;  animation-delay: -1s; }
.falling-petals span:nth-child(2)  { left: 15%; animation-duration: 12s; animation-delay: -6s; }
.falling-petals span:nth-child(3)  { left: 27%; animation-duration: 10s; animation-delay: -3s; }
.falling-petals span:nth-child(4)  { left: 38%; animation-duration: 13s; animation-delay: -9s; }
.falling-petals span:nth-child(5)  { left: 49%; animation-duration: 11s; animation-delay: -2s; }
.falling-petals span:nth-child(6)  { left: 60%; animation-duration: 9s;  animation-delay: -7s; }
.falling-petals span:nth-child(7)  { left: 70%; animation-duration: 14s; animation-delay: -4s; }
.falling-petals span:nth-child(8)  { left: 80%; animation-duration: 10s; animation-delay: -8s; }
.falling-petals span:nth-child(9)  { left: 88%; animation-duration: 12s; animation-delay: -5s; }
.falling-petals span:nth-child(10) { left: 95%; animation-duration: 11s; animation-delay: -10s; }

/* Short fade when a new scene appears */
.game.is-changing-scene .scene,
.game.is-changing-scene .field {
  animation: scene-in 700ms ease;
}

/* ---------- 8. ANIMATIONS ---------- */
@keyframes flap {
  from { transform: rotate(-18deg) scaleY(1); }
  to { transform: rotate(14deg) scaleY(0.6); }
}

@keyframes sway {
  from { transform: rotate(-4deg); }
  to { transform: rotate(4deg); }
}

@keyframes drift {
  from { left: -160px; }
  to { left: 110%; }
}

@keyframes hover-bob {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-6px) rotate(6deg); }
}

@keyframes jitter {
  0% { transform: scaleX(var(--facing, 1)) translate(1px, 0); }
  50% { transform: scaleX(var(--facing, 1)) translate(-1px, 1px); }
  100% { transform: scaleX(var(--facing, 1)) translate(1px, -1px); }
}

@keyframes caught {
  0% { transform: scale(1) rotate(0); opacity: 1; }
  40% { transform: scale(1.25) rotate(-20deg); opacity: 1; }
  100% { transform: scale(0) rotate(240deg); opacity: 0; }
}

@keyframes float-up {
  from { transform: translate(-50%, 0) scale(0.8); opacity: 1; }
  to { transform: translate(-50%, -60px) scale(1.1); opacity: 0; }
}

@keyframes swing {
  0% { transform: rotate(0); }
  50% { transform: rotate(-25deg) scale(0.92); }
  100% { transform: rotate(0); }
}

@keyframes stung {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(18deg) scale(1.15); }
  40% { transform: rotate(-14deg); }
  60% { transform: rotate(10deg); }
  80% { transform: rotate(-6deg); }
}

@keyframes flash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

@keyframes wobble {
  0%, 100% { transform: rotate(0) scale(1); }
  30% { transform: rotate(-8deg) scale(1.08); }
  60% { transform: rotate(6deg) scale(1.04); }
}

@keyframes twinkle {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

@keyframes petal-fall {
  0% { transform: translate(0, 0) rotate(0); }
  50% { transform: translate(-30px, 300px) rotate(180deg); }
  100% { transform: translate(20px, 700px) rotate(360deg); }
}

@keyframes scene-in {
  from { opacity: 0; filter: blur(6px); }
  to { opacity: 1; filter: blur(0); }
}

@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.9); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  20% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(0.98); }
}

@keyframes node-pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.06); }
}

@keyframes pop-in {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------- 9. RESPONSIVE & ACCESSIBILITY TWEAKS ---------- */

/* Small screens: stack the HUD into two rows (pot on top spanning full width) */
@media (max-width: 560px) {
  .header-actions .btn {
    padding: var(--space-2) var(--space-3);
    font-size: var(--fs-sm);
  }

  .hud {
    grid-template-columns: 1fr 1fr;
  }

  .hud__item:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .card {
    padding: var(--space-3) var(--space-4);
  }
}

/* Touch screens: the net stays where you last tapped, slightly see-through
   so it doesn't hide the bees diving at it */
@media (hover: none) {
  .cursor.is-visible { opacity: 0.8; }
}

/* Respect users who prefer less motion: stop decorative animations */
@media (prefers-reduced-motion: reduce) {
  .cloud,
  .flower svg,
  .stars,
  .falling-petals span,
  .game.is-changing-scene .scene,
  .game.is-changing-scene .field,
  .logo-mark,
  .game.is-shaking {
    animation: none;
  }

  .bee__wing {
    animation-duration: 600ms;
  }
}
