/* Neon Cube: pantalla completa, primero para celular. La escena la dibuja neon.js. */

* { box-sizing: border-box; }

/* texto para lectores de pantalla y buscadores (el juego en si es un canvas) */
.solo-lector { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

html, body {
  margin: 0;
  height: 100%;
  background: #020208;
  color: #e8ecff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.cubo-escena {
  position: fixed;
  inset: 0;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 45%, #0a0820 0%, #020208 70%);
}

#cubo-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
#cubo-canvas:active { cursor: grabbing; }

.cubo-confeti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---- Arriba: marca, cronometro y botones chicos ---- */

.cubo-hud {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  pointer-events: none;
}
.cubo-hud > * { pointer-events: auto; }
.cubo-hud-der { display: flex; gap: 8px; justify-self: end; }

.cubo-marca {
  justify-self: start;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 5px;
  color: #e9fbff;
  text-shadow: 0 0 6px #22e6ff, 0 0 18px rgba(34, 230, 255, 0.55);
  padding-top: 6px;
}
.cubo-marca span {
  margin-left: 6px;
  color: #ffe9fb;
  text-shadow: 0 0 6px #ff2bd6, 0 0 18px rgba(255, 43, 214, 0.6);
}

.cubo-crono {
  text-align: center;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 30px;
  font-weight: 600;
  color: #e9fbff;
  letter-spacing: 1px;
  text-shadow: 0 0 6px rgba(34, 230, 255, 0.7), 0 0 20px rgba(34, 230, 255, 0.35);
  transition: color 0.3s, text-shadow 0.3s;
}
.cubo-crono.corriendo {
  color: #fff;
  text-shadow: 0 0 8px #22e6ff, 0 0 26px rgba(34, 230, 255, 0.75);
}
.cubo-crono small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  color: #8a91b8;
  text-shadow: none;
}

/* ---- Botones con borde de neon ---- */

.cubo-btn {
  background: rgba(10, 10, 26, 0.55);
  border: 1px solid rgba(120, 140, 255, 0.35);
  color: #e8ecff;
  padding: 11px 20px;
  border-radius: 999px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.1s, opacity 0.2s;
}
@media (hover: hover) {
  .cubo-btn:hover:not(:disabled) {
    border-color: #22e6ff;
    box-shadow: 0 0 12px rgba(34, 230, 255, 0.45), inset 0 0 10px rgba(34, 230, 255, 0.12);
  }
  .cubo-btn-principal:hover:not(:disabled) {
    border-color: #ff2bd6;
    box-shadow: 0 0 14px rgba(255, 43, 214, 0.55), inset 0 0 10px rgba(255, 43, 214, 0.15);
  }
}
.cubo-btn:active:not(:disabled) { transform: scale(0.96); }
.cubo-btn:disabled { opacity: 0.4; cursor: default; }
.cubo-btn-principal { border-color: rgba(255, 43, 214, 0.6); }
.cubo-btn-icono {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 17px;
}

/* el boton compartir late despues de resolverlo */
.cubo-btn.destacar {
  border-color: #ff2bd6;
  animation: latido 1s ease-in-out infinite;
}
@keyframes latido {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 43, 214, 0.4); }
  50% { box-shadow: 0 0 22px rgba(255, 43, 214, 0.9), inset 0 0 10px rgba(255, 43, 214, 0.25); }
}

/* ---- Abajo: ayuda, controles y firma ---- */

.cubo-controles {
  position: absolute;
  left: 50%;
  bottom: max(26px, calc(env(safe-area-inset-bottom) + 14px));
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}

.cubo-ayuda {
  position: absolute;
  left: 50%;
  bottom: max(82px, calc(env(safe-area-inset-bottom) + 70px));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: #8188ad;
  pointer-events: none;
  transition: opacity 0.6s;
}
.cubo-ayuda.vista { opacity: 0; }
.solo-tactil { display: none; }
@media (hover: none) and (pointer: coarse) {
  .solo-tactil { display: inline; }
  .solo-mouse { display: none; }
}

.cubo-firma {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  font-size: 11px;
  color: #4d5275;
  letter-spacing: 0.5px;
  pointer-events: none;
}

/* ---- Textos que aparecen: paso del "Resolver", aviso y mensaje grande ---- */

.cubo-paso {
  position: absolute;
  top: calc(max(14px, env(safe-area-inset-top)) + 70px);
  left: 50%;
  transform: translate(-50%, -6px);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 20px;
  font-weight: 600;
  color: #ffe9fb;
  text-shadow: 0 0 8px #ff2bd6, 0 0 22px rgba(255, 43, 214, 0.6);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.cubo-paso.visible { opacity: 1; transform: translate(-50%, 0); }

.cubo-aviso {
  position: absolute;
  left: 50%;
  bottom: max(118px, calc(env(safe-area-inset-bottom) + 104px));
  transform: translate(-50%, 6px);
  max-width: calc(100% - 32px);
  background: rgba(10, 10, 26, 0.85);
  border: 1px solid rgba(120, 140, 255, 0.3);
  color: #e8ecff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.cubo-aviso.visible { opacity: 1; transform: translate(-50%, 0); }

.cubo-mensaje {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.45s, transform 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.cubo-mensaje.visible { opacity: 1; transform: scale(1); }
.cubo-mensaje h2 {
  margin: 0;
  font-size: clamp(40px, 9vw, 80px);
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 0 10px #ff2bd6, 0 0 32px #ff2bd6, 0 0 70px rgba(34, 230, 255, 0.7);
}
.cubo-mensaje p {
  margin: 10px 0 0;
  font-size: clamp(15px, 2.4vw, 20px);
  font-weight: 600;
  color: #e9fbff;
  text-shadow: 0 0 8px rgba(34, 230, 255, 0.8);
}

/* ---- Modo foto (?foto=og / ?foto=icono): solo para generar las imagenes del sitio ---- */

.modo-foto .cubo-hud,
.modo-foto .cubo-controles,
.modo-foto .cubo-ayuda,
.modo-foto .cubo-firma { display: none; }
.foto-og .cubo-mensaje { opacity: 1; transform: none; justify-content: space-between; padding: 44px 0; }
.foto-og .cubo-mensaje h2 { font-size: 64px; letter-spacing: 14px; }
.foto-og .cubo-mensaje p { font-size: 26px; }

/* ---- Panel de botones para girar (sigue a la camara; el puntito es el color de esa cara) ---- */

.cubo-pad {
  position: absolute;
  left: 50%;
  bottom: max(84px, calc(env(safe-area-inset-bottom) + 72px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 108px);
  grid-template-areas:
    "sentido arriba atras"
    "izq frente der"
    ". abajo .";
  gap: 7px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(6, 6, 18, 0.6);
  border: 1px solid rgba(120, 140, 255, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.cubo-pad[hidden] { display: none; }
.pad-sentido { grid-area: sentido; }
.pad-arriba { grid-area: arriba; }
.pad-atras { grid-area: atras; }
.pad-izq { grid-area: izq; }
.pad-frente { grid-area: frente; }
.pad-der { grid-area: der; }
.pad-abajo { grid-area: abajo; }

.pad-btn, .pad-sentido {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 42px;
  padding: 0 8px;
  border-radius: 12px;
  background: rgba(14, 14, 32, 0.8);
  border: 1px solid rgba(120, 140, 255, 0.25);
  color: #e8ecff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s, border-color 0.2s, box-shadow 0.2s;
}
.pad-btn i {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--cara, #888);
  box-shadow: 0 0 6px var(--cara, #888), 0 0 14px var(--cara, #888);
}
.pad-btn:active:not(:disabled), .pad-sentido:active { transform: scale(0.95); }
.pad-btn:disabled { opacity: 0.4; cursor: default; }
@media (hover: hover) {
  .pad-btn:hover:not(:disabled) { border-color: var(--cara, #22e6ff); box-shadow: 0 0 10px color-mix(in srgb, var(--cara, #22e6ff) 45%, transparent); }
}
.pad-sentido { color: #ffe9fb; border-color: rgba(255, 43, 214, 0.45); }
.pad-sentido[aria-pressed="true"] { border-color: #ff2bd6; box-shadow: 0 0 10px rgba(255, 43, 214, 0.45); }
.cubo-btn-icono[aria-pressed="true"] { border-color: #22e6ff; box-shadow: 0 0 12px rgba(34, 230, 255, 0.45); }

/* con el panel abierto, la ayuda y los avisos no se le encima */
.pad-abierto .cubo-ayuda { opacity: 0; }
.pad-abierto .cubo-aviso { bottom: max(272px, calc(env(safe-area-inset-bottom) + 258px)); }

/* ---- Sin WebGL / error de carga / el celular pauso el 3D ---- */

.sin-webgl-aviso, .error-aviso { display: none; }
.error-carga .error-aviso,
.sin-webgl .sin-webgl-aviso {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: #020208;
}
.error-carga .error-aviso { z-index: 10; }
.sin-webgl-aviso h1, .error-aviso h1 {
  margin: 0 0 12px;
  letter-spacing: 6px;
  text-shadow: 0 0 10px #22e6ff;
}
.sin-webgl-aviso p, .error-aviso p { color: #9aa3c7; max-width: 340px; margin: 0 0 20px; }

/* "Reducir movimiento" del sistema: sin animaciones de la interfaz */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Celular ---- */

@media (max-width: 600px) {
  .cubo-hud { grid-template-columns: 1fr auto; row-gap: 6px; }
  .cubo-marca { font-size: 13px; letter-spacing: 4px; }
  .cubo-crono {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: 30px;
  }
  .cubo-btn-icono { width: 38px; height: 38px; font-size: 16px; }
  .cubo-paso { top: calc(max(14px, env(safe-area-inset-top)) + 104px); }
  .cubo-controles { width: calc(100% - 24px); gap: 6px; }
  .cubo-controles .cubo-btn { flex: 1; padding: 13px 4px; font-size: 13px; }
  .cubo-controles .cubo-btn-icono { flex: 0 0 42px; width: 42px; height: 46px; padding: 0; font-size: 17px; }
  .cubo-pad { grid-template-columns: repeat(3, minmax(0, 1fr)); width: calc(100% - 24px); padding: 8px; gap: 6px; }
  .pad-btn, .pad-sentido { font-size: 12px; height: 44px; padding: 0 4px; gap: 5px; }
  .cubo-firma { left: 50%; right: auto; transform: translateX(-50%); }
}

/* ============================================================
   Duelos 1 vs 1 (duelo.js)
   ============================================================ */

.solo-duelo { display: none; }
.en-duelo .solo-libre { display: none !important; }
.en-duelo .solo-duelo { display: inline-block; }
.modo-foto .duelo-entrar { display: none; }

/* entrada: "⚔️ Duelo" y "🎲 Buscar rival", arriba de los controles */
.duelo-entrar {
  position: absolute;
  left: 50%;
  bottom: max(80px, calc(env(safe-area-inset-bottom) + 68px));
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.duelo-entrar .cubo-btn { padding: 8px 12px; font-size: 13px; border-color: rgba(34, 230, 255, 0.4); white-space: nowrap; }
.duelo-panel .duelo-dificultad { display: block; margin: 10px auto; border-color: rgba(34, 230, 255, 0.4); }
.pad-abierto .duelo-entrar, .duelo-panel-abierto .duelo-entrar { display: none; }
body:not(.en-duelo) .cubo-ayuda { bottom: max(126px, calc(env(safe-area-inset-bottom) + 114px)); }
body:not(.en-duelo) .cubo-aviso { bottom: max(160px, calc(env(safe-area-inset-bottom) + 148px)); }
.pad-abierto .cubo-aviso { bottom: max(272px, calc(env(safe-area-inset-bottom) + 258px)) !important; }

/* el rival en miniatura (esquina de arriba a la izquierda, debajo de la marca) */
.duelo-rival {
  position: absolute;
  top: calc(max(14px, env(safe-area-inset-top)) + 40px);
  left: max(12px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  border-radius: 14px;
  background: rgba(6, 6, 18, 0.62);
  border: 1px solid rgba(255, 43, 214, 0.45);
  box-shadow: 0 0 12px rgba(255, 43, 214, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
  max-width: calc(100% - 24px);
}
.duelo-rival[hidden] { display: none; }
.duelo-rival.fantasma { border-color: rgba(190, 200, 255, 0.5); border-style: dashed; }
.duelo-rival.pulso { animation: pulso-rival 0.35s ease-out; }
@keyframes pulso-rival {
  0% { box-shadow: 0 0 22px rgba(255, 43, 214, 0.65); }
  100% { box-shadow: 0 0 12px rgba(255, 43, 214, 0.18); }
}
#duelo-mini { width: 104px; height: 52px; display: block; }
.duelo-rival-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.duelo-rival-info b {
  font-size: 13px;
  color: #ffe9fb;
  text-shadow: 0 0 6px rgba(255, 43, 214, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.duelo-rival-info span { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; color: #e9fbff; }
.duelo-rival-info small { font-size: 11px; color: #8a91b8; }

/* 3-2-1 */
.duelo-cuenta {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(90px, 28vw, 180px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 14px #22e6ff, 0 0 40px #22e6ff, 0 0 80px rgba(255, 43, 214, 0.7);
  pointer-events: none;
  opacity: 0;
}
.duelo-cuenta.visible { opacity: 1; }
.duelo-cuenta.late { animation: late-cuenta 0.9s ease-out; }
@keyframes late-cuenta {
  0% { transform: scale(1.5); opacity: 0; }
  20% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.85); opacity: 0.85; }
}

/* panel central: apodo, sala de espera, buscando, resultado */
.duelo-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(380px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow-y: auto;
  padding: 20px 18px 16px;
  border-radius: 20px;
  text-align: center;
  background: rgba(8, 8, 22, 0.9);
  border: 1px solid rgba(255, 43, 214, 0.5);
  box-shadow: 0 0 26px rgba(255, 43, 214, 0.25), inset 0 0 18px rgba(34, 230, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  -webkit-user-select: text;
  user-select: text;
  z-index: 5;
}
.duelo-panel[hidden] { display: none; }
.duelo-panel h2 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 8px #ff2bd6, 0 0 22px rgba(255, 43, 214, 0.6);
}
.duelo-panel p { margin: 8px 0; font-size: 15px; color: #d6dbf5; }
.duelo-panel .duelo-nota { font-size: 12px; color: #8a91b8; }
.duelo-panel .duelo-nota.destacada { font-size: 14px; color: #ffe9fb; text-shadow: 0 0 6px rgba(255, 43, 214, 0.7); }
.duelo-panel input {
  width: 100%;
  margin: 8px 0 4px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(34, 230, 255, 0.45);
  background: rgba(2, 2, 10, 0.8);
  color: #fff;
  font: inherit;
  font-size: 16px;   /* 16px: el iPhone no hace zoom al escribir */
  text-align: center;
  outline: none;
}
.duelo-panel input:focus { border-color: #22e6ff; box-shadow: 0 0 12px rgba(34, 230, 255, 0.4); }
.duelo-botones { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.duelo-botones .cubo-btn { flex: 1 1 auto; min-width: 110px; }
.duelo-link {
  margin: 6px 0;
  padding: 10px;
  border-radius: 10px;
  border: 1px dashed rgba(34, 230, 255, 0.5);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 14px;
  color: #e9fbff;
  word-break: break-all;
}
.duelo-jugadores { list-style: none; margin: 12px 0 4px; padding: 0; text-align: left; }
.duelo-jugadores li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  margin: 4px 0;
  border-radius: 10px;
  background: rgba(20, 20, 44, 0.6);
  border: 1px solid rgba(120, 140, 255, 0.2);
  font-size: 14px;
}
.duelo-jugadores li b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duelo-jugadores li span { color: #8a91b8; white-space: nowrap; }
.duelo-jugadores li.ok { border-color: rgba(25, 255, 122, 0.45); }
.duelo-jugadores li.ok span { color: #19ff7a; text-shadow: 0 0 6px rgba(25, 255, 122, 0.6); }
.duelo-tabla { width: 100%; margin: 10px 0; border-collapse: collapse; font-size: 14px; }
.duelo-tabla th, .duelo-tabla td { padding: 7px 6px; border-bottom: 1px solid rgba(120, 140, 255, 0.18); }
.duelo-tabla th { text-align: left; color: #ffe9fb; font-weight: 700; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duelo-tabla td { font-family: ui-monospace, "SF Mono", Menlo, monospace; color: #e9fbff; text-align: right; }

/* radar mientras busca rival */
.duelo-radar {
  width: 70px;
  height: 70px;
  margin: 6px auto;
  border-radius: 50%;
  border: 2px solid rgba(34, 230, 255, 0.6);
  box-shadow: 0 0 14px rgba(34, 230, 255, 0.4), inset 0 0 14px rgba(34, 230, 255, 0.25);
  background: conic-gradient(from 0deg, rgba(34, 230, 255, 0.55), transparent 30%);
  animation: radar 1.4s linear infinite;
}
@keyframes radar { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  .duelo-rival { top: calc(max(14px, env(safe-area-inset-top)) + 96px); }
  .en-duelo .cubo-controles { width: auto; }
}
