* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #bcd5ee;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1d2330;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#hud {
  position: fixed;
  top: env(safe-area-inset-top, 12px);
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}

.money {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 800;
  font-size: 20px;
  color: #1d2330;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

#joystick {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 50%;
  height: 50%;
  pointer-events: auto;
}

.stick-base {
  position: absolute;
  left: 90px;
  bottom: 90px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  border: 2px solid rgba(255, 255, 255, 0.55);
  pointer-events: none;
  transform: translate(-50%, 50%);
}

.stick-thumb {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.popup {
  position: fixed;
  font-weight: 800;
  font-size: 20px;
  color: #2ecc71;
  text-shadow: 0 2px 0 rgba(255,255,255,0.7);
  pointer-events: none;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
}

/* --- v2 HUD --- */
.money {
  font-size: 24px;
  padding: 8px 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 3px 0 rgba(0,0,0,0.12), 0 6px 14px rgba(0,0,0,0.1);
}
.money.bump { animation: bump 0.18s ease-out; }
@keyframes bump { 50% { transform: scale(1.15); } }

.bag {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 800;
  font-size: 15px;
}
.bag.full { background: #e53935; color: #fff; animation: bump 0.5s infinite; }

.popup { font-size: 22px; -webkit-text-stroke: 1px rgba(0,0,0,0.25); }
.popup.p-wood  { color: #43a047; }
.popup.p-stone { color: #2ecc71; font-size: 28px; }
.popup.p-gold  { color: #ffb300; font-size: 38px; text-shadow: 0 0 12px rgba(255,193,7,0.9), 0 2px 0 #fff; }

.popup.p-big { color: #2ecc71; font-size: 44px; text-shadow: 0 3px 0 #fff, 0 0 16px rgba(46,204,113,0.6); }

/* --- v3 --- */
#goal {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 12px;
  max-width: calc(100% - 170px);
  padding: 9px 16px;
  border-radius: 16px;
  background: rgba(30, 35, 48, 0.82);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  line-height: 1.25;
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
  pointer-events: none;
}
#goal.in { animation: goalin 0.35s cubic-bezier(.3,1.6,.5,1); }
@keyframes goalin { from { transform: translateY(-14px) scale(0.9); opacity: 0; } }

#toast {
  position: fixed;
  left: 50%;
  top: 28%;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  padding: 14px 26px;
  border-radius: 20px;
  background: linear-gradient(#ffd54f, #ffb300);
  color: #4a2c00;
  font-weight: 900;
  font-size: 30px;
  white-space: nowrap;
  box-shadow: 0 6px 0 #c77c00, 0 12px 30px rgba(0,0,0,0.25);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
#toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); animation: toastin 0.45s cubic-bezier(.3,1.8,.5,1); }
@keyframes toastin { from { transform: translate(-50%, -50%) scale(0.3); } }

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #7fc65b;
  color: #fff;
  font-size: 34px;
  z-index: 5;
}
#loading span { width: 220px; height: 14px; border-radius: 8px; background: rgba(0,0,0,0.2); overflow: hidden; }
#loading i { display: block; height: 100%; width: 0; background: #fff; transition: width 0.15s; }

/* --- v5: lodge --- */
.lodge-badge {
  background: #ffb300;
  color: #3e2f1c;
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 900;
  font-size: 14px;
}

#loading em { font-style: normal; font-size: 22px; font-weight: 800; animation: tapPulse 1.1s ease-in-out infinite; }
@keyframes tapPulse { 50% { opacity: 0.45; transform: scale(0.96); } }
