/* ============================================================
   PIÑATA BASH — style.css
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;700;900&display=swap');

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --yellow:   #FFD700;
  --orange:   #FF6B00;
  --pink:     #FF3E9D;
  --purple:   #9B2CFA;
  --teal:     #00C9B1;
  --red:      #FF2244;
  --green:    #22DD66;
  --blue:     #1EAAFF;
  --bg-dark:  #1A0A2E;
  --bg-mid:   #2D1458;
  --card-bg:  rgba(255,255,255,0.07);
  --gold:     #FFD700;
  --font-head: 'Fredoka One', cursive;
  --font-body: 'Nunito', sans-serif;
  --radius:   16px;
  --shadow:   0 8px 32px rgba(0,0,0,0.5);
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  font-family: var(--font-body);
  color: #fff;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Screens ── */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity 0.35s ease;
  overflow: hidden;
}
.screen.active {
  opacity: 1; pointer-events: all;
}

/* ── Bunting ── */
.bunting-top {
  width: 100%; height: 48px;
  background: repeating-linear-gradient(
    90deg,
    #FF2244 0 40px, #FFD700 40px 80px, #00C9B1 80px 120px,
    #FF3E9D 120px 160px, #1EAAFF 160px 200px, #9B2CFA 200px 240px
  );
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.bunting-top::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0 30px,
    rgba(0,0,0,0.2) 30px 32px
  );
}
.bunting-top::after {
  content: '▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲';
  position: absolute; bottom: 0; left: 0;
  font-size: 24px; letter-spacing: -4px;
  color: rgba(0,0,0,0.15);
  line-height: 1;
}

/* ═══════════════════════════════════════════
   HOME SCREEN
═══════════════════════════════════════════ */
#screen-home {
  background: radial-gradient(ellipse at 60% 30%, #3D1A7A 0%, #1A0A2E 70%);
  align-items: center; justify-content: center;
}

.home-bg-anim {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(255,107,0,0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(155,44,250,0.15) 0%, transparent 50%);
  animation: bgPulse 4s ease-in-out infinite alternate;
}
@keyframes bgPulse {
  from { opacity: 0.7; } to { opacity: 1; }
}

.home-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  align-items: center; gap: 28px;
  padding: 20px;
}

.logo-wrap {
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
}
.logo-pinata-anim {
  width: 160px; height: 160px;
}
.logo-text {
  display: flex; flex-direction: column;
  align-items: center; line-height: 1;
}
.logo-pin {
  font-family: var(--font-head);
  font-size: clamp(48px, 10vw, 88px);
  color: var(--yellow);
  text-shadow: 4px 4px 0 var(--orange), 8px 8px 0 rgba(0,0,0,0.3);
  letter-spacing: 4px;
  animation: logoWobble 2.5s ease-in-out infinite;
}
.logo-bash {
  font-family: var(--font-head);
  font-size: clamp(56px, 12vw, 104px);
  color: var(--pink);
  text-shadow: 4px 4px 0 #AA0060, 8px 8px 0 rgba(0,0,0,0.3);
  letter-spacing: 8px;
  margin-top: -12px;
  animation: logoWobble 2.5s ease-in-out infinite 0.3s;
}
@keyframes logoWobble {
  0%,100% { transform: rotate(-1deg) scale(1); }
  50% { transform: rotate(1deg) scale(1.03); }
}
.logo-sub {
  font-size: 13px; color: rgba(255,255,255,0.6);
  text-align: center; margin-top: 4px;
  letter-spacing: 1px;
}

.home-buttons {
  display: flex; flex-direction: column;
  align-items: center; gap: 16px;
  width: 100%; max-width: 400px;
}

.btn-primary {
  padding: 18px 48px;
  font-family: var(--font-head);
  font-size: 26px; letter-spacing: 2px;
  background: linear-gradient(135deg, var(--orange), var(--pink));
  border: none; border-radius: 50px;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,0.4), 0 12px 32px rgba(255,62,157,0.4);
  transition: transform 0.1s, box-shadow 0.1s;
  width: 100%;
}
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 9px 0 rgba(0,0,0,0.4), 0 16px 40px rgba(255,62,157,0.5); }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.4); }

.btn-secondary {
  padding: 14px 32px;
  font-family: var(--font-head);
  font-size: 18px;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50px;
  color: #fff; cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { background: rgba(255,255,255,0.2); border-color: var(--yellow); }
.btn-secondary:active { transform: scale(0.96); }

.pulse { animation: pulseGlow 2s ease-in-out infinite; }
@keyframes pulseGlow {
  0%,100% { box-shadow: 0 6px 0 rgba(0,0,0,0.4), 0 12px 32px rgba(255,62,157,0.4); }
  50% { box-shadow: 0 6px 0 rgba(0,0,0,0.4), 0 12px 60px rgba(255,62,157,0.8), 0 0 40px rgba(255,215,0,0.3); }
}

.mode-select-row {
  display: flex; gap: 8px; width: 100%;
}
.btn-mode {
  flex: 1; padding: 10px 4px;
  font-family: var(--font-body); font-weight: 700; font-size: 12px;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 10px; color: rgba(255,255,255,0.7);
  cursor: pointer; transition: all 0.15s;
}
.btn-mode.active {
  background: rgba(155,44,250,0.4);
  border-color: var(--purple); color: #fff;
  box-shadow: 0 0 16px rgba(155,44,250,0.5);
}
.btn-mode:hover:not(.active) { background: rgba(255,255,255,0.15); }

.mode-desc {
  font-size: 13px; color: rgba(255,255,255,0.6);
  text-align: center; min-height: 20px;
}

.sound-toggle {
  position: fixed; top: 60px; right: 16px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%; width: 44px; height: 44px;
  font-size: 20px; cursor: pointer;
  transition: all 0.15s; z-index: 100;
}
.sound-toggle:hover { background: rgba(255,255,255,0.2); }
.sound-toggle.muted { filter: grayscale(1) opacity(0.5); }

/* ═══════════════════════════════════════════
   SELECTION SCREEN
═══════════════════════════════════════════ */
#screen-selection {
  background: radial-gradient(ellipse at 50% 0%, #2D1458 0%, #110828 100%);
}

.sel-header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  background: rgba(0,0,0,0.3);
  flex-shrink: 0;
}
.btn-back {
  padding: 8px 16px;
  font-family: var(--font-body); font-weight: 700; font-size: 14px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px; color: #fff; cursor: pointer; white-space: nowrap;
  transition: all 0.15s;
}
.btn-back:hover { background: rgba(255,255,255,0.2); }
.sel-title {
  font-family: var(--font-head); font-size: clamp(18px,3vw,28px);
  color: var(--yellow); text-shadow: 2px 2px 0 var(--orange);
  flex: 1; text-align: center;
}
.sel-search-wrap { flex-shrink: 0; }
.sel-search {
  padding: 8px 14px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px; color: #fff; font-size: 13px;
  outline: none; width: 180px;
  transition: border-color 0.15s;
}
.sel-search:focus { border-color: var(--yellow); }
.sel-search::placeholder { color: rgba(255,255,255,0.4); }

/* Category tabs */
.cat-tabs {
  display: flex; gap: 6px;
  padding: 8px 16px;
  overflow-x: auto; flex-shrink: 0;
  scrollbar-width: none;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  padding: 8px 18px; border-radius: 20px; border: none;
  font-family: var(--font-body); font-weight: 700; font-size: 13px;
  cursor: pointer; white-space: nowrap; transition: all 0.15s;
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.08);
}
.cat-tab.active { color: #fff; }
.cat-tab[data-cat="all"]     { background: linear-gradient(135deg,#FF6B00,#FF2244); }
.cat-tab[data-cat="animals"].active  { background: linear-gradient(135deg,#22DD66,#00C9B1); }
.cat-tab[data-cat="fantasy"].active  { background: linear-gradient(135deg,#9B2CFA,#FF3E9D); }
.cat-tab[data-cat="food"].active     { background: linear-gradient(135deg,#FF6B00,#FFD700); }
.cat-tab[data-cat="scifi"].active    { background: linear-gradient(135deg,#1EAAFF,#9B2CFA); }
.cat-tab[data-cat="memes"].active    { background: linear-gradient(135deg,#FF2244,#FF6B00); }
.cat-tab:not(.active):hover { background: rgba(255,255,255,0.15); }

/* Grid */
.sel-grid-wrap {
  flex: 1; overflow-y: auto; padding: 12px 16px 60px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.sel-grid-wrap::-webkit-scrollbar { width: 6px; }
.sel-grid-wrap::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

.sel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.cat-section-title {
  grid-column: 1 / -1;
  font-family: var(--font-head); font-size: 20px;
  padding: 8px 0 4px;
  border-bottom: 2px solid rgba(255,255,255,0.1);
  margin-top: 8px;
}

.pinata-card {
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 12px 8px 10px;
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  position: relative; overflow: hidden;
}
.pinata-card::before {
  content: '';
  position: absolute; inset: 0; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255,255,255,0.05), transparent);
}
.pinata-card:hover {
  transform: translateY(-4px) scale(1.03);
  border-color: var(--yellow);
  box-shadow: 0 8px 24px rgba(255,215,0,0.3), 0 0 0 2px rgba(255,215,0,0.4);
}
.pinata-card:active { transform: scale(0.97); }

.pinata-card.locked {
  opacity: 0.45; cursor: default; filter: grayscale(0.5);
}
.pinata-card.locked:hover { transform: none; box-shadow: none; border-color: rgba(255,255,255,0.12); }
.lock-badge {
  position: absolute; top: 6px; right: 6px;
  font-size: 14px; opacity: 0.8;
}

.card-canvas-wrap {
  width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
}
.card-canvas {
  width: 80px; height: 80px;
  display: block;
}
.card-name {
  font-weight: 700; font-size: 11px;
  text-align: center; line-height: 1.2;
  color: rgba(255,255,255,0.9);
}
.card-hp {
  font-size: 10px; color: rgba(255,255,255,0.5);
  font-weight: 700;
}
.card-hp-bar {
  width: 60px; height: 4px;
  background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden;
}
.card-hp-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, #22DD66, #FFD700, #FF2244);
  transition: width 0s;
}

.sel-footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 10px; text-align: center;
  background: linear-gradient(to top, rgba(17,8,40,0.95), transparent);
  font-size: 13px; color: rgba(255,255,255,0.5);
  pointer-events: none;
}

/* ═══════════════════════════════════════════
   GAME SCREEN
═══════════════════════════════════════════ */
#screen-game {
  background: radial-gradient(ellipse at 50% 10%, #4A1E8A 0%, #1A0A2E 60%, #0A0518 100%);
  flex-direction: column;
}

/* HUD */
.game-hud {
  display: flex; align-items: center;
  gap: 12px; padding: 8px 16px;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  z-index: 10;
}
.hud-left { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.hud-pinata-name { font-family: var(--font-head); font-size: 15px; color: var(--yellow); }
.hud-hp-wrap { display: flex; align-items: center; gap: 6px; }
.hud-hp-label { font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.5); }
.hud-hp-bar-bg {
  flex: 1; height: 12px; background: rgba(255,255,255,0.1);
  border-radius: 6px; overflow: hidden; position: relative;
}
.hud-hp-bar {
  height: 100%; width: 100%; border-radius: 6px;
  background: linear-gradient(90deg, #FF2244, #FFD700, #22DD66);
  transition: width 0.3s ease;
  position: relative;
}
.hud-hp-bar::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 50%; background: rgba(255,255,255,0.2); border-radius: 4px 4px 0 0;
}
.hud-hp-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: 700; color: rgba(255,255,255,0.8);
}
.hud-center { flex: 1; display: flex; flex-direction: column; align-items: center; }
.hud-score-label { font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.5); }
.hud-score {
  font-family: var(--font-head); font-size: 28px;
  color: var(--yellow); text-shadow: 0 0 16px rgba(255,215,0,0.5);
  transition: transform 0.1s;
}
.hud-score.pop { animation: scorePop 0.2s ease; }
@keyframes scorePop { 0%,100% { transform: scale(1); } 50% { transform: scale(1.3); } }
.hud-combo {
  font-family: var(--font-head); font-size: 16px;
  color: var(--orange); min-height: 20px;
  animation: comboPop 0.2s ease;
}
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; min-width: 80px; }
.hud-timer-label { font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.5); }
.hud-timer {
  font-family: var(--font-head); font-size: 28px;
  color: var(--teal);
}
.hud-timer.urgent { color: var(--red); animation: urgentBlink 0.5s ease infinite; }
@keyframes urgentBlink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.hud-highscore { font-size: 10px; color: rgba(255,255,255,0.4); font-weight: 700; }

/* Canvas */
#gameCanvas {
  flex: 1; display: block; width: 100%;
  cursor: crosshair;
}

/* Sweet spot ring */
.sweet-spot-ring {
  position: absolute; pointer-events: none;
  border: 3px solid var(--yellow);
  border-radius: 50%; opacity: 0;
  transform: translate(-50%, -50%) scale(0.5);
  transition: opacity 0.1s, transform 0.1s;
  box-shadow: 0 0 20px var(--yellow), inset 0 0 20px rgba(255,215,0,0.3);
}
.sweet-spot-ring.active {
  opacity: 1; transform: translate(-50%, -50%) scale(1);
  animation: sweetPulse 0.6s ease-in-out infinite;
}
@keyframes sweetPulse {
  0%,100% { box-shadow: 0 0 20px var(--yellow), inset 0 0 20px rgba(255,215,0,0.3); }
  50% { box-shadow: 0 0 40px var(--yellow), inset 0 0 30px rgba(255,215,0,0.5); }
}

/* Power bar */
.power-wrap {
  position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  opacity: 0; transition: opacity 0.15s; pointer-events: none;
}
.power-wrap.visible { opacity: 1; }
.power-label { font-family: var(--font-head); font-size: 12px; color: var(--yellow); }
.power-bar-bg {
  width: 160px; height: 10px;
  background: rgba(255,255,255,0.1); border-radius: 5px; overflow: hidden;
}
.power-bar {
  height: 100%; width: 0%; border-radius: 5px;
  background: linear-gradient(90deg, #22DD66, #FFD700, #FF6B00, #FF2244);
  transition: width 0.05s linear;
}

/* Popup layer */
#popupLayer {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}
.hit-popup {
  position: absolute; font-family: var(--font-head);
  font-size: 20px; pointer-events: none;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
  animation: popupFloat 0.9s ease forwards;
  white-space: nowrap;
}
@keyframes popupFloat {
  0% { opacity: 1; transform: translateY(0) scale(0.8); }
  30% { transform: translateY(-20px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-70px) scale(0.9); }
}
.combo-popup {
  position: absolute; font-family: var(--font-head);
  font-size: 36px; pointer-events: none;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.4);
  animation: comboPopup 0.8s cubic-bezier(0.175,0.885,0.32,1.275) forwards;
}
@keyframes comboPopup {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(0.2) rotate(-10deg); }
  40% { opacity: 1; transform: translate(-50%,-50%) scale(1.2) rotate(3deg); }
  70% { transform: translate(-50%,-50%) scale(1) rotate(-1deg); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(0.8) rotate(0deg) translateY(-40px); }
}

/* Bottom bar */
.game-bottom-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px;
  background: rgba(0,0,0,0.4);
  flex-shrink: 0;
}
.btn-sm {
  padding: 6px 14px; font-weight: 700; font-size: 12px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px; color: #fff; cursor: pointer; transition: all 0.15s;
}
.btn-sm:hover { background: rgba(255,255,255,0.2); }
.swing-hint { font-size: 12px; color: rgba(255,255,255,0.4); font-weight: 700; }

/* ═══════════════════════════════════════════
   BREAK SCREEN
═══════════════════════════════════════════ */
#screen-break {
  background: radial-gradient(ellipse at 50% 50%, #3D1A7A 0%, #1A0A2E 80%);
  justify-content: center; align-items: center;
}

#breakCanvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none;
}

.break-content {
  position: relative; z-index: 5;
  display: flex; flex-direction: column;
  align-items: center; gap: 16px;
  padding: 24px;
  background: rgba(0,0,0,0.5);
  border: 2px solid rgba(255,215,0,0.3);
  border-radius: 24px;
  backdrop-filter: blur(12px);
  max-width: 400px; width: 90%;
  animation: breakSlideIn 0.5s cubic-bezier(0.175,0.885,0.32,1.275);
}
@keyframes breakSlideIn {
  0% { transform: scale(0.5) rotate(-5deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.break-burst {
  font-family: var(--font-head); font-size: clamp(32px, 8vw, 56px);
  color: var(--yellow);
  text-shadow: 4px 4px 0 var(--orange), 0 0 40px rgba(255,215,0,0.6);
  animation: burstText 0.6s cubic-bezier(0.175,0.885,0.32,1.275) 0.2s both;
}
@keyframes burstText {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.break-pinata-name {
  font-family: var(--font-head); font-size: 24px;
  color: var(--teal);
}
.break-stars {
  font-size: 40px; letter-spacing: 8px;
}
.break-stars .star-filled { filter: drop-shadow(0 0 8px var(--yellow)); }
.break-stars .star-empty { opacity: 0.3; }

.break-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; width: 100%;
}
.break-stat {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 10px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.bstat-label { font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.5); letter-spacing: 1px; }
.bstat-val { font-family: var(--font-head); font-size: 22px; color: var(--yellow); }

.break-new-record {
  font-family: var(--font-head); font-size: 20px;
  color: var(--gold);
  text-shadow: 0 0 20px var(--gold);
  animation: recordPulse 1s ease infinite;
}
@keyframes recordPulse {
  0%,100% { transform: scale(1); } 50% { transform: scale(1.05); }
}

.break-buttons {
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: center; width: 100%;
}
.break-buttons .btn-primary { padding: 12px 28px; font-size: 18px; }
.break-buttons .btn-secondary { padding: 12px 20px; font-size: 14px; }

/* ═══════════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

/* ═══════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════ */
@media (max-width: 480px) {
  .game-hud { padding: 6px 10px; gap: 8px; }
  .hud-left { min-width: 110px; }
  .hud-score { font-size: 22px; }
  .hud-timer { font-size: 22px; }
  .sel-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}
@media (max-height: 600px) {
  .logo-pin  { font-size: 36px; }
  .logo-bash { font-size: 44px; }
  .logo-pinata-anim { width: 100px; height: 100px; }
}
