* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; background: #0b0e17;
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  touch-action: none;
  user-select: none;
}
#gameContainer {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #0b0e17 0%, #1a1030 100%);
}
#gameCanvas {
  background: #10131f;
  display: block;
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 0 40px rgba(255,120,40,0.15);
}

/* Top bar (pause / HUD / autopilot). Flex layout instead of hardcoded
   absolute offsets so nothing overlaps regardless of how narrow the
   embedding viewport is (e.g. a mobile in-page embed vs. full screen). */
#topBar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Autopilot toggle */
#autoBtn {
  flex: 0 0 auto;
  background: rgba(10,10,20,0.55);
  border: 1px solid rgba(255,255,255,0.25);
  color: #ffe9c7;
  font-weight: bold;
  font-size: clamp(11px, 3vw, 13px);
  letter-spacing: 1px;
  padding: clamp(6px, 2vw, 8px) clamp(8px, 3vw, 14px);
  border-radius: 20px;
  cursor: pointer;
  backdrop-filter: blur(3px);
  white-space: nowrap;
}
#autoBtn.active {
  background: rgba(90,220,140,0.28);
  border-color: #7CFC9A;
  color: #d6ffe4;
  box-shadow: 0 0 14px rgba(124,252,154,0.5);
}

/* Pause toggle */
#pauseBtn {
  flex: 0 0 auto;
  background: rgba(10,10,20,0.55);
  border: 1px solid rgba(255,255,255,0.25);
  color: #ffe9c7;
  font-size: 16px;
  padding: 7px 12px;
  border-radius: 20px;
  cursor: pointer;
  line-height: 1;
  backdrop-filter: blur(3px);
}
#pauseBtn:active {
  background: rgba(255,255,255,0.15);
}

/* HUD */
#hud {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
#hudInner {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(10,10,20,0.55);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 14px;
  padding: 8px clamp(10px, 3vw, 22px);
  color: #ffe9c7;
  font-size: clamp(14px, 4vw, 20px);
  font-weight: bold;
  letter-spacing: 1px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  backdrop-filter: blur(3px);
}

/* Overlays */
.overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(30,10,20,0.85) 0%, rgba(5,3,10,0.95) 100%);
  color: #fff;
  text-align: center;
  z-index: 10;
  padding: 20px;
}
.hidden { display: none !important; }

.title {
  font-size: clamp(32px, 8vw, 56px);
  font-weight: 900;
  color: #ffb347;
  text-shadow: 0 0 20px rgba(255,140,40,0.8), 0 4px 0 #7a2f0a;
  margin-bottom: 6px;
  letter-spacing: 2px;
}
.subtitle {
  color: #ffdca8;
  font-size: clamp(13px, 3vw, 16px);
  margin-bottom: 24px;
  opacity: 0.85;
  max-width: 420px;
  line-height: 1.5;
}
.capybara-emoji-preview {
  font-size: 60px;
  margin-bottom: 10px;
  filter: drop-shadow(0 0 12px rgba(255,140,40,0.5));
}
.capy-icon-svg {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  vertical-align: -0.15em;
}
.capy-icon-svg svg {
  width: 100%;
  height: 100%;
}

.btn {
  background: linear-gradient(180deg, #ff9d4d, #e8641a);
  border: none;
  color: #2a1400;
  font-weight: 900;
  font-size: 20px;
  padding: 14px 40px;
  border-radius: 40px;
  cursor: pointer;
  box-shadow: 0 6px 0 #a8460a, 0 10px 20px rgba(0,0,0,0.4);
  letter-spacing: 1px;
  transition: transform 0.08s ease;
}
.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #a8460a, 0 4px 10px rgba(0,0,0,0.4);
}

.stat-row {
  display: flex;
  gap: 30px;
  margin-bottom: 26px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stat .val {
  font-size: 28px;
  font-weight: 900;
  color: #ffcf87;
}
.stat .lbl {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #cba;
  opacity: 0.8;
}
.new-best {
  color: #7CFC9A;
  font-weight: bold;
  margin-bottom: 10px;
  font-size: 15px;
  text-shadow: 0 0 10px rgba(124,252,154,0.6);
}

/* Mobile controls */
#controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: clamp(10px, 4vw, 18px);
  z-index: 6;
  pointer-events: none;
}
.ctrl-btn {
  pointer-events: auto;
  width: clamp(52px, 16vw, 68px);
  height: clamp(52px, 16vw, 68px);
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: 2px solid rgba(255,255,255,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(22px, 7vw, 30px);
  color: #fff;
  backdrop-filter: blur(2px);
  user-select: none;
  touch-action: none;
}
.ctrl-btn:active, .ctrl-btn.pressed {
  background: rgba(255,160,60,0.45);
  border-color: #ffb347;
}
#moveGroup {
  display: flex;
  gap: clamp(8px, 3vw, 14px);
}
#jumpBtn {
  width: clamp(64px, 20vw, 84px);
  height: clamp(64px, 20vw, 84px);
  font-size: clamp(26px, 8vw, 34px);
}

@media (min-width: 900px) {
  #controls { display: none; }
}
