:root {
  --tan: #e8a85a;
  --tan-dark: #c47e34;
  --cream: #fbe6cf;
  --green: #7cc36a;
  --green-dark: #3f7a3a;
  --ink: #20281f;
  --panel: #243524;
  --accent: #ffd24a;
  --danger: #ff5b5b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #0e160f;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--cream);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#game-wrap {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: #1b2a1f;
  image-rendering: optimizeQuality;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-weight: bold;
  text-shadow: 0 2px 0 rgba(0,0,0,0.45);
}

.hud-top {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 16px;
}
.hud-block { text-align: left; }
.hud-block.center { text-align: center; flex: 1; }
.hud-block.right { text-align: right; }
.hud-label { font-size: 12px; letter-spacing: 2px; opacity: 0.7; }
.hud-value { font-size: 30px; line-height: 1; color: #fff; }
#wave { color: var(--accent); }

.hud-health-row {
  position: absolute;
  top: calc(max(12px, env(safe-area-inset-top)) + 58px);
  left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.paw { font-size: 18px; filter: drop-shadow(0 1px 0 rgba(0,0,0,0.4)); }
.health-bar {
  width: 190px; max-width: 40vw;
  height: 16px;
  background: rgba(0,0,0,0.4);
  border: 2px solid rgba(0,0,0,0.5);
  border-radius: 10px;
  overflow: hidden;
}
.health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff7a7a, #6fe06f);
  background-size: 250px 100%;
  transition: width 0.18s ease;
}

.combo {
  position: absolute;
  top: calc(max(12px, env(safe-area-inset-top)) + 84px);
  left: 16px;
  font-size: 22px;
  color: var(--accent);
  text-shadow: 0 2px 0 rgba(0,0,0,0.5);
}

.icon-btn {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(0,0,0,0.35);
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  pointer-events: auto;
  display: flex; align-items: center; justify-content: center;
}
#pause-btn { right: 64px; letter-spacing: 1px; }
#mute-btn { right: 16px; }
.icon-btn:active { transform: scale(0.92); }

.dash-meter {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 160px; height: 14px;
  background: rgba(0,0,0,0.4);
  border: 2px solid rgba(0,0,0,0.5);
  border-radius: 8px;
  overflow: hidden;
}
.dash-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #6fd0ff, #c9a3ff);
  transition: width 0.1s linear;
}
.dash-label {
  position: absolute;
  inset: 0;
  font-size: 10px;
  letter-spacing: 2px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}

/* ---------- Banner ---------- */
.banner {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(28px, 8vw, 64px);
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  text-align: center;
  text-shadow: 0 4px 0 rgba(0,0,0,0.45);
  pointer-events: none;
  animation: bannerPop 0.4s ease both;
  white-space: nowrap;
}
.banner.boss { color: var(--danger); }
@keyframes bannerPop {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  60% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(20,30,20,0.7), rgba(8,14,9,0.92));
  backdrop-filter: blur(2px);
  z-index: 10;
  padding: 16px;
}
.panel {
  width: min(440px, 92vw);
  background: linear-gradient(160deg, #2c3f2c, #1c2a1c);
  border: 3px solid rgba(255,255,255,0.12);
  border-radius: 22px;
  padding: 28px 26px 30px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.55), inset 0 2px 0 rgba(255,255,255,0.08);
  max-height: 96vh;
  overflow-y: auto;
}

.game-title {
  font-size: clamp(34px, 11vw, 64px);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: 1px;
  color: var(--tan);
  text-shadow: 0 4px 0 var(--tan-dark), 0 6px 14px rgba(0,0,0,0.5);
}
.game-title span { display: block; color: var(--green); text-shadow: 0 4px 0 var(--green-dark); }
.shiba-emoji { font-size: 70px; margin: 8px 0 2px; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
.tagline { opacity: 0.85; margin-bottom: 18px; font-size: 15px; }

.big-btn {
  display: block;
  width: 100%;
  margin: 6px 0;
  padding: 15px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--ink);
  background: linear-gradient(180deg, var(--accent), #e6b321);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 5px 0 #b98a14, 0 8px 16px rgba(0,0,0,0.35);
  transition: transform 0.06s, box-shadow 0.06s;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #b98a14; }

.text-btn {
  background: none;
  border: none;
  color: var(--cream);
  opacity: 0.75;
  font-size: 14px;
  margin-top: 10px;
  cursor: pointer;
  text-decoration: underline;
}
.text-btn:hover { opacity: 1; }

.how {
  text-align: left;
  margin-top: 16px;
  background: rgba(0,0,0,0.25);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
}
.how h3 { margin-bottom: 8px; color: var(--accent); }
.how ul { list-style: none; }
.how li { margin: 7px 0; line-height: 1.4; }
.how .tip { margin-top: 10px; opacity: 0.85; font-size: 13px; }
.key {
  display: inline-block;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 12px;
  font-family: ui-monospace, monospace;
}
.credit { margin-top: 16px; font-size: 13px; opacity: 0.7; }

.panel h2 { font-size: 34px; margin-bottom: 12px; }
.go-title { color: var(--danger); }
.go-emoji { font-size: 56px; margin-bottom: 12px; }
.go-stats { display: flex; justify-content: center; gap: 22px; margin-bottom: 16px; }
.go-stats > div { display: flex; flex-direction: column; }
.go-label { font-size: 12px; letter-spacing: 1px; opacity: 0.7; }
.go-num { font-size: 30px; font-weight: 900; color: var(--accent); }
.new-best { color: var(--accent); font-weight: 900; margin-bottom: 12px; font-size: 18px; animation: bob 1.2s infinite; }

/* ---------- Touch controls ---------- */
#touch-controls { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.joystick {
  position: absolute;
  bottom: max(34px, env(safe-area-inset-bottom));
  left: 28px;
  width: 130px; height: 130px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(255,255,255,0.18);
  pointer-events: auto;
  touch-action: none;
}
.joystick-knob {
  position: absolute;
  top: 50%; left: 50%;
  width: 56px; height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.28);
  border: 2px solid rgba(255,255,255,0.35);
}
.pounce-btn {
  position: absolute;
  bottom: max(46px, calc(env(safe-area-inset-bottom) + 12px));
  right: 28px;
  width: 110px; height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c9a3ff, #7a4fd0);
  border: 3px solid rgba(255,255,255,0.4);
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 1px;
  pointer-events: auto;
  box-shadow: 0 6px 0 #4f2f9e;
  touch-action: none;
}
.pounce-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #4f2f9e; }
.pounce-btn.cooling { opacity: 0.45; }

/* ---------- Title extras ---------- */
.meta-line { font-size: 13px; opacity: 0.8; margin-bottom: 14px; }
.meta-line b { color: var(--accent); }
.title-links { display: flex; gap: 18px; justify-content: center; }

.skins { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; }
.skin {
  width: 56px; height: 56px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.25);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: bold;
  position: relative;
  color: var(--cream);
  pointer-events: auto;
}
.skin.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,210,74,0.4); }
.skin.locked { opacity: 0.5; cursor: not-allowed; }
.skin .swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(0,0,0,0.4); }
.skin .lock { position: absolute; font-size: 18px; }
.skin .req { position: absolute; bottom: -16px; font-size: 9px; opacity: 0.7; white-space: nowrap; }

/* ---------- Upgrade cards ---------- */
.panel.wide { width: min(680px, 95vw); }
.up-title { color: var(--accent); }
.up-sub { opacity: 0.8; margin-bottom: 16px; font-size: 14px; }
.up-hint { margin-top: 14px; font-size: 13px; opacity: 0.7; }
.cards { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.card {
  flex: 1 1 0;
  min-width: 150px;
  max-width: 200px;
  background: linear-gradient(165deg, #32472f, #1f2d1f);
  border: 2px solid var(--rar, #9fe08a);
  border-radius: 16px;
  padding: 18px 14px 16px;
  cursor: pointer;
  position: relative;
  text-align: center;
  transition: transform 0.08s, box-shadow 0.08s;
  pointer-events: auto;
}
.card:hover, .card.focus {
  transform: translateY(-6px) scale(1.03);
  box-shadow: 0 10px 22px rgba(0,0,0,0.4), 0 0 0 2px var(--rar);
}
.card-rarity {
  font-size: 10px; letter-spacing: 2px; font-weight: 900;
  color: var(--rar, #9fe08a); margin-bottom: 6px;
}
.card-icon { font-size: 42px; margin-bottom: 8px; }
.card-name { font-size: 17px; font-weight: 900; margin-bottom: 6px; color: #fff; }
.card-desc { font-size: 13px; opacity: 0.85; line-height: 1.3; min-height: 34px; }
.card-key {
  margin-top: 10px;
  display: inline-block;
  width: 24px; height: 24px; line-height: 22px;
  border-radius: 7px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  font-family: ui-monospace, monospace; font-size: 13px;
}

/* ---------- Settings toggles ---------- */
.toggle {
  display: block; width: 100%;
  margin: 8px 0; padding: 13px 16px;
  font-size: 16px; font-weight: bold;
  color: var(--cream);
  background: rgba(0,0,0,0.28);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
}
.toggle span { float: right; font-weight: 900; }
.toggle.on span { color: #7cff7c; }
.toggle.off span { color: #ff7a7a; }

@media (max-width: 520px) {
  .cards { gap: 10px; }
  .card { min-width: 90px; padding: 14px 8px; }
  .card-icon { font-size: 34px; }
  .card-name { font-size: 14px; }
  .card-desc { font-size: 11px; min-height: 44px; }
}
