/* =====================================================================
   TABLERO SEGUN LA CAPTURA REAL DE PORTAL APP
   ---------------------------------------------------------------------
   Paleta medida sobre youtu.be/IsTPdPuqsIk (miniatura 1280x720, que es una
   captura de partida autentica):

       crema claro .... #fff8dd      pergamino del centro y de los huecos
       crema oscuro ... #fdefca
       tostado ........ #dba569      tono dominante del fondo (60.000 px)
       oxido .......... #803c0f      banda ornamental
       granate oscuro . #31020a      bordes y sombras de la banda

   Esta hoja se carga LA ULTIMA para no tener que pelearse con las seis
   anteriores (tt.css, tt-cartas.css, tt-propiedad.css, tt-efectos.css,
   tt-ffxiv.css, tt-ffxiv2.css, tt-menu.css, tt-tinte.css,
   tt-cartas-ref.css, tt-ui.css) que ya usan !important entre si.

   El ornamento es propio: no se ha extraido arte de Square Enix. Va marcado
   como PROVISIONAL.
   ===================================================================== */

:root {
  --ref-crema:      #fff8dd;
  --ref-crema-osc:  #fdefca;
  --ref-tostado:    #dba569;
  --ref-tostado-os: #c08c4e;
  --ref-oxido:      #803c0f;
  --ref-granate:    #31020a;
}

/* ---------------- el tablero: pergamino con banda de oxido ---------------- */
.tt-tablero,
#tt-tablero {
  background:
    /* el logotipo tenue del centro, como en el original */
    radial-gradient(circle at 50% 46%, rgba(255, 255, 255, .34), transparent 42%),
    /* tornasolado del pergamino */
    radial-gradient(120% 90% at 30% 12%, rgba(255, 248, 221, .55), transparent 55%),
    radial-gradient(120% 90% at 78% 88%, rgba(49, 2, 10, .22), transparent 58%),
    linear-gradient(160deg, var(--ref-tostado) 0%, var(--ref-tostado-os) 52%, #a8752f 100%) !important;
  border: 0 !important;
  border-radius: 4px !important;
  padding: 14px !important;
  gap: 6px !important;
  position: relative !important;
  box-shadow:
    inset 0 0 0 2px rgba(128, 60, 15, .75),
    inset 0 0 0 5px rgba(49, 2, 10, .35),
    0 6px 22px rgba(0, 0, 0, .45) !important;
}

/* se quitan los adornos del diseno anterior */
.tt-tablero::before,
.tt-tablero::after,
#tt-tablero::before,
#tt-tablero::after {
  content: none !important;
  display: none !important;
}

/* ---------------- casillas: sin marco propio, como el original ---------------- */
.tt-tablero .tt-casilla {
  background:
    linear-gradient(180deg, rgba(255, 248, 221, .92), rgba(253, 239, 202, .82)) !important;
  border: 1px solid rgba(128, 60, 15, .55) !important;
  border-radius: 3px !important;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .35),
    inset 0 2px 8px rgba(49, 2, 10, .18) !important;
  transition: background .12s ease, box-shadow .12s ease, border-color .12s ease !important;
}

/* casilla libre: apenas se distingue del pergamino */
.tt-tablero .tt-casilla.libre {
  background:
    linear-gradient(180deg, rgba(219, 165, 105, .30), rgba(168, 117, 47, .34)) !important;
  border-color: rgba(128, 60, 15, .42) !important;
}

/* casilla donde puedes poner: borde dorado y brillo suave */
.tt-tablero .tt-casilla.jugable {
  background:
    linear-gradient(180deg, rgba(255, 250, 226, .96), rgba(253, 236, 190, .90)) !important;
  border-color: #e8b44a !important;
  box-shadow:
    inset 0 0 0 2px rgba(232, 180, 74, .75),
    0 0 14px rgba(240, 190, 90, .55) !important;
  cursor: pointer !important;
}

.tt-tablero .tt-casilla.jugable:hover {
  background:
    linear-gradient(180deg, #fffdf0, #fdeec2) !important;
  box-shadow:
    inset 0 0 0 2px rgba(255, 205, 90, .95),
    0 0 20px rgba(255, 205, 90, .75) !important;
}

/* casilla con carta: se quita el fondo para que mande la carta */
.tt-tablero .tt-casilla.mia,
.tt-tablero .tt-casilla.suya {
  background: transparent !important;
  border-color: rgba(49, 2, 10, .45) !important;
  box-shadow: none !important;
}

/* ---------------- cifras y textos sobre el pergamino ---------------- */
.tt-tablero .tt-vacio,
#tt-tablero .tt-vacio {
  background: rgba(255, 248, 221, .85) !important;
  color: #5a3410 !important;
  border: 1px dashed rgba(128, 60, 15, .55) !important;
}

/* =====================================================================
   PANELES LATERALES Y MEDALLON DE TURNO
   Copiados de la captura: medallon azul con borde dorado ("YOUR TURN"),
   panel "RULE VAR." con cajas de color por regla y panel "TRADE RULE"
   carmesi con el icono y "x1".
   ===================================================================== */

/* ---------- medallon YOUR TURN ---------- */
.tt-medallon {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .10em;
  line-height: 1.25;
  color: #12395c;
  background:
    radial-gradient(circle at 34% 28%, #cfe9ff 0%, #7cc0ee 34%, #2f7fc4 68%, #12395c 100%);
  border: 3px solid #e8c477;
  box-shadow:
    inset 0 0 10px rgba(255, 255, 255, .55),
    0 0 0 2px rgba(49, 2, 10, .55),
    0 4px 14px rgba(0, 0, 0, .45);
  animation: ttMedallon 1.9s ease-in-out infinite;
}
.tt-medallon[hidden] { display: none !important; }
@keyframes ttMedallon {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.045); }
}

/* ---------- escudo ---------- */
.tt-escudo {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  background: linear-gradient(180deg, #bfe6fb, #6fb4dd);
  border: 2px solid #e8c477;
  box-shadow: inset 0 0 8px rgba(255, 255, 255, .7), 0 3px 10px rgba(0, 0, 0, .4);
  position: relative;
}
.tt-escudo::after {
  content: "";
  position: absolute;
  inset: 26% 30% 18% 30%;
  background: #f4fbff;
  clip-path: polygon(50% 0%, 100% 22%, 100% 62%, 50% 100%, 0% 62%, 0% 22%);
}

/* ---------- columnas laterales ---------- */
.tt-col-lado {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-width: 92px;
}

/* ---------- paneles de reglas ---------- */
/* OJO: esto estaba como `.tt-panel` a secas y comprimia TODOS los
   paneles del sitio a 108 px (tutorial, tienda, perfil, ranking...).
   Solo debe aplicarse a los paneles de la columna del tablero. */
.tt-col-lado .tt-panel {
  width: 100%;
  max-width: 108px;
  font-family: Georgia, serif;
}
.tt-panel-cab {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .14em;
  text-align: center;
  color: #fde3c0;
  background: linear-gradient(180deg, #7a2a12, #45110a);
  border: 1px solid #e8c477;
  border-radius: 3px 3px 0 0;
  padding: 3px 2px;
  text-shadow: 0 1px 1px #000;
}
.tt-panel-cuerpo {
  background: rgba(49, 2, 10, .55);
  border: 1px solid rgba(232, 196, 119, .65);
  border-top: 0;
  border-radius: 0 0 3px 3px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 20px;
}
.tt-panel-var {
  font-size: 9px;
  letter-spacing: .08em;
  text-align: center;
  padding: 2px 1px;
  border-radius: 2px;
  color: #08202f;
  font-weight: 700;
  background: #7cc0ee;                 /* azul: la mayoria de las reglas */
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45);
}
/* colores por tipo, como en la captura */
.tt-panel-var[data-regla="plus"]     { background: #4f8fd6; color: #06192b; }
.tt-panel-var[data-regla="same"]     { background: #6fa8dc; color: #06192b; }
.tt-panel-var[data-regla="combo"]    { background: #8e7cc3; color: #10061f; }
.tt-panel-var[data-regla="swap"]     { background: #4ecdc4; color: #04211f; }
.tt-panel-var[data-regla="reverse"]  { background: #e06666; color: #2a0505; }
.tt-panel-var[data-regla="fallen_ace"] { background: #e69138; color: #2a1505; }
.tt-panel-var[data-regla="chaos"]    { background: #9c6ade; color: #150a26; }
.tt-panel-var[data-regla="order"]    { background: #f1c232; color: #2a2105; }
.tt-panel-var[data-regla="open"],
.tt-panel-var[data-regla="all_open"] { background: #93c47d; color: #0b2210; }
.tt-panel-var[data-regla="three_open"] { background: #76a5af; color: #04211f; }
.tt-panel-var[data-regla="sudden_death"] { background: #c27ba0; color: #2a0a19; }
.tt-panel-var[data-regla="random_hand"] { background: #b4a7d6; color: #150a26; }
.tt-panel-var[data-regla="none"]     { background: rgba(255, 248, 221, .30); color: #fde3c0; }

/* el panel de intercambio va en carmesi */
.tt-panel-trade .tt-panel-cab { background: linear-gradient(180deg, #a01d3c, #5d0f22); }
.tt-panel-trade .tt-panel-cuerpo { background: rgba(160, 29, 60, .55); }
.tt-panel-trade .tt-panel-var {
  background: #d94f6d;
  color: #2a0510;
}

/* en pantallas estrechas, los paneles pasan a una fila debajo */
@media (max-width: 760px) {
  .tt-zona { flex-wrap: wrap; }
  .tt-col-lado {
    flex-direction: row;
    min-width: 0;
    width: 100%;
    justify-content: center;
    gap: 8px;
  }
  .tt-medallon { width: 62px; height: 62px; font-size: 9px; }
  .tt-escudo { width: 42px; height: 42px; }
  .tt-col-lado .tt-panel { max-width: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  .tt-medallon { animation: none !important; }
}


/* =====================================================================
   MARCADOR CON FLORONES  (segun la captura real)
   ---------------------------------------------------------------------
   En el original el marcador es un numero BLANCO muy grande con un floron
   blanco encima y otro debajo (reflejado), y el nombre va en una banda
   marron oscuro con el borde derecho en diagonal sobre una linea dorada.

   El floron es un SVG en linea dibujado por mi: PROVISIONAL.
   ===================================================================== */

#tt-mesa .tt-marcador,
.tt-marcador {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 2px 4px 6px !important;
  align-items: center !important;
  gap: 10px !important;
}
/* se quitan los adornos del diseno anterior */
.tt-marcador::before,
.tt-marcador::after {
  content: none !important;
  display: none !important;
}

/* ---------- el numero: grande, blanco, con florones ---------- */
.tt-marcador .tt-lado-puntos {
  position: relative !important;
  display: block !important;
  font-family: Georgia, "Times New Roman", serif !important;
  font-size: 54px !important;
  font-weight: 700 !important;
  line-height: .92 !important;
  color: #fdf4dc !important;
  text-shadow:
    0 2px 0 #6b2a12,
    0 3px 6px rgba(0, 0, 0, .65) !important;
  letter-spacing: -1px !important;
  padding: 14px 0 !important;
  margin: 0 !important;
  order: 1;
}

/* floron encima */
.tt-marcador .tt-lado-puntos::before,
.tt-marcador .tt-lado-puntos::after {
  content: "" !important;
  display: block !important;
  position: absolute !important;
  left: 50% !important;
  width: 74px !important;
  height: 15px !important;
  transform: translateX(-50%) !important;
  background-repeat: no-repeat !important;
  background-size: contain !important;
  background-position: center !important;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)) !important;
  background-image: url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%20120%2020%27%3E%3Cpath%20d%3D%27M60%2019C44%2019%2030%2012%2010%201c14%209%2026%2014%2050%2015%2024-1%2036-6%2050-15C90%2012%2076%2019%2060%2019Z%27%20fill%3D%27%2523fdf4dc%27%2F%3E%3C%2Fsvg%3E") !important;
  pointer-events: none !important;
}
.tt-marcador .tt-lado-puntos::before { top: -2px !important; }
.tt-marcador .tt-lado-puntos::after  { bottom: -2px !important; transform: translateX(-50%) scaleY(-1) !important; }

/* ---------- el nombre: banda marron con corte diagonal ---------- */
.tt-marcador .tt-lado-nombre {
  position: relative !important;
  display: block !important;
  order: 2;
  font-family: Georgia, serif !important;
  font-size: 12px !important;
  letter-spacing: .06em !important;
  text-transform: none !important;
  color: #fdf4dc !important;
  background: linear-gradient(180deg, #3a1d10, #200d06) !important;
  border-top: 2px solid #e0b45e !important;
  padding: 3px 22px 3px 10px !important;
  clip-path: polygon(0 0, 100% 0, 88% 100%, 0 100%) !important;
  text-shadow: 0 1px 1px #000 !important;
  white-space: nowrap !important;
  max-width: 100% !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* el lado del rival, con el corte al reves */
.tt-marcador .tt-lado-rival .tt-lado-nombre {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 12% 100%) !important;
  padding: 3px 10px 3px 22px !important;
}

/* el bloque del lado no debe centrar el nombre */
.tt-marcador .tt-lado {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 0 !important;
  min-width: 0 !important;
}
.tt-marcador .tt-lado-rival {
  align-items: center !important;
  text-align: center !important;
}

/* ---------- el turno en el centro ---------- */
.tt-marcador .tt-turno {
  order: 2;
  font-family: Georgia, serif !important;
  font-size: 12px !important;
  letter-spacing: .10em !important;
  text-transform: uppercase !important;
  color: #fdf4dc !important;
  background: rgba(49, 2, 10, .55) !important;
  border: 1px solid rgba(232, 196, 119, .55) !important;
  border-radius: 3px !important;
  padding: 4px 10px !important;
  text-shadow: 0 1px 2px #000 !important;
}
.tt-marcador .tt-turno.rival {
  background: rgba(120, 22, 32, .65) !important;
  border-color: rgba(255, 150, 130, .65) !important;
}

/* en pantallas estrechas, numeros mas pequenos */
@media (max-width: 760px) {
  .tt-marcador .tt-lado-puntos { font-size: 38px !important; padding: 10px 0 !important; }
  .tt-marcador .tt-lado-puntos::before,
  .tt-marcador .tt-lado-puntos::after { width: 54px !important; height: 11px !important; }
  .tt-marcador .tt-lado-nombre { font-size: 10px !important; }
}


/* =====================================================================
   DISTINTIVO DE CARTA LIMITADA
   ---------------------------------------------------------------------
   La seccion 2 dice: "Ltd. tiene esquina azul (rosa hasta tener una copia)
   y Res. esquina multicolor". La captura real muestra un "RES." verde en
   la esquina inferior derecha de la carta.
   ===================================================================== */
.tt-cara .tt-limitada {
  position: absolute !important;
  right: 4% !important;
  bottom: 17% !important;
  z-index: 6 !important;
  font-family: Georgia, "Times New Roman", serif !important;
  font-size: 7px !important;
  font-weight: 700 !important;
  letter-spacing: .06em !important;
  line-height: 1 !important;
  padding: 2px 3px !important;
  border-radius: 2px !important;
  color: #fff !important;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .85) !important;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .45),
    0 1px 3px rgba(0, 0, 0, .6) !important;
  pointer-events: none !important;
}

/* Ltd.: esquina azul */
.tt-cara .tt-limitada-ltd {
  background: linear-gradient(150deg, #6fb4dd, #1f5f8f) !important;
  border: 1px solid #bfe6fb !important;
}

/* Res.: esquina multicolor */
.tt-cara .tt-limitada-res {
  background: linear-gradient(150deg, #7ad16a 0%, #f2d94a 34%, #f28b3a 62%, #c85fd4 100%) !important;
  border: 1px solid #fff0b8 !important;
  color: #12220c !important;
  text-shadow: 0 1px 1px rgba(255, 255, 255, .55) !important;
}

/* en la mano y en coleccion, algo mas grande para que se lea */
.tt-mano .tt-cara .tt-limitada,
.tt-coleccion .tt-cara .tt-limitada {
  font-size: 8px !important;
  padding: 2px 4px !important;
}


/* =====================================================================
   BOTIN: cartas que no se pueden reclamar
   ---------------------------------------------------------------------
   Seccion 2: "Ltd.: el ganador solo puede reclamarla si ya tiene una copia
   (si no, aparece oscurecida). Res.: nunca reclamable."
   El servidor decide; aqui solo se oscurece y se explica por que.
   ===================================================================== */
.tt-botin-op.no-puede {
  opacity: .45 !important;
  filter: grayscale(.85) brightness(.65) !important;
  cursor: not-allowed !important;
  position: relative !important;
}
.tt-botin-op.no-puede::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg, rgba(0, 0, 0, .22) 0 6px, rgba(0, 0, 0, 0) 6px 12px);
  border-radius: inherit;
  pointer-events: none;
}
.tt-botin-no {
  display: block !important;
  font-size: 9px !important;
  font-style: normal !important;
  letter-spacing: .02em !important;
  color: #ffb4a2 !important;
  text-shadow: 0 1px 1px #000 !important;
  margin-top: 2px !important;
}
.tt-botin-si {
  display: block !important;
  font-size: 9px !important;
  font-style: normal !important;
  color: #a8e0a0 !important;
  text-shadow: 0 1px 1px #000 !important;
  margin-top: 2px !important;
}


/* =====================================================================
   GRUPOS DE REGLAS ELEGIBLES
   ---------------------------------------------------------------------
   Solo se ensenan en versus: en individual las reglas las pone el rival y no
   se pueden cambiar (seccion 2). Se separan las de Portal App de las de
   FFXIV para no presentar como del juego original algo que no lo es.
   ===================================================================== */
/* Cada grupo de reglas va en SU PROPIA FILA, debajo de los botones.
   Antes usaba `display: contents`, y eso metia las once casillas en la misma
   linea que los botones: se veia desparramado en el PC. */
.tt-reglas-elegibles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  width: 100%;
  justify-content: center;
  padding-top: 8px;
  border-top: 1px solid rgba(232, 196, 119, .18);
}
.tt-reglas-elegibles[hidden] {
  display: none !important;
}
.tt-reglas-tit {
  display: block;
  width: 100%;
  font-family: Georgia, serif;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #f0d9a8;
  opacity: .85;
  margin: 6px 0 2px;
}
.tt-reglas-ffxiv .tt-reglas-tit {
  color: #c9b3f0;
}
.tt-reglas-ffxiv .tt-check {
  opacity: .8;
}


/* =====================================================================
   REJILLA DE LA ZONA DE JUEGO
   ---------------------------------------------------------------------
   .tt-zona venia de tt.css como flex en COLUMNA:

       display: flex; flex-direction: column;

   Al anadir las dos columnas laterales (medallon y paneles), se apilaban
   ENCIMA y DEBAJO del tablero en vez de a los lados. Eso es lo que hacia que
   la pantalla se viera rara en el PC.

   Ahora es una rejilla:

       rival  rival  rival
       izq    tablero der
       mano   mano   mano
   ===================================================================== */
@media (min-width: 761px) {
  .tt-zona {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) auto !important;
    grid-template-areas:
      "rival rival rival"
      "izq   tablero der"
      "mano  mano  mano" !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-items: center !important;
    gap: 10px 14px !important;
  }
  .tt-zona > .tt-mano:first-child { grid-area: rival !important; }
  .tt-zona > .tt-mano:last-child  { grid-area: mano !important; }
  .tt-zona > .tt-tablero {
    grid-area: tablero !important;
    max-width: 100% !important;
    width: 100% !important;
    justify-self: stretch !important;
  }
  .tt-zona > .tt-col-lado:nth-of-type(1) { grid-area: izq !important; }
  .tt-zona > .tt-col-lado:nth-of-type(2) { grid-area: der !important; }
  .tt-zona > .tt-col-lado { justify-self: center !important; }
}

/* en pantalla estrecha se sigue apilando en columna, como antes */
@media (max-width: 760px) {
  .tt-zona {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 12px !important;
  }
}


/* =====================================================================
   PANEL DE DIFICULTAD CON PARTIDA EN MARCHA
   ---------------------------------------------------------------------
   El boton "Volver" vive DENTRO de este panel, asi que no se puede ocultar
   el panel entero: te quedarias atrapado en la partida. Lo que se hace es
   quitarle el aspecto de cajon y dejar solo el boton a la vista.
   ===================================================================== */
.tt-dificultad.tt-jugando {
  background: none !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  min-height: 0 !important;
}
.tt-dificultad.tt-jugando .tt-dif-pie {
  border-top: 0 !important;
  padding-top: 4px !important;
}


/* =====================================================================
   MANOS EN COLUMNA (APAISADO) - como el juego real
   ---------------------------------------------------------------------
   Referencia: docs/triple-triad/referencias/tablero-real-apaisado.png
   En el juego real, con la pantalla apaisada, las manos van en COLUMNAS
   verticales a los lados: yo a la izquierda, el rival a la derecha, y el
   tablero en el centro. En vertical van en filas, arriba y abajo.

   En el proyecto estaban SIEMPRE en fila, tambien en el PC, y por eso el
   tablero quedaba apretado y la pantalla se veia mal.
   ===================================================================== */
@media (min-width: 1000px) {
  .tt-zona {
    grid-template-columns: auto auto minmax(0, 1fr) auto auto !important;
    grid-template-areas: "rival izq tablero der mano" !important;
    align-items: center !important;
    justify-items: center !important;
    gap: 6px 10px !important;
  }
  .tt-zona > .tt-mano {
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 0 !important;
    gap: 4px !important;
  }
  .tt-zona > .tt-mano .tt-carta {
    width: 74px !important;
  }
  .tt-zona > .tt-mano-rival .tt-carta {
    width: 62px !important;
  }
  /* el tablero manda: que no se estire ni se encoja de mas */
  .tt-zona > .tt-tablero {
    max-width: min(58vw, 560px) !important;
    width: auto !important;
    justify-self: center !important;
  }
  /* las columnas laterales, mas estrechas */
  .tt-zona > .tt-col-lado {
    max-width: 110px !important;
  }
}

/* pantallas muy anchas: un poco mas de holgura */
@media (min-width: 1500px) {
  .tt-zona > .tt-mano .tt-carta { width: 86px !important; }
  .tt-zona > .tt-mano-rival .tt-carta { width: 72px !important; }
  .tt-zona > .tt-tablero { max-width: min(52vw, 620px) !important; }
}


/* =====================================================================
   RED DE SEGURIDAD DE MAQUETACION
   ---------------------------------------------------------------------
   No he podido ver la pagina renderizada (no hay navegador en el equipo),
   asi que esto es una red de seguridad contra las dos causas mas comunes de
   "se alarga y se ve mal" en todas las pantallas a la vez:

     1. un hijo mas ancho que su contenedor -> barra horizontal y todo
        desplazado
     2. contenedores flex/grid que no encogen porque su contenido no tiene
        min-width: 0

   Los contenedores de nivel superior ya tienen max-width (1240px en
   .tt-contenido, 1180px en .tt-main), pero eso no impide que un hijo se
   salga. Esto lo impide.

   NO oculta sintomas: overflow-x:hidden en el body solo actua si algo se
   sale, y los contenedores con min-width:0 permiten que el contenido
   encoja de verdad en vez de empujar.
   ===================================================================== */
html, body {
  overflow-x: hidden;
}
/* OJO: aqui NO se pone max-width.
   Lo puse como `max-width: 100%` y eso PISA el `max-width: 1240px` de
   .tt-contenido, porque este fichero se carga el ultimo y tiene la misma
   especificidad. Resultado: toda la pagina se estiraba al ancho del monitor.
   Solo se deja min-width: 0, que permite encoger sin tocar el ancho maximo. */
.tt-contenido,
.tt-main,
.tt-principal,
.tt-vista {
  min-width: 0;
  box-sizing: border-box;
}
/* imagenes, tablas y bloques preformateados nunca deben mandar sobre el ancho */
.tt-vista img,
.tt-vista table,
.tt-vista pre {
  max-width: 100%;
}
/* Las tablas NO se tocan.
   Aqui puse `display: block` para que una tabla ancha se pudiera desplazar, y
   eso DESTROZA el alineado de columnas: las tablas del ranking, del libro
   mayor y del perfil se generan por JS con la clase .tt-tabla y habrian
   quedado con las columnas descolocadas.
   Para las tablas anchas está .tt-tabla-caja, que ya tiene overflow propio. */
.tt-tabla-caja {
  overflow-x: auto;
}


/* =====================================================================
   CLASES DEL HTML QUE NO TENIAN NINGUN ESTILO
   ---------------------------------------------------------------------
   Una auditoria de las 94 clases del HTML encontro cuatro sin ninguna regla:
   tt-bot-gratis, tt-lado-yo, tt-modos y tt-roulette. Un elemento sin estilo
   hereda lo del navegador y desentona. Se les da lo minimo.
   ===================================================================== */
.tt-bot-gratis {
  display: block;
  width: 100%;
  margin-top: 4px;
}
.tt-modos {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 18px;
}
.tt-roulette {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--tt-humo, #cfc6b0);
  margin-top: 8px;
}
.tt-lado-yo {
  display: block;
  margin-top: 4px;
}


/* =====================================================================
   CASILLAS CON ADORNOS EN LAS ESQUINAS
   ---------------------------------------------------------------------
   Referencia: referencias/review-hq2.jpg (partida real).
   En el juego las casillas NO llevan borde continuo: llevan ADORNOS rojo
   oscuro en las cuatro esquinas, como corchetes. Es lo que da el aire de
   tablero. Ahora habia un borde completo.

   Se hace con cuatro degradados de fondo, uno por esquina, sin tocar el HTML
   ni anadir elementos. Todo va acotado a #tt-mesa .tt-tablero .tt-casilla
   para no afectar a ningun otro sitio.
   ===================================================================== */
#tt-mesa .tt-tablero .tt-casilla {
  border: 0 !important;
  border-radius: 2px !important;
  background-color: rgba(255, 248, 221, .04) !important;
  background-image:
    /* esquina superior izquierda: dos trazos en L */
    linear-gradient(90deg, #7c1d10 0 3px, transparent 3px),
    linear-gradient(180deg, #7c1d10 0 3px, transparent 3px),
    /* esquina superior derecha */
    linear-gradient(270deg, #7c1d10 0 3px, transparent 3px),
    linear-gradient(180deg, #7c1d10 0 3px, transparent 3px),
    /* esquina inferior izquierda */
    linear-gradient(90deg, #7c1d10 0 3px, transparent 3px),
    linear-gradient(0deg, #7c1d10 0 3px, transparent 3px),
    /* esquina inferior derecha */
    linear-gradient(270deg, #7c1d10 0 3px, transparent 3px),
    linear-gradient(0deg, #7c1d10 0 3px, transparent 3px) !important;
  background-repeat: no-repeat !important;
  background-size:
    18px 3px, 3px 18px,
    18px 3px, 3px 18px,
    18px 3px, 3px 18px,
    18px 3px, 3px 18px !important;
  background-position:
    top left, top left,
    top right, top right,
    bottom left, bottom left,
    bottom right, bottom right !important;
}

/* la carta entra un poco hacia dentro para que se vean los adornos */
#tt-mesa .tt-tablero .tt-casilla .tt-carta {
  width: 92% !important;
  margin: 4% auto !important;
}

/* CASILLA JUGABLE: un latido tenue al pasar por encima, sin cambiar el tamano */
#tt-mesa .tt-tablero .tt-casilla.jugable {
  outline: 1px solid rgba(124, 29, 16, .55);
  outline-offset: -1px;
  cursor: pointer;
}
#tt-mesa .tt-tablero .tt-casilla.jugable:hover {
  background-color: rgba(255, 233, 170, .16) !important;
}


/* =====================================================================
   EL ATRIBUTO hidden TIENE QUE MANDAR
   ---------------------------------------------------------------------
   #tt-mesa lleva `hidden` en el HTML, pero el tablero se veia igual: una
   regla de display con mas especificidad gana sobre el atributo hidden del
   navegador. Es el fallo clasico: `hidden` solo aplica `display:none` con la
   especificidad de la hoja del navegador.

   Con esto, cualquier elemento con hidden desaparece de verdad.
   ===================================================================== */
[hidden] {
  display: none !important;
}


/* =====================================================================
   RIVAL SELECCIONADO
   ---------------------------------------------------------------------
   Al pulsar un rival se le pone la clase `activo`, pero NINGUN CSS la
   pintaba: parecia que no se quedaba marcado. Solo existia .tt-rival:hover.
   Esto tiene que verse mucho mas que el hover, para saber cual esta elegido.
   ===================================================================== */
.tt-rival.activo {
  border-color: #e8c477 !important;
  background: linear-gradient(180deg, rgba(201, 162, 39, .22), rgba(201, 162, 39, .06)) !important;
  box-shadow: 0 0 0 1px #e8c477, 0 0 14px rgba(232, 196, 119, .45) !important;
  transform: translateY(-2px) !important;
}
.tt-rival.activo span {
  color: #ffe9a8 !important;
  font-weight: 700 !important;
}
.tt-rival.activo img {
  border-color: #e8c477 !important;
}
/* una marca de "elegido" en la esquina, para que no haya duda */
.tt-rival.activo::after {
  content: '\2713';
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 13px;
  font-weight: 700;
  color: #ffe9a8;
  text-shadow: 0 1px 3px #000;
}
.tt-rival {
  position: relative;
}


/* =====================================================================
   BARRA DE VUELTA (dentro de la mesa)
   ---------------------------------------------------------------------
   El boton "Volver a elegir rival" vivia DENTRO del panel de seleccion, y por
   eso no se podia ocultar el panel entero al empezar la partida. Ahora vive
   arriba de la mesa, discreto.
   ===================================================================== */
.tt-barra-vuelta {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  padding: 0 4px 6px;
}
.tt-barra-vuelta .tt-btn {
  font-size: 11px;
  padding: 5px 12px;
  letter-spacing: .08em;
}


/* =====================================================================
   EL BOTIN TIENE QUE IR POR ENCIMA DE LA ESCENA FINAL
   ---------------------------------------------------------------------
   #tt-final es una capa fija a pantalla completa con z-index 260 y un velo
   opaco. #tt-botin NO tenia ni position ni z-index: abria a los 1900 ms
   DEBAJO del velo, asi que la recompensa se abria y no se veia nunca.

   Ahora el botin es una capa fija por encima (z-index 300) y con su propio
   fondo oscurecido.
   ===================================================================== */
#tt-botin {
  position: fixed !important;
  inset: 0 !important;
  z-index: 300 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
  background: radial-gradient(circle at 50% 45%, rgba(8, 10, 14, .78), rgba(4, 6, 9, .94)) !important;
  backdrop-filter: blur(3px);
  overflow-y: auto !important;
}
#tt-botin[hidden] {
  display: none !important;
}
#tt-botin > * {
  max-width: 560px;
  width: 100%;
}


/* =====================================================================
   DAMERO Y EMBLEMA DEL TABLERO
   ---------------------------------------------------------------------
   [VISTO EN CAPTURA] En las imagenes de referencia el tablero NO es una
   cuadricula plana:
     - las casillas alternan GRANATE OSCURO y PERGAMINO CLARO, a modo de
       damero
     - detras hay un GRAN EMBLEMA CIRCULAR DORADO difuminado
     - y en el centro, el logotipo "Triple Triad" en caligrafia granate

   Todo acotado a #tt-mesa .tt-tablero para no tocar nada mas.
   ===================================================================== */
#tt-mesa .tt-tablero {
  position: relative !important;
  background-color: #f3e0b6 !important;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(214, 168, 62, .55) 0%, rgba(214, 168, 62, .22) 38%, rgba(243, 224, 182, 0) 62%) !important;
  border: 0 !important;
  border-radius: 6px !important;
  box-shadow:
    0 0 0 3px #8c5a1e,
    0 0 0 5px #d6a83e,
    0 10px 30px rgba(0, 0, 0, .55) !important;
  padding: 8px !important;
}

/* el emblema circular dorado, detras de todo */
#tt-mesa .tt-tablero::before {
  content: '';
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%,
      rgba(255, 241, 200, .95) 0%,
      rgba(246, 214, 140, .80) 30%,
      rgba(214, 168, 62, .55) 55%,
      rgba(214, 168, 62, 0) 72%);
  pointer-events: none;
  z-index: 0;
}

/* marca de agua "Triple Triad" en el centro */
#tt-mesa .tt-tablero::after {
  content: 'Triple Triad';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-size: clamp(18px, 3.2vw, 40px);
  letter-spacing: .01em;
  color: rgba(122, 26, 20, .55);
  text-shadow: 0 1px 0 rgba(255, 245, 214, .6);
  pointer-events: none;
  z-index: 1;
}

/* las casillas van por encima del emblema y del texto */
#tt-mesa .tt-tablero .tt-casilla {
  position: relative !important;
  z-index: 2 !important;
  border-radius: 2px !important;
}

/* DAMERO: granate y pergamino alternos, como en las capturas */
#tt-mesa .tt-tablero .tt-casilla:nth-child(1),
#tt-mesa .tt-tablero .tt-casilla:nth-child(3),
#tt-mesa .tt-tablero .tt-casilla:nth-child(5),
#tt-mesa .tt-tablero .tt-casilla:nth-child(7),
#tt-mesa .tt-tablero .tt-casilla:nth-child(9) {
  background-color: rgba(122, 26, 20, .16) !important;
}
#tt-mesa .tt-tablero .tt-casilla:nth-child(2),
#tt-mesa .tt-tablero .tt-casilla:nth-child(4),
#tt-mesa .tt-tablero .tt-casilla:nth-child(6),
#tt-mesa .tt-tablero .tt-casilla:nth-child(8) {
  background-color: rgba(255, 248, 221, .30) !important;
}

/* y una linea dorada fina entre casillas, no un borde grueso */
#tt-mesa .tt-tablero .tt-casilla {
  box-shadow: inset 0 0 0 1px rgba(140, 90, 30, .35) !important;
}


/* =====================================================================
   SPLASH DE TITULO  (punto 1 del objetivo)
   ---------------------------------------------------------------------
   [VISTO EN CAPTURA] La pantalla de entrada del juego original: pergamino
   con manchas, emblema circular ornamental dorado, motivo floral radial y
   el texto "Triple Triad" en caligrafia oscura.

   Todo dibujado con CSS propio (degradados radiales y bordes), sin usar
   ninguna imagen de Square Enix.
   ===================================================================== */
#tt-splash {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background:
    radial-gradient(circle at 50% 46%, #fdf3d6 0%, #f3e0b6 34%, #e0c48d 62%, #b9905a 88%, #7d5a30 100%);
  cursor: pointer;
  transition: opacity .55s ease, visibility .55s ease;
  overflow: hidden;
}
#tt-splash.tt-fuera {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
/* el emblema circular */
.tt-splash-emblema {
  position: relative;
  width: min(58vmin, 340px);
  height: min(58vmin, 340px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 50%,
      rgba(255, 246, 214, .95) 0%,
      rgba(246, 220, 150, .72) 42%,
      rgba(214, 168, 62, .38) 66%,
      rgba(214, 168, 62, 0) 78%);
  box-shadow:
    0 0 0 2px rgba(140, 90, 30, .45),
    0 0 0 10px rgba(214, 168, 62, .22),
    0 0 0 12px rgba(140, 90, 30, .30);
  animation: ttSplashEntra .9s cubic-bezier(.2, .8, .3, 1) both;
}
/* motivos radiales florales */
.tt-splash-emblema::before,
.tt-splash-emblema::after {
  content: '';
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background:
    conic-gradient(from 0deg,
      rgba(140, 90, 30, .35) 0deg 6deg, transparent 6deg 30deg,
      rgba(140, 90, 30, .35) 30deg 36deg, transparent 36deg 60deg,
      rgba(140, 90, 30, .35) 60deg 66deg, transparent 66deg 90deg,
      rgba(140, 90, 30, .35) 90deg 96deg, transparent 96deg 120deg,
      rgba(140, 90, 30, .35) 120deg 126deg, transparent 126deg 150deg,
      rgba(140, 90, 30, .35) 150deg 156deg, transparent 156deg 180deg,
      rgba(140, 90, 30, .35) 180deg 186deg, transparent 186deg 210deg,
      rgba(140, 90, 30, .35) 210deg 216deg, transparent 216deg 240deg,
      rgba(140, 90, 30, .35) 240deg 246deg, transparent 246deg 270deg,
      rgba(140, 90, 30, .35) 270deg 276deg, transparent 276deg 300deg,
      rgba(140, 90, 30, .35) 300deg 306deg, transparent 306deg 330deg,
      rgba(140, 90, 30, .35) 330deg 336deg, transparent 336deg 360deg);
  mask-image: radial-gradient(circle, transparent 52%, #000 56%, #000 92%, transparent 96%);
  -webkit-mask-image: radial-gradient(circle, transparent 52%, #000 56%, #000 92%, transparent 96%);
}
.tt-splash-emblema::after {
  inset: 20%;
  animation: ttSplashGira 46s linear infinite;
}
/* el titulo */
.tt-splash-titulo {
  position: relative;
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-weight: 700;
  font-size: clamp(30px, 7.2vmin, 64px);
  letter-spacing: .01em;
  color: #6d1a13;
  text-shadow:
    0 1px 0 rgba(255, 246, 214, .9),
    0 2px 6px rgba(90, 50, 20, .35);
  z-index: 2;
}
.tt-splash-sub {
  position: relative;
  margin: 0;
  font-family: Georgia, serif;
  font-size: clamp(10px, 1.6vmin, 13px);
  letter-spacing: .32em;
  text-transform: uppercase;
  color: rgba(109, 26, 19, .75);
  z-index: 2;
}
.tt-splash-pie {
  position: absolute;
  bottom: 26px;
  font-family: Georgia, serif;
  font-size: 11px;
  letter-spacing: .18em;
  color: rgba(80, 48, 20, .65);
  z-index: 2;
}
/* la linea dorada a los lados del titulo, como en la portada */
.tt-splash-titulo::before,
.tt-splash-titulo::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 16vmin;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(140, 90, 30, .8));
}
.tt-splash-titulo::before { right: calc(100% + 1.4vmin); }
.tt-splash-titulo::after {
  left: calc(100% + 1.4vmin);
  background: linear-gradient(270deg, transparent, rgba(140, 90, 30, .8));
}
@keyframes ttSplashEntra {
  from { transform: scale(.86); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
@keyframes ttSplashGira {
  to { transform: rotate(360deg); }
}
/* si el usuario pide menos animaciones, el splash no gira ni escala */
@media (prefers-reduced-motion: reduce) {
  .tt-splash-emblema { animation: none; }
  .tt-splash-emblema::after { animation: none; }
  #tt-splash { transition: none; }
}


/* =====================================================================
   BORDE DE CARTA POR RAREZA
   ---------------------------------------------------------------------
   [VISTO EN CAPTURA] El borde de la carta cambia con las estrellas:
     1 estrella  gris oscuro
     2 estrellas gris hierro
     3 estrellas bronce
     4 estrellas plata azulada
     5 estrellas oro
   Se aplica con el atributo data-nivel que pone tt.js al pintar la carta.
   ===================================================================== */
.tt-carta[data-nivel="1"] { box-shadow: 0 0 0 2px #4a4a4a, 0 2px 6px rgba(0,0,0,.5) !important; }
.tt-carta[data-nivel="2"] { box-shadow: 0 0 0 2px #7c7c84, 0 2px 7px rgba(0,0,0,.5) !important; }
.tt-carta[data-nivel="3"] { box-shadow: 0 0 0 2px #a8703c, 0 2px 8px rgba(0,0,0,.55) !important; }
.tt-carta[data-nivel="4"] { box-shadow: 0 0 0 2px #9fb6cf, 0 0 10px rgba(159,182,207,.45) !important; }
.tt-carta[data-nivel="5"] { box-shadow: 0 0 0 2px #e8c477, 0 0 14px rgba(232,196,119,.60) !important; }


/* =====================================================================
   EFECTOS DE SELECCION E IMPACTO
   ---------------------------------------------------------------------
   Todo con CSS: transformaciones y filtros, sin imagenes. Respeta
   prefers-reduced-motion al final del bloque.
   ===================================================================== */

/* ---------- SELECCION: la carta se levanta, brilla y palpita ---------- */
#tt-mesa .tt-mano .tt-carta {
  transition: transform .16s cubic-bezier(.2, .9, .3, 1),
              box-shadow .16s ease, filter .16s ease;
}
#tt-mesa .tt-mano .tt-carta:hover {
  transform: translateY(-10px) scale(1.06) rotate(-1deg);
  filter: brightness(1.12);
  z-index: 5;
}
#tt-mesa .tt-mano .tt-carta.elegida {
  transform: translateY(-16px) scale(1.12) rotate(0deg);
  filter: brightness(1.2) saturate(1.15);
  box-shadow:
    0 0 0 2px #ffe9a8,
    0 0 18px 4px rgba(255, 233, 168, .75),
    0 12px 26px rgba(0, 0, 0, .55) !important;
  /* animacion infinita retirada */
  z-index: 6;
}
@keyframes ttPalpita {
  0%, 100% { box-shadow: 0 0 0 2px #ffe9a8, 0 0 16px 3px rgba(255,233,168,.65), 0 12px 26px rgba(0,0,0,.55); }
  50%      { box-shadow: 0 0 0 3px #fff3c9, 0 0 26px 8px rgba(255,233,168,.95), 0 14px 30px rgba(0,0,0,.6); }
}

/* un brillo que recorre la carta elegida */
#tt-mesa .tt-mano .tt-carta.elegida .tt-cara::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: linear-gradient(115deg,
    transparent 30%, rgba(255,255,255,.55) 45%, transparent 60%);
  background-size: 250% 100%;
  animation: ttBrillo 1.6s linear 1;
  pointer-events: none;
  mix-blend-mode: screen;
}
@keyframes ttBrillo {
  from { background-position: 180% 0; }
  to   { background-position: -80% 0; }
}

/* ---------- IMPACTO al colocar: la casilla late ---------- */
#tt-mesa .tt-tablero .tt-casilla.recien-puesta {
  animation: ttImpacto .42s cubic-bezier(.15, .9, .25, 1) both;
}
@keyframes ttImpacto {
  0%   { transform: scale(.86); filter: brightness(2.2); }
  45%  { transform: scale(1.08); filter: brightness(1.35); }
  100% { transform: scale(1);    filter: brightness(1); }
}


/* destello rojo/azul en la casilla capturada */
#tt-mesa .tt-tablero .tt-casilla.destello-captura::after {
  content: '';
  position: absolute;
  inset: -12%;
  border-radius: 50%;
  pointer-events: none;
  animation: ttDestello .5s ease-out both;
  background: radial-gradient(circle, rgba(255,255,255,.95) 0%, rgba(255,214,120,.55) 40%, transparent 70%);
}
@keyframes ttDestello {
  0%   { opacity: 0;   transform: scale(.4); }
  30%  { opacity: 1;   transform: scale(1.1); }
  100% { opacity: 0;   transform: scale(1.5); }
}

/* ---------- respeto a quien pide menos animaciones ---------- */
@media (prefers-reduced-motion: reduce) {
  #tt-mesa .tt-mano .tt-carta,
  #tt-mesa .tt-mano .tt-carta.elegida,
  #tt-mesa .tt-tablero .tt-casilla.recien-puesta,
  #tt-mesa .tt-tablero .tt-casilla.destello-captura::after {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}


/* =====================================================================
   EFECTOS 3D PROFUNDOS
   ---------------------------------------------------------------------
   Aqui el tablero y las cartas viven en el MISMO espacio 3D:
     - perspective en el tablero  -> los giros tienen profundidad real
     - preserve-3d en la carta    -> el volteo no se aplana
     - translateZ                 -> la carta se acerca al colocarse
   Todo con CSS. Respeta prefers-reduced-motion al final.
   ===================================================================== */
#tt-mesa .tt-tablero {
  perspective: 1100px;
  perspective-origin: 50% 45%;
}
#tt-mesa .tt-tablero .tt-casilla {
  transform-style: preserve-3d;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta {
  transform-style: preserve-3d;
  backface-visibility: visible;
  will-change: transform, filter;
}

/* ---------- SELECCION en 3D: se levanta hacia el jugador ---------- */
#tt-mesa .tt-mano {
  perspective: 800px;
}
#tt-mesa .tt-mano .tt-carta {
  transition: transform .18s cubic-bezier(.2, .9, .3, 1),
              box-shadow .18s ease, filter .18s ease;
}
#tt-mesa .tt-mano .tt-carta:hover {
  transform: translateY(-8px) translateZ(40px) rotateX(8deg) scale(1.05);
  filter: brightness(1.15);
  box-shadow: 0 18px 30px rgba(0, 0, 0, .6) !important;
}
#tt-mesa .tt-mano .tt-carta.elegida {
  transform: translateY(-14px) translateZ(70px) rotateX(10deg) scale(1.10);
  filter: brightness(1.22) saturate(1.18);
  /* SIN ANIMACION INFINITA: la carta elegida se queda quieta con su halo.
     Antes latia para siempre y, junto al transform en linea del JS, producia
     un bucle visual y desincronizado. */
}
@keyframes ttPalpita3D {
  0%, 100% {
    box-shadow: 0 0 0 2px #ffe9a8, 0 0 18px 4px rgba(255,233,168,.65),
                0 22px 34px rgba(0,0,0,.62);
  }
  50% {
    box-shadow: 0 0 0 3px #fff3c9, 0 0 30px 10px rgba(255,233,168,.95),
                0 26px 40px rgba(0,0,0,.68);
  }
}

/* ---------- COLOCACION: la carta cae desde arriba con giro ---------- */
#tt-mesa .tt-tablero .tt-casilla.recien-puesta {
  animation: ttImpacto3D .5s cubic-bezier(.16, .9, .24, 1) both;
}
@keyframes ttImpacto3D {
  0%   { transform: translateZ(160px) rotateX(-32deg) scale(1.35); filter: brightness(2.4) blur(1px); }
  55%  { transform: translateZ(18px)  rotateX(6deg)   scale(1.04); filter: brightness(1.35) blur(0); }
  78%  { transform: translateZ(-6px)  rotateX(-2deg)  scale(.98);  filter: brightness(1.1); }
  100% { transform: translateZ(0)     rotateX(0)      scale(1);    filter: brightness(1); }
}


/* ---------- DESTELLO de captura: onda que se expande en 3D ---------- */
#tt-mesa .tt-tablero .tt-casilla.destello-captura::after {
  content: '';
  position: absolute;
  inset: -20%;
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
  animation: ttOnda .62s cubic-bezier(.2, .8, .3, 1) both;
  background:
    radial-gradient(circle,
      rgba(255,255,255,.98) 0%,
      rgba(255,226,140,.75) 32%,
      rgba(255,160,90,.35) 55%,
      transparent 74%);
}
@keyframes ttOnda {
  0%   { opacity: 0;   transform: scale(.25) translateZ(0); }
  25%  { opacity: 1;   transform: scale(1.05) translateZ(30px); }
  100% { opacity: 0;   transform: scale(1.7) translateZ(90px); }
}

/* ---------- un segundo destello, mas rapido, en cruz ---------- */
#tt-mesa .tt-tablero .tt-casilla.destello-captura::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  animation: ttCruz .34s ease-out both;
  background:
    linear-gradient(90deg, transparent 46%, rgba(255,255,255,.95) 50%, transparent 54%),
    linear-gradient(0deg,  transparent 46%, rgba(255,255,255,.95) 50%, transparent 54%);
}
@keyframes ttCruz {
  0%   { opacity: 0; transform: scale(.6); }
  30%  { opacity: 1; transform: scale(1.1); }
  100% { opacity: 0; transform: scale(1.35); }
}

/* ---------- el turno cambia: la mano late suavemente ---------- */
#tt-mesa .tt-mano.mano-activa .tt-carta {
  /* ttManoLate retirada: la mano latia para siempre y peleaba con el
     hover y la elevacion de la carta seleccionada. */
}
@keyframes ttManoLate {
  0%, 100% { transform: translateZ(0); }
  50%      { transform: translateZ(10px); }
}

@media (prefers-reduced-motion: reduce) {
  #tt-mesa .tt-tablero { perspective: none; }
  #tt-mesa .tt-mano .tt-carta,
  #tt-mesa .tt-mano .tt-carta:hover,
  #tt-mesa .tt-mano .tt-carta.elegida,
  #tt-mesa .tt-tablero .tt-casilla.recien-puesta,
  #tt-mesa .tt-tablero .tt-casilla.destello-captura::after,
  #tt-mesa .tt-tablero .tt-casilla.destello-captura::before,
  #tt-mesa .tt-mano.mano-activa .tt-carta {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    filter: none !important;
  }
}


/* =====================================================================
   3D VISIBLE: sin overflow ni filter en el elemento que gira
   ---------------------------------------------------------------------
   POR QUE NO SE VEIA EL GIRO:
     1) .tt-carta tiene `overflow: hidden`, y eso APLANA cualquier rotateY.
        El navegador no puede mostrar profundidad de un elemento recortado.
     2) Yo ponia `filter` (brillo, saturacion) en el MISMO elemento que gira.
        Un filtro crea un contexto nuevo y tambien aplana el 3D.

   Arreglo: la CAJA gira (sin overflow ni filtro) y el COLOR cambia en la
   capa interior .tt-cara, que es la que lleva el dibujo.
   ===================================================================== */
#tt-mesa .tt-tablero .tt-casilla {
  overflow: visible !important;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta {
  overflow: visible !important;
}
/* durante el giro, el marco tampoco recorta */
#tt-mesa .tt-tablero .tt-casilla .tt-carta.recien-capturada,
#tt-mesa .tt-tablero .tt-casilla .tt-carta.recibida {
  overflow: visible !important;
  filter: none !important;
}

/* y el brillo va en la capa del dibujo */
#tt-mesa .tt-tablero .tt-casilla .tt-carta.recien-capturada .tt-cara {
  animation: ttGiroColor .85s ease-in-out both;
}
@keyframes ttGiroColor {
  0%   { filter: brightness(1) saturate(1); }
  22%  { filter: brightness(2.6) saturate(1.8); }
  50%  { filter: brightness(3.2) saturate(.15) hue-rotate(20deg); }
  78%  { filter: brightness(1.5) saturate(1.3); }
  100% { filter: brightness(1) saturate(1); }
}

/* ---------- CAIDA: igual, sin filtro en la caja ---------- */
#tt-mesa .tt-tablero .tt-casilla.recien-puesta {
  animation: ttCaeCaja .52s cubic-bezier(.16, .9, .24, 1) both;
}
@keyframes ttCaeCaja {
  0%   { transform: translateZ(190px) rotateX(-38deg) scale(1.4); }
  58%  { transform: translateZ(16px)  rotateX(7deg)   scale(1.05); }
  80%  { transform: translateZ(-8px)  rotateX(-2deg)  scale(.98); }
  100% { transform: translateZ(0)     rotateX(0)      scale(1); }
}
#tt-mesa .tt-tablero .tt-casilla.recien-puesta .tt-carta .tt-cara {
  animation: ttCaeColor .52s ease-out both;
}
@keyframes ttCaeColor {
  0%   { filter: brightness(2.6); }
  100% { filter: brightness(1); }
}

@media (prefers-reduced-motion: reduce) {
  #tt-mesa .tt-tablero .tt-casilla,
  #tt-mesa .tt-tablero .tt-casilla .tt-carta:not(.recien-capturada),
  #tt-mesa .tt-tablero .tt-casilla .tt-carta .tt-cara {
    animation: none !important;
    transform: none !important;
    filter: none !important;
  }
}


/* =====================================================================
   CHIP DE MUSICA DEL MENU
   ---------------------------------------------------------------------
   Una casilla pequenita, arriba a la derecha de la pantalla de menu.
   Marcada = silencio. Desmarcada = suena (por defecto).
   ===================================================================== */
.tt-chip-musica {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 10px;
  border-radius: 50%;
  border: 1px solid rgba(232, 196, 119, .38);
  background: rgba(20, 26, 36, .55);
  cursor: pointer;
  flex: 0 0 auto;
  opacity: .7;
  transition: opacity .15s ease, border-color .15s ease, transform .12s ease;
}
.tt-chip-musica:hover {
  opacity: 1;
  border-color: #e8c477;
  transform: scale(1.15);
}
.tt-chip-musica input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.tt-chip-musica span {
  font-size: 10px;
  line-height: 1;
  filter: grayscale(.25);
}
.tt-chip-musica:has(input:checked) {
  opacity: .9;
  border-color: #a01d3c;
  background: rgba(60, 16, 24, .8);
}

/* la seccion de menu tiene que ser el ancla del chip */



/* =====================================================================
   SEPARADOR DE PRACTICA
   ---------------------------------------------------------------------
   "Partida contra el bot" y "Reiniciar" ya no viven en la mesa: estan en
   la zona de seleccion, separados de los rivales con una linea y un texto.
   Asi no aparecen durante la partida.
   ===================================================================== */
.tt-separador-practica {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 18px 0 12px;
  font-family: Georgia, serif;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(232, 196, 119, .75);
  white-space: nowrap;
}
.tt-separador-practica::before,
.tt-separador-practica::after {
  content: '';
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201, 162, 39, .7));
}
.tt-separador-practica::after {
  background: linear-gradient(270deg, transparent, rgba(201, 162, 39, .7));
}
.tt-practica {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  width: 100%;
}


/* =====================================================================
   EFECTOS PERFILADOS  (mas visibles, sin tocar la logica)
   ---------------------------------------------------------------------
   Los efectos existian pero se apreciaban poco. Dos motivos:
     1) los tamanos y brillos eran discretos
     2) en `prefers-reduced-motion` se DESACTIVABA TODO, y si el sistema
        del jugador tiene la reduccion activada no se veia NADA
   Aqui se amplifican y se deja una version breve pero VISIBLE para quien
   tenga la reduccion de movimiento activada.
   ===================================================================== */

/* ---------- IMPACTO al colocar: mas grande y con rebote ---------- */
#tt-mesa .tt-tablero .tt-casilla.recien-puesta {
  animation: ttCaeFuerte .52s cubic-bezier(.14, .92, .22, 1) both !important;
  z-index: 8 !important;
}
@keyframes ttCaeFuerte {
  0%   { transform: translateZ(240px) rotateX(-46deg) rotateZ(-6deg) scale(1.55);
         filter: brightness(3.2); }
  52%  { transform: translateZ(26px)  rotateX(10deg)  rotateZ(3deg)  scale(1.12);
         filter: brightness(1.8); }
  76%  { transform: translateZ(-10px) rotateX(-3deg)  rotateZ(-1deg) scale(.95);
         filter: brightness(1.25); }
  100% { transform: none; filter: brightness(1); }
}
/* chispas de impacto en la casilla */
#tt-mesa .tt-tablero .tt-casilla.recien-puesta::after {
  content: '';
  position: absolute; inset: -18%;
  border-radius: 50%;
  pointer-events: none; z-index: 9;
  background: radial-gradient(circle, rgba(255,255,255,.95) 0%, rgba(255,226,140,.7) 34%, transparent 68%);
  animation: ttChispas .42s ease-out both;
}
@keyframes ttChispas {
  0%   { opacity: 0; transform: scale(.3); }
  35%  { opacity: 1; transform: scale(1.15); }
  100% { opacity: 0; transform: scale(1.8); }
}

/* el color del dibujo, mucho mas marcado a mitad del giro */
#tt-mesa .tt-tablero .tt-casilla .tt-carta.recien-capturada .tt-cara {
  animation: ttColorFuerte .9s ease-in-out both !important;
}
@keyframes ttColorFuerte {
  0%   { filter: brightness(1) saturate(1); }
  16%  { filter: brightness(3.4) saturate(2.4); }
  50%  { filter: brightness(4.2) saturate(0) hue-rotate(30deg); }
  84%  { filter: brightness(1.9) saturate(1.6); }
  100% { filter: brightness(1) saturate(1); }
}
/* onda doble, mas grande y mas tiempo */
#tt-mesa .tt-tablero .tt-casilla.destello-captura::after {
  animation: ttOndaFuerte .78s cubic-bezier(.18, .82, .28, 1) both !important;
  inset: -34% !important;
  background: radial-gradient(circle,
    rgba(255,255,255,1) 0%,
    rgba(255,232,150,.85) 26%,
    rgba(255,150,90,.5) 50%,
    transparent 72%) !important;
  z-index: 11 !important;
}
@keyframes ttOndaFuerte {
  0%   { opacity: 0;  transform: scale(.2) translateZ(0); }
  22%  { opacity: 1;  transform: scale(1.15) translateZ(50px); }
  100% { opacity: 0;  transform: scale(2.2) translateZ(130px); }
}
/* y el destello en cruz, mas brillante */
#tt-mesa .tt-tablero .tt-casilla.destello-captura::before {
  animation: ttCruzFuerte .48s ease-out both !important;
  z-index: 12 !important;
}
@keyframes ttCruzFuerte {
  0%   { opacity: 0; transform: scale(.5) rotate(0deg); }
  28%  { opacity: 1; transform: scale(1.25) rotate(8deg); }
  100% { opacity: 0; transform: scale(1.7) rotate(16deg); }
}

/* ---------- la carta elegida, mas evidente ---------- */
#tt-mesa .tt-mano .tt-carta.elegida {
  transform: translateY(-18px) translateZ(80px) scale(1.14) !important;
  filter: brightness(1.35) saturate(1.25) !important;
  box-shadow:
    0 0 0 3px #ffe9a8,
    0 0 26px 10px rgba(255, 233, 168, .95),
    0 18px 34px rgba(0, 0, 0, .7) !important;
}

/* =====================================================================
   REDUCCION DE MOVIMIENTO: NO se apaga todo.
   Antes habia `animation: none !important` para TODO, y quien tuviera la
   reduccion del sistema activada no veia ningun efecto. Ahora se mantiene
   una version BREVE (180 ms) que informa sin marear.
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  #tt-mesa .tt-tablero .tt-casilla.recien-puesta {
    animation: ttBreve .18s ease-out both !important;
  }
  #tt-mesa .tt-tablero .tt-casilla .tt-carta.recien-capturada {
    animation: ttBreve .18s ease-out both !important;
  }
  #tt-mesa .tt-tablero .tt-casilla.destello-captura::after {
    animation: ttBreve .18s ease-out both !important;
  }
  @keyframes ttBreve {
    0%   { opacity: .45; }
    100% { opacity: 1; }
  }
}


/* =====================================================================
   BOTIN QUE NO BLOQUEA
   ---------------------------------------------------------------------
   Al poner el botin a pantalla completa (inset:0, z-index 300) para que se
   viera la recompensa, se convirtio en una capa que TAPABA TODA la
   interfaz. Si el botin salia vacio o el boton de cerrar quedaba fuera de
   vista, la pantalla quedaba atascada al terminar la partida.

   Ahora la CAPA no captura clics: solo el contenido del panel. Asi los
   botones de la escena final siguen siendo pulsables y nunca hay bloqueo.
   ===================================================================== */
#tt-botin {
  pointer-events: none !important;
}
#tt-botin > * {
  pointer-events: auto !important;
  max-height: 86vh !important;
  overflow-y: auto !important;
  margin: auto !important;
}
/* el boton de cerrar, siempre alcanzable */
#tt-botin-cerrar {
  pointer-events: auto !important;
  position: sticky !important;
  bottom: 0 !important;
  margin-top: 14px !important;
  z-index: 5 !important;
}
/* y la escena final por debajo, sin que el botin la tape del todo */
#tt-final { z-index: 260 !important; }


/* =====================================================================
   FASES DE COMBATE  (las pone tt-combate.js)
   ---------------------------------------------------------------------
   Cada fase tiene su propio aspecto, para que se distingan:
     tt-fase-prepara    -> la carta se eleva y brilla
     tt-fase-embestida  -> se inclina hacia el objetivo
     tt-fase-impacto    -> el choque
     tt-fase-combate    -> se esta resolviendo la comparacion
   ===================================================================== */
#tt-mesa .tt-tablero .tt-casilla.tt-fase-prepara {
  animation: ttPrepara .24s ease-out both !important;
  z-index: 9 !important;
}
@keyframes ttPrepara {
  0%   { transform: translateZ(0) scale(1); filter: brightness(1); }
  100% { transform: translateZ(70px) scale(1.10); filter: brightness(1.9); }
}

#tt-mesa .tt-tablero .tt-casilla.tt-fase-embestida {
  animation: ttEmbiste .22s ease-in both !important;
  z-index: 9 !important;
}
@keyframes ttEmbiste {
  0%   { transform: translateZ(70px) rotateX(0) scale(1.10); }
  100% { transform: translateZ(120px) rotateX(-14deg) scale(1.16); filter: brightness(2.2); }
}

#tt-mesa .tt-tablero .tt-casilla.tt-fase-impacto {
  animation: ttChoque .32s cubic-bezier(.2, .9, .3, 1) both !important;
  z-index: 10 !important;
}
@keyframes ttChoque {
  0%   { transform: translateZ(120px) scale(1.16); }
  40%  { transform: translateZ(10px) scale(.94) rotateZ(2deg); filter: brightness(2.6); }
  70%  { transform: translateZ(0) scale(1.03) rotateZ(-1deg); }
  100% { transform: none; filter: brightness(1); }
}

#tt-mesa .tt-tablero .tt-casilla.tt-fase-combate {
  animation: ttCombate .28s ease-out both !important;
  z-index: 10 !important;
}
@keyframes ttCombate {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.14); filter: brightness(2.4) saturate(1.6); }
  100% { transform: scale(1.06); filter: brightness(1.5); }
}

@media (prefers-reduced-motion: reduce) {
  #tt-mesa .tt-tablero .tt-casilla.tt-fase-prepara,
  #tt-mesa .tt-tablero .tt-casilla.tt-fase-embestida,
  #tt-mesa .tt-tablero .tt-casilla.tt-fase-impacto,
  #tt-mesa .tt-tablero .tt-casilla.tt-fase-combate {
    animation: none !important;
    transform: none !important;
  }
}


/* RETIRADO: ocultar la carta la hacia desaparecer durante el efecto.
   Se deja la clase por compatibilidad, pero NO oculta nada. */
#tt-mesa .tt-tablero .tt-casilla.tt-esperando .tt-carta {
  visibility: visible !important;
  opacity: 1 !important;
}
#tt-mesa .tt-tablero .tt-casilla.tt-esperando {
  outline: 1px dashed rgba(201, 162, 39, .35);
  outline-offset: -3px;
}


/* =====================================================================
   MAGIA DE COMBATE
   ---------------------------------------------------------------------
   Cada fase del enfrentamiento gana su propia capa magica:
     prepara    -> circulo magico que se dibuja bajo la carta + runas
     embestida  -> aura de energia y estela en la direccion del ataque
     impacto    -> fogonazo blanco y onda de choque expansiva
     combate    -> sello de duelo latiendo
     captura    -> explosion de particulas doradas
   Solo CSS: no toca ninguna regla del juego.
   ===================================================================== */

/* ---------- circulo magico al preparar ---------- */
#tt-mesa .tt-tablero .tt-casilla.tt-fase-prepara::before {
  content: '';
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
  border: 2px solid rgba(150, 210, 255, .85);
  box-shadow:
    0 0 12px rgba(120, 190, 255, .9),
    inset 0 0 12px rgba(120, 190, 255, .7);
  animation: ttCirculo .5s ease-out both;
}
@keyframes ttCirculo {
  0%   { opacity: 0; transform: scale(.4) rotate(0deg); }
  45%  { opacity: 1; transform: scale(1.05) rotate(140deg); }
  100% { opacity: 0; transform: scale(1.25) rotate(260deg); }
}

/* ---------- aura y estela al embestir ---------- */
#tt-mesa .tt-tablero .tt-casilla.tt-fase-embestida::before {
  content: '';
  position: absolute;
  inset: -16%;
  border-radius: 18px;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(140, 200, 255, .55), transparent 66%),
    conic-gradient(from 0deg, transparent, rgba(190, 230, 255, .55), transparent 40%);
  filter: blur(3px);
  animation: ttAura .26s ease-out both;
}
@keyframes ttAura {
  0%   { opacity: 0; transform: scale(.7) translateZ(0); }
  60%  { opacity: 1; transform: scale(1.12) translateZ(40px); }
  100% { opacity: .75; transform: scale(1.2) translateZ(80px); }
}

/* ---------- fogonazo y onda de choque al impactar ---------- */
#tt-mesa .tt-tablero .tt-casilla.tt-fase-impacto::before {
  content: '';
  position: absolute;
  inset: -40%;
  border-radius: 50%;
  pointer-events: none;
  z-index: 12;
  background: radial-gradient(circle,
    #ffffff 0%,
    rgba(255, 248, 200, .95) 18%,
    rgba(255, 190, 90, .55) 42%,
    transparent 70%);
  animation: ttFogonazo .34s cubic-bezier(.18, .85, .3, 1) both;
}
@keyframes ttFogonazo {
  0%   { opacity: 0; transform: scale(.15); }
  30%  { opacity: 1; transform: scale(1.1); }
  100% { opacity: 0; transform: scale(2.3); }
}
/* el aro que se expande tras el fogonazo */
#tt-mesa .tt-tablero .tt-casilla.tt-fase-impacto::after {
  content: '';
  position: absolute;
  inset: -10%;
  border-radius: 50%;
  pointer-events: none;
  z-index: 11;
  border: 4px solid rgba(255, 236, 170, .95);
  animation: ttAro .44s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes ttAro {
  0%   { opacity: 0; transform: scale(.3); border-width: 8px; }
  35%  { opacity: 1; }
  100% { opacity: 0; transform: scale(2.6); border-width: 1px; }
}

/* ---------- sello de duelo, latiendo, mientras se resuelve ---------- */
#tt-mesa .tt-tablero .tt-casilla.tt-fase-combate::before {
  content: '';
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
  border: 3px double rgba(255, 220, 140, .95);
  background: radial-gradient(circle, rgba(255, 220, 140, .18), transparent 65%);
  animation: ttSello .55s ease-in-out infinite;
}
@keyframes ttSello {
  0%, 100% { opacity: .55; transform: scale(.96) rotate(0deg); }
  50%      { opacity: 1;   transform: scale(1.06) rotate(180deg); }
}

/* ---------- particulas doradas en la captura ---------- */
#tt-mesa .tt-tablero .tt-casilla.destello-captura::before {
  background:
    radial-gradient(circle, rgba(255,255,255,.98) 0%, rgba(255,226,140,.8) 30%, transparent 70%),
    conic-gradient(from 0deg,
      transparent 0 8%, rgba(255,240,190,.9) 9% 11%, transparent 12% 24%,
      rgba(255,240,190,.9) 25% 27%, transparent 28% 42%,
      rgba(255,240,190,.9) 43% 45%, transparent 46% 60%,
      rgba(255,240,190,.9) 61% 63%, transparent 64% 100%) !important;
  animation: ttSelloDoro .62s cubic-bezier(.2, .8, .3, 1) both !important;
}
@keyframes ttSelloDoro {
  0%   { opacity: 0; transform: scale(.4) rotate(0deg); }
  30%  { opacity: 1; transform: scale(1.2) rotate(90deg); }
  100% { opacity: 0; transform: scale(1.9) rotate(220deg); }
}

/* las esquinas del tablero brillan un instante con el impacto */
#tt-mesa .tt-tablero:has(.tt-fase-impacto) {
  box-shadow:
    0 0 0 1px #6b4a16,
    0 0 0 4px #c9a227,
    0 0 0 6px #8a6a1e,
    0 0 0 7px #e8d9a0,
    0 0 26px 6px rgba(255, 236, 170, .55),
    0 14px 34px rgba(0, 0, 0, .62) !important;
}

@media (prefers-reduced-motion: reduce) {
  #tt-mesa .tt-tablero .tt-casilla.tt-fase-prepara::before,
  #tt-mesa .tt-tablero .tt-casilla.tt-fase-embestida::before,
  #tt-mesa .tt-tablero .tt-casilla.tt-fase-impacto::before,
  #tt-mesa .tt-tablero .tt-casilla.tt-fase-impacto::after,
  #tt-mesa .tt-tablero .tt-casilla.tt-fase-combate::before,
  #tt-mesa .tt-tablero .tt-casilla.destello-captura::before {
    animation: none !important;
    opacity: 0 !important;
  }
}


/* =====================================================================
   COLOR VIEJO CONGELADO  (el cambio de dueno lo hace el efecto)
   ---------------------------------------------------------------------
   tt.js repinta el tablero y pone la clase del dueno NUEVO de inmediato:
   el color cambiaba antes de que empezara el giro, y el efecto se quedaba
   sin sentido. tt-combate.js pone `tt-era-suya` o `tt-era-mia` al empezar
   la captura y lo suelta justo cuando la carta esta de canto.
   Estas reglas van DESPUES de las de tinte, por eso ganan.
   ===================================================================== */
#tt-mesa .tt-tablero .tt-casilla .tt-carta.mia.tt-era-suya .tt-cara::after {
  background-color: #c0392b !important;
  opacity: .46 !important;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta.suya.tt-era-mia .tt-cara::after {
  background-color: #2f6fd0 !important;
  opacity: .46 !important;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta.mia.tt-era-suya .tt-cara {
  box-shadow: inset 0 0 0 2px #ff7a68, inset 0 0 14px rgba(255, 122, 104, .5) !important;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta.suya.tt-era-mia .tt-cara {
  box-shadow: inset 0 0 0 2px #6aa6ff, inset 0 0 14px rgba(106, 166, 255, .5) !important;
}

/* ---------- y el giro, mas largo y visible ---------- */
#tt-mesa .tt-tablero .tt-casilla .tt-carta.recien-capturada {
  animation-duration: 1s !important;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta.recien-capturada .tt-cara {
  animation-duration: 1s !important;
}


/* =====================================================================
   CAPA DE DESTELLO GLOBAL
   ---------------------------------------------------------------------
   Va POR ENCIMA de todo el tablero (z-index 200) y no captura clics.
   Los efectos dentro de la casilla se camuflaban con la ilustracion de
   la carta; esta capa no la puede tapar nada.
   ===================================================================== */
#tt-destello-global {
  position: fixed;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  mix-blend-mode: screen;
  background: radial-gradient(circle at 50% 50%,
    var(--tt-destello-color, rgba(255,240,200,.95)) 0%,
    rgba(255, 255, 255, .35) 42%,
    transparent 76%);
  transition: opacity .12s ease-out;
}
#tt-destello-global.tt-destello-on {
  animation: ttDestelloGlobal .44s cubic-bezier(.18, .85, .3, 1) both;
}
#tt-destello-global.tt-destello-total.tt-destello-on {
  animation: ttDestelloTotal .5s cubic-bezier(.15, .9, .25, 1) both;
}
@keyframes ttDestelloGlobal {
  0%   { opacity: 0;   transform: scale(.55); }
  28%  { opacity: .95; transform: scale(1.05); }
  100% { opacity: 0;   transform: scale(1.5); }
}
@keyframes ttDestelloTotal {
  0%   { opacity: 0;   transform: scale(.92); filter: brightness(1); }
  18%  { opacity: .8;  transform: scale(1);   filter: brightness(2.2); }
  55%  { opacity: .35; transform: scale(1.02); filter: brightness(1.3); }
  100% { opacity: 0;   transform: scale(1.04); filter: brightness(1); }
}

@media (prefers-reduced-motion: reduce) {
  #tt-destello-global { display: none !important; }
}


/* =====================================================================
   TEXTOS DESTACADOS
   ---------------------------------------------------------------------
   Los mensajes (#tt-aviso), el indicador de turno (#tt-turno), el marcador
   y los titulos se perdian sobre el fondo. Aqui se refuerzan: fondo solido,
   borde dorado, sombra fuerte y tamano mayor.
   ===================================================================== */

/* ---------- AVISOS: "Has capturado 2 cartas", errores, etc. ---------- */
#tt-aviso {
  display: block;
  margin: 8px auto 0;
  padding: 9px 22px !important;
  max-width: 92%;
  border-radius: 8px !important;
  font-family: Georgia, "Times New Roman", serif !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  letter-spacing: .05em !important;
  text-align: center;
  color: #fff8e2 !important;
  background:
    linear-gradient(180deg, rgba(28, 18, 40, .96), rgba(14, 8, 22, .98)) !important;
  border: 2px solid #c9a227 !important;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, .85),
    0 4px 16px rgba(0, 0, 0, .8),
    0 0 20px rgba(232, 196, 119, .35) !important;
  text-shadow:
    0 1px 0 #000,
    0 0 10px rgba(255, 236, 170, .55) !important;
  animation: ttAvisoEntra .22s ease-out both;
}
#tt-aviso:empty {
  display: none !important;
}
@keyframes ttAvisoEntra {
  0%   { opacity: 0; transform: translateY(-6px) scale(.96); }
  100% { opacity: 1; transform: none; }
}

/* aviso bueno: dorado */
#tt-aviso.bien {
  border-color: #ffe08a !important;
  color: #fffdf2 !important;
  background:
    linear-gradient(180deg, rgba(64, 46, 14, .96), rgba(30, 20, 6, .98)) !important;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, .85),
    0 4px 16px rgba(0, 0, 0, .8),
    0 0 26px rgba(255, 224, 138, .55) !important;
}
/* aviso malo: rojo */
#tt-aviso.mal {
  border-color: #ff8f7a !important;
  color: #fff2ee !important;
  background:
    linear-gradient(180deg, rgba(74, 20, 16, .96), rgba(34, 8, 6, .98)) !important;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, .85),
    0 4px 16px rgba(0, 0, 0, .8),
    0 0 26px rgba(255, 143, 122, .5) !important;
}

/* ---------- INDICADOR DE TURNO: grande y legible ---------- */
#tt-mesa .tt-marcador .tt-turno,
.tt-marcador .tt-turno {
  font-family: Georgia, "Times New Roman", serif !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  letter-spacing: .16em !important;
  text-transform: uppercase !important;
  padding: 9px 26px !important;
  color: #d8f2ff !important;
  background:
    linear-gradient(180deg, rgba(16, 48, 76, .96), rgba(8, 24, 40, .98)) !important;
  border: 2px solid #6aa6ff !important;
  border-radius: 999px !important;
  text-shadow:
    0 1px 0 #000,
    0 0 12px rgba(140, 200, 255, .85) !important;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, .8),
    0 3px 14px rgba(0, 0, 0, .75),
    0 0 18px rgba(106, 166, 255, .45) !important;
}
.tt-marcador .tt-turno.rival {
  color: #ffe3dc !important;
  background:
    linear-gradient(180deg, rgba(84, 22, 18, .96), rgba(38, 10, 8, .98)) !important;
  border-color: #ff8f7a !important;
  text-shadow:
    0 1px 0 #000,
    0 0 12px rgba(255, 143, 122, .85) !important;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, .8),
    0 3px 14px rgba(0, 0, 0, .75),
    0 0 18px rgba(255, 143, 122, .45) !important;
}

/* ---------- MARCADOR y TITULOS con contraste ---------- */
.tt-marcador {
  text-shadow: 0 1px 0 #000, 0 0 8px rgba(0, 0, 0, .9) !important;
}
.tt-titulo,
.tt-dif-titulo {
  text-shadow:
    0 2px 0 #000,
    0 0 14px rgba(0, 0, 0, .9),
    0 0 26px rgba(232, 196, 119, .45) !important;
}
/* los nombres de jugador, con fondo para que no se pierdan en el violeta */
#tt-mesa .tt-lado-nombre {
  font-size: 13px !important;
  font-weight: 700 !important;
  text-shadow:
    0 2px 0 #000,
    0 0 10px rgba(0, 0, 0, .95) !important;
}

@media (prefers-reduced-motion: reduce) {
  #tt-aviso { animation: none !important; }
}


/* =====================================================================
   TEXTO CON EFECTOS
   ---------------------------------------------------------------------
   Los textos seguian leyendose mal. Se va directo a los IDs (no pueden
   fallar por especificidad) y se les da:
     - fondo oscuro CASI OPACO
     - borde dorado grueso y halo
     - tamano grande, mayusculas y espaciado
     - ANIMACION: el texto respira y una luz lo recorre
   ===================================================================== */

/* ---------- INDICADOR DE TURNO ---------- */
#tt-turno {
  display: inline-block;
  padding: 11px 30px !important;
  font-family: Georgia, "Times New Roman", serif !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  letter-spacing: .18em !important;
  text-transform: uppercase !important;
  color: #eaf7ff !important;
  background:
    linear-gradient(180deg, rgba(14, 52, 84, .97), rgba(6, 22, 38, .99)) !important;
  border: 2px solid #7cc0ff !important;
  border-radius: 999px !important;
  text-shadow:
    0 2px 0 #000,
    0 0 14px rgba(124, 192, 255, .95),
    0 0 28px rgba(124, 192, 255, .55) !important;
  box-shadow:
    0 0 0 1px #000,
    0 0 26px rgba(124, 192, 255, .55),
    0 6px 20px rgba(0, 0, 0, .8),
    inset 0 1px 0 rgba(255, 255, 255, .25) !important;
  animation: ttTurnoRespira 2.4s ease-in-out infinite;
}
@keyframes ttTurnoRespira {
  0%, 100% {
    box-shadow: 0 0 0 1px #000, 0 0 18px rgba(124,192,255,.4),
                0 6px 20px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.2);
    text-shadow: 0 2px 0 #000, 0 0 10px rgba(124,192,255,.8);
  }
  50% {
    box-shadow: 0 0 0 1px #000, 0 0 34px rgba(124,192,255,.85),
                0 6px 20px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.35);
    text-shadow: 0 2px 0 #000, 0 0 20px rgba(124,192,255,1),
                 0 0 40px rgba(124,192,255,.6);
  }
}
/* turno del rival: rojo, con el mismo tratamiento */
#tt-turno.rival {
  color: #fff0ec !important;
  background:
    linear-gradient(180deg, rgba(96, 24, 18, .97), rgba(40, 8, 6, .99)) !important;
  border-color: #ff9a84 !important;
  animation: ttTurnoRespiraRojo 2.4s ease-in-out infinite;
}
@keyframes ttTurnoRespiraRojo {
  0%, 100% {
    box-shadow: 0 0 0 1px #000, 0 0 18px rgba(255,154,132,.4),
                0 6px 20px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.2);
    text-shadow: 0 2px 0 #000, 0 0 10px rgba(255,154,132,.8);
  }
  50% {
    box-shadow: 0 0 0 1px #000, 0 0 34px rgba(255,154,132,.9),
                0 6px 20px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.35);
    text-shadow: 0 2px 0 #000, 0 0 20px rgba(255,154,132,1),
                 0 0 40px rgba(255,154,132,.6);
  }
}

/* ---------- AVISOS: con brillo que recorre el texto ---------- */
#tt-aviso {
  display: block;
  margin: 10px auto 0;
  padding: 12px 26px !important;
  max-width: 94%;
  border-radius: 10px !important;
  font-family: Georgia, "Times New Roman", serif !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  letter-spacing: .06em !important;
  text-align: center;
  color: #fffdf4 !important;
  background:
    linear-gradient(180deg, rgba(24, 16, 36, .98), rgba(10, 6, 16, .99)) !important;
  border: 3px solid #f0cf6a !important;
  text-shadow:
    0 2px 0 #000,
    0 0 16px rgba(255, 236, 170, .9),
    0 0 34px rgba(232, 196, 119, .6) !important;
  box-shadow:
    0 0 0 1px #000,
    0 0 30px rgba(240, 207, 106, .6),
    0 8px 24px rgba(0, 0, 0, .85),
    inset 0 1px 0 rgba(255, 255, 255, .28) !important;
  animation: ttAvisoLatido .9s ease-in-out infinite alternate;
}
@keyframes ttAvisoLatido {
  from {
    border-color: #f0cf6a;
    box-shadow: 0 0 0 1px #000, 0 0 18px rgba(240,207,106,.4),
                0 8px 24px rgba(0,0,0,.85), inset 0 1px 0 rgba(255,255,255,.2);
  }
  to {
    border-color: #fff3c4;
    box-shadow: 0 0 0 1px #000, 0 0 40px rgba(255,243,196,.85),
                0 8px 24px rgba(0,0,0,.85), inset 0 1px 0 rgba(255,255,255,.4);
  }
}
#tt-aviso:empty { display: none !important; }
#tt-aviso.bien {
  border-color: #ffe08a !important;
  background:
    linear-gradient(180deg, rgba(70, 50, 12, .98), rgba(30, 20, 4, .99)) !important;
}
#tt-aviso.mal {
  border-color: #ff9a84 !important;
  color: #fff4f0 !important;
  background:
    linear-gradient(180deg, rgba(82, 20, 14, .98), rgba(34, 8, 4, .99)) !important;
  box-shadow:
    0 0 0 1px #000, 0 0 34px rgba(255, 154, 132, .7),
    0 8px 24px rgba(0, 0, 0, .85), inset 0 1px 0 rgba(255, 255, 255, .28) !important;
}

/* ---------- TITULOS con resplandor ---------- */
.tt-titulo, .tt-dif-titulo {
  font-size: 20px !important;
  letter-spacing: .12em !important;
  color: #fff8e6 !important;
  text-shadow:
    0 2px 0 #000,
    0 0 12px rgba(240, 207, 106, .95),
    0 0 30px rgba(240, 207, 106, .6),
    0 0 50px rgba(0, 0, 0, .9) !important;
  animation: ttTituloBrilla 3s ease-in-out infinite;
}
@keyframes ttTituloBrilla {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.25); }
}

/* ---------- nombres de jugador ---------- */
#tt-mesa .tt-lado-nombre {
  font-size: 13px !important;
  font-weight: 700 !important;
  letter-spacing: .14em !important;
  text-shadow:
    0 2px 0 #000,
    0 0 12px rgba(0, 0, 0, .98),
    0 0 22px currentColor !important;
}

@media (prefers-reduced-motion: reduce) {
  #tt-turno, #tt-aviso, .tt-titulo, .tt-dif-titulo { animation: none !important; }
}


/* =====================================================================
   MARCA DE VERSION  (para saber si los cambios llegan al navegador)
   ---------------------------------------------------------------------
   Si ves esta etiqueta arriba a la derecha, la pagina cargada es la nueva.
   Si NO la ves, el navegador esta sirviendo una copia vieja de cache y
   ningun cambio de CSS llegara hasta que se fuerce la recarga.
   ===================================================================== */
#tt-marca-version {
  position: fixed;
  top: 4px;
  right: 6px;
  z-index: 500;
  padding: 3px 8px;
  font: 700 10px/1.2 monospace;
  letter-spacing: .08em;
  color: #0b0b0b;
  background: #ffe08a;
  border: 1px solid #7d5a1b;
  border-radius: 4px;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .6);
}


/* =====================================================================
   RECHAZO DEL ATAQUE
   ---------------------------------------------------------------------
   Cuando la comprobacion dice que la casilla NO cambio de dueno, el
   ataque fue rechazado. La atacante rebota y la defensora aguanta.
   Distinto del impacto, distinto de la captura: identidad propia.
   ===================================================================== */
#tt-mesa .tt-tablero .tt-casilla.tt-rechazo {
  animation: ttRechazo .52s cubic-bezier(.3, .8, .3, 1) both !important;
  z-index: 9 !important;
}
@keyframes ttRechazo {
  0%   { transform: translateZ(0) translateX(0); }
  18%  { transform: translateZ(20px) translateX(-9%) scale(.94); filter: brightness(.7) saturate(.4); }
  42%  { transform: translateZ(14px) translateX(7%) scale(.97); }
  66%  { transform: translateZ(8px) translateX(-4%) scale(.99); }
  100% { transform: none; filter: none; }
}
#tt-mesa .tt-tablero .tt-casilla.tt-resiste {
  animation: ttResiste .52s ease-out both !important;
  z-index: 8 !important;
}
@keyframes ttResiste {
  0%   { transform: scale(1); filter: brightness(1); }
  30%  { transform: scale(1.06); filter: brightness(1.6) saturate(.5); }
  60%  { transform: scale(.98);  filter: brightness(1.2); }
  100% { transform: scale(1);    filter: brightness(1); }
}
/* el ataque rechazado deja un brillo grisaceo, no dorado */
#tt-mesa .tt-tablero .tt-casilla.tt-rechazo::before {
  content: '';
  position: absolute;
  inset: -12%;
  border-radius: 50%;
  pointer-events: none;
  z-index: 10;
  background: radial-gradient(circle, rgba(200, 210, 225, .55) 0%, transparent 68%);
  animation: ttAroGris .42s ease-out both;
}
@keyframes ttAroGris {
  0%   { opacity: 0; transform: scale(.5); }
  35%  { opacity: .9; transform: scale(1.1); }
  100% { opacity: 0; transform: scale(1.5); }
}

@media (prefers-reduced-motion: reduce) {
  #tt-mesa .tt-tablero .tt-casilla.tt-rechazo,
  #tt-mesa .tt-tablero .tt-casilla.tt-resiste,
  #tt-mesa .tt-tablero .tt-casilla.tt-rechazo::before {
    animation: none !important;
  }
}


/* =====================================================================
   BLOQUEO DURANTE LA SECUENCIA  (caso F del prompt)
   ---------------------------------------------------------------------
   Mientras dura una secuencia de combate, tt-combate.js pone
   `body.tt-en-combate`. Aqui se desactivan las cartas de la mano y las
   casillas del tablero, para que un clic rapido no dispare dos jugadas
   ni corrompa el estado.
   Hay una red de seguridad de 15 s en el JS: el bloqueo nunca se queda.
   ===================================================================== */
body.tt-en-combate .tt-mano .tt-carta {
  pointer-events: none !important;
  cursor: default !important;
}
body.tt-en-combate .tt-tablero .tt-casilla {
  pointer-events: none !important;
}
/* y se nota que esta ocupado, sin molestar */
body.tt-en-combate .tt-tablero {
  filter: saturate(1.04);
}
body.tt-en-combate .tt-mano {
  opacity: .82;
  transition: opacity .15s ease;
}


/* =====================================================================
   IDENTIFICACION DEL ENFRENTAMIENTO  (punto 2.1 del prompt)
   ---------------------------------------------------------------------
   - Se atenua el RESTO del tablero mientras dura el duelo.
   - Se marcan la carta atacante y la defensora.
   - Se ilumina el LADO que participa en cada una, con la direccion real.
   ===================================================================== */

/* ---------- el resto del tablero se atenua ---------- */
#tt-mesa .tt-tablero.tt-en-duelo .tt-casilla {
  filter: brightness(.52) saturate(.6);
  transition: filter .18s ease;
}
#tt-mesa .tt-tablero.tt-en-duelo .tt-casilla.tt-duelo {
  filter: brightness(1.18) saturate(1.15) !important;
  z-index: 9;
}

/* ---------- la atacante, con marco dorado ---------- */
#tt-mesa .tt-tablero .tt-casilla.tt-atacante .tt-carta {
  box-shadow:
    0 0 0 2px #ffe08a,
    0 0 22px 6px rgba(255, 224, 138, .8),
    0 8px 18px rgba(0, 0, 0, .6) !important;
}
/* ---------- la defensora, con marco rojo ---------- */
#tt-mesa .tt-tablero .tt-casilla.tt-defensora .tt-carta {
  box-shadow:
    0 0 0 2px #ff9a84,
    0 0 22px 6px rgba(255, 154, 132, .7),
    0 8px 18px rgba(0, 0, 0, .6) !important;
}

/* ---------- el LADO que ataca: una cuna de luz en ese borde ---------- */
#tt-mesa .tt-tablero .tt-casilla.tt-atacante::after {
  content: '';
  position: absolute;
  pointer-events: none;
  z-index: 11;
  background: linear-gradient(90deg, rgba(255, 236, 170, .95), transparent);
}
#tt-mesa .tt-tablero .tt-casilla.tt-atacante.tt-ataca-der::after {
  top: 12%; bottom: 12%; right: -14%; width: 26%;
  background: linear-gradient(90deg, rgba(255, 236, 170, .95), transparent);
  animation: ttLadoLuz .34s ease-out both;
}
#tt-mesa .tt-tablero .tt-casilla.tt-atacante.tt-ataca-izq::after {
  top: 12%; bottom: 12%; left: -14%; width: 26%;
  background: linear-gradient(270deg, rgba(255, 236, 170, .95), transparent);
  animation: ttLadoLuz .34s ease-out both;
}
#tt-mesa .tt-tablero .tt-casilla.tt-atacante.tt-ataca-aba::after {
  left: 12%; right: 12%; bottom: -14%; height: 26%;
  background: linear-gradient(180deg, rgba(255, 236, 170, .95), transparent);
  animation: ttLadoLuz .34s ease-out both;
}
#tt-mesa .tt-tablero .tt-casilla.tt-atacante.tt-ataca-arr::after {
  left: 12%; right: 12%; top: -14%; height: 26%;
  background: linear-gradient(0deg, rgba(255, 236, 170, .95), transparent);
  animation: ttLadoLuz .34s ease-out both;
}
@keyframes ttLadoLuz {
  0%   { opacity: 0; }
  40%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- el lado que RECIBE, con un filo rojo ---------- */
#tt-mesa .tt-tablero .tt-casilla.tt-defensora.tt-agujero-izq { border-left: 3px solid #ff9a84; }
#tt-mesa .tt-tablero .tt-casilla.tt-defensora.tt-agujero-der { border-right: 3px solid #ff9a84; }
#tt-mesa .tt-tablero .tt-casilla.tt-defensora.tt-agujero-arr { border-top: 3px solid #ff9a84; }
#tt-mesa .tt-tablero .tt-casilla.tt-defensora.tt-agujero-aba { border-bottom: 3px solid #ff9a84; }

@media (prefers-reduced-motion: reduce) {
  #tt-mesa .tt-tablero.tt-en-duelo .tt-casilla { filter: none !important; }
  #tt-mesa .tt-tablero .tt-casilla.tt-atacante::after { animation: none !important; }
}


/* =====================================================================
   CUADRO DE VALORES DEL DUELO  (Fase D del prompt)
   ---------------------------------------------------------------------
   Entre las dos cartas, con el valor que ataca en dorado y el que defiende
   en rojo. Se lee del `alt` de cada tt-val: no se inventa nada.
   ===================================================================== */
#tt-valores-duelo {
  position: fixed;
  z-index: 210;
  transform: translate(-50%, -50%) scale(.7);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  font: 700 24px/1 Georgia, "Times New Roman", serif;
  letter-spacing: .04em;
  background: linear-gradient(180deg, rgba(16, 10, 24, .97), rgba(6, 4, 10, .99));
  border: 2px solid #c9a227;
  box-shadow:
    0 0 0 1px #000,
    0 0 26px rgba(232, 196, 119, .65),
    0 8px 22px rgba(0, 0, 0, .85);
  transition: opacity .12s ease, transform .12s ease;
}
#tt-valores-duelo.tt-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  animation: ttValoresLate .5s ease-in-out infinite alternate;
}
@keyframes ttValoresLate {
  from { box-shadow: 0 0 0 1px #000, 0 0 18px rgba(232,196,119,.45), 0 8px 22px rgba(0,0,0,.85); }
  to   { box-shadow: 0 0 0 1px #000, 0 0 36px rgba(255,236,170,.95), 0 8px 22px rgba(0,0,0,.85); }
}
#tt-valores-duelo .tt-v-ataca {
  color: #ffe9a8;
  text-shadow: 0 2px 0 #000, 0 0 16px rgba(255, 233, 168, .95);
}
#tt-valores-duelo .tt-v-signo {
  color: #c9a227;
  font-size: 18px;
  text-shadow: 0 2px 0 #000;
}
#tt-valores-duelo .tt-v-defiende {
  color: #ff9a84;
  text-shadow: 0 2px 0 #000, 0 0 16px rgba(255, 154, 132, .95);
}
@media (prefers-reduced-motion: reduce) {
  #tt-valores-duelo.tt-visible { animation: none !important; }
}


/* =====================================================================
   MARCO PROGRESIVO EN LA CAPTURA  (punto 3 del prompt)
   ---------------------------------------------------------------------
   "Durante el giro, el marco y la iluminacion cambian progresivamente."
   El color ya cambiaba a media vuelta; aqui el MARCO va cambiando de color
   a lo largo de todo el giro: rojo del dueno viejo -> dorado -> azul del
   nuevo. Con la misma duracion que el giro (650 ms).
   ===================================================================== */
#tt-mesa .tt-tablero .tt-casilla .tt-carta.recien-capturada .tt-cara {
  animation: ttGiroColor .65s ease-in-out both,
             ttMarcoProgresivo .65s linear both !important;
}
@keyframes ttMarcoProgresivo {
  0% {
    box-shadow: inset 0 0 0 2px #ff7a68, 0 0 16px rgba(255, 122, 104, .65);
  }
  45% {
    box-shadow: inset 0 0 0 3px #ffe08a, 0 0 30px rgba(255, 224, 138, .95);
  }
  100% {
    box-shadow: inset 0 0 0 2px #6aa6ff, 0 0 16px rgba(106, 166, 255, .65);
  }
}
/* el mismo recorrido al reves cuando el rival te captura a ti */
#tt-mesa .tt-tablero .tt-casilla .tt-carta.recien-capturada.suya .tt-cara {
  animation: ttGiroColor .65s ease-in-out both,
             ttMarcoProgresivoRojo .65s linear both !important;
}
@keyframes ttMarcoProgresivoRojo {
  0% {
    box-shadow: inset 0 0 0 2px #6aa6ff, 0 0 16px rgba(106, 166, 255, .65);
  }
  45% {
    box-shadow: inset 0 0 0 3px #ffe08a, 0 0 30px rgba(255, 224, 138, .95);
  }
  100% {
    box-shadow: inset 0 0 0 2px #ff7a68, 0 0 16px rgba(255, 122, 104, .65);
  }
}

@media (prefers-reduced-motion: reduce) {
  #tt-mesa .tt-tablero .tt-casilla .tt-carta.recien-capturada .tt-cara {
    animation: none !important;
  }
}


/* =====================================================================
   ESTELA DE LA EMBESTIDA  (Fase B)  y  DESVANECIMIENTO (Fase E)
   ===================================================================== */

/* la casilla deja un rastro de energia mientras la carta viaja */
#tt-mesa .tt-tablero .tt-casilla.tt-embistiendo::before {
  content: '';
  position: absolute;
  inset: -22%;
  border-radius: 14px;
  pointer-events: none;
  z-index: 7;
  background:
    linear-gradient(90deg,
      rgba(255, 240, 190, 0) 0%,
      rgba(255, 240, 190, .75) 42%,
      rgba(255, 255, 255, .95) 50%,
      rgba(255, 240, 190, .75) 58%,
      rgba(255, 240, 190, 0) 100%);
  filter: blur(6px);
  animation: ttEstela .34s ease-out both;
}
@keyframes ttEstela {
  0%   { opacity: 0; transform: scaleX(.5); }
  35%  { opacity: .95; transform: scaleX(1.15); }
  100% { opacity: 0; transform: scaleX(1.5); }
}

/* Fase E: al terminar el duelo, la iluminacion baja poco a poco */
#tt-mesa .tt-tablero.tt-duelo-saliendo .tt-casilla {
  transition: filter .24s ease-out;
}
#tt-mesa .tt-tablero.tt-duelo-saliendo .tt-casilla.tt-duelo {
  filter: brightness(1) saturate(1) !important;
  transition: filter .24s ease-out;
}
#tt-mesa .tt-tablero.tt-duelo-saliendo .tt-casilla.tt-atacante .tt-carta,
#tt-mesa .tt-tablero.tt-duelo-saliendo .tt-casilla.tt-defensora .tt-carta {
  box-shadow: 0 3px 10px rgba(0, 0, 0, .5) !important;
  transition: box-shadow .24s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  #tt-mesa .tt-tablero .tt-casilla.tt-embistiendo::before { animation: none !important; opacity: 0 !important; }
}


/* =====================================================================
   ENFASIS DEL TABLERO  (Fase A y Fase C)
   ---------------------------------------------------------------------
   El prompt sugiere que el tablero reciba un pequeno enfasis visual en la
   preparacion y una onda expansiva sutil en el impacto. Nunca debe
   desorientar: son cambios de brillo del marco, nada de mover la vista.
   ===================================================================== */
#tt-mesa .tt-tablero.tt-tablero-prepara {
  box-shadow:
    0 0 0 1px #6b4a16,
    0 0 0 4px #c9a227,
    0 0 0 6px #8a6a1e,
    0 0 0 7px #ffe9a8,
    0 0 22px 4px rgba(255, 233, 168, .45),
    0 14px 34px rgba(0, 0, 0, .62) !important;
  transition: box-shadow .16s ease-out;
}
#tt-mesa .tt-tablero.tt-tablero-golpe {
  box-shadow:
    0 0 0 1px #6b4a16,
    0 0 0 4px #ffe9a8,
    0 0 0 6px #c9a227,
    0 0 0 8px #fff8e0,
    0 0 40px 12px rgba(255, 236, 170, .75),
    0 14px 34px rgba(0, 0, 0, .62) !important;
  animation: ttTableroGolpe .42s cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes ttTableroGolpe {
  0%   { transform: scale(1); }
  22%  { transform: scale(1.012); }
  60%  { transform: scale(.998); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  #tt-mesa .tt-tablero.tt-tablero-golpe { animation: none !important; }
}


/* =====================================================================
   SIN TENIDO INTERIOR  (punto 8 del prompt)
   ---------------------------------------------------------------------
   PROBLEMA ENCONTRADO EN LA AUDITORIA:
     tt-tinte.css pinta `.tt-carta.mia .tt-cara::after` con #2f6fd0 y
     `.tt-carta.suya .tt-cara::after` con #c0392b a opacidad .38 ENCIMA de
     la ilustracion. Y gana a la neutralizacion de tt-cartas-ref.css porque
     tiene mas especificidad, aunque se cargue antes.
     Resultado: las cartas se ven como masas azules y rojas y se pierde el
     dibujo.

   SOLUCION: se eliminan las capas de color y los filtros del INTERIOR.
   La propiedad se marca con el MARCO, que ya existe, y con una franja
   discreta. El color distingue sin ocultar nada.
   ===================================================================== */

/* ---------- fuera las capas de color sobre la ilustracion ---------- */
#tt-mesa .tt-tablero .tt-casilla .tt-carta .tt-cara::after,
#tt-mesa .tt-tablero .tt-casilla .tt-carta.mia .tt-cara::after,
#tt-mesa .tt-tablero .tt-casilla .tt-carta.suya .tt-cara::after,
#tt-mesa .tt-tablero .tt-casilla .tt-carta.mia .tt-cara::before,
#tt-mesa .tt-tablero .tt-casilla .tt-carta.suya .tt-cara::before {
  content: none !important;
  background: none !important;
  opacity: 0 !important;
  display: none !important;
  mix-blend-mode: normal !important;
}

/* ---------- fuera los filtros sobre la ilustracion ---------- */
#tt-mesa .tt-tablero .tt-casilla .tt-carta .tt-foto,
#tt-mesa .tt-tablero .tt-casilla .tt-carta .tt-cara img,
#tt-mesa .tt-tablero .tt-casilla .tt-carta img {
  filter: none !important;
  opacity: 1 !important;
  mix-blend-mode: normal !important;
  -webkit-filter: none !important;
}

/* ---------- la propiedad se ve en el MARCO, no dentro ---------- */
#tt-mesa .tt-tablero .tt-casilla .tt-carta.mia .tt-cara {
  box-shadow:
    inset 0 0 0 2px #6aa6ff,
    inset 0 0 0 3px rgba(10, 20, 40, .55),
    0 0 12px rgba(106, 166, 255, .45) !important;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta.suya .tt-cara {
  box-shadow:
    inset 0 0 0 2px #ff7a68,
    inset 0 0 0 3px rgba(40, 10, 8, .55),
    0 0 12px rgba(255, 122, 104, .45) !important;
}

/* ---------- franja elegante de propiedad, arriba y fina ---------- */
#tt-mesa .tt-tablero .tt-casilla .tt-carta.mia::before,
#tt-mesa .tt-tablero .tt-casilla .tt-carta.suya::before {
  content: '';
  position: absolute;
  left: 12%;
  right: 12%;
  top: 2px;
  height: 3px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 3;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta.mia::before {
  background: linear-gradient(90deg, transparent, #6aa6ff, transparent);
  box-shadow: 0 0 8px rgba(106, 166, 255, .9);
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta.suya::before {
  background: linear-gradient(90deg, transparent, #ff7a68, transparent);
  box-shadow: 0 0 8px rgba(255, 122, 104, .9);
}


/* =====================================================================
   GIRO LIMPIO — SUSTITUYE A TODOS LOS ANTERIORES
   ---------------------------------------------------------------------
   POR QUE ESTE BLOQUE
   A lo largo de varias rondas se anadieron CUATRO animaciones distintas para
   `.tt-carta.recien-capturada` (ttVoltea, ttVoltea3D, ttGiroCaja, ttGiroFuerte).
   El navegador solo aplica la ultima, pero la que ganaba hacia:

       translateZ(190px) scale(1.44) rotateY(180deg)

   Es decir: la carta SALIA de su casilla y CAMBIABA DE TAMANO. Eso produce el
   salto y la sensacion artificial que se ve.

   LO QUE PIDE EL PROMPT (punto 3):
     - la carta permanece DENTRO de su casilla
     - su tamano y posicion NO cambian
     - giro sobre el eje VERTICAL con perspectiva
     - sin duplicados visibles
     - el nuevo dueno se revela al final

   SOLUCION: una sola animacion, solo rotateY, sin scale y sin translateZ.
   Las animaciones antiguas siguen escritas mas arriba pero esta las anula.
   ===================================================================== */

/* la perspectiva va en la CASILLA, no en la carta: asi el giro tiene
   profundidad sin que la carta se mueva de sitio */
#tt-mesa .tt-tablero .tt-casilla {
  perspective: 700px !important;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta {
  transform-style: preserve-3d !important;
  transform-origin: 50% 50% !important;
  /* La carta puede mostrar dos caras; cada cara oculta su propio reverso. */
  backface-visibility: visible !important;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta .tt-cara {
  backface-visibility: hidden !important;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta .tt-dorso {
  position: absolute;
  inset: 0;
  display: block;
  transform: rotateY(180deg);
  transform-origin: 50% 50%;
  backface-visibility: hidden !important;
  pointer-events: none;
  border-radius: inherit;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta .tt-dorso .tt-cara {
  position: absolute;
  inset: 0;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta.tt-girando > .tt-nombre {
  opacity: 0 !important;
}

/* ---------- EL GIRO: solo rotateY ---------- */
#tt-mesa .tt-tablero .tt-casilla .tt-carta.recien-capturada {
  animation: ttGiroLimpio 650ms cubic-bezier(.4, .1, .3, 1) both !important;
  /* OJO: aqui NO se pone `transform: none !important`. Una declaracion
     !important GANA a las animaciones de CSS y dejaria el giro muerto. */
  will-change: transform !important;
}
@keyframes ttGiroLimpio {
  0%   { transform: rotateY(0deg); }
  100% { transform: rotateY(180deg); }
}

/* la capa del dibujo NO se filtra: la ilustracion se conserva intacta */
#tt-mesa .tt-tablero .tt-casilla .tt-carta.recien-capturada .tt-cara {
  animation: none !important;
  filter: none !important;
}

/* ---------- EL DESTELLO DE LA CASILLA: limpio y breve ---------- */
#tt-mesa .tt-tablero .tt-casilla.destello-captura::after {
  inset: -8% !important;
  background: radial-gradient(circle,
    rgba(255, 255, 255, .85) 0%,
    rgba(255, 236, 170, .45) 40%,
    transparent 68%) !important;
  animation: ttDestelloLimpio 360ms ease-out both !important;
}
@keyframes ttDestelloLimpio {
  0%   { opacity: 0;   transform: scale(.7); }
  40%  { opacity: .9;  transform: scale(1.05); }
  100% { opacity: 0;   transform: scale(1.25); }
}
/* el segundo destello (cruz girada) sobraba: se anula */
#tt-mesa .tt-tablero .tt-casilla.destello-captura::before {
  content: none !important;
  display: none !important;
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  #tt-mesa .tt-tablero .tt-casilla .tt-carta.recien-capturada {
    animation: ttGiroReducido 200ms linear both !important;
  }
  @keyframes ttGiroReducido {
    0%   { transform: rotateY(0deg); }
    100% { transform: rotateY(180deg); }
  }
  #tt-mesa .tt-tablero .tt-casilla.destello-captura::after { animation: none !important; }
}


/* panel del registro de eventos: solo con ?ttdebug=1 en la URL */
#tt-registro {
  position: fixed;
  left: 6px;
  bottom: 6px;
  z-index: 400;
  max-width: 44vw;
  max-height: 32vh;
  overflow-y: auto;
  padding: 6px 8px;
  font: 10px/1.45 monospace;
  color: #d8f2ff;
  background: rgba(4, 8, 14, .92);
  border: 1px solid #6aa6ff;
  border-radius: 6px;
  pointer-events: auto;
}
#tt-registro .tt-reg-l { white-space: nowrap; }
#tt-registro .tt-reg-l span { color: #7cc0ff; }


/* =====================================================================
   ANIMACIONES REDUCIDAS (INTERRUPTOR)  — punto 10 del prompt
   ---------------------------------------------------------------------
   `body.tt-anim-reducidas` acorta los efectos sin tocar NINGUNA regla:
   el giro pasa a ser un fundido corto y los destellos se apagan.
   Se activa con TT_COMBATE.animaciones(true) o desde el menu.
   ===================================================================== */
body.tt-anim-reducidas #tt-mesa .tt-tablero .tt-casilla .tt-carta.recien-capturada {
  animation: ttGiroCorto 180ms linear both !important;
}
@keyframes ttGiroCorto {
  0%   { transform: rotateY(0deg); opacity: .55; }
  100% { transform: rotateY(180deg); opacity: 1; }
}
body.tt-anim-reducidas #tt-mesa .tt-tablero .tt-casilla.destello-captura::after,
body.tt-anim-reducidas #tt-mesa .tt-tablero .tt-casilla.recien-puesta::after,
body.tt-anim-reducidas #tt-mesa .tt-tablero .tt-casilla.tt-embistiendo::before {
  animation: none !important;
  display: none !important;
}
body.tt-anim-reducidas #tt-destello-global { display: none !important; }
body.tt-anim-reducidas #tt-mesa .tt-tablero .tt-casilla.tt-fase-prepara,
body.tt-anim-reducidas #tt-mesa .tt-tablero .tt-casilla.tt-fase-embestida {
  animation-duration: 120ms !important;
}

/* El giro reducido conserva las dos caras: no hay que volver a ocultar la
   carta de 90 a 180. Solo se acorta la misma animación. */
@media (prefers-reduced-motion: reduce) {
  #tt-mesa .tt-tablero .tt-casilla .tt-carta.recien-capturada {
    animation: ttGiroLimpio 300ms cubic-bezier(.4, .1, .3, 1) both !important;
  }
}
body.tt-anim-reducidas #tt-mesa .tt-tablero .tt-casilla .tt-carta.recien-capturada {
  animation: ttGiroLimpio 300ms cubic-bezier(.4, .1, .3, 1) both !important;
}

/* =====================================================================
   SOLO LA IMAGEN
   ---------------------------------------------------------------------
   La carta ya trae el color de propiedad en su propia ilustracion. Fuera
   el marco azul/rojo, el resplandor, el liston superior, el simbolo y la
   sombra de rareza: en el tablero se ve unicamente la imagen de la carta.
   ===================================================================== */
#tt-mesa .tt-tablero .tt-casilla .tt-carta,
#tt-mesa .tt-tablero .tt-casilla .tt-carta.mia,
#tt-mesa .tt-tablero .tt-casilla .tt-carta.suya {
  background: transparent !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta .tt-cara,
#tt-mesa .tt-tablero .tt-casilla .tt-carta.mia .tt-cara,
#tt-mesa .tt-tablero .tt-casilla .tt-carta.suya .tt-cara {
  background: transparent !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta::before,
#tt-mesa .tt-tablero .tt-casilla .tt-carta.mia::before,
#tt-mesa .tt-tablero .tt-casilla .tt-carta.suya::before,
#tt-mesa .tt-tablero .tt-casilla .tt-carta .tt-cara::before,
#tt-mesa .tt-tablero .tt-casilla .tt-carta .tt-cara::after {
  content: none !important;
  display: none !important;
  background: none !important;
  box-shadow: none !important;
}
#tt-mesa .tt-tablero .tt-casilla .tt-carta .tt-dueno {
  display: none !important;
}
