/* ============================================================
   BEE RESCUE: GARDEN PATROL  -  style sheet
   Colours are set once here, so a re-skin is easy.
   ============================================================ */
:root {
  --ink: #6b4b2d;
  --ink-soft: #927158;
  --edge: #82542e;
  --edge-shadow: #87552d;
  --panel: #fff8e8;
  --gold: #f4b52e;
}

@font-face {
  font-family: Fredoka;
  src: url('../assets/fonts/fredoka.ttf');
  font-weight: 300 700;
  font-display: swap;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; font-family: Fredoka, system-ui, sans-serif; color: var(--ink); }
body { background: #bceba2; user-select: none; -webkit-user-select: none; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- icons ---------- */
.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; fill: currentColor; }
.ic.gold { color: var(--gold); }

/* ---------- screens ---------- */
.screen {
  display: none; position: fixed; inset: 0; overflow: auto; flex-direction: column;
  background: linear-gradient(#ffffff1a, #ffe9a511), url('../assets/images/garden-1.jpg') center / cover;
}
.screen.active { display: flex; animation: screenIn .35s ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- buttons ---------- */
.btn, .round, .level {
  border: 4px solid var(--edge); border-radius: 17px; color: #fff; font-weight: 700;
  text-shadow: 0 2px #97613d;
  box-shadow: inset 0 4px #ffffffb0, 0 5px var(--edge-shadow), 0 9px 15px #345c3440;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn { padding: 12px 20px; font-size: 19px; line-height: 1.1; display: inline-flex; align-items: center; justify-content: center; gap: 9px; }
@media (hover: hover) {
  .btn:hover:not(:disabled), .round:hover:not(:disabled), .level:hover:not(:disabled) {
    transform: translateY(-3px); filter: brightness(1.07) saturate(1.08);
    box-shadow: inset 0 4px #ffffffb0, 0 8px var(--edge-shadow), 0 14px 18px #345c3455;
  }
}
.btn:active:not(:disabled), .round:active:not(:disabled), .level:active:not(:disabled) {
  transform: translateY(4px); filter: none; box-shadow: inset 0 3px #ffffffa0, 0 1px var(--edge-shadow);
}
.btn:focus-visible, .round:focus-visible, .level:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
.btn:disabled { filter: grayscale(.55) brightness(.95); opacity: .75; cursor: default; }
.round:disabled { filter: grayscale(.6); opacity: .55; cursor: default; }

.orange { background: linear-gradient(#ffd48b, #ffa34b 55%, #e97c29); }
.purple { background: linear-gradient(#f4d7ff, #c89bf0 55%, #a86bd2); }
.green  { background: linear-gradient(#baf4a8, #78d985 55%, #43af63); }
.blue   { background: linear-gradient(#b6efff, #68c5ed 55%, #3997d3); }
.yellow { background: linear-gradient(#fff1a0, #ffce58 55%, #eba337); }
.pink   { background: linear-gradient(#ffd3e7, #f694bd 55%, #dc6c9d); }
.cream, .round { background: linear-gradient(#fff9de, #f1d4a0); color: #754a30; text-shadow: none; }
.small { font-size: 16px; padding: 9px 14px; }
.round { width: 49px; height: 49px; flex: none; font-size: 22px; line-height: 1; display: inline-grid; place-items: center; padding: 0; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; background: #fff8df; border: 3px solid #8c5b36;
  border-radius: 30px; padding: 7px 12px; font-weight: 700; box-shadow: 0 4px #be8d59; white-space: nowrap;
}

/* ---------- menu ---------- */
.top { display: flex; justify-content: flex-end; gap: 9px; padding: 16px 22px; }
.home {
  width: min(1050px, 96vw); margin: auto; display: grid; grid-template-columns: 1fr 1fr;
  align-items: center; gap: 22px 20px; padding: 0 20px 28px;
}
.brand { text-align: center; }
.brand-card {
  display: inline-block; padding: 22px 28px 20px; background: #fff8e8e6; border: 4px solid #92613b;
  border-radius: 27px; box-shadow: 0 7px #c08d59, 0 16px 35px #41684a44;
}
.eyebrow { font-size: 12px; letter-spacing: 2px; font-weight: 700; color: #a46a43; }
.brand h1 {
  font-size: clamp(55px, 7vw, 90px); line-height: .9; margin: 14px 0; color: #f6a33d;
  -webkit-text-stroke: 2px #784a31; text-shadow: 0 6px #9b653c, 0 10px 14px #456a4355;
}
.brand h1 span { color: #fff0a1; }
.brand h2 {
  display: inline-block; border: 3px solid #a36b3f; border-radius: 30px; background: #ffe596;
  color: #a66335; font-size: 18px; letter-spacing: 3px; padding: 6px 20px; margin: 0;
}
.brand p { font-size: 20px; font-weight: 600; color: #6b4f3a; margin: 14px 0 0; }

.hero { height: 320px; position: relative; display: flex; justify-content: center; align-items: center; }
.hero img {
  height: 300px; max-width: 90%; object-fit: contain; position: relative;
  filter: drop-shadow(0 9px 5px #49664477); animation: heroFloat 3.2s ease-in-out infinite;
}
.halo {
  position: absolute; width: 280px; height: 280px; border: 6px solid #fff8; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff9, #ffe9a9aa, #a8e5c599);
  animation: haloPulse 3.2s ease-in-out infinite;
}
@keyframes heroFloat { 0%, 100% { transform: translateY(8px) rotate(-1.5deg); } 50% { transform: translateY(-10px) rotate(1.5deg); } }
@keyframes haloPulse { 0%, 100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.06); opacity: 1; } }

.actions { grid-column: 1 / -1; text-align: center; }
.primary { display: flex; justify-content: center; gap: 14px; }
.primary .btn { font-size: 28px; min-width: 220px; justify-content: space-between; }
.menu-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; max-width: 900px; margin: 18px auto 0; }
.note { color: #7a5a40; font-size: 14px; font-weight: 600; }
.actions .note { display: inline-block; background: #fff8e8e6; border-radius: 20px; padding: 5px 16px; margin: 16px 0 0; }
.version { margin: 4px 0 0; font-size: 12px; opacity: .8; }

/* ---------- panels ---------- */
.panel {
  width: min(850px, 94vw); margin: 24px auto; padding: 24px 30px; background: #fff8e8f2;
  border: 4px solid #92613b; border-radius: 27px; box-shadow: 0 7px #c08d59, 0 16px 35px #41684a44; text-align: center;
}
.panel h2 { font-size: 34px; color: #75472e; margin: 6px; }
.panel p { color: var(--ink-soft); }

.loading { margin: auto; width: min(440px, 92vw); }
.loading img { height: 160px; max-width: 100%; object-fit: contain; animation: heroFloat 1.6s ease-in-out infinite; }
.loading h1 { font-size: 40px; color: #e99a34; margin: 8px; }

.track, .energy-track { height: 19px; background: #e7d9ba; border: 3px solid #b48458; border-radius: 20px; overflow: hidden; }
.track { margin: 18px auto 5px; max-width: 280px; }
.track i, .energy-track i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #a2d965, #ffd35b); transition: width .25s ease; }

header {
  padding: 14px 24px; background: #fff6e2ed; border-bottom: 4px solid #a87446; display: flex;
  align-items: center; justify-content: space-between; gap: 10px;
}
header h2 { font-size: 27px; margin: 0; }

.levels-panel { max-width: 760px; }
.world-picker { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.world-picker p { margin: 4px; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 18px 0; }
.level {
  height: auto; aspect-ratio: 1.15; font-size: 28px; background: linear-gradient(#b4edff, #57bce8);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.level b { line-height: 1; }
.level span { display: flex; gap: 1px; font-size: 14px; color: var(--gold); line-height: 1; }
.level span .ic { width: 1em; height: 1em; }
.level.current { background: linear-gradient(#ffe9a0, #ffb94d); animation: currentPulse 1.8s ease-in-out infinite; }
@keyframes currentPulse { 0%, 100% { box-shadow: inset 0 4px #ffffffb0, 0 5px var(--edge-shadow), 0 0 0 0 #fff8; } 50% { box-shadow: inset 0 4px #ffffffb0, 0 5px var(--edge-shadow), 0 0 0 8px #fff0; } }
.level.locked { background: linear-gradient(#e5d7bd, #c7b49b); color: #a38a72; text-shadow: none; box-shadow: 0 4px #a58a70; }
.level.locked span { color: #a38a72; }

.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; text-align: left; margin: 22px 0; }
.cards article { background: #fffdf2; border: 2px solid #eac89a; border-radius: 18px; padding: 15px; }
.cards b { display: inline-grid; place-items: center; background: #f9b65b; border-radius: 50%; color: #fff; width: 38px; height: 38px; }
.cards h3 { font-size: 20px; margin: 8px 0 3px; }
.cards p { font-size: 16px; margin: 0; line-height: 1.35; }

.setting-panel { max-width: 520px; }
.setting { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #ebd8b9; padding: 16px 0; font-weight: 600; font-size: 20px; }

/* ---------- game screen ---------- */
#game { overflow: hidden; background: #c5eca9; }
.game-header {
  display: flex; align-items: center; justify-content: center; gap: 16px; min-height: 68px;
  background: #fff7e5ee; border-bottom: 4px solid #a87446; padding: 7px 12px;
}
.game-title { text-align: center; display: flex; flex-direction: column; min-width: 140px; }
.game-title small { font-size: 11px; letter-spacing: 1px; color: #a67950; font-weight: 700; }
.game-title b { font-size: 21px; }
.bug-icon { width: 23px; height: 23px; object-fit: contain; }
.stage { flex: 1; min-height: 0; position: relative; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
canvas.hit { animation: hitShake .35s ease; }
@keyframes hitShake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
.hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: #fff9e8ee; border: 2px solid #fff;
  border-radius: 30px; padding: 5px 13px; font-size: 14px; font-weight: 600; white-space: nowrap; pointer-events: none;
}
.game-bottom {
  min-height: 78px; background: #fff6e3ed; border-top: 4px solid #a87446; display: flex;
  align-items: center; justify-content: center; gap: 24px; padding: 9px 20px;
}
.energy { width: min(330px, 55vw); }
.energy > div:first-child { display: flex; justify-content: space-between; font-size: 14px; color: #8c6848; }
.energy-track { margin-top: 6px; }
.energy-track i { width: 100%; }
.energy.low .energy-track i { background: linear-gradient(90deg, #ff8a7a, #ffb25b); }
.energy.low .energy-track { animation: lowPulse .9s ease-in-out infinite; }
.energy.hit .energy-track { animation: hitShake .35s ease; border-color: #d9534f; }
@keyframes lowPulse { 0%, 100% { border-color: #b48458; } 50% { border-color: #e0584a; } }
.status { font-size: 16px; font-weight: 700; color: #8a5d3a; }

/* ---------- dialog ---------- */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 12px; background: #40372fb0; animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(450px, 96vw); max-height: 96dvh; overflow: auto; border: 4px solid #8c5735; border-radius: 27px;
  padding: 9px; background: #dca16c; box-shadow: 0 15px 30px #42352e55; animation: pop .32s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes pop { from { opacity: 0; transform: scale(.85) translateY(14px); } to { opacity: 1; transform: none; } }
.modal-inner { text-align: center; background: #fff7e5; border: 3px solid #fff; border-radius: 18px; padding: 16px 24px; }
.modal img { width: 95px; height: 105px; object-fit: contain; animation: heroFloat 2.4s ease-in-out infinite; }
.modal h2 { font-size: 32px; margin: 4px; }
.modal p { font-size: 17px; color: #85654c; margin: 5px 0; }
#modalStars { display: flex; justify-content: center; gap: 6px; font-size: 40px; color: var(--gold); min-height: 0; }
#modalStars .ic { filter: drop-shadow(0 3px 0 #a6652e55); animation: starIn .5s cubic-bezier(.2, 1.6, .4, 1) both; }
#modalStars .ic:nth-child(2) { animation-delay: .15s; }
#modalStars .ic:nth-child(3) { animation-delay: .3s; }
@keyframes starIn { from { opacity: 0; transform: scale(.2) rotate(-40deg); } to { opacity: 1; transform: none; } }
#modalButtons { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; }

/* ---------- small screens ---------- */
@media (max-width: 700px) {
  .top { padding: 9px; }
  .pill { font-size: 12px; padding: 5px 8px; }
  .home { display: flex; flex-direction: column; justify-content: flex-start; flex-shrink: 0; padding: 10px 12px 24px; }
  .brand-card { padding: 14px 16px; }
  .brand h1 { font-size: 48px; margin: 12px 0; }
  .brand h2 { font-size: 15px; }
  .brand p { font-size: 15px; margin: 8px 0 0; }
  .eyebrow { font-size: 10px; }
  .hero { height: 190px; }
  .hero img { height: 180px; }
  .halo { width: 170px; height: 170px; }
  .primary { gap: 8px; }
  .primary .btn { min-width: 0; width: 45vw; max-width: 180px; font-size: 22px; }
  .menu-grid { grid-template-columns: 1fr 1fr; width: min(360px, 94vw); gap: 10px; margin: 15px auto 0; }
  .menu-grid .btn { font-size: 16px; min-height: 50px; padding: 8px 4px; }
  header { padding: 10px; }
  header h2 { font-size: 20px; }
  header .btn { padding: 8px 12px; font-size: 16px; }
  .panel { padding: 18px 16px; margin: 16px auto; }
  .panel h2 { font-size: 26px; }
  .cards { grid-template-columns: 1fr; }
  .level-grid { gap: 7px; }
  .level { border-width: 3px; font-size: 21px; border-radius: 12px; }
  .level span { font-size: 10px; }
  .round { height: 40px; width: 40px; }
  .game-header { min-height: 56px; gap: 6px; padding: 5px; }
  .game-title { min-width: 75px; }
  .game-title b { font-size: 16px; }
  .game-title small { font-size: 9px; }
  .hint { font-size: 11px; max-width: 95%; overflow: hidden; text-overflow: ellipsis; }
  .game-bottom { min-height: 68px; padding: 8px 10px; gap: 10px; }
  .energy { flex: 1; }
  .status { font-size: 13px; }
  .modal h2 { font-size: 27px; }
}

/* ---------- menu always fits one screen (no scrolling) ---------- */
#menu { overflow: hidden; }
#menu .top { padding: clamp(6px, 1.6vh, 16px) 22px; }
#menu .home {
  flex: 1; min-height: 0; width: min(1050px, 96vw); margin: 0 auto; padding: 0 20px clamp(8px, 2vh, 24px);
  grid-template-rows: minmax(0, 1fr) auto; gap: clamp(8px, 2vh, 22px) 20px;
}
#menu .brand { align-self: center; }
#menu .brand-card { padding: clamp(10px, 2.6vh, 22px) clamp(16px, 2.6vh, 28px); }
#menu .brand h1 { font-size: clamp(34px, min(7vw, 11.5vh), 90px); margin: clamp(4px, 1.4vh, 14px) 0; }
#menu .brand h2 { font-size: clamp(13px, 2.6vh, 18px); padding: 4px 18px; }
#menu .brand p { font-size: clamp(13px, 2.8vh, 20px); margin-top: clamp(6px, 1.4vh, 14px); }
#menu .eyebrow { font-size: clamp(9px, 1.6vh, 12px); }
#menu .hero { height: 100%; min-height: 0; }
#menu .hero img { height: auto; max-height: min(300px, 92%); width: auto; max-width: 90%; }
#menu .halo { width: min(280px, 42vh); height: min(280px, 42vh); }
#menu .primary .btn { font-size: clamp(18px, 3.8vh, 28px); padding: clamp(7px, 1.5vh, 12px) 20px; }
#menu .menu-grid { margin-top: clamp(8px, 1.6vh, 18px); gap: clamp(8px, 1.6vh, 14px) 14px; }
#menu .menu-grid .btn { font-size: clamp(14px, 2.6vh, 19px); padding: clamp(6px, 1.3vh, 12px) 12px; }
#menu .actions .note { margin-top: clamp(6px, 1.4vh, 16px); padding: 3px 14px; font-size: clamp(11px, 1.8vh, 14px); }
@media (max-width: 700px) {
  #menu .home { display: flex; flex-direction: column; padding: 0 12px 10px; gap: 8px; }
  #menu .brand { flex: none; }
  #menu .hero { flex: 1; min-height: 0; width: 100%; height: auto; }
  #menu .halo { width: min(170px, 80%); height: min(170px, 80%); }
  #menu .actions { flex: none; width: 100%; }
  #menu .primary .btn { min-width: 0; width: 45vw; max-width: 180px; }
  #menu .menu-grid { grid-template-columns: 1fr 1fr; width: min(360px, 94vw); }
}
@media (max-width: 700px) and (max-height: 460px) {
  #menu .home { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  #menu .brand-card { padding: 8px 12px; }
  #menu .hero { height: 100%; }
  #menu .hero img { max-height: 44vh; }
  #menu .halo { width: 40vh; height: 40vh; }
  #menu .brand h1 { font-size: 34px; margin: 4px 0; }
  #menu .brand p { margin-top: 4px; }
  #menu .actions { grid-column: 1 / -1; }
  #menu .primary .btn { width: auto; min-width: 150px; font-size: 18px; padding: 6px 14px; }
  #menu .menu-grid { grid-template-columns: repeat(4, 1fr); width: auto; max-width: 600px; }
  #menu .menu-grid .btn { font-size: 13px; min-height: 0; padding: 5px 4px; }
  #menu .note { display: none; }
}
@media (max-height: 460px) and (min-width: 701px) {
  #menu .menu-grid .btn { padding: 5px 8px; }
  #menu .note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
