/* P04 — game feel / presentation polish */

:root {
  --p04-glass: rgba(18, 7, 31, 0.62);
  --p04-glass-strong: rgba(20, 8, 37, 0.88);
  --p04-line: rgba(255, 255, 255, 0.16);
  --p04-gold: #ffd94d;
  --p04-pink: #ff667e;
}

#hud {
  gap: 8px;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#hud .pill,
#hud .icon-btn {
  background: var(--p04-glass);
  border-color: var(--p04-line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

#hud .score-pill {
  min-width: 118px;
  justify-content: space-between;
}

#hud .coin-pill {
  min-width: 76px;
  justify-content: center;
}

.hud-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.hud-actions .icon-btn {
  margin-left: 0;
}

#audioBtn {
  font-size: 17px;
}

body[data-game-mode="paused"] #hud {
  opacity: 0.82;
  transform: translateY(2px);
}

.overlay {
  isolation: isolate;
}

.overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 185, 90, 0.10), transparent 26%),
    radial-gradient(circle at 50% 68%, rgba(153, 90, 220, 0.14), transparent 34%);
  pointer-events: none;
}

#menu .logo {
  animation: p04LogoFloat 3.2s ease-in-out infinite;
}

@keyframes p04LogoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.menu-best {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: -4px;
  color: rgba(255, 255, 255, 0.46);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2.5px;
}

.menu-best strong {
  color: var(--p04-gold);
  font-size: 18px;
  letter-spacing: 0.5px;
  text-shadow: 0 0 14px rgba(255, 217, 77, 0.35);
}

.btn {
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-130%) skewX(-18deg);
  width: 45%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.45), transparent);
  transition: transform 0.45s ease;
}

.btn:hover::after {
  transform: translateX(330%) skewX(-18deg);
}

.panel {
  background:
    linear-gradient(180deg, rgba(40, 18, 62, 0.92), var(--p04-glass-strong));
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.52),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#over .panel {
  min-width: min(340px, calc(100vw - 32px));
}

#over .stat {
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

#over .stat:last-of-type {
  border-bottom: 0;
}

.new-best-badge {
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe87c, #ffb22e);
  color: #4b2100;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  box-shadow: 0 8px 24px rgba(255, 177, 46, 0.28);
  animation: p04BestPop 0.7s cubic-bezier(.2, 1.5, .3, 1);
}

@keyframes p04BestPop {
  0% { transform: scale(0.5) rotate(-5deg); opacity: 0; }
  65% { transform: scale(1.08) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

body.p04-new-best #over .panel {
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.52),
    0 0 46px rgba(255, 205, 76, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

body[data-game-mode="dead"] #hud {
  opacity: 0;
  transform: translateY(-8px);
}

#toast {
  will-change: transform, opacity;
}

@media (max-width: 680px) {
  #hud {
    gap: 6px;
  }

  .pill {
    padding: 6px 11px;
    font-size: 16px;
  }

  .pill .lbl {
    font-size: 9px;
    letter-spacing: 1.4px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
  }

  .hud-actions {
    gap: 6px;
  }

  .menu-best {
    margin-top: -8px;
  }

  .panel {
    padding: 28px 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #menu .logo,
  .new-best-badge,
  .panel,
  .overlay,
  #toast {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .btn::after {
    display: none;
  }
}
