/* Apanha o Kwanza — interface cartoon, leve e responsiva */

:root {
  --gold: #f4c430;
  --gold-dark: #c49200;
  --ink: #1a0a2e;
  --panel: rgba(18, 8, 36, 0.88);
  --coral: #ff5a5a;
  --mint: #3ddeb3;
  --cream: #fff6e0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

#game-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;
}

/* ---------- HUD ---------- */

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: linear-gradient(180deg, rgba(10, 4, 24, 0.72), transparent);
  pointer-events: none;
  flex-wrap: wrap;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
}

.hud-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  opacity: 0.75;
  font-weight: 700;
}

#score,
#best {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

#score { color: var(--gold); }
#best { color: #ffe7a0; }

.hud-sep {
  width: 1px;
  height: 28px;
  background: rgba(255, 246, 224, 0.25);
}

.lives-item { min-width: 90px; }

#lives {
  display: flex;
  gap: 4px;
  height: 22px;
  align-items: center;
}

.heart {
  width: 18px;
  height: 16px;
  display: inline-block;
  position: relative;
  transition: transform 0.2s, opacity 0.2s, filter 0.2s;
}

.heart::before,
.heart::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 16px;
  background: #ff4d6d;
  border-radius: 10px 10px 0 0;
  top: 0;
}

.heart::before {
  left: 9px;
  transform: rotate(-45deg);
  transform-origin: 0 100%;
}

.heart::after {
  left: 0;
  transform: rotate(45deg);
  transform-origin: 100% 100%;
}

.heart.empty {
  opacity: 0.28;
  filter: grayscale(1);
  transform: scale(0.85);
}

.heart.hit {
  animation: heart-pop 0.35s ease;
}

@keyframes heart-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

#mute-btn {
  pointer-events: auto;
  position: absolute;
  right: 12px;
  top: calc(10px + env(safe-area-inset-top));
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: var(--cream);
  cursor: pointer;
  display: grid;
  place-items: center;
  backdrop-filter: blur(6px);
}

#mute-btn:hover { background: rgba(255, 255, 255, 0.24); }

.hidden { display: none !important; }

#level-badge {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  background: var(--gold);
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0.14em;
  padding: 6px 16px;
  border-radius: 999px;
  box-shadow: 0 6px 0 #c49200;
  animation: badge-in 0.7s ease;
  pointer-events: none;
}

@keyframes badge-in {
  0% { transform: translateX(-50%) translateY(-12px) scale(0.6); opacity: 0; }
  50% { transform: translateX(-50%) translateY(4px) scale(1.08); opacity: 1; }
  100% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
}

#combo-pop {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  font-weight: 800;
  font-size: 22px;
  color: var(--gold);
  text-shadow: 0 2px 0 #8a5a00;
  opacity: 0;
}

#combo-pop.show {
  animation: float-up 0.7s ease forwards;
}

@keyframes float-up {
  0% { opacity: 1; transform: translate(-50%, 0) scale(0.8); }
  100% { opacity: 0; transform: translate(-50%, -48px) scale(1.2); }
}

/* ---------- Overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(8, 2, 20, 0.55);
  padding: 20px;
}

.panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 3px solid var(--gold);
  border-radius: 28px;
  padding: 28px 24px 26px;
  text-align: center;
  box-shadow: 0 18px 0 rgba(0, 0, 0, 0.35), 0 0 0 6px rgba(244, 196, 48, 0.15);
  animation: panel-in 0.45s cubic-bezier(0.2, 1.2, 0.4, 1);
}

@keyframes panel-in {
  from { transform: scale(0.86) translateY(18px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.coin-hero {
  width: 84px;
  height: 84px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe98a, #f4c430 45%, #c49200);
  color: #7a4a00;
  font-weight: 800;
  font-size: 28px;
  display: grid;
  place-items: center;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.15), 0 8px 0 #9a6a00;
  animation: spin-y 2.8s linear infinite;
}

@keyframes spin-y {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(360deg); }
}

h1 {
  font-size: clamp(28px, 7vw, 40px);
  line-height: 1.05;
  color: var(--gold);
  text-shadow: 0 3px 0 #8a5a00;
  margin-bottom: 8px;
}

h2 {
  font-size: clamp(32px, 8vw, 44px);
  color: #ff6b6b;
  text-shadow: 0 3px 0 #7a2020;
  margin-bottom: 10px;
  letter-spacing: 0.04em;
}

.tagline {
  opacity: 0.85;
  margin-bottom: 16px;
  font-size: 15px;
}

.howto {
  list-style: none;
  text-align: left;
  margin: 0 auto 20px;
  width: fit-content;
  font-size: 14px;
  line-height: 1.7;
  opacity: 0.92;
}

.howto .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.dot.gold { background: var(--gold); box-shadow: 0 0 0 2px #8a5a00; }
.dot.red { background: var(--coral); box-shadow: 0 0 0 2px #7a2020; }

.over-score {
  font-size: 20px;
  margin-bottom: 8px;
}

.over-score strong {
  color: var(--gold);
  font-size: 28px;
}

.new-record {
  color: var(--mint);
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 16px;
  animation: pulse 0.9s ease infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

.btn {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 14px 28px;
  border-radius: 16px;
  width: 100%;
  max-width: 280px;
}

.btn.primary {
  background: linear-gradient(180deg, #ffe27a, var(--gold));
  color: var(--ink);
  box-shadow: 0 6px 0 var(--gold-dark);
  transition: transform 0.12s, box-shadow 0.12s;
}

.btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 var(--gold-dark);
}

.btn.primary:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--gold-dark);
}

.btn.ghost {
  margin-top: 10px;
  background: transparent;
  color: var(--cream);
  border: 2px solid rgba(244, 196, 48, 0.55);
  box-shadow: none;
}

.btn.ghost:hover {
  background: rgba(244, 196, 48, 0.12);
}

.install-hint {
  margin-top: 12px;
  font-size: 12px;
  opacity: 0.7;
  line-height: 1.4;
}

@media (max-width: 480px) {
  #score, #best { font-size: 18px; }
  .hud-item { min-width: 60px; }
  #mute-btn { width: 36px; height: 36px; }
}
