/* HUD, popups, overlays and the chain bar (split out of style.css so each
   stylesheet stays <=300 lines, CLAUDE.md §3). R-008.10: colour only via the
   --c-* custom properties main.js sets on :root from theme.palette. */

#hud {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  flex: 0 0 auto;
  background: var(--c-panel);
  color: var(--c-text);
}

.hud-col { display: flex; align-items: center; gap: 6px; flex: 1 1 0; }
.hud-right { justify-content: flex-end; }
.hud-center { flex-direction: column; align-items: center; gap: 2px; }

.icon-btn, .powerup-btn {
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--c-background);
  color: var(--c-text);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 20px;
  padding: 0;
}

.powerup-btn[disabled] { opacity: 0.4; }

.powerup-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--c-accent);
  color: var(--c-text);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  padding: 0 3px;
}

.powerup-btn[data-selected="true"] { outline: 2px solid var(--c-accent); }

.best-row { display: flex; align-items: center; gap: 3px; font-size: 11px; opacity: 0.8; }
.trophy { font-size: 12px; }
.score-cloud { font-size: 22px; font-weight: 700; }
.coins-row { display: flex; align-items: center; gap: 6px; }

.coins-pill {
  background: var(--c-accent);
  color: var(--c-text);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 13px;
  font-weight: 600;
}

/* R-008.9: pulses on 'coinsEarned'. */
.coins-pill.pulse { animation: coins-pulse 240ms ease; }

@keyframes coins-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* R-008.9: floating "+N" coin label, positioned over the board (in
   #play-area, its position:relative ancestor) at the merge's screen
   position; rises and fades over ~700ms, then removed/pooled (see hud.js). */
.coin-float {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -50%);
  font-size: 13px;
  font-weight: 700;
  color: var(--c-accent);
  opacity: 0;
  z-index: 5;
}

.coin-float.rise { animation: coin-float-rise 700ms ease-out forwards; }

@keyframes coin-float-rise {
  0% { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -170%); }
}

.combo-badge {
  background: var(--c-boardFrame);
  color: var(--c-text);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
}

/* R-006.12: pulse on each merge, break on comboReset. */
.combo-badge.pulse { animation: combo-pulse 220ms ease; }
.combo-badge.break { animation: combo-break 260ms ease; }

@keyframes combo-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@keyframes combo-break {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}

#next { width: 48px; height: 48px; border-radius: 10px; background: var(--c-background); }

#chain-bar { flex: 0 0 auto; min-height: 40px; padding: 4px 8px 6px; background: var(--c-panel); }
.chain-bar-title { font-size: 10px; opacity: 0.7; text-align: center; margin-bottom: 2px; }

.chain-bar-tiers {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  overflow-x: auto;
}

.chain-bar-tier { display: flex; flex-direction: column; align-items: center; gap: 1px; flex: 0 0 auto; }

.chain-bar-tier .chain-bar-coin {
  font-size: 9px;
  font-weight: 700;
  color: var(--c-text);
  opacity: 0.8;
}

/* ---- popups (R-007.3, R-008.4, R-008.8) ---- */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
}

.popup-card {
  background: var(--c-panel);
  color: var(--c-text);
  border-radius: 16px;
  padding: 16px;
  width: min(320px, 100%);
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.popup-title { font-size: 18px; font-weight: 700; margin: 0 0 8px; padding-right: 28px; }
.popup-body { font-size: 14px; line-height: 1.4; margin: 0 0 14px; }

.popup-close {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 32px;
  min-height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--c-background);
  color: var(--c-text);
  font-size: 16px;
  line-height: 1;
}

.popup-actions { display: flex; gap: 8px; justify-content: flex-end; }

.popup-btn {
  min-height: 44px;
  padding: 0 16px;
  border: none;
  border-radius: 10px;
  background: var(--c-accent);
  color: var(--c-text);
  font-size: 14px;
  font-weight: 700;
}

.popup-btn:disabled { opacity: 0.4; }
.popup-btn.secondary { background: var(--c-background); font-weight: 500; }

.popup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.popup-row:last-of-type { border-bottom: none; }
.popup-note { font-size: 11px; opacity: 0.7; margin: 8px 0 0; }

/* ---- game-over overlay (R-008.5) ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 16px;
}

.overlay-card {
  background: var(--c-panel);
  color: var(--c-text);
  border-radius: 16px;
  padding: 24px 20px;
  width: min(320px, 100%);
  text-align: center;
}

.overlay-card h2 { margin: 0 0 12px; }
.overlay-stat { font-size: 14px; margin: 4px 0; }
.overlay-stat .new-best { color: var(--c-accent); font-weight: 700; }

.overlay-play-again {
  margin-top: 16px;
  min-height: 44px;
  padding: 0 24px;
  border: none;
  border-radius: 10px;
  background: var(--c-accent);
  color: var(--c-text);
  font-size: 16px;
  font-weight: 700;
}

/* ---- R-008.7: landscape "rotate your phone" overlay, CSS-only trigger ---- */
#rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  align-items: center;
  justify-content: center;
  background: var(--c-background);
  color: var(--c-text);
  font-size: 18px;
  text-align: center;
  padding: 16px;
}

@media (orientation: landscape) and (max-height: 500px) {
  #rotate-overlay { display: flex; }
}
