:root {
  --gold: #ffd23f;
  --gold-deep: #f29e1f;
  --ink: #1b1d3a;
  --sky: #69b8ff;
  --glass: rgba(20, 24, 58, 0.58);
  --stroke: 0 3px 0 #1b1d3a, 3px 0 0 #1b1d3a, -3px 0 0 #1b1d3a, 0 -3px 0 #1b1d3a,
    2px 2px 0 #1b1d3a, -2px -2px 0 #1b1d3a, 2px -2px 0 #1b1d3a, -2px 2px 0 #1b1d3a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: linear-gradient(180deg, #2478e0 0%, #8cd0ff 56%, #ffe8c8 100%);
  font-family: 'Nunito', system-ui, sans-serif; color: #fff;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: none; overscroll-behavior: none;
}
#game {
  position: fixed; inset: 0; width: 100vw; height: 100vh; display: block;
  background: transparent;
  touch-action: none; outline: none;
}
.hidden { display: none !important; }

#underwater {
  position: fixed; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(40,140,220,0.15), rgba(10,50,120,0.55));
  transition: opacity 0.25s;
}
#underwater.on { opacity: 1; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud-counters {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 4px;
}
.hud-item {
  font-family: 'Lilita One', cursive; font-size: 38px; letter-spacing: 1px;
  display: flex; align-items: center; gap: 6px; text-shadow: var(--stroke);
}
.hud-item .x { font-size: 26px; opacity: 0.9; }
.hud-item .total { font-size: 22px; opacity: 0.75; margin-left: 2px; }
.icon-star { color: var(--gold); font-size: 42px; filter: drop-shadow(0 0 8px rgba(255,210,63,.8)); animation: spin-y 3s linear infinite; display: inline-block; }
.icon-coin {
  width: 30px; height: 30px; border-radius: 50%; display: inline-block;
  background: radial-gradient(circle at 35% 30%, #fff6c4, var(--gold) 40%, var(--gold-deep));
  border: 3px solid var(--ink); animation: spin-y 1.6s linear infinite;
}
.icon-bone {
  font-size: 30px;
  display: inline-block;
  filter: drop-shadow(0 2px 6px rgba(255, 225, 130, 0.75));
  animation: bone-wiggle 2.2s ease-in-out infinite;
}
@keyframes bone-wiggle {
  0%, 100% { transform: rotate(-10deg) scale(1); }
  50% { transform: rotate(12deg) scale(1.08); }
}
.outfit-badge {
  margin-top: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 210, 63, 0.65);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.3px;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s, border-color 0.2s, background 0.2s;
  align-self: flex-start;
}
.outfit-badge:hover {
  border-color: #ffd23f;
  background: rgba(35, 42, 96, 0.78);
}
.outfit-badge:active {
  transform: scale(0.94);
}
@keyframes spin-y { 0% { transform: scaleX(1); } 50% { transform: scaleX(0.15); } 100% { transform: scaleX(1); } }
.bump { animation: bump 0.35s ease-out; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }

#health {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  width: 106px; height: 106px; transition: transform .2s;
}
#health.hurt { animation: shake 0.4s; }
@keyframes shake { 0%,100% { transform: translateX(-50%); } 25% { transform: translateX(calc(-50% - 8px)); } 75% { transform: translateX(calc(-50% + 8px)); } }

/* Top-right quick action pills (Audio, Touch Toggle, 1P Camera, Pause) */
#hud-top-actions {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  display: flex; gap: 8px; align-items: center;
  pointer-events: auto; z-index: 22;
}
.hud-pill {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--glass); backdrop-filter: blur(8px);
  border: 2px solid rgba(255,255,255,.26);
  color: #fff; font-size: 20px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; touch-action: manipulation;
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
  transition: transform .1s, background .15s, border-color .15s;
}
.hud-pill:active { transform: scale(0.9); }
.hud-pill.active {
  background: rgba(255, 210, 63, 0.88);
  color: var(--ink);
  border-color: var(--ink);
}

#cam-mode {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  padding: 8px 14px; border-radius: 999px;
  background: var(--glass); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.24);
  color: #fff; font-family: inherit;
  font-weight: 800; font-size: 13.5px; display: flex; gap: 7px; align-items: center;
  pointer-events: auto; cursor: pointer; touch-action: manipulation;
  z-index: 22;
}
#cam-mode:active { transform: scale(0.95); }

#move-label {
  position: absolute; left: 50%; top: 28%; transform: translate(-50%, -50%) scale(0.6);
  font-family: 'Lilita One', cursive; font-size: 44px; color: #fff; opacity: 0;
  text-shadow: var(--stroke), 0 0 24px rgba(105,184,255,.9); letter-spacing: 2px; white-space: nowrap;
}
#move-label.show { animation: pop-label 0.9s ease-out forwards; }
@keyframes pop-label {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(-6deg); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(2deg); }
  40% { transform: translate(-50%, -50%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}

/* ---------- Mobile / Touch Virtual Controls ---------- */
#touch-ui {
  position: fixed; inset: 0; pointer-events: none; z-index: 20;
}
#stick-zone {
  position: absolute;
  left: max(10px, env(safe-area-inset-left));
  bottom: max(10px, env(safe-area-inset-bottom));
  width: min(44vw, 240px);
  height: min(46vh, 240px);
  pointer-events: auto;
  touch-action: none;
}
#stick-base {
  position: absolute;
  left: 24px;
  bottom: 24px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, rgba(20,26,64,0.48) 70%, rgba(255,255,255,0.22) 100%);
  border: 2.5px solid rgba(255,255,255,0.34);
  box-shadow: 0 8px 24px rgba(0,0,0,0.38), inset 0 0 18px rgba(105,184,255,0.22);
  backdrop-filter: blur(6px);
  transition: border-color 0.15s, box-shadow 0.15s;
}
#stick-base.active {
  border-color: rgba(255, 210, 63, 0.85);
  box-shadow: 0 8px 28px rgba(0,0,0,0.45), inset 0 0 24px rgba(255,210,63,0.32);
}
.stick-dir {
  position: absolute; font-size: 11px; color: rgba(255,255,255,0.45); pointer-events: none;
}
.stick-dir.up { top: 8px; left: 50%; transform: translateX(-50%); }
.stick-dir.down { bottom: 8px; left: 50%; transform: translateX(-50%); }
.stick-dir.left { left: 10px; top: 50%; transform: translateY(-50%); }
.stick-dir.right { right: 10px; top: 50%; transform: translateY(-50%); }

#stick-nub {
  position: absolute;
  left: 50%; top: 50%;
  width: 56px; height: 56px;
  margin-left: -28px; margin-top: -28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #d9ecff 55%, #79b8ff 100%);
  border: 3px solid var(--ink);
  box-shadow: 0 5px 14px rgba(0,0,0,0.45);
  pointer-events: none;
  will-change: transform;
}
#stick-base.active #stick-nub {
  background: radial-gradient(circle at 35% 30%, #fffbe0, var(--gold) 55%, var(--gold-deep) 100%);
}

#action-cluster {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  width: 176px;
  height: 164px;
  pointer-events: auto;
  touch-action: none;
}
.act-btn {
  position: absolute;
  border-radius: 50%;
  border: 3px solid var(--ink);
  color: #fff;
  font-family: 'Lilita One', cursive;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1;
  cursor: pointer;
  touch-action: none;
  box-shadow: 0 6px 0 var(--ink), 0 10px 22px rgba(0,0,0,0.45);
  transition: transform 0.06s, filter 0.08s;
}
.act-btn .act-letter {
  font-size: 26px;
  text-shadow: 0 2px 0 var(--ink);
}
.act-btn .act-sub {
  font-family: 'Nunito', sans-serif;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.5px;
  margin-top: 2px;
  opacity: 0.95;
  text-shadow: 0 1px 2px rgba(0,0,0,0.85);
}
.act-btn.pressed, .act-btn:active {
  transform: translateY(4px) scale(0.95);
  box-shadow: 0 2px 0 var(--ink), 0 4px 10px rgba(0,0,0,0.4);
  filter: brightness(1.16);
}

/* Primary A Button (Jump / Swim) - bottom right */
.act-a {
  right: 2px; bottom: 4px;
  width: 78px; height: 78px;
  background: radial-gradient(circle at 35% 28%, #8dffb8, #27c96b 55%, #138a46 100%);
}
.act-a .act-letter { font-size: 30px; }

/* B Button (Dive / Punch) - left of A */
.act-b {
  right: 92px; bottom: 14px;
  width: 64px; height: 64px;
  background: radial-gradient(circle at 35% 28%, #ff9ea8, #f04658 55%, #b82132 100%);
}

/* Z Button (Crouch / Ground Pound) - above A/B */
.act-z {
  right: 24px; bottom: 94px;
  width: 58px; height: 58px;
  background: radial-gradient(circle at 35% 28%, #9be5ff, #3898ff 55%, #1c5ec4 100%);
}
.act-z .act-letter { font-size: 22px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(0.4); opacity: 0;
  text-align: center; pointer-events: none; z-index: 25; width: 92vw;
}
#toast.show { animation: toast 2.6s cubic-bezier(.2,1.4,.4,1) forwards; }
#toast-title {
  font-family: 'Lilita One', cursive; font-size: clamp(40px, 8vw, 72px); color: var(--gold);
  text-shadow: var(--stroke), 0 0 40px rgba(255,190,40,.9);
}
#toast-sub { font-weight: 900; font-size: clamp(16px, 3.6vw, 24px); text-shadow: var(--stroke); margin-top: 4px; }
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  25% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(0.95); }
}

#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.6s; z-index: 30; }
#fade.on { opacity: 1; }

/* ---------- Overlays & Start Screen ---------- */
.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(30,40,110,0.28), rgba(8,10,30,0.78));
  overflow-y: auto; padding: 16px; z-index: 40;
}

/* Open, sunlit 3D showcase layout for the Start Screen */
.overlay.title-overlay {
  background: linear-gradient(
    180deg,
    rgba(12, 22, 58, 0.52) 0%,
    rgba(12, 22, 58, 0.06) 36%,
    rgba(12, 22, 58, 0.06) 64%,
    rgba(10, 18, 46, 0.62) 100%
  );
  align-items: stretch;
  padding: max(20px, env(safe-area-inset-top)) 20px max(26px, env(safe-area-inset-bottom));
}

.start-hero-layout {
  width: min(860px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  pointer-events: none;
  animation: rise 0.75s cubic-bezier(.2,1.2,.4,1);
}

.start-brand {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: clamp(4px, 2vh, 18px);
}

.paw-crest {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 5px 18px;
  border-radius: 999px;
  background: rgba(18, 25, 64, 0.58);
  border: 2px solid rgba(255, 210, 63, 0.65);
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  margin-bottom: 6px;
}
.crest-star {
  font-size: 24px;
  color: var(--gold);
  filter: drop-shadow(0 0 10px rgba(255, 200, 40, 0.9));
  animation: float 2.4s ease-in-out infinite;
}
.crest-paw {
  font-size: 26px;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.game-title {
  font-family: 'Lilita One', cursive;
  font-size: clamp(44px, 8.5vw, 88px);
  line-height: 0.98;
  margin: 2px 0 8px;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #ffffff 12%, #ffe680 52%, #ff9f1c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 5px 0 #1b1d3a) drop-shadow(0 10px 24px rgba(0,0,0,.55));
}
.game-title span {
  background: linear-gradient(180deg, #b8f6ff 10%, #48b8ff 60%, #1d7dfa 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.subtitle-ribbon {
  display: inline-block;
  font-family: 'Lilita One', cursive;
  font-size: clamp(18px, 3.2vw, 27px);
  letter-spacing: 2.2px;
  color: #1b1d3a;
  background: linear-gradient(180deg, #fff3a6 0%, #ffd23f 55%, #f29e1f 100%);
  padding: 6px 26px;
  border-radius: 999px;
  border: 3px solid #1b1d3a;
  box-shadow: 0 5px 0 #1b1d3a, 0 10px 24px rgba(0, 0, 0, 0.4);
  transform: rotate(-1.2deg);
  margin-bottom: 10px;
}

.tagline {
  font-size: clamp(14px, 2.2vw, 17.5px);
  font-weight: 900;
  color: #ffffff;
  text-shadow: var(--stroke), 0 4px 14px rgba(0, 0, 0, 0.65);
  margin: 0;
  max-width: 720px;
}

.start-actions {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: clamp(4px, 1.5vh, 14px);
}

.btn-play {
  font-size: clamp(24px, 4.2vw, 32px);
  padding: 15px 48px;
}

.start-sub-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.btn-pill {
  font-family: 'Lilita One', cursive;
  font-size: clamp(16px, 2.6vw, 19px);
  letter-spacing: 0.8px;
  padding: 10px 24px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-glass {
  color: #ffffff;
  background: rgba(20, 28, 68, 0.78);
  backdrop-filter: blur(10px);
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 5px 0 #1b1d3a, 0 10px 22px rgba(0, 0, 0, 0.42);
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
}
.btn-glass:hover {
  transform: translateY(-2px) scale(1.03);
  background: rgba(32, 44, 102, 0.88);
  border-color: #ffd23f;
}
.btn-glass:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #1b1d3a;
}

.title-card {
  width: min(720px, 100%); max-height: 92vh; overflow-y: auto;
  padding: 28px 34px 24px; border-radius: 26px; text-align: center;
  background: linear-gradient(160deg, rgba(34, 46, 118, 0.90), rgba(16, 20, 54, 0.94));
  backdrop-filter: blur(16px); border: 2px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 30px 80px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.25);
  animation: rise 0.45s cubic-bezier(.2,1.2,.4,1);
}
.title-card.small { width: min(420px, 100%); }
@keyframes rise { from { opacity: 0; transform: translateY(30px) scale(.96); } to { opacity: 1; transform: none; } }

.btn-primary {
  font-family: 'Lilita One', cursive; font-size: clamp(24px, 4vw, 28px); letter-spacing: 1px; color: #1b1d3a; cursor: pointer;
  padding: 13px 40px; border-radius: 999px; border: 3px solid #1b1d3a;
  background: linear-gradient(180deg, #fff3a6, var(--gold) 45%, var(--gold-deep));
  box-shadow: 0 6px 0 #1b1d3a, 0 12px 30px rgba(255,180,40,.45);
  transition: transform .12s, box-shadow .12s; animation: pulse 1.8s ease-in-out infinite;
  touch-action: manipulation;
}
.btn-primary:hover { transform: translateY(-2px) scale(1.04); }
.btn-primary:active { transform: translateY(4px); box-shadow: 0 2px 0 #1b1d3a; }
@keyframes pulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.12); } }

/* ---------- Separate Desktop Controls Modal ---------- */
.controls-modal-card {
  width: min(700px, 100%);
  padding: 20px 28px 18px;
  overflow-y: auto;
}
.controls-modal-header {
  margin-bottom: 10px;
}
.controls-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.2);
  border: 1.5px solid rgba(56, 189, 248, 0.6);
  color: #bae6fd;
  font-weight: 900;
  font-size: 11.5px;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.controls-title {
  font-family: 'Lilita One', cursive;
  font-size: clamp(28px, 4.5vw, 38px);
  color: var(--gold);
  text-shadow: var(--stroke);
  margin: 0 0 2px;
  font-weight: 400;
}
.controls-sub {
  font-size: 13.5px;
  font-weight: 800;
  color: #cbd5e1;
  margin: 0;
}
.controls { margin: 10px 0 14px; text-align: left; }
.controls-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}
.ctrl-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 52, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.ctrl-keys {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-weight: 900;
  font-size: 13px;
  color: #9ff3ff;
}
.ctrl-desc {
  font-size: 13.5px;
  font-weight: 800;
  color: #f8fafc;
}
kbd {
  display: inline-block; min-width: 24px; padding: 2px 7px; border-radius: 7px; font-family: inherit; font-weight: 900; font-size: 12px;
  background: linear-gradient(180deg, #fff, #d9e2ff); color: #1b1d3a; border-bottom: 3px solid #8b95c9; text-align: center;
}
.controls-modal-footer {
  display: flex;
  justify-content: center;
}
.pause-title { font-family: 'Lilita One', cursive; font-size: 50px; margin: 0 0 10px; font-weight: 400; color: var(--gold); text-shadow: var(--stroke); }
#pause-stats { font-weight: 800; font-size: 18px; margin-bottom: 20px; line-height: 1.7; }
#pause-stats .s { color: var(--gold); }
#pause-stats .got { opacity: 1; } #pause-stats .miss { opacity: .45; }
.pause-actions {
  display: flex; flex-direction: column; gap: 12px; align-items: center;
}
.btn-secondary {
  font-family: 'Lilita One', cursive; font-size: clamp(19px, 3.2vw, 22px); letter-spacing: 0.8px; color: #fff; cursor: pointer;
  padding: 11px 28px; border-radius: 999px; border: 3px solid #1b1d3a;
  background: linear-gradient(180deg, #38bdf8, #0284c7 55%, #0369a1);
  box-shadow: 0 5px 0 #1b1d3a, 0 10px 24px rgba(2,132,199,.45);
  transition: transform .12s, box-shadow .12s;
  touch-action: manipulation;
}
.btn-secondary:hover { transform: translateY(-2px) scale(1.03); filter: brightness(1.08); }
.btn-secondary:active { transform: translateY(3px); box-shadow: 0 2px 0 #1b1d3a; }

#overworld-banner {
  position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 12px 26px; border-radius: 20px;
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.90), rgba(30, 41, 59, 0.92));
  border: 2.5px solid rgba(56, 189, 248, 0.65);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  text-align: center; pointer-events: none; z-index: 18;
  backdrop-filter: blur(8px);
}
#ow-world-title {
  font-family: 'Lilita One', cursive; font-size: clamp(20px, 3.5vw, 28px);
  color: #38bdf8; letter-spacing: 0.8px; text-shadow: 0 2px 0 #090d16;
}
#ow-world-sub {
  font-family: 'Nunito', sans-serif; font-weight: 800; font-size: clamp(13px, 2.2vw, 15.5px);
  color: #e2e8f0; margin-top: 3px;
}

/* ---------- Live Scene & Animation Debug Tuner Panel ---------- */
.debug-panel {
  position: fixed;
  top: max(62px, calc(env(safe-area-inset-top) + 56px));
  right: max(12px, env(safe-area-inset-right));
  width: min(390px, calc(100vw - 24px));
  max-height: calc(100vh - 74px);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(11, 18, 38, 0.94), rgba(20, 29, 58, 0.96));
  border: 2px solid rgba(114, 214, 255, 0.45);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  color: #f8fafc;
  z-index: 45;
  pointer-events: auto;
  overflow: hidden;
}
.debug-panel.hidden {
  display: none !important;
}
.dbg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.75);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.dbg-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dbg-icon {
  font-size: 18px;
}
.dbg-title {
  font-family: 'Lilita One', cursive;
  font-size: 16.5px;
  color: #ffd23f;
  letter-spacing: 0.4px;
}
.dbg-sub {
  font-size: 10.5px;
  font-weight: 800;
  color: #94a3b8;
}
.dbg-icon-btn {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(30, 41, 59, 0.8);
  color: #e2e8f0;
  font-weight: 900;
  cursor: pointer;
}
.dbg-icon-btn:hover {
  background: rgba(239, 68, 68, 0.8);
  color: #fff;
}
.dbg-body {
  flex: 1;
  min-height: 0;
  padding: 8px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dbg-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;
  padding: 7px 9px;
}
.dbg-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 900;
  font-size: 11.5px;
  color: #72d6ff;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.dbg-pill {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 210, 63, 0.18);
  color: #ffd23f;
  border: 1px solid rgba(255, 210, 63, 0.45);
  white-space: nowrap;
}
#dbg-wave-canvas {
  width: 100%;
  height: 76px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: block;
}
.dbg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 800;
  color: #cbd5e1;
}
.dbg-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.dbg-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dbg-btn-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.dbg-chip {
  font-family: 'Nunito', sans-serif;
  font-size: 10.5px;
  font-weight: 900;
  padding: 4px 4px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(30, 41, 59, 0.8);
  color: #e2e8f0;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.12s, border-color 0.12s;
}
.dbg-chip:hover {
  background: rgba(51, 65, 85, 0.9);
}
.dbg-chip.active {
  background: linear-gradient(180deg, #ffd23f, #f59e0b);
  color: #1b1d3a;
  border-color: #fff;
}
.dbg-slider-row {
  margin-bottom: 6px;
}
.dbg-slider-row:last-child {
  margin-bottom: 0;
}
.dbg-slider-top {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 800;
  margin-bottom: 2px;
}
.dbg-label {
  color: #e2e8f0;
}
.dbg-val {
  color: #ffd23f;
  font-variant-numeric: tabular-nums;
}
.dbg-range {
  width: 100%;
  accent-color: #38bdf8;
  height: 5px;
  cursor: pointer;
}
.dbg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
}
.dbg-select {
  flex: 1;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.92);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.24);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 800;
}
.dbg-footer {
  display: flex;
  gap: 8px;
  padding: 9px 12px;
  background: rgba(15, 23, 42, 0.85);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.dbg-action-btn {
  flex: 1;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: rgba(30, 41, 59, 0.9);
  color: #f8fafc;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 12px;
  cursor: pointer;
}
.dbg-action-btn.primary {
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  border-color: #bae6fd;
  color: #fff;
}
.dbg-action-btn:hover {
  filter: brightness(1.1);
}
.dbg-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.dbg-mini-btn {
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid rgba(114, 214, 255, 0.35);
  background: rgba(30, 41, 59, 0.85);
  color: #bae6fd;
  font-family: 'Nunito', sans-serif;
  font-size: 10.5px;
  font-weight: 900;
  cursor: pointer;
}
.dbg-mini-btn.active {
  background: linear-gradient(180deg, #ffd23f, #f59e0b);
  color: #1b1d3a;
  border-color: #fff;
}
.dbg-nav-wrap {
  padding: 6px 10px 6px;
  background: rgba(10, 15, 30, 0.82);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.dbg-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.dbg-tab {
  font-family: 'Nunito', sans-serif;
  font-size: 10.2px;
  font-weight: 900;
  padding: 4px 4px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(30, 41, 59, 0.78);
  color: #cbd5e1;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.12s;
}
.dbg-tab:hover {
  background: rgba(51, 65, 85, 0.92);
  color: #fff;
}
.dbg-tab.active {
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  color: #fff;
  border-color: #bae6fd;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}
.dbg-tab-num {
  opacity: 0.75;
  font-size: 9.5px;
}
.dbg-pager-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.dbg-nav-btn {
  font-family: 'Nunito', sans-serif;
  font-size: 10.5px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(30, 41, 59, 0.85);
  color: #f8fafc;
  cursor: pointer;
}
.dbg-nav-btn:hover {
  background: rgba(56, 189, 248, 0.35);
}
.dbg-page-title {
  font-size: 11px;
  font-weight: 900;
  color: #ffd23f;
  text-align: center;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dbg-search-row {
  display: flex;
}
.dbg-search-input {
  width: 100%;
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.9);
  color: #f8fafc;
  font-family: 'Nunito', sans-serif;
  font-size: 11px;
  font-weight: 800;
  outline: none;
}
.dbg-search-input:focus {
  border-color: #38bdf8;
}
.dbg-page {
  display: none;
  flex-direction: column;
  gap: 8px;
}
.dbg-page.active {
  display: flex;
}
.dbg-btn-grid.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}
.dbg-btn-grid.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}
.dbg-telemetry-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  font-size: 11px;
  font-weight: 800;
  color: #cbd5e1;
}
.dbg-telemetry-grid div {
  display: flex;
  justify-content: space-between;
  padding: 2px 4px;
  border-radius: 5px;
  background: rgba(8, 13, 28, 0.55);
}
.dbg-telemetry-grid b {
  color: #ffd23f;
  font-variant-numeric: tabular-nums;
}

/* ---------- Responsive Mobile Adjustments ---------- */
@media (max-width: 820px), (pointer: coarse) {
  .hud-item { font-size: 28px; }
  .hud-item .x { font-size: 20px; }
  .hud-item .total { font-size: 17px; }
  .icon-star { font-size: 30px; }
  .icon-coin { width: 22px; height: 22px; border-width: 2px; }
  #health { width: 82px; height: 82px; top: max(8px, env(safe-area-inset-top)); }
  .hud-pill { width: 40px; height: 40px; font-size: 18px; }
  #cam-mode {
    top: calc(max(16px, env(safe-area-inset-top)) + 50px);
    bottom: auto;
    right: max(16px, env(safe-area-inset-right));
    padding: 6px 11px;
    font-size: 12px;
  }
  .title-card { padding: 20px 18px 18px; border-radius: 20px; }
  .logo-star { font-size: 46px; }
  .grid { font-size: 12.5px; gap: 5px 10px; }
}

@media (max-height: 460px) and (orientation: landscape) {
  .title-card { padding: 14px 20px; }
  .logo-star { display: none; }
  h1 { font-size: 38px; margin-bottom: 2px; }
  .tagline { margin-bottom: 10px; font-size: 13.5px; }
  .controls { margin-top: 12px; }
  .grid { grid-template-columns: auto 1fr auto 1fr; gap: 4px 10px; font-size: 11.5px; }
  #stick-base { width: 112px; height: 112px; left: 16px; bottom: 14px; }
  #stick-nub { width: 48px; height: 48px; margin-left: -24px; margin-top: -24px; }
  #action-cluster { bottom: 12px; right: 14px; width: 164px; height: 144px; }
  .act-a { width: 70px; height: 70px; }
  .act-b { width: 58px; height: 58px; right: 82px; }
  .act-z { width: 52px; height: 52px; bottom: 82px; }
}
