:root {
  --honey: #ffb300;
  --honey-d: #e08e00;
  --cream: #fff8e6;
  --cream-d: #f3e3b8;
  --brown: #4a2f12;
  --brown-l: #8a6a45;
  --green: #58a942;
  --purple: #8e5cf0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: 'Fredoka', system-ui, 'Segoe UI', sans-serif;
  color: var(--brown);
  background: #5fae48;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }

#app { display: flex; height: 100%; }

/* ---------- stage ---------- */
#stage { position: relative; flex: 1; min-width: 0; min-height: 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }

#hud { position: absolute; top: 14px; left: 14px; pointer-events: none; }
#honeyBox {
  background: rgba(255, 248, 230, .92);
  border: 3px solid #fff;
  border-radius: 22px;
  padding: 8px 18px 8px 12px;
  box-shadow: 0 6px 18px rgba(40, 25, 5, .22);
  min-width: 150px;
}
#honeyRow { display: flex; align-items: center; gap: 8px; font-size: 34px; font-weight: 700; line-height: 1.1; }
#honeyRow .drop { font-size: 28px; }
#rate { font-size: 15px; font-weight: 500; color: var(--brown-l); padding-left: 4px; }
#jellyRow { font-size: 15px; font-weight: 600; color: var(--purple); padding-left: 4px; margin-top: 2px; }

#buff {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(#ffe27a, #ffb300);
  border: 3px solid #fff; border-radius: 18px;
  padding: 6px 16px 8px; text-align: center;
  box-shadow: 0 6px 20px rgba(255, 170, 0, .5);
  pointer-events: none;
  animation: pulse 0.6s ease-in-out infinite alternate;
}
#buffLabel { font-weight: 700; font-size: 17px; color: #6b3d00; white-space: nowrap; }
#buffBar { height: 6px; border-radius: 3px; background: rgba(107, 61, 0, .25); margin-top: 4px; overflow: hidden; }
#buffBar i { display: block; height: 100%; width: 100%; background: #fff; border-radius: 3px; }
@keyframes pulse { from { transform: translateX(-50%) scale(1); } to { transform: translateX(-50%) scale(1.05); } }

#hint {
  position: absolute; bottom: 58px; left: 50%; transform: translateX(-50%);
  max-width: min(90%, 460px);
  background: rgba(74, 47, 18, .88); color: #fff8e6;
  padding: 10px 18px; border-radius: 16px;
  font-size: 16px; font-weight: 500; text-align: center;
  pointer-events: none;
  animation: bob 1.2s ease-in-out infinite alternate;
}
@keyframes bob { from { margin-bottom: 0; } to { margin-bottom: 6px; } }

#stats {
  position: absolute; left: 14px; bottom: 12px;
  background: rgba(255, 248, 230, .85); border-radius: 14px;
  padding: 5px 12px; font-size: 14px; font-weight: 500;
  pointer-events: none;
}

#tools { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 8px; }
#tools button {
  width: 38px; height: 38px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(255, 248, 230, .88);
  font-size: 14px; font-weight: 700; display: grid; place-items: center; padding: 0;
  box-shadow: 0 3px 8px rgba(40, 25, 5, .2);
}
#tools button:hover { background: #fff; }

#toasts { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  background: #fff; border: 3px solid var(--honey); border-radius: 16px;
  padding: 8px 14px; font-weight: 600; font-size: 15px;
  box-shadow: 0 6px 18px rgba(40, 25, 5, .25);
  animation: toastIn .35s cubic-bezier(.2, 1.4, .4, 1), toastOut .4s 3.2s forwards;
  max-width: 300px;
}
.toast.gold { background: linear-gradient(#fff3b8, #ffd54a); }
.toast small { display: block; font-weight: 500; color: var(--brown-l); }
@keyframes toastIn { from { transform: translateX(40px) scale(.8); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-10px); opacity: 0; } }

#flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity 1.2s; }
#flash.on { opacity: 1; transition: opacity .15s; }

/* ---------- panel ---------- */
#panel {
  width: 372px; flex: none;
  background: var(--cream);
  display: flex; flex-direction: column;
  box-shadow: -6px 0 24px rgba(40, 25, 5, .25);
  border-left: 4px solid #e9c46a;
  z-index: 2; min-height: 0;
}
#brand { display: flex; align-items: center; gap: 8px; padding: 12px 16px 6px; font-size: 26px; font-weight: 700; color: #b36b00; }
#brand .logo { font-size: 28px; }

#tabs { display: flex; gap: 6px; padding: 6px 12px 0; }
#tabs button {
  flex: 1; padding: 8px 4px; border: none; border-radius: 12px 12px 0 0;
  background: var(--cream-d); font-weight: 600; font-size: 15px; color: var(--brown-l); position: relative;
}
#tabs button.on { background: #fff; color: var(--brown); box-shadow: 0 -2px 0 var(--honey) inset; }
#tabs button.alert::after {
  content: ''; position: absolute; top: 6px; right: 8px; width: 9px; height: 9px; border-radius: 50%;
  background: #ff4d6d; box-shadow: 0 0 0 2px #fff;
}

#buyMode { display: flex; gap: 6px; padding: 8px 12px; background: #fff; border-bottom: 2px solid var(--cream-d); }
#buyMode button {
  flex: 1; padding: 4px; border-radius: 10px; border: 2px solid var(--cream-d); background: var(--cream);
  font-weight: 600; font-size: 14px; color: var(--brown-l);
}
#buyMode button.on { background: var(--honey); border-color: var(--honey-d); color: #fff; }

.tab { flex: 1; overflow-y: auto; padding: 10px 12px 16px; background: #fff; min-height: 0; }
.tab::-webkit-scrollbar { width: 8px; }
.tab::-webkit-scrollbar-thumb { background: var(--cream-d); border-radius: 4px; }

.card {
  display: grid; grid-template-columns: 46px 1fr auto; gap: 10px; align-items: center;
  width: 100%; text-align: left;
  padding: 9px 10px; margin-bottom: 8px;
  border-radius: 16px; border: 2px solid var(--cream-d); background: var(--cream);
  transition: transform .08s, box-shadow .15s, border-color .15s, opacity .15s;
  opacity: .66;
}
.card .ic { font-size: 26px; width: 46px; height: 46px; display: grid; place-items: center; background: #fff; border-radius: 12px; border: 2px solid var(--cream-d); }
.card .ic img { width: 42px; height: 42px; }
.card .nm { font-weight: 600; font-size: 16px; line-height: 1.15; }
.card .lvl { font-weight: 500; font-size: 12px; color: var(--brown-l); margin-left: 6px; }
.card .ds { font-size: 13px; color: var(--brown-l); line-height: 1.2; margin-top: 2px; }
.card .cost { font-weight: 700; font-size: 14px; padding: 5px 10px; border-radius: 999px; background: var(--cream-d); white-space: nowrap; }
.card.can { opacity: 1; border-color: var(--honey); background: #fff; box-shadow: 0 3px 0 var(--honey-d); }
.card.can .cost { background: var(--honey); color: #fff; }
.card.can:hover { transform: translateY(-1px); }
.card.can:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--honey-d); }
.card.maxed { opacity: .5; }
.card.special { background: linear-gradient(120deg, #fff6d8, #ffe9f2); border-style: dashed; }
.card.special.can { border-style: solid; border-color: #ff7aa8; box-shadow: 0 3px 0 #e0558f; }
.card.special.can .cost { background: #ff5d8f; }
.card.perk.can { border-color: var(--purple); box-shadow: 0 3px 0 #6a3fc7; }
.card.perk.can .cost { background: var(--purple); }

/* queen tab */
.queenBox { background: linear-gradient(160deg, #f6edff, #fff6d8); border: 2px solid #d9c2ff; border-radius: 18px; padding: 14px; margin-bottom: 12px; }
.queenBox h3 { margin: 0 0 6px; font-size: 20px; color: #6a3fc7; }
.queenBox p { margin: 0 0 10px; font-size: 14px; line-height: 1.35; color: var(--brown-l); }
.qStat { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.bar { height: 10px; border-radius: 5px; background: #e8dcff; overflow: hidden; margin: 8px 0; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #b28dff, #8e5cf0); border-radius: 5px; transition: width .3s; }
#qGain { font-size: 14px; font-weight: 600; color: #6a3fc7; margin-bottom: 10px; }
.bigBtn {
  width: 100%; padding: 11px; border-radius: 14px; border: none;
  background: var(--purple); color: #fff; font-weight: 700; font-size: 17px;
  box-shadow: 0 4px 0 #6a3fc7;
}
.bigBtn:active { transform: translateY(2px); box-shadow: 0 2px 0 #6a3fc7; }
.bigBtn:disabled { background: #cfc4e6; box-shadow: none; cursor: default; }
.secTitle { font-weight: 700; font-size: 15px; margin: 4px 2px 8px; color: var(--brown-l); }

/* achievements */
#achHead { font-weight: 600; font-size: 14px; color: var(--brown-l); margin: 0 2px 10px; }
.achGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ach { border: 2px solid var(--cream-d); border-radius: 14px; padding: 8px; background: var(--cream); opacity: .5; filter: grayscale(1); }
.ach.got { opacity: 1; filter: none; border-color: var(--honey); background: #fffbe9; }
.ach .aic { font-size: 22px; }
.ach .anm { font-weight: 600; font-size: 14px; line-height: 1.15; }
.ach .ads { font-size: 12px; color: var(--brown-l); line-height: 1.2; margin-top: 2px; }

/* modal */
#modal { position: fixed; inset: 0; background: rgba(40, 25, 5, .55); display: grid; place-items: center; z-index: 10; padding: 16px; }
#modal[hidden] { display: none; }
.mbox {
  background: var(--cream); border: 4px solid #fff; border-radius: 24px; padding: 22px 24px;
  max-width: 400px; width: 100%; text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
  animation: toastIn .3s cubic-bezier(.2, 1.4, .4, 1);
}
.mbox h2 { margin: 0 0 8px; font-size: 24px; color: #b36b00; }
.mbox p { margin: 0 0 16px; font-size: 16px; line-height: 1.4; }
.mbox b { color: #b36b00; }
#mBtns { display: flex; gap: 10px; justify-content: center; }
#mBtns button {
  padding: 10px 22px; border-radius: 14px; border: none; font-weight: 700; font-size: 16px;
  background: var(--honey); color: #fff; box-shadow: 0 4px 0 var(--honey-d);
}
#mBtns button.ghost { background: var(--cream-d); color: var(--brown); box-shadow: 0 4px 0 #d8c48f; }
#mBtns button:active { transform: translateY(2px); }

[hidden] { display: none !important; }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  #app { flex-direction: column; }
  #panel { width: 100%; height: 46%; border-left: none; border-top: 4px solid #e9c46a; box-shadow: 0 -6px 24px rgba(40, 25, 5, .25); }
  #brand { display: none; }
  #honeyRow { font-size: 26px; }
  #honeyRow .drop { font-size: 22px; }
  #hud { top: 8px; left: 8px; }
  #hint { bottom: 52px; font-size: 14px; }
  #toasts { top: 84px; left: 8px; right: 8px; align-items: center; }
  #buff { top: 84px; }
  .card { padding: 7px 8px; }
}
