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

html, body {
  width: 100%;
  min-height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  background: #0f0a2a;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
}

#backBtn {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 6px 14px;
  background: rgba(30, 20, 60, 0.75);
  color: #e0d0ff;
  font: bold 14px "Segoe UI", system-ui, sans-serif;
  text-decoration: none;
  border: 2px solid rgba(180, 140, 255, 0.5);
  border-radius: 20px;
  backdrop-filter: blur(6px);
  transition: background 0.2s, border-color 0.2s;
}

#backBtn:hover {
  background: rgba(60, 40, 110, 0.85);
  border-color: rgba(200, 170, 255, 0.8);
}

#leaderboardToggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  padding: 6px 10px;
  background: rgba(30, 20, 60, 0.75);
  border: 2px solid rgba(180, 140, 255, 0.5);
  border-radius: 20px;
  backdrop-filter: blur(6px);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
#leaderboardToggle:hover {
  background: rgba(60, 40, 110, 0.85);
  border-color: rgba(200, 170, 255, 0.8);
}

/* ── Fullscreen button ──────────────────────────────────── */
.uc-mute-btn {
  position: fixed;
  top: 12px;
  right: 104px;
  z-index: 100;
  padding: 6px 10px;
  background: rgba(30, 20, 60, 0.75);
  border: 2px solid rgba(180, 140, 255, 0.5);
  border-radius: 20px;
  backdrop-filter: blur(6px);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  line-height: 1;
}
.uc-mute-btn:hover {
  background: rgba(60, 40, 110, 0.85);
  border-color: rgba(200, 170, 255, 0.8);
}
.uc-fullscreen-btn {
  position: fixed;
  top: 12px;
  right: 56px;
  z-index: 100;
  padding: 6px 10px;
  background: rgba(30, 20, 60, 0.75);
  border: 2px solid rgba(180, 140, 255, 0.5);
  border-radius: 20px;
  backdrop-filter: blur(6px);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  line-height: 1;
}
.uc-fullscreen-btn:hover {
  background: rgba(60, 40, 110, 0.85);
  border-color: rgba(200, 170, 255, 0.8);
}

/* ── Fullscreen ─────────────────────────────────────────── */
:fullscreen #backBtn,
:-webkit-full-screen #backBtn,
body.pseudo-fullscreen #backBtn,
:fullscreen #leaderboardToggle,
:-webkit-full-screen #leaderboardToggle,
body.pseudo-fullscreen #leaderboardToggle,
:fullscreen .achievements-panel,
:-webkit-full-screen .achievements-panel,
body.pseudo-fullscreen .achievements-panel {
  display: none !important;
}

:fullscreen canvas,
:-webkit-full-screen canvas,
body.pseudo-fullscreen canvas {
  max-width: 100vw;
  max-height: calc(100vh - 8px);
  max-height: calc(100dvh - 8px);
  border-radius: 0;
  box-shadow: 0 0 80px rgba(200, 140, 255, 0.15), 0 0 160px rgba(200, 140, 255, 0.06);
}

:fullscreen .uc-fullscreen-btn,
:-webkit-full-screen .uc-fullscreen-btn,
body.pseudo-fullscreen .uc-fullscreen-btn {
  top: 8px;
  right: 8px;
}

body.pseudo-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #1a0a2a;
}

:fullscreen #leaderboardPanel,
:-webkit-full-screen #leaderboardPanel,
body.pseudo-fullscreen #leaderboardPanel {
  display: none !important;
}

/* ── Achievements ────────────────────────────────────────── */
.achievements-panel {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  z-index: 90; text-align: center;
}
.achievements-toggle {
  border: 1px solid rgba(255,105,180,0.3);
  border-radius: 999px; padding: 6px 16px;
  background: rgba(30,20,60,0.75); color: rgba(255,180,220,0.7);
  font-weight: 600; font-size: 0.8rem; cursor: pointer; font-family: inherit;
  backdrop-filter: blur(6px);
  transition: background 0.2s, border-color 0.2s;
}
.achievements-toggle:hover { background: rgba(255,105,180,0.1); border-color: rgba(255,105,180,0.5); }
.achievements-list {
  display: none; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px;
  max-width: 90vw;
}
.achievements-list.open { display: flex; }
.achievement-item {
  display: flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 10px;
  font-size: 0.72rem; border: 1px solid rgba(255,105,180,0.1);
  background: rgba(30,20,60,0.8); color: rgba(255,180,220,0.4);
  backdrop-filter: blur(4px);
  transition: all 0.3s;
}
.achievement-item.unlocked { border-color: rgba(255,215,0,0.4); background: rgba(255,215,0,0.1); color: #ffd700; }
.achievement-item__icon { font-size: 1rem; }
.achievement-popup {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-120px);
  display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 14px;
  background: rgba(10,10,10,0.95); border: 2px solid rgba(255,215,0,0.5);
  box-shadow: 0 8px 30px rgba(0,0,0,0.6), 0 0 20px rgba(255,215,0,0.15);
  z-index: 1000; transition: transform 0.5s cubic-bezier(0.34,1.56,0.64,1); pointer-events: none;
}
.achievement-popup.show { transform: translateX(-50%) translateY(0); }
.achievement-popup__icon { font-size: 1.5rem; }
.achievement-popup__text { display: flex; flex-direction: column; gap: 2px; }
.achievement-popup__text strong { color: #ffd700; font-size: 0.85rem; }
.achievement-popup__text span { color: rgba(255,180,220,0.7); font-size: 0.72rem; }
