/* ── RHYTHM KABOOM — EXPLOSIVE SKIN ── */

@font-face {
  font-family: 'FontNotas';
  src: url('../fonts/fontnotas.ttf') format('truetype');
  font-display: swap;
}

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: #0e0910;
  --bg2: #130d18;
  --surface: #1a1020;
  --surface2: #211528;
  --surface3: #2a1b34;
  --fire: #ff5a00;
  --fire-light: #ff8c00;
  --gold: #f5c842;
  --gold-glow: rgba(245, 200, 66, 0.35);
  --ember: #ff3a1a;
  --ok: #4dcc7a;
  --fail: #ff3a1a;
  --text: #f0e8d8;
  --muted: #7a6a8a;
  --radius: 14px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(255, 90, 0, 0.12), transparent 55%),
    radial-gradient(ellipse at 20% 100%, rgba(245, 200, 66, 0.07), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(120, 40, 160, 0.08), transparent 50%);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  overflow: hidden;
  transition: background 0.3s;
}

body.kaboom-bg {
  animation: kaboom-flash 0.15s ease-in-out 4 alternate;
}

@keyframes kaboom-flash {
  from {
    background-color: var(--bg);
  }

  to {
    background-color: #4a0a00;
  }
}

/* ── Back button ── */
.back-btn {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  transition: color 0.2s;
}

.back-btn:hover {
  color: var(--text);
}

/* ── Setup area ── */
#setup-area {
  width: 100%;
  max-width: 520px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  overflow-y: auto;
  scrollbar-width: none;
}

#setup-area::-webkit-scrollbar {
  display: none;
}

/* ── LOGO ── */
.game-logo {
  width: min(340px, 88%);
  display: block;
  margin: 0 auto 0;
  filter:
    drop-shadow(0 6px 28px rgba(255, 90, 0, 0.45)) drop-shadow(0 0 60px rgba(245, 200, 66, 0.2));
  animation: logo-float 4s ease-in-out infinite;
}

@keyframes logo-float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-7px);
  }
}

/* Title & subtitle kept for JS fallback, hidden visually */
.game-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2rem, 6vw, 2.8rem);
  color: var(--fire);
  text-shadow: 0 0 30px rgba(255, 90, 0, 0.6), 3px 3px 0 rgba(0, 0, 0, 0.5);
  text-align: center;
  letter-spacing: .1em;
  display: none;
  /* logo replaces this */
}

.game-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  text-align: center;
  font-weight: 500;
}

/* ── Setup card ── */
.setup-card {
  background: var(--surface);
  border: 1px solid rgba(255, 90, 0, 0.18);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  box-shadow:
    0 0 50px rgba(255, 90, 0, 0.08),
    0 20px 40px rgba(0, 0, 0, 0.5);
  position: relative;
}

/* Inner carved border */
.setup-card::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(245, 200, 66, 0.08);
  border-radius: 10px;
  pointer-events: none;
}

.setup-section {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  z-index: 1;
}

.setup-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.section-label {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1rem;
  font-weight: 400;
  color: var(--gold);
  letter-spacing: .15em;
  text-shadow: 0 0 8px var(--gold-glow);
}

.input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.input-row.center {
  justify-content: center;
}

label {
  font-weight: 600;
  color: var(--text);
}

input[type="number"],
select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 6px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  width: 70px;
}

input[type="number"]:focus,
select:focus {
  outline: 2px solid var(--fire);
}

select {
  width: auto;
  cursor: pointer;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--fire);
  cursor: pointer;
}

/* ── Teams list ── */
.teams-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.team-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.team-name-input {
  flex: 1;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 9px 13px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  width: auto;
  transition: border-color 0.2s;
}

.team-name-input:focus {
  outline: none;
  border-color: var(--fire-light);
}

.emoji-select-btn {
  background: var(--surface2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  cursor: pointer;
  font-size: 1.4rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, border-color 0.15s;
}

.emoji-select-btn:hover {
  transform: scale(1.1);
  border-color: var(--gold);
}

/* ── Emoji picker modal ── */
.emoji-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  animation: fade-in 0.15s ease;
}

.emoji-picker-overlay.hidden {
  display: none;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.emoji-picker-modal {
  background: var(--surface);
  border: 1px solid rgba(255, 90, 0, 0.25);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
  max-width: 280px;
  width: 90vw;
  animation: scale-in 0.15s ease;
}

@keyframes scale-in {
  from {
    transform: scale(0.88);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.emoji-opt {
  font-size: 1.45rem;
  cursor: pointer;
  padding: 5px;
  border-radius: 7px;
  text-align: center;
  transition: background 0.1s, transform 0.1s;
  user-select: none;
}

.emoji-opt:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(1.2);
}

.emoji-opt.selected {
  background: var(--fire);
}

/* ── Figuras toggles ── */
.figuras-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.toggle-figura {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 9px;
  background: var(--surface2);
  border: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}

.toggle-figura:has(input:checked) {
  border-color: var(--fire-light);
  background: rgba(255, 140, 0, 0.15);
}

.toggle-figura input {
  display: none;
}

.figura-label {
  font-size: 2rem;
  line-height: 1;
}

.fontnotas {
  font-family: 'FontNotas', sans-serif;
}

/* ── Buttons ── */
.btn-primary {
  background: linear-gradient(135deg, var(--fire) 0%, var(--ember) 100%);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 13px 40px;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.3rem;
  letter-spacing: .12em;
  cursor: pointer;
  box-shadow: 0 4px 22px rgba(255, 90, 0, 0.45);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(255, 90, 0, 0.6);
}

.btn-restart {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 6px 13px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.btn-restart:hover {
  color: var(--text);
  border-color: var(--fire-light);
}

.center {
  display: flex;
  justify-content: center;
}

/* ── Game area ── */
#game-area {
  width: 100%;
  max-width: 520px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.game-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

#current-player-info {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  text-align: center;
  text-shadow: 0 0 8px var(--gold-glow);
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: .08em;
  font-size: 1.1rem;
}

#cards-remaining {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Scoreboard ── */
#scoreboard {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  width: 100%;
  padding: 0.65rem 0;
  flex-shrink: 0;
}

.team-score {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 50px;
  padding: 6px 16px;
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.2s, background 0.2s;
}

.team-score.active {
  border-color: var(--fire-light);
  background: rgba(255, 140, 0, 0.14);
  box-shadow: 0 0 14px rgba(255, 90, 0, 0.2);
}

.team-avatar {
  font-size: 1.15rem;
}

/* ── Card ── */
#card-display-area {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0;
  min-height: 0;
}

#card-container {
  perspective: 900px;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#card {
  width: min(440px, 94vw);
  height: min(260px, 100%);
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 0.25s, transform 0.25s, border-color 0.2s;
  cursor: default;
  user-select: none;
}

#card.visible {
  opacity: 1;
  transform: scale(1);
}

#card.clickable-deck {
  cursor: pointer;
  border-color: rgba(255, 140, 0, 0.4);
  box-shadow: 0 0 24px rgba(255, 90, 0, 0.12), 0 6px 30px rgba(0, 0, 0, 0.5);
}

#card.clickable-deck:hover {
  transform: scale(1.03);
  border-color: var(--fire-light);
  box-shadow: 0 0 36px rgba(255, 90, 0, 0.22), 0 6px 30px rgba(0, 0, 0, 0.5);
}

#card.kaboom-active {
  border-color: var(--ember);
  background: #1f0600;
  box-shadow: 0 0 50px rgba(255, 58, 26, 0.3);
}

#card.flipping {
  animation: flip-out 0.15s ease-in forwards;
}

@keyframes flip-out {
  to {
    transform: rotateY(90deg) scale(0.9);
    opacity: 0.3;
  }
}

@keyframes pop {
  0% {
    transform: scale(0.88);
  }

  60% {
    transform: scale(1.06);
  }

  100% {
    transform: scale(1);
  }
}

#card.pop-animate {
  animation: pop 0.35s ease;
}

#card-content {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
}

.card-text {
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
  width: 100%;
}

.kaboom-text {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.2rem;
  color: var(--ember);
  text-shadow: 0 0 30px rgba(255, 58, 26, 0.7), 3px 3px 0 rgba(0, 0, 0, 0.5);
  letter-spacing: .12em;
}

/* ── Notas musicales ── */
.nota-musical {
  font-size: clamp(2rem, 8vw, 3.6rem);
  line-height: 1;
  padding: clamp(4px, 1.5vw, 8px) clamp(4px, 1.5vw, 10px);
  border-radius: 9px;
  transition: background 0.12s, color 0.12s, transform 0.1s;
  color: var(--text);
  flex-shrink: 1;
  min-width: 0;
}

.nota-musical.nota-active {
  background: rgba(245, 200, 66, 0.2);
  transform: scale(1.15);
  color: var(--gold);
}

.nota-musical.nota-acierto {
  color: var(--ok);
}

.nota-musical.nota-error {
  color: var(--fail);
}

/* ── TAP zone ── */
#tap-zone {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 0.65rem 0;
  flex-shrink: 0;
}

#rr-tap-btn {
  background: linear-gradient(135deg, var(--fire) 0%, var(--ember) 100%);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 17px 60px;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.7rem;
  letter-spacing: .14em;
  cursor: pointer;
  box-shadow: 0 4px 22px rgba(255, 90, 0, 0.45);
  transition: transform 0.1s, box-shadow 0.1s;
  touch-action: manipulation;
  user-select: none;
  width: min(320px, 85vw);
}

#rr-tap-btn:active,
#rr-tap-btn.tap-active {
  transform: scale(0.93);
  box-shadow: 0 1px 8px rgba(255, 90, 0, 0.3);
}

#rr-tap-btn:disabled {
  background: var(--surface2);
  color: var(--muted);
  box-shadow: none;
  cursor: not-allowed;
}

/* ── Message area ── */
#message-area {
  min-height: 2.5rem;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  border-radius: 10px;
  padding: 0.65rem 1.25rem;
  transition: all 0.2s;
  width: 100%;
  flex-shrink: 0;
  margin-bottom: 0.5rem;
}

.feedback-correct {
  color: var(--ok);
  background: rgba(77, 204, 122, 0.1);
}

.feedback-incorrect {
  color: var(--fail);
  background: rgba(255, 58, 26, 0.1);
}

.feedback-info {
  color: var(--gold);
}

/* ── Confetti ── */
#confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 200;
}

.confetti-piece {
  position: absolute;
  top: -10px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  animation: confetti-fall 1.4s ease-in forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ── Kaboom explosion ── */
#kaboom-explosion-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 300;
}

.kaboom-emoji {
  font-size: 6rem;
  animation: kaboom-pop 1.1s ease forwards;
  display: block;
}

@keyframes kaboom-pop {
  0% {
    transform: scale(0.3);
    opacity: 1;
  }

  50% {
    transform: scale(1.6);
    opacity: 1;
  }

  100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* ── Premium Locks ── */
.locked-premium {
  position: relative !important;
  opacity: 0.65;
  cursor: not-allowed !important;
}

.locked-premium>* {
  pointer-events: none;
}

.locked-premium::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  background-color: rgba(255, 255, 255, 0.45);
  mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C9.243 2 7 4.243 7 7V10H6V20H18V10H17V7C17 4.243 14.757 2 12 2ZM9 7C9 5.346 10.346 4 12 4C13.654 4 15 5.346 15 7V10H9V7ZM12 17C10.895 17 10 16.105 10 15C10 13.895 10.895 13 12 13C13.105 13 14 13.895 14 15C14 16.105 13.105 17 12 17Z" fill="white"/></svg>');
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C9.243 2 7 4.243 7 7V10H6V20H18V10H17V7C17 4.243 14.757 2 12 2ZM9 7C9 5.346 10.346 4 12 4C13.654 4 15 5.346 15 7V10H9V7ZM12 17C10.895 17 10 16.105 10 15C10 13.895 10.895 13 12 13C13.105 13 14 13.895 14 15C14 16.105 13.105 17 12 17Z" fill="white"/></svg>');
  mask-size: contain;
  -webkit-mask-size: contain;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-position: center;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

/* For form inputs and labels specifically */
label:has(input.locked-premium) {
  opacity: 0.65;
  cursor: not-allowed !important;
  position: relative;
}

label:has(input.locked-premium)::after {
  content: '🔒';
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 1.1rem;
  z-index: 10;
  pointer-events: none;
}

label.locked-premium::after {
  content: "";
  position: absolute;
  top: -12px;
  right: -10px;
  width: 14px;
  height: 14px;
  background-color: rgba(255, 255, 255, 0.45);
  mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C9.243 2 7 4.243 7 7V10H6V20H18V10H17V7C17 4.243 14.757 2 12 2ZM9 7C9 5.346 10.346 4 12 4C13.654 4 15 5.346 15 7V10H9V7ZM12 17C10.895 17 10 16.105 10 15C10 13.895 10.895 13 12 13C13.105 13 14 13.895 14 15C14 16.105 13.105 17 12 17Z" fill="white"/></svg>');
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C9.243 2 7 4.243 7 7V10H6V20H18V10H17V7C17 4.243 14.757 2 12 2ZM9 7C9 5.346 10.346 4 12 4C13.654 4 15 5.346 15 7V10H9V7ZM12 17C10.895 17 10 16.105 10 15C10 13.895 10.895 13 12 13C13.105 13 14 13.895 14 15C14 16.105 13.105 17 12 17Z" fill="white"/></svg>');
  mask-size: contain;
  -webkit-mask-size: contain;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-position: center;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

/* ── Responsive ── */
@media (max-width: 420px) {
  body {
    padding: 0.6rem 0.75rem;
  }

  .btn-primary {
    padding: 11px 28px;
    font-size: 1.1rem;
  }

  #rr-tap-btn {
    padding: 13px 36px;
    font-size: 1.4rem;
  }

  #card {
    padding: 1rem 0.75rem;
  }

  #card-content {
    gap: 0.2rem;
  }

  .setup-card {
    padding: 1.1rem;
  }

  .game-logo {
    width: min(280px, 85%);
  }
}