:root {
  --pink: #ff4da6;
  --pink-dark: #d9368a;
  --blue: #4db8ff;
  --blue-dark: #2a8fd4;
  --toolbar-h: 72px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: 'Nunito', system-ui, sans-serif;
  background: #0a0a10;
  color: #fff;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* --- Arena ancha (pantalla completa menos barra) --- */
.arena {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

.zone {
  position: absolute;
  top: 0;
  bottom: 0;
  transition: width 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
  z-index: 0;
  overflow: visible;
}

.zone-hud {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 20;
  pointer-events: none;
}

.zone-girls {
  left: 0;
  width: 50%;
  background-color: #ff4da6;
  overflow: hidden;
}

.zone-girls::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(2340px, 100%);
  max-width: 100%;
  height: 100%;
  background: url('assets/girls-crowd-nobg.png') no-repeat center bottom / contain;
  pointer-events: none;
  z-index: 1;
}

.zone-boys {
  right: 0;
  width: 50%;
  background-color: #4db8ff;
  overflow: hidden;
}

.zone-boys::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(2340px, 100%);
  max-width: 100%;
  height: 100%;
  background: url('assets/boys-crowd-nobg.png') no-repeat center bottom / contain;
  pointer-events: none;
  z-index: 1;
}

.line-anchor {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 13;
  pointer-events: none;
  transition: left 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
  will-change: left;
}

.center-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 10px;
  transform: translateX(-50%);
  background: #ffffff;
  box-shadow:
    0 0 20px rgba(255, 255, 255, 0.95),
    0 0 40px rgba(255, 255, 255, 0.45);
}

.vs-logo {
  position: absolute;
  top: 14%;
  left: 50%;
  width: min(22vw, 200px);
  height: auto;
  transform: translate(-50%, 0);
  z-index: 2;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 0 18px rgba(255, 90, 0, 0.85));
}

/* Personajes (sprites) */
.sprite-slot {
  position: absolute;
  bottom: 8%;
  height: 72%;
  z-index: 8;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: transform 0.25s ease, filter 0.25s ease;
}

.sprite-girls {
  left: 0;
  width: min(95%, 900px);
  height: 94%;
  bottom: 0;
  z-index: 11;
  justify-content: flex-end;
  --girl-img-nudge: 370px;
  transform: translateX(var(--fighter-x, 0));
  transition:
    transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1),
    filter 0.25s ease;
  will-change: transform;
}

.sprite-boys {
  left: 0;
  width: min(95%, 900px);
  height: 94%;
  bottom: 0;
  z-index: 11;
  justify-content: flex-start;
  --boy-img-nudge: -25px;
  transform: translateX(var(--fighter-x, 0));
  transition:
    transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1),
    filter 0.25s ease;
  will-change: transform;
}

.fighter-img-boys {
  object-position: 0% 100%;
  transform-origin: 4% 92%;
  transform: translateX(var(--boy-img-nudge, 0));
}

.sprite-boys .fighter-img-boys {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.sprite-boys .fighter-img-boys-hero {
  display: none;
}

.sprite-boys.pushing .fighter-img-boys-base {
  display: none;
}

.sprite-boys.pushing .fighter-img-boys-hero {
  display: block;
}

.sprite-boys.pushing .fighter-img-boys {
  animation: boys-push 0.35s ease-in-out infinite alternate;
}

@keyframes boys-push {
  from {
    transform: translateX(var(--boy-img-nudge, 0)) scale(1);
  }
  to {
    transform: translateX(calc(var(--boy-img-nudge, 0) - 16px)) scale(1.03);
  }
}

.fighter-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.25));
}

.fighter-img-girls {
  object-position: 100% 100%;
  transform-origin: 100% 92%;
  transform: translateX(var(--girl-img-nudge, 0));
}

.sprite-girls .fighter-img-girls {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.sprite-girls .fighter-img-girls-hero {
  display: none;
}

.sprite-girls.pushing .fighter-img-girls-base {
  display: none;
}

.sprite-girls.pushing .fighter-img-girls-hero {
  display: block;
}

.sprite-girls.pushing .fighter-img-girls {
  animation: girls-push 0.35s ease-in-out infinite alternate;
}

@keyframes girls-push {
  from {
    transform: translateX(var(--girl-img-nudge, 0)) scale(1);
  }
  to {
    transform: translateX(calc(var(--girl-img-nudge, 0) + 16px)) scale(1.03);
  }
}

.sprite-slot.pushing {
  filter: brightness(1.06);
}

.team-badge {
  display: inline-flex;
  align-items: stretch;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  font-family: 'Bebas Neue', 'Bangers', sans-serif;
  flex-shrink: 0;
  line-height: 1;
}

.team-score {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.6em;
  padding: 6px 14px 4px;
  background: #0a0a0a;
  color: #fff;
  font-size: clamp(2rem, 4.5vw, 3.25rem);
  letter-spacing: 0.02em;
}

.team-name {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 20px 4px;
  color: #fff;
  font-size: clamp(1.35rem, 3vw, 2rem);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.team-badge-girls .team-name {
  background: linear-gradient(180deg, #ff7ebf 0%, #ff4da6 38%, #d9368a 72%, #a8206a 100%);
}

.team-badge-boys .team-name {
  background: linear-gradient(180deg, #7ad4ff 0%, #4db8ff 38%, #2a8fd4 72%, #1a5f9e 100%);
}

.team-badge-boys {
  flex-direction: row;
}

.win-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.72);
  z-index: 30;
  pointer-events: none;
  text-align: center;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.4s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.win-banner--show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.win-banner-text {
  margin: 0;
  font-family: 'Bangers', 'Bebas Neue', sans-serif;
  font-size: clamp(2.75rem, 9vw, 5.5rem);
  letter-spacing: 0.06em;
  line-height: 1.05;
  color: #fff;
  text-shadow:
    0 0 12px rgba(0, 0, 0, 0.9),
    0 4px 0 rgba(0, 0, 0, 0.55),
    0 0 40px currentColor;
  -webkit-text-stroke: 2px rgba(0, 0, 0, 0.35);
  paint-order: stroke fill;
}

.win-banner--girls .win-banner-text {
  color: #fff;
  text-shadow:
    0 0 24px rgba(255, 77, 166, 0.95),
    0 4px 0 #a8206a,
    0 0 60px rgba(255, 126, 191, 0.85);
}

.win-banner--boys .win-banner-text {
  color: #fff;
  text-shadow:
    0 0 24px rgba(77, 184, 255, 0.95),
    0 4px 0 #1a5f9e,
    0 0 60px rgba(122, 212, 255, 0.85);
}

.gift-feed {
  position: absolute;
  left: 20px;
  top: 22%;
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 40%;
  pointer-events: none;
}

.gift-toast {
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  animation: toast-in 0.3s ease, toast-out 0.4s ease 2.6s forwards;
  border-left: 4px solid var(--pink);
}

.gift-toast.boys {
  border-left-color: var(--blue);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* --- Barra inferior (misma página) --- */
.toolbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 12px 20px;
  min-height: var(--toolbar-h);
  background: #14141c;
  border-top: 2px solid #2a2a38;
}

body.stream-mode .toolbar {
  display: none;
}

body.stream-mode .arena {
  height: 100vh;
}

.toolbar-brand {
  display: flex;
  flex-direction: column;
  min-width: 140px;
}

.toolbar-brand .title {
  font-family: 'Bangers', cursive;
  font-size: 1.35rem;
  color: var(--pink);
  letter-spacing: 1px;
  line-height: 1;
}

.toolbar-brand .hint {
  font-size: 0.75rem;
  opacity: 0.75;
  margin-top: 2px;
}

.connect-form {
  display: flex;
  flex: 1;
  min-width: 220px;
  max-width: 420px;
  gap: 8px;
}

.connect-form input {
  flex: 1;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  border: 2px solid #333;
  background: #0a0a10;
  color: #fff;
  font-size: 0.95rem;
}

.connect-form button,
.demo-btns button,
.btn-stream-mode {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--pink), var(--blue));
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
}

.connect-form button:hover,
.demo-btns button:hover,
.btn-stream-mode:hover {
  filter: brightness(1.1);
}

.status {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: #2a2a36;
  font-size: 0.85rem;
  min-width: 120px;
  text-align: center;
}

.status.ok {
  background: #1b3d2a;
  color: #7dffb0;
}

.status.err {
  background: #3d1b1b;
  color: #ff8a8a;
}

.demo-btns {
  display: flex;
  gap: 6px;
}

.demo-btns button {
  min-width: 44px;
  padding: 0.6rem 0.75rem;
}

.btn-stream-mode {
  position: fixed;
  bottom: calc(var(--toolbar-h) + 10px);
  right: 16px;
  z-index: 50;
  background: #2a2a38;
  border: 2px solid #444;
}

body.stream-mode .btn-stream-mode {
  bottom: 12px;
  opacity: 0.4;
}

body.stream-mode .btn-stream-mode:hover {
  opacity: 1;
}

/* --- Botón configuración --- */
.btn-settings {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 450;
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.35rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
  border: 2px solid rgba(255, 255, 255, 0.35);
  line-height: 1;
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn-settings:hover {
  transform: rotate(45deg) scale(1.05);
  background: rgba(0, 0, 0, 0.75);
}

body.stream-mode .btn-settings {
  top: 12px;
  right: 12px;
}

/* --- Panel configuración regalos --- */
.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 460;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.settings-backdrop[hidden],
.settings-backdrop:not(.is-open) {
  display: none;
}

.settings-backdrop.is-open {
  display: flex;
}

.settings-panel {
  width: min(980px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: #1a1a24;
  border-radius: 16px;
  border: 2px solid #3a3a4a;
  padding: 20px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.settings-header h2 {
  font-family: 'Bangers', cursive;
  font-size: 1.6rem;
  letter-spacing: 1px;
  color: #ffe566;
}

.settings-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: #2a2a38;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.settings-desc {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-bottom: 16px;
  line-height: 1.45;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.settings-team h3 {
  font-family: 'Bangers', cursive;
  font-size: 1.2rem;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.settings-team-girls h3 {
  color: var(--pink);
}

.settings-team-boys h3 {
  color: var(--blue);
}

.gift-rule-row {
  display: grid;
  grid-template-columns: auto 1fr 72px 40px;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.btn-test-gift {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #3d8bfd, #2a5faa);
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.btn-test-gift:hover {
  filter: brightness(1.15);
  transform: scale(1.05);
}

.settings-team-girls .btn-test-gift {
  background: linear-gradient(135deg, #ff4da6, #c4127a);
}

.settings-team-boys .btn-test-gift {
  background: linear-gradient(135deg, #4db8ff, #1a5f9e);
}

.gift-pick {
  min-width: 0;
}

.gift-picker-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 2px solid #3a3a4a;
  border-radius: 10px;
  background: #0f0f18;
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.gift-picker-trigger:hover {
  border-color: #5a5a72;
  background: #161622;
}

.gift-preview {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  padding: 4px;
}

.gift-preview[hidden] {
  display: none;
}

.gift-picker-trigger:not(.has-gift) .gift-preview {
  display: none;
}

.gift-picker-label {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gift-picker-label-name {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-word;
}

.gift-picker-label-price {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffd54f;
}

.gift-picker-arrow {
  font-size: 1.25rem;
  opacity: 0.5;
  flex-shrink: 0;
}

.coin-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  background: radial-gradient(circle at 35% 35%, #fff6b0, #ffd54f 45%, #e6a800 100%);
  border-radius: 50%;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

/* --- Selector visual de regalos --- */
.gift-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 480;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.gift-picker-backdrop[hidden],
.gift-picker-backdrop:not(.is-open) {
  display: none;
}

.gift-picker-backdrop.is-open {
  display: flex;
}

.gift-picker-panel {
  width: min(720px, 100%);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: #12121c;
  border-radius: 14px;
  border: 2px solid #3a3a4a;
  overflow: hidden;
}

.gift-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #2a2a38;
}

.gift-picker-header h3 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  letter-spacing: 1px;
}

.gift-picker-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: #2a2a38;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
}

.gift-picker-search {
  margin: 12px 16px 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 2px solid #333;
  background: #0a0a10;
  color: #fff;
  font-size: 0.95rem;
}

.gift-picker-grid {
  padding: 12px 16px 16px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 10px;
  flex: 1;
  min-height: 0;
  align-content: start;
}

.gift-picker-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  border: 2px solid #2a2a38;
  border-radius: 10px;
  background: #1a1a28;
  color: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.gift-picker-card:hover {
  border-color: #ff4da6;
  transform: translateY(-2px);
}

.gift-picker-card[hidden] {
  display: none;
}

.gift-picker-card img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.gift-picker-card-name {
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
}

.gift-picker-card-price {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #ffd54f;
}

.gift-rule-row input[type='number'] {
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 2px solid #333;
  background: #0a0a10;
  color: #fff;
  font-size: 0.9rem;
  width: 100%;
}

.gift-rule-row label.touches-label {
  display: flex;
  flex-direction: column;
  font-size: 0.65rem;
  opacity: 0.75;
  gap: 2px;
}

.settings-extra {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #333;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.settings-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  flex: 1;
  min-width: 240px;
}

.settings-fallback {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.settings-fallback input {
  width: 72px;
  padding: 0.5rem;
  border-radius: 8px;
  border: 2px solid #333;
  background: #0a0a10;
  color: #fff;
}

.settings-footer {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

.btn-save-settings {
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--pink), var(--blue));
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  font-size: 1rem;
}

@media (max-width: 720px) {
  .toolbar {
    padding: 10px 12px;
  }

  .connect-form {
    width: 100%;
    max-width: none;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.license-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(6px);
  padding: 24px;
}

.license-gate:not(.is-open) {
  pointer-events: none !important;
  visibility: hidden;
}

.license-gate.is-open {
  display: grid;
  pointer-events: auto;
}

.license-gate[hidden] {
  display: none !important;
}

.license-card {
  width: min(100%, 420px);
  background: #14141f;
  border: 1px solid #2f2f42;
  border-radius: 16px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.license-card h2 {
  font-family: 'Bebas Neue', 'Bangers', sans-serif;
  font-size: 2rem;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.license-card p {
  color: #bbb;
  font-size: 0.95rem;
  margin-bottom: 16px;
}

#licenseForm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#licenseKeyInput {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #3a3a4a;
  background: #0a0a10;
  color: #fff;
  font-family: ui-monospace, monospace;
  text-align: center;
  letter-spacing: 0.08em;
}

#licenseForm button {
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(135deg, var(--pink), var(--blue));
  color: #fff;
}

.license-error {
  min-height: 1.2em;
  color: #ff7a7a;
  font-size: 0.9rem;
  margin-top: 10px;
}

.license-hint {
  margin-top: 12px;
  font-size: 0.8rem;
  color: #777;
}

body.license-locked .app {
  filter: blur(4px);
  user-select: none;
}
