/* ─── Base del repo (R2: body transparente, 8th Wall pinta la cámara detrás) ── */
*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --red: #c8102e;
  --red-dark: #8a0a1f;
  --gold: #e8b65a;
  --ui-font: Impact, 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
}

html {
  background: #000;
  height: 100%;
}

body {
  background: transparent;
  margin: 0;
  overflow: hidden;
  height: 100%;
  width: 100%;
}

a-scene {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* <video> de cámara que inyecta 8th Wall (sin id). Los vídeos de las
   pantallas (id="vid-*") viven en <a-assets> y no se muestran en el DOM. */
video:not([id]) {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  z-index: -2;
}

/* ─── Pantalla de carga ─────────────────────────────────────────────────── */
#loading {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, #2a0508 0%, #000 70%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0 16px;
}

#loading-logo {
  max-width: 60%;
  max-height: 40%;
  margin-bottom: 1.5rem;
}

#loading-title {
  margin: 0 0 2rem;
  color: #f2e6dc;
  font-family: var(--ui-font);
  font-size: 1rem;
  letter-spacing: 0.25em;
  text-align: center;
}

#loading-title span {
  display: block;
  margin-top: 0.3rem;
  color: var(--gold);
  font-size: 1.9rem;
  letter-spacing: 0.12em;
}

#continuar-btn {
  background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
  color: #fff;
  border: 2px solid #ff4d5e;
  padding: 0.9rem 2.6rem;
  font-family: var(--ui-font);
  font-size: 1.35rem;
  letter-spacing: 0.15em;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(200, 16, 46, 0.55);
}

#continuar-btn:active {
  transform: scale(0.97);
}

#continuar-btn:disabled {
  opacity: 0.7;
}

/* ─── Indicación "APUNTA AL MARCADOR" ───────────────────────────────────── */
#hint {
  display: none;
  position: fixed;
  left: 50%;
  bottom: calc(6vh + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 0.6rem 1.2rem;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(200, 16, 46, 0.8);
  border-radius: 6px;
  color: #fff;
  font-family: var(--ui-font);
  letter-spacing: 0.15em;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}

body[data-state="RUNNING"]:not(.marker-found) #hint {
  display: block;
}

/* ─── Botones flotantes ─────────────────────────────────────────────────── */
#recenterButtonContainer {
  position: absolute;
  width: 10vmin;
  height: 10vmin;
  right: 2vmax;
  top: calc(2vmax + env(safe-area-inset-top));
  pointer-events: auto;
  z-index: 200;
}

#recenterButtonContainer img {
  pointer-events: none;
  max-height: 10vmin;
  filter: drop-shadow(1px 1px 7px #00000026);
}

#music-btn {
  position: absolute;
  left: 2vmax;
  top: calc(2vmax + env(safe-area-inset-top));
  width: 48px;
  height: 48px;
  padding: 11px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  background: rgba(200, 16, 46, 0.75);
  z-index: 200;
  cursor: pointer;
}

#music-btn svg {
  width: 100%;
  height: 100%;
  fill: #fff;
}

#music-btn .icon-off,
#music-btn.muted .icon-on {
  display: none;
}

#music-btn.muted .icon-off {
  display: block;
}

#music-btn.muted {
  background: rgba(0, 0, 0, 0.55);
}

.pulse-once {
  animation: pulse-once 0.2s cubic-bezier(0.785, 0.135, 0.15, 0.86) both;
}
@keyframes pulse-once {
  0%   { transform: scale(1); }
  50%  { transform: scale(0.8); }
  100% { transform: scale(1); }
}

/* ─── HUD de pelea (js/hud.js) ──────────────────────────────────────────── */
#hud {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  font-family: var(--ui-font);
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body[data-state="RUNNING"] #hud {
  display: block;
}

/* sin marcador: fuera controles (la pelea está en pausa) */
body[data-state="RUNNING"]:not(.marker-found) #joystick,
body[data-state="RUNNING"]:not(.marker-found) #hud-btns {
  opacity: 0.25;
}

#hud-top {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.hud-side {
  flex: 1;
  min-width: 0;
}

.hud-name {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 0 #000, 0 0 6px #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p2 .hud-name,
.p2 .hud-wins {
  text-align: right;
}

.hud-bar {
  height: 16px;
  margin-top: 3px;
  border: 2px solid #fff;
  border-radius: 4px;
  background: #3a0710;
  box-shadow: 0 2px 0 #000;
  overflow: hidden;
  display: flex;
}

.p2 .hud-bar {
  justify-content: flex-end;   /* la vida del rival se vacía hacia la derecha */
}

.hud-bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #ffe46b 0%, #f2b200 100%);
  transition: width 0.15s ease-out;
}

.hud-bar.low i {
  background: linear-gradient(180deg, #ff6b6b 0%, #d4001c 100%);
}

.hud-wins {
  margin-top: 4px;
  height: 12px;
}

.hud-wins b {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 4px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
}

.p2 .hud-wins b {
  margin: 0 0 0 4px;
}

.hud-wins b.on {
  background: #ffc400;
}

#hud-timer {
  flex: none;
  min-width: 46px;
  padding: 2px 6px;
  font-size: 1.6rem;
  line-height: 1.1;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid #ffc400;
  border-radius: 6px;
}

#hud-timer.low {
  color: #ff5a5a;
}

#hud-banner {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 32%;
  text-align: center;
  font-size: 2.4rem;
  line-height: 1.05;
  letter-spacing: 0.04em;
  color: #ffc400;
  -webkit-text-stroke: 2px #2a0d4a;
  text-shadow: 0 4px 0 #2a0d4a, 0 0 18px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s, transform 0.15s;
}

#hud-banner.show {
  opacity: 1;
  transform: scale(1);
  animation: banner-pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}

#hud-banner.big { font-size: 3.2rem; }
#hud-banner.fight { color: #fff; }
#hud-banner.ko { font-size: 4rem; color: #ff3b3b; }
#hud-banner.mid { font-size: 2rem; }

@keyframes banner-pop {
  0% { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

#rematch-btn {
  display: none;
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translateX(-50%);
  pointer-events: auto;
  padding: 0.8rem 2.2rem;
  font-family: var(--ui-font);
  font-size: 1.4rem;
  letter-spacing: 0.12em;
  color: #fff;
  background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
  border: 2px solid #ff4d5e;
  border-radius: 6px;
  box-shadow: 0 0 24px rgba(200, 16, 46, 0.55);
}

/* ── Controles ── */
#joystick,
#hud-btns,
#hud-btns button {
  pointer-events: auto;
  touch-action: none;
}

#joystick {
  position: absolute;
  left: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.6);
}

#joystick::before {          /* marca: arriba = hacia el fondo del ring */
  content: 'FONDO';
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  opacity: 0.7;
}

#joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe46b, #d99a00);
  border: 2px solid #fff;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
}

#hud-btns {
  position: absolute;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 190px;
  height: 160px;
}

#hud-btns button {
  position: absolute;
  width: 72px;
  height: 72px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #fff;
  font-family: var(--ui-font);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 1px 0 #000;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.5);
}

#hud-btns button.on {
  transform: translateY(3px) scale(0.95);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

#hud-btns .b-punch { right: 0; bottom: 0; background: rgba(200, 16, 46, 0.85); }
#hud-btns .b-kick  { right: 86px; bottom: 14px; background: rgba(214, 118, 0, 0.85); }
#hud-btns .b-block { right: 8px; bottom: 88px; width: 62px; height: 62px; background: rgba(42, 13, 74, 0.85); }
#hud-btns .b-dodge { right: 92px; bottom: 98px; width: 56px; height: 56px; background: rgba(20, 110, 160, 0.85); }

#loading-sound {
  margin: -1rem 0 1.4rem;
  color: #f2e6dc;
  opacity: 0.75;
  font-family: var(--ui-font);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-align: center;
}
