* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #3f7422;
  font-family: "Baloo 2", "Segoe UI", system-ui, sans-serif;
  touch-action: none;
  overscroll-behavior: none;
}

#stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 960px;
  height: 600px;
  transform-origin: 0 0;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, .35);
}

#cv {
  position: absolute;
  inset: 0;
  width: 960px;
  height: 600px;
  display: block;
  cursor: pointer;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }

.pill {
  background: rgba(255, 248, 225, .94);
  border: 2px solid #8d6e3f;
  border-radius: 999px;
  padding: 2px 14px;
  font-weight: 800;
  color: #5d3d17;
  font-size: 19px;
  line-height: 32px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .25);
  white-space: nowrap;
}
#coins { min-width: 110px; }
#timer { min-width: 96px; }
#timer.gold { background: #fff3b0; border-color: #d4a017; }
#timer.silver { background: #eceff1; border-color: #90a4ae; }
#timer.bronze { background: #f3d5bf; border-color: #a0522d; }

#goals {
  display: flex;
  gap: 6px;
  margin: 0 auto;
}
.goal {
  background: rgba(255, 248, 225, .94);
  border: 2px solid #8d6e3f;
  border-radius: 12px;
  padding: 0 10px;
  font-weight: 800;
  font-size: 17px;
  line-height: 30px;
  color: #5d3d17;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .25);
}
.goal.done { background: #c8f7a8; border-color: #3f8a1c; color: #2e6b12; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 800;
  border: none;
  border-radius: 14px;
  padding: 6px 16px;
  background: linear-gradient(#ffe082, #ffb300);
  color: #5d3d17;
  box-shadow: 0 3px 0 #b07a00;
  cursor: pointer;
  font-size: 18px;
}
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #b07a00; }
.btn:disabled { filter: grayscale(1); opacity: .55; cursor: default; }
.btn.green { background: linear-gradient(#aed581, #689f38); color: #fff; box-shadow: 0 3px 0 #33691e; text-shadow: 0 1px 0 rgba(0,0,0,.3); }
.btn.red { background: linear-gradient(#ef9a9a, #e53935); color: #fff; box-shadow: 0 3px 0 #8e1b1b; }
.btn.small { font-size: 15px; padding: 2px 10px; border-radius: 10px; }
.btn.round { width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 20px; }
.btn.on { background: linear-gradient(#80deea, #00acc1); box-shadow: 0 3px 0 #00727f; }

/* ---------- Shop bar ---------- */
#shop {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
}
.buy {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px 3px 6px;
}
.buy .em { font-size: 26px; line-height: 34px; }
.buy .pr { font-size: 14px; line-height: 1.1; text-align: left; }
.buy .pr b { display: block; font-size: 13px; opacity: .8; }

/* ---------- Toast ---------- */
#toast {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(62, 39, 35, .9);
  color: #fff;
  padding: 6px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Modal ---------- */
#modal {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card {
  background: #fff8e1;
  border: 4px solid #8d6e3f;
  border-radius: 22px;
  padding: 16px 24px 20px;
  min-width: 380px;
  max-width: 660px;
  max-height: 560px;
  overflow: auto;
  color: #4e342e;
  box-shadow: 0 8px 0 rgba(0, 0, 0, .3);
  text-align: center;
}
.card.pop { animation: pop .22s ease-out; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.card h2 { margin: 0 0 6px; font-size: 30px; color: #6d3d0f; }
.card p { margin: 6px 0; font-size: 18px; line-height: 1.35; }
.card .row-btns { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.card ul.goals-list { list-style: none; padding: 0; margin: 8px 0; font-size: 21px; font-weight: 700; }
.card .stars { font-size: 52px; letter-spacing: 6px; }
.card .stars .off { filter: grayscale(1) brightness(1.4); opacity: .4; }
.card .tip { background: #fff0c2; border-radius: 12px; padding: 8px 12px; font-size: 17px; }
.card .muted { font-size: 15px; opacity: .75; }

table.items { width: 100%; border-collapse: collapse; font-size: 18px; margin: 6px 0; }
table.items td { padding: 4px 6px; border-bottom: 1px dashed #d7c49e; }
table.items td.em { font-size: 26px; width: 40px; }
table.items td.l { text-align: left; font-weight: 700; }
table.items td.num { font-weight: 800; min-width: 40px; }

.build-grid { display: flex; gap: 12px; justify-content: center; margin-top: 8px; }
.build-item {
  background: #fff;
  border: 2px solid #d7c49e;
  border-radius: 16px;
  padding: 10px 12px;
  width: 170px;
}
.build-item .big { font-size: 40px; }
.build-item .nm { font-weight: 800; font-size: 19px; }
.build-item .ds { font-size: 15px; margin-bottom: 6px; }

/* ---------- Menu ---------- */
#menu {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: radial-gradient(ellipse at center, rgba(30, 60, 15, .35), rgba(20, 45, 10, .65));
}
.title {
  font-size: 56px;
  font-weight: 800;
  color: #ffeb3b;
  line-height: 1;
  text-shadow: 0 4px 0 #8d4f0f, 0 0 2px #5d3d17, 3px 3px 0 #5d3d17, -3px -3px 0 #5d3d17, 3px -3px 0 #5d3d17, -3px 3px 0 #5d3d17;
}
.subtitle {
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  text-shadow: 0 2px 2px rgba(0, 0, 0, .6);
  margin-bottom: 8px;
}
.levels {
  display: grid;
  grid-template-columns: repeat(10, 74px);
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding: 8px;
  touch-action: pan-y;
  background: rgba(62, 39, 35, .35);
  border-radius: 18px;
}
.lvl {
  height: 62px;
  font-size: 24px;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border-radius: 14px;
}
.lvl small { font-size: 11px; margin-top: 4px; letter-spacing: 0; }
.menu-row { display: flex; gap: 10px; margin-top: 6px; align-items: center; }
.btn.big { font-size: 22px; padding: 8px 22px; }
.btn.blue { background: linear-gradient(#81d4fa, #0288d1); color: #fff; box-shadow: 0 3px 0 #01579b; }

/* ---------- Portrait hint ---------- */
#rotate {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px;
  text-align: center;
  background: #fff8e1;
  color: #5d3d17;
  font-weight: 700;
  z-index: 10;
  display: none;
}
@media (orientation: portrait) and (max-width: 760px) {
  #rotate { display: block; }
}
