* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  background: #111;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  font-family: 'Trebuchet MS', sans-serif;
  overscroll-behavior: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#gameContainer {
  position: relative;
  width: min(100vw, calc(100dvh * 16 / 9));
  height: min(100dvh, calc(100vw * 9 / 16));
  max-width: 100vw;
  max-height: 100dvh;
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  overflow: hidden;
  touch-action: none;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #1a1a2e;
  image-rendering: pixelated;
  touch-action: none;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.5);
}

.overlay.hidden {
  display: none;
}

.panel {
  background: rgba(30, 30, 60, 0.95);
  border: 3px solid #6ad1ff;
  border-radius: 16px;
  padding: clamp(20px, 4vw, 32px) clamp(24px, 5vw, 48px);
  text-align: center;
  color: #fff;
  max-width: min(90vw, 420px);
}

.panel h1 {
  margin-bottom: 10px;
  color: #ffd166;
}

.panel p {
  margin-bottom: 15px;
  font-size: clamp(14px, 2.2vw, 16px);
  line-height: 1.4;
}

.ui-button {
  width: min(200px, 70vw);
  height: clamp(64px, 14vw, 80px);
  border: none;
  background-color: transparent;
  background-image: url('assets/images/ui_buttons.png');
  background-repeat: no-repeat;
  background-size: 400px 80px;
  cursor: pointer;
  transition: transform 0.1s ease;
  margin-top: 20px;
}

.ui-button:hover {
  transform: scale(1.05);
}

.play-btn {
  background-position: 0 0;
}

.restart-btn {
  background-position: -200px 0;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  color: #fff;
  font-size: clamp(14px, 2.4vw, 20px);
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
  pointer-events: none;
}

#hud.hidden {
  display: none;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.35);
  padding: 4px 12px;
  border-radius: 20px;
}

#robotModeStatus {
  font-size: 16px;
  color: #7dd3fc;
  background: rgba(15,23,42,0.85);
  border: 1px solid rgba(96,165,250,0.8);
}

#robotModeStatus.hidden {
  display: none;
}

.coin-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  background: #ffd166;
  border-radius: 50%;
  border: 2px solid #b8860b;
}