:root {
  --ink: #0c0c0f;
  --paper: #f4f0e8;
  --paper-2: #ded7c8;
  --red: #ff3b30;
  --red-dark: #b61816;
  --orange: #ff9d1c;
  --yellow: #ffd84a;
  --blue: #34a8ff;
  --violet: #8b5dff;
  --text: #f8f6f0;
  --muted: #b8b8c2;
  --panel: #17171d;
  --panel-2: #22222a;
  --line: rgba(255,255,255,.13);
  --shadow: 10px 10px 0 rgba(0,0,0,.45);
}

* {
  box-sizing: border-box;
}

html {
  background: #0b0b0f;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(255,59,48,.07) 0 12%, transparent 12% 50%, rgba(255,157,28,.06) 50% 62%, transparent 62% 100%),
    radial-gradient(circle at 20% 0%, rgba(255,59,48,.18), transparent 28rem),
    radial-gradient(circle at 85% 8%, rgba(52,168,255,.12), transparent 26rem),
    #0c0c11;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -2;
  pointer-events: none;
}

body::before {
  width: 58vw;
  height: 58vw;
  right: -18vw;
  top: -20vw;
  background:
    repeating-conic-gradient(
      from 10deg,
      rgba(255,255,255,.035) 0 2deg,
      transparent 2deg 8deg
    );
  border-radius: 50%;
  opacity: .6;
}

body::after {
  width: 52vw;
  height: 52vw;
  left: -28vw;
  bottom: -22vw;
  background:
    repeating-radial-gradient(
      circle,
      rgba(255,255,255,.035) 0 2px,
      transparent 2px 8px
    );
  opacity: .55;
}

.page-noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .16;
  background-image:
    radial-gradient(circle at 20% 20%, #fff 0 1px, transparent 1.2px),
    radial-gradient(circle at 80% 65%, #fff 0 1px, transparent 1.2px);
  background-size: 17px 17px, 23px 23px;
  mix-blend-mode: soft-light;
}

button, input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(1500px, 94vw);
  margin: 0 auto;
  padding: 28px 0 70px;
}

.hero {
  position: relative;
  max-width: 970px;
  margin: 0 auto 30px;
  padding: 26px 26px 24px;
  text-align: center;
  border: 4px solid #08080b;
  background:
    linear-gradient(120deg, transparent 0 12%, rgba(255,255,255,.045) 12% 14%, transparent 14% 100%),
    linear-gradient(180deg, #24242e, #121217);
  box-shadow:
    0 0 0 2px rgba(255,255,255,.08),
    12px 12px 0 rgba(0,0,0,.45);
  transform: skewY(-1deg);
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: auto -10% -40px;
  height: 92px;
  background:
    repeating-linear-gradient(
      -18deg,
      rgba(255,59,48,.16) 0 8px,
      transparent 8px 28px
    );
}

.hero > * {
  position: relative;
  transform: skewY(1deg);
}

.hero-kicker {
  display: inline-block;
  padding: 7px 12px 5px;
  color: #0b0b0d;
  background: var(--yellow);
  border: 3px solid #08080b;
  box-shadow: 4px 4px 0 #08080b;
  font-size: 13px;
  letter-spacing: .13em;
  transform: rotate(-2deg) skewY(1deg);
}

.hero-title-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 16px 0 10px;
}

.hero h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(38px, 6.2vw, 82px);
  line-height: .86;
  letter-spacing: -.04em;
  text-transform: uppercase;
  text-shadow:
    4px 4px 0 #000,
    -2px -2px 0 #000;
}

.hero h1 span {
  color: var(--orange);
  text-shadow:
    4px 4px 0 #000,
    -2px -2px 0 #000;
}

.hero-slash {
  color: var(--red);
  font-size: clamp(26px, 3vw, 44px);
  letter-spacing: -.2em;
  text-shadow: 2px 2px 0 #000;
  transform: rotate(-10deg);
}

.hero-slash.right {
  transform: rotate(10deg);
}

.hero p {
  margin: 0 auto;
  max-width: 650px;
  color: #d2d0d5;
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: .02em;
}

.hero-tags {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.hero-tags span {
  padding: 5px 9px;
  color: #f8f3e8;
  border: 2px solid rgba(255,255,255,.20);
  background: rgba(0,0,0,.25);
  font-size: 11px;
  letter-spacing: .10em;
}

.panel {
  position: relative;
  border: 4px solid #09090c;
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,0)),
    var(--panel);
  box-shadow:
    0 0 0 2px rgba(255,255,255,.06),
    var(--shadow);
}

.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle, rgba(255,255,255,.045) 0 1px, transparent 1.4px);
  background-size: 10px 10px;
  opacity: .24;
}

.panel > * {
  position: relative;
  z-index: 1;
}

.panel-label {
  display: inline-block;
  margin-bottom: 10px;
  padding: 4px 9px 3px;
  color: #08080b;
  background: var(--red);
  border: 2px solid #08080b;
  box-shadow: 3px 3px 0 #08080b;
  font-size: 11px;
  letter-spacing: .12em;
  transform: rotate(-1.5deg);
}

.section-copy h2,
.section-header h2,
.game-header h2 {
  margin: 0;
}

h2 {
  color: #fff;
  font-size: clamp(24px, 2.5vw, 34px);
  line-height: .98;
  letter-spacing: -.02em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 600;
}

.setup {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px;
}

.setup .muted {
  margin: 6px 0 0;
}

.anime-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.anime-option {
  cursor: pointer;
  user-select: none;
}

.anime-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.anime-option span {
  position: relative;
  display: flex;
  min-height: 116px;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px;
  overflow: hidden;
  color: #fff;
  border: 4px solid #09090c;
  background:
    linear-gradient(180deg, transparent 0 28%, rgba(0,0,0,.72) 100%),
    #25252d;
  box-shadow: 6px 6px 0 #09090c;
  transition: transform .12s ease, filter .12s ease;
}

.anime-option span::before,
.anime-option span::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.anime-option span::before {
  inset: 0;
  background:
    repeating-linear-gradient(
      -20deg,
      rgba(255,255,255,.08) 0 2px,
      transparent 2px 13px
    );
  opacity: .35;
}

.anime-option span::after {
  width: 100px;
  height: 180px;
  right: -38px;
  top: -42px;
  transform: rotate(21deg);
  background: rgba(255,255,255,.10);
}

.anime-option.naruto span {
  background:
    linear-gradient(180deg, transparent 0 24%, rgba(0,0,0,.72) 100%),
    linear-gradient(135deg, #f57c00, #ffbd59 60%, #ff6d00);
}

.anime-option.onepiece span {
  background:
    linear-gradient(180deg, transparent 0 24%, rgba(0,0,0,.72) 100%),
    linear-gradient(135deg, #155fd0, #45b7ff 60%, #0a3d98);
}

.anime-option.dragonball span {
  background:
    linear-gradient(180deg, transparent 0 24%, rgba(0,0,0,.72) 100%),
    linear-gradient(135deg, #f04b2d, #ffb42d 60%, #dd251d);
}

.anime-option strong,
.anime-option small {
  position: relative;
  z-index: 2;
}

.anime-option strong {
  font-size: 24px;
  line-height: .95;
  text-shadow: 2px 2px 0 #000;
}

.anime-option small {
  margin-top: 4px;
  color: rgba(255,255,255,.80);
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: .04em;
}

.anime-option:hover span {
  transform: translate(-2px, -2px);
  filter: brightness(1.08);
}

.anime-option input:checked + span {
  transform: translate(-3px, -3px) rotate(-1deg);
  box-shadow:
    9px 9px 0 #09090c,
    0 0 0 4px var(--yellow);
}

.anime-option input:checked + span::before {
  opacity: .55;
}

.anime-option input:checked + span strong::before {
  content: "✓";
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-right: 8px;
  border-radius: 50%;
  color: #07070a;
  background: var(--yellow);
  border: 2px solid #07070a;
  font-size: 15px;
  vertical-align: 3px;
  text-shadow: none;
}

.actions,
.section-header,
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

button {
  position: relative;
  border: 3px solid #09090c;
  padding: 11px 18px;
  font-weight: 900;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: .035em;
  box-shadow: 5px 5px 0 #09090c;
  transition: transform .11s ease, box-shadow .11s ease, filter .11s ease;
}

button:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 #09090c;
  filter: brightness(1.05);
}

button:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #09090c;
}

button:disabled {
  opacity: .55;
  cursor: wait;
}

.primary {
  color: #0b0b0d;
  background:
    linear-gradient(135deg, #ffe56e 0 48%, #ffad20 48% 100%);
}

.primary::after {
  content: "→";
  margin-left: 12px;
  font-size: 20px;
}

.secondary {
  color: #fff;
  background: #2b2b34;
}

.status {
  min-height: 22px;
  margin: 14px 0 0;
  color: #bfc1cb;
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 650;
  font-size: 14px;
}

.status.error { color: #ff8f99; }
.status.ok { color: #7ee89b; }

.hidden {
  display: none !important;
}

.section-header {
  margin-bottom: 16px;
}

.section-header p,
.game-header p {
  margin: 6px 0 0;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns, 5), minmax(0, 1fr));
  gap: 8px;
}

.character-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 3px solid #08080b;
  background: #15151b;
  aspect-ratio: 3 / 4;
  box-shadow: 4px 4px 0 #08080b;
  contain: layout paint;
}

.character-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), transparent 18%),
    radial-gradient(circle at 80% 12%, rgba(255,255,255,.12), transparent 22%);
}

.character-card img {
  display: block;
  width: 100%;
  height: calc(100% - 34px);
  object-fit: cover;
  background: #1c1c24;
  filter: saturate(1.07) contrast(1.04);
}

.character-name {
  position: relative;
  z-index: 3;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px 5px;
  color: #fff;
  background:
    linear-gradient(90deg, #202028, #121217);
  border-top: 2px solid #09090c;
  text-align: center;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 10px;
  font-weight: 850;
  line-height: 1.03;
  overflow: hidden;
}

.character-card.eliminated {
  filter: none;
}

.character-card.eliminated img,
.character-card.eliminated .character-name {
  filter: grayscale(.82) brightness(.52);
}

.character-card.eliminated::after {
  content: "×";
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  color: #ff2f2f;
  font-family: Arial, sans-serif;
  font-size: clamp(76px, 8vw, 140px);
  font-weight: 1000;
  line-height: 1;
  text-shadow:
    4px 4px 0 #000,
    -2px -2px 0 #000;
  background:
    repeating-linear-gradient(
      -14deg,
      rgba(255,0,0,.05) 0 4px,
      transparent 4px 14px
    );
  pointer-events: none;
}

#editor {
  width: min(720px, 96vw);
  margin: 0 auto;
  padding: 18px;
}

#editor .section-header h2 {
  font-size: 22px;
}

#editor .section-header p {
  font-size: 13px;
}

#editor .primary {
  padding: 9px 12px;
  font-size: 12px;
}

.game-header {
  margin-bottom: 12px;
  padding: 18px 20px;
}


.players {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.player {
  padding: 18px;
}


.player-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.player-title h3 {
  margin: 0;
  color: #fff;
  font-size: 18px;
  letter-spacing: .05em;
}

.player-number {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 30px;
  color: #09090c;
  border: 3px solid #09090c;
  box-shadow: 3px 3px 0 #09090c;
  font-size: 13px;
}


.player .character-grid {
  gap: 6px;
}

.player .character-card {
  cursor: pointer;
}

.player .character-name {
  font-size: clamp(8px, .75vw, 11px);
}

@media (max-width: 1000px) {
  .players {
    grid-template-columns: 1fr;
  }

  .player .character-name {
    font-size: 10px;
  }
}

@media (max-width: 760px) {
  .anime-options {
    grid-template-columns: 1fr;
  }

  .anime-option span {
    min-height: 92px;
  }

  .hero-title-wrap {
    gap: 8px;
  }

  .hero-slash {
    display: none;
  }
}

@media (max-width: 650px) {
  .app {
    width: 96vw;
    padding-top: 16px;
  }

  .hero {
    padding: 22px 14px 18px;
  }

  .setup,
  .player,
  #editor,
  .game-header {
    padding: 14px;
  }

  .section-header,
  .game-header {
    align-items: stretch;
    flex-direction: column;
  }

  .character-grid {
    gap: 4px;
  }

  .character-card {
    border-width: 2px;
    box-shadow: 2px 2px 0 #08080b;
  }

  .character-card img {
    height: calc(100% - 30px);
  }

  .character-name {
    height: 30px;
    font-size: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}


/* Tipografía más legible manteniendo identidad manga */
.hero h1,
.section-copy h2,
.section-header h2,
.game-header h2,
.player-title h3,
.anime-option strong {
  font-family: "Arial Narrow", "Franklin Gothic Medium", "Segoe UI", Arial, sans-serif;
  font-stretch: condensed;
  font-weight: 700;
  letter-spacing: .015em;
}

.hero h1 {
  font-weight: 800;
  letter-spacing: -.015em;
  line-height: .92;
}

.hero-kicker,
.hero-tags span,
.panel-label,
button,
.player-number {
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 800;
}

button {
  letter-spacing: .025em;
}

.anime-option strong {
  font-size: 23px;
  line-height: 1;
}

.player-title h3 {
  font-weight: 750;
  letter-spacing: .04em;
}

.hero-slash {
  font-family: Arial, sans-serif;
  font-weight: 900;
}


/* Home, hover/reroll y tipografía japonesa */

/* Título clicable / volver al inicio */
.home-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.home-link:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 7px;
}

.home-link:hover h1 {
  filter: brightness(1.08);
}

.home-link:hover .hero-slash {
  transform: rotate(-10deg) translateX(-3px);
}

.home-link:hover .hero-slash.right {
  transform: rotate(10deg) translateX(3px);
}

/* Reggae One: estética japonesa/shonen, pero legible en caracteres latinos */
.hero h1,
.section-copy h2,
.section-header h2,
.game-header h2,
.player-title h3,
.anime-option strong,
.hero-kicker,
.panel-label,
button,
.player-number,
.hero-tags span {
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
  font-weight: 400;
}

.hero h1 {
  letter-spacing: .01em;
  line-height: .94;
}

.section-copy h2,
.section-header h2,
.game-header h2 {
  letter-spacing: .025em;
}

.anime-option strong {
  font-size: 21px;
  letter-spacing: .015em;
}

button {
  letter-spacing: .02em;
  line-height: 1.1;
}

.hero-kicker,
.panel-label,
.player-number,
.hero-tags span {
  letter-spacing: .07em;
}

/* El hover debe quedar POR ENCIMA de cartas y sombras vecinas */
.character-card.editor {
  z-index: 0;
  overflow: hidden;
  cursor: pointer;
  transition: transform .10s ease, box-shadow .10s ease, filter .10s ease;
}

.character-card.editor:hover,
.character-card.editor:focus-within {
  z-index: 20;
  transform: translate(-2px, -2px) rotate(-.6deg);
  box-shadow: 6px 6px 0 #08080b;
  outline: 3px solid var(--yellow);
  outline-offset: 1px;
  filter: brightness(1.06);
}

/* Feedback visual de reroll */
.reroll-badge {
  position: absolute;
  z-index: 8;
  top: 7px;
  right: 7px;
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  color: #0a0a0d;
  background: var(--yellow);
  border: 2px solid #08080b;
  border-radius: 50%;
  box-shadow: 2px 2px 0 #08080b;
  opacity: 0;
  transform: scale(.72) rotate(-35deg);
  transition:
    opacity .12s ease,
    transform .16s ease;
  pointer-events: none;
}

.reroll-badge svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.character-card.editor:hover .reroll-badge {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Pequeño oscurecido para que el icono destaque sin tapar la foto */
.character-card.editor:hover img {
  filter: saturate(1.08) contrast(1.04) brightness(.91);
}

@media (hover: none) {
  /* En móvil no existe hover: dejamos una pista discreta permanente. */
  .reroll-badge {
    opacity: .84;
    transform: scale(.82) rotate(0deg);
    top: 5px;
    right: 5px;
  }
}


/* Fix definitivo del amarillo en selector de animes */

/* La tarjeta bajo el ratón siempre queda por encima de sus vecinas. */
.anime-option:hover {
  z-index: 30;
}

/* Separamos completamente el amarillo de la sombra negra. */
.anime-option input:checked + span {
  z-index: 2;
  outline-offset: 1px;
}

/* También al hacer hover sobre una seleccionada mantenemos ambas capas limpias. */
.anime-option:hover input:checked + span {
  outline-offset: 1px;
}


/* Nuevos animes + hover amarillo del selector */

/* Hover visible SIEMPRE, esté seleccionada o no la tarjeta. */
.anime-option {
  position: relative;
  z-index: 0;
}

.anime-option:hover {
  z-index: 50;
}

.anime-option:hover span {
  position: relative;
  z-index: 2;
  outline: 4px solid var(--yellow);
  outline-offset: 2px;
  box-shadow: 8px 8px 0 #09090c;
}

/* Al estar seleccionada conserva el amarillo también sin hover. */
.anime-option input:checked + span {
  position: relative;
  z-index: 3;
  outline: 4px solid var(--yellow);
  outline-offset: 2px;
  box-shadow: 9px 9px 0 #09090c;
}

.anime-option:hover input:checked + span {
  outline: 4px solid var(--yellow);
  outline-offset: 2px;
  box-shadow: 9px 9px 0 #09090c;
}

/* Identidad visual de los nuevos universos */
.anime-option.deathnote span {
  background:
    linear-gradient(180deg, transparent 0 24%, rgba(0,0,0,.78) 100%),
    linear-gradient(135deg, #202127, #61646f 55%, #15161b);
}

.anime-option.demonslayer span {
  background:
    linear-gradient(180deg, transparent 0 24%, rgba(0,0,0,.74) 100%),
    linear-gradient(135deg, #194c3d, #39a070 54%, #132e28);
}

.anime-option.attackontitan span {
  background:
    linear-gradient(180deg, transparent 0 24%, rgba(0,0,0,.76) 100%),
    linear-gradient(135deg, #69402a, #b27346 52%, #313c32);
}

.anime-option.dandadan span {
  background:
    linear-gradient(180deg, transparent 0 24%, rgba(0,0,0,.72) 100%),
    linear-gradient(135deg, #7c2cff, #df4aff 52%, #2a78d7);
}

/* Con 7 opciones, aprovechamos un poco mejor el ancho en escritorio. */
@media (min-width: 1050px) {
  .setup {
    max-width: 1040px;
  }

  .anime-options {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}


/* Cuadrículas ligeramente más compactas */

/* Edición: un poco más estrecha y menos alta */
#editor {
  width: min(660px, 94vw);
}

#editor .character-grid {
  gap: 7px;
}

#editor .character-card img {
  height: calc(100% - 30px);
}

#editor .character-name {
  height: 30px;
  font-size: 9px;
}

/* Partida: reducimos un poco cada tablero sin cambiar la estructura */
.players {
  max-width: 1320px;
  margin: 0 auto;
}

.player {
  padding: 16px;
}

.player .character-grid {
  gap: 5px;
}

.player .character-card img {
  height: calc(100% - 31px);
}

.player .character-name {
  height: 31px;
  font-size: clamp(8px, .7vw, 10px);
}

@media (min-width: 1001px) {
  .players {
    grid-template-columns: repeat(2, minmax(0, 620px));
    justify-content: center;
  }
}

@media (max-width: 1000px) {
  #editor {
    width: min(630px, 95vw);
  }
}


/* Bleach */
.anime-option.bleach span {
  background:
    linear-gradient(180deg, transparent 0 24%, rgba(0,0,0,.76) 100%),
    linear-gradient(135deg, #15171d, #ececec 44%, #5ab7ff 72%, #0c2645);
}


/* selector de tamaño estable */
.grid-dimensions-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 2px 0 22px;
  padding: 14px 16px;
  border: 3px solid #09090c;
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,0)),
    #202028;
  box-shadow: 5px 5px 0 #09090c;
}

.grid-size-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.grid-size-copy strong {
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  font-weight: 400;
}

.grid-size-copy small {
  color: var(--muted);
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 650;
}

.grid-size-options {
  display: flex;
  gap: 8px;
}

.grid-size-option {
  position: relative;
  cursor: pointer;
}

.grid-size-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.grid-size-option span {
  display: grid;
  place-items: center;
  min-width: 54px;
  height: 38px;
  padding: 0 10px;
  border: 3px solid #09090c;
  color: #fff;
  background: #30303a;
  box-shadow: 3px 3px 0 #09090c;
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
  font-size: 12px;
  transition: transform .1s ease, box-shadow .1s ease;
}

.grid-size-option:hover span {
  outline: 2px solid var(--yellow);
  outline-offset: 1px;
  transform: translate(-1px, -1px);
}

.grid-size-option input:checked + span {
  color: #09090c;
  background: var(--yellow);
  outline: 3px solid var(--yellow);
  outline-offset: 1px;
  box-shadow: 4px 4px 0 #09090c;
}

.character-grid {
  --grid-columns: 5;
}


@media (max-width: 720px) {
  .grid-dimensions-selector {
    align-items: stretch;
    flex-direction: column;
  }

  .grid-size-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }

  .grid-size-option span {
    min-width: 0;
    width: 100%;
  }
}


/* Selector de jugadores 2-4 + tableros dinámicos */

.player-count-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 22px;
  padding: 14px 16px;
  border: 3px solid #09090c;
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,0)),
    #202028;
  box-shadow: 5px 5px 0 #09090c;
}

.player-count-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.player-count-copy strong {
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  font-weight: 400;
}

.player-count-copy small {
  color: var(--muted);
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 650;
}

.player-count-options {
  display: flex;
  gap: 8px;
}

.player-count-option {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.player-count-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.player-count-option span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 38px;
  color: #fff;
  border: 3px solid #09090c;
  background: #30303a;
  box-shadow: 3px 3px 0 #09090c;
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
  font-size: 12px;
  transition: transform .1s ease, box-shadow .1s ease;
}

.player-count-option:hover span {
  outline: 2px solid var(--yellow);
  outline-offset: 1px;
  transform: translate(-1px, -1px);
}

.player-count-option input:checked + span {
  color: #09090c;
  background: var(--yellow);
  outline: 3px solid var(--yellow);
  outline-offset: 1px;
  box-shadow: 4px 4px 0 #09090c;
}

/* Resumen P1 VS P2 ... */
.players-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
  margin: 16px 0;
}

.players-summary b {
  color: #fff;
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  transform: rotate(-5deg);
}

.player-summary-chip {
  display: inline-grid;
  place-items: center;
  min-width: 46px;
  height: 36px;
  padding: 0 9px;
  color: #09090c;
  border: 3px solid #09090c;
  box-shadow: 4px 4px 0 #09090c;
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
  font-size: 12px;
}

.player-summary-1 { background: var(--red); }
.player-summary-2 { background: var(--blue); }
.player-summary-3 { background: #65d36e; }
.player-summary-4 { background: #b26cff; }

/* Colores de jugador */
.player-1 {
  box-shadow:
    0 0 0 2px rgba(255,59,48,.18),
    var(--shadow);
}

.player-2 {
  box-shadow:
    0 0 0 2px rgba(52,168,255,.18),
    var(--shadow);
}

.player-3 {
  box-shadow:
    0 0 0 2px rgba(101,211,110,.18),
    var(--shadow);
}

.player-4 {
  box-shadow:
    0 0 0 2px rgba(178,108,255,.18),
    var(--shadow);
}

.player-1 .player-number { background: var(--red); }
.player-2 .player-number { background: var(--blue); }
.player-3 .player-number { background: #65d36e; }
.player-4 .player-number { background: #b26cff; }

/* Máximo dos rosters por fila: 3 jugadores se distribuyen 2 + 1. */
.players[data-player-count="2"],
.players[data-player-count="3"],
.players[data-player-count="4"] {
  max-width: 1260px;
  grid-template-columns: repeat(2, minmax(0, 600px));
  justify-content: center;
}

@media (max-width: 1000px) {
  .players[data-player-count="2"],
  .players[data-player-count="3"],
  .players[data-player-count="4"] {
    grid-template-columns: 1fr;
    max-width: 620px;
  }
}

@media (max-width: 720px) {
  .player-count-selector {
    align-items: stretch;
    flex-direction: column;
  }

  .player-count-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .player-count-option span {
    width: 100%;
  }
}


/* Cuadrícula compartida o diferente por jugador */

.grid-mode-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 22px;
  padding: 14px 16px;
  border: 3px solid #09090c;
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,0)),
    #202028;
  box-shadow: 5px 5px 0 #09090c;
}

.grid-mode-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.grid-mode-copy strong {
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  font-weight: 400;
}

.grid-mode-copy small {
  color: var(--muted);
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 650;
}

.grid-mode-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  min-width: 300px;
}

.grid-mode-option {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.grid-mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.grid-mode-option > span {
  display: flex;
  min-height: 54px;
  flex-direction: column;
  justify-content: center;
  padding: 7px 12px;
  color: #fff;
  border: 3px solid #09090c;
  background: #30303a;
  box-shadow: 3px 3px 0 #09090c;
  transition: transform .1s ease, box-shadow .1s ease;
}

.grid-mode-option > span strong {
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
  font-size: 11px;
  font-weight: 400;
}

.grid-mode-option > span small {
  margin-top: 2px;
  color: var(--muted);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 11px;
  font-weight: 650;
}

.grid-mode-option:hover > span {
  outline: 2px solid var(--yellow);
  outline-offset: 1px;
  transform: translate(-1px, -1px);
}

.grid-mode-option input:checked + span {
  color: #09090c;
  background: var(--yellow);
  outline: 3px solid var(--yellow);
  outline-offset: 1px;
  box-shadow: 4px 4px 0 #09090c;
}

.grid-mode-option input:checked + span small {
  color: #3b3000;
}

/* Editor dinámico */
.editor-boards {
  display: grid;
  gap: 18px;
  width: 100%;
  margin: 0 auto;
}

.editor-board {
  min-width: 0;
}

.editor-board-player {
  padding: 13px;
  border: 3px solid #09090c;
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,0)),
    #17171d;
  box-shadow: 6px 6px 0 #09090c;
}

.editor-player-title {
  margin-bottom: 10px;
}

/* Compartida: mantiene exactamente el tamaño compacto que ya gustaba */
#editor[data-grid-mode="shared"] {
  width: min(660px, 94vw);
}

#editor[data-grid-mode="shared"] .editor-boards {
  grid-template-columns: minmax(0, 1fr);
}

/* Diferentes: abrimos el editor para enseñar todos los rosters */
#editor[data-grid-mode="individual"] {
  width: min(1380px, 96vw);
}

#editor[data-grid-mode="individual"][data-player-count="2"] .editor-boards {
  grid-template-columns: repeat(2, minmax(0, 600px));
  justify-content: center;
}

#editor[data-grid-mode="individual"][data-player-count="3"] .editor-boards,
#editor[data-grid-mode="individual"][data-player-count="4"] .editor-boards {
  max-width: 1260px;
  grid-template-columns: repeat(2, minmax(0, 600px));
  justify-content: center;
}

/* Colores de jugador también durante edición */
.editor-board.player-1 {
  box-shadow: 6px 6px 0 #09090c, 0 0 0 2px rgba(255,59,48,.22);
}

.editor-board.player-2 {
  box-shadow: 6px 6px 0 #09090c, 0 0 0 2px rgba(52,168,255,.22);
}

.editor-board.player-3 {
  box-shadow: 6px 6px 0 #09090c, 0 0 0 2px rgba(101,211,110,.22);
}

.editor-board.player-4 {
  box-shadow: 6px 6px 0 #09090c, 0 0 0 2px rgba(178,108,255,.22);
}

@media (max-width: 1000px) {
  #editor[data-grid-mode="individual"][data-player-count="2"] .editor-boards,
  #editor[data-grid-mode="individual"][data-player-count="3"] .editor-boards,
  #editor[data-grid-mode="individual"][data-player-count="4"] .editor-boards {
    max-width: 620px;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .grid-mode-selector {
    align-items: stretch;
    flex-direction: column;
  }

  .grid-mode-options {
    min-width: 0;
  }
}


/* La X queda fuera del oscurecido de la carta */
.character-card.eliminated::after {
  color: #ff202a;
  opacity: 1;
  filter: none;
  text-shadow:
    4px 4px 0 #000,
    -2px -2px 0 #000,
    0 0 12px rgba(255, 32, 42, .42);
}


/* Cuadrículas rectangulares: columnas × filas */

.grid-dimensions-controls {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.grid-dimension-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.grid-dimension-group > small {
  color: var(--muted);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
}

.grid-dimension-x {
  display: grid;
  place-items: center;
  height: 38px;
  padding-bottom: 2px;
  color: var(--yellow);
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
  font-size: 22px;
  line-height: 1;
}

.grid-dimension-preview {
  display: flex;
  min-width: 112px;
  height: 48px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  border: 3px solid #09090c;
  background: var(--yellow);
  color: #09090c;
  box-shadow: 4px 4px 0 #09090c;
}

.grid-dimension-preview strong {
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
}

.grid-dimension-preview small {
  margin-top: 3px;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .05em;
}

/* El tamaño visual de texto depende de las COLUMNAS, no de las filas. */
.character-grid[data-grid-columns="3"] .character-name {
  height: 36px;
  font-size: 13px;
}

.character-grid[data-grid-columns="3"] .character-card img {
  height: calc(100% - 36px);
}

.character-grid[data-grid-columns="4"] .character-name {
  height: 33px;
  font-size: 11px;
}

.character-grid[data-grid-columns="4"] .character-card img {
  height: calc(100% - 33px);
}

.character-grid[data-grid-columns="5"] .character-name {
  font-size: 9px;
}

.character-grid[data-grid-columns="6"] .character-name {
  height: 27px;
  padding: 2px 3px;
  font-size: 8px;
}

.character-grid[data-grid-columns="6"] .character-card img {
  height: calc(100% - 27px);
}

@media (max-width: 820px) {
  .grid-dimensions-controls {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .grid-dimensions-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .grid-dimension-x {
    display: none;
  }

  .grid-dimension-preview {
    width: 100%;
    margin-left: 0;
  }

  .grid-dimension-group .grid-size-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }
}


/* Selección de personaje secreto */

.secret-selection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 12px;
  padding: 18px 20px;
}

.secret-selection-header h2 {
  margin: 0;
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
  font-size: 22px;
  font-weight: 400;
}

.secret-selection-header p {
  margin: 6px 0 0;
}

.secret-selection-status {
  width: fit-content;
  margin: 14px auto 18px;
  padding: 8px 13px;
  border: 3px solid #09090c;
  background: #24242c;
  box-shadow: 4px 4px 0 #09090c;
  color: var(--muted);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.secret-selection-status.ready {
  color: #09090c;
  background: var(--yellow);
}

.secret-selection-player {
  min-width: 0;
}

.secret-choice-zone,
.game-secret-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  margin: 2px 0 13px;
}

.secret-choice-label {
  color: var(--muted);
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
  font-size: 9px;
  font-weight: 400;
  letter-spacing: .08em;
}

.secret-card {
  position: relative;
  display: grid;
  width: 112px;
  aspect-ratio: 3 / 4;
  place-items: center;
  overflow: hidden;
  padding: 0;
  border: 4px solid #09090c;
  background:
    repeating-linear-gradient(
      -45deg,
      #24242d 0 9px,
      #1a1a21 9px 18px
    );
  box-shadow: 6px 6px 0 #09090c;
  color: var(--yellow);
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
}

.secret-card:not(:disabled) {
  cursor: pointer;
}

.secret-card:not(:disabled):hover {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
  transform: translate(-1px, -1px);
}

.secret-card.empty {
  opacity: .65;
}

.secret-card-question {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border: 4px solid var(--yellow);
  border-radius: 50%;
  background: #111116;
  box-shadow: 4px 4px 0 #09090c;
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
  font-size: 38px;
  line-height: 1;
}

.secret-card-copy {
  position: absolute;
  right: 4px;
  bottom: 5px;
  left: 4px;
  padding: 4px 2px;
  border-top: 2px solid #09090c;
  background: rgba(9,9,12,.88);
  color: #fff;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .04em;
  text-align: center;
}

.secret-card.revealed {
  display: block;
  background: #15151b;
  color: #fff;
}

.secret-card.revealed img {
  display: block;
  width: 100%;
  height: calc(100% - 28px);
  object-fit: cover;
}

.secret-card-name {
  display: flex;
  height: 28px;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  border-top: 2px solid #09090c;
  background: linear-gradient(90deg, #202028, #121217);
  color: #fff;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.secret-player-hint {
  min-height: 30px;
  margin: 0 0 10px;
  color: var(--muted);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

.character-card.secret-select-card {
  cursor: pointer;
  transition: transform .10s ease, box-shadow .10s ease, filter .10s ease;
}

.character-card.secret-select-card:hover {
  transform: translate(-2px, -2px);
  box-shadow:
    6px 6px 0 #08080b,
    0 0 0 3px var(--yellow);
  filter: brightness(1.08);
}

.game-secret-area {
  padding: 8px 0 15px;
  border-bottom: 2px solid rgba(255,255,255,.08);
  margin-bottom: 13px;
}

.game-secret-area .secret-card {
  width: 102px;
}

#startGameBtn:disabled {
  cursor: not-allowed;
  opacity: .42;
  filter: grayscale(.55);
}

@media (max-width: 760px) {
  .secret-selection-header {
    align-items: stretch;
    flex-direction: column;
  }

  .secret-selection-header .primary {
    width: 100%;
  }

  .secret-card {
    width: 100px;
  }
}


/* Mejor feedback de selección secreta */

.secret-card-wrap {
  position: relative;
  display: inline-block;
  border-radius: 2px;
}

.secret-card-wrap.has-selection {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.secret-selected-check {
  position: absolute;
  top: -11px;
  right: -11px;
  z-index: 8;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 3px solid #09090c;
  border-radius: 50%;
  background: #2ee66b;
  color: #09090c;
  box-shadow: 3px 3px 0 #09090c;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 18px;
  font-weight: 1000;
  line-height: 1;
}

.secret-selection-player .secret-card {
  cursor: pointer;
}

.secret-selection-player .secret-card:disabled {
  cursor: default;
}

.secret-selection-player .secret-card:not(:disabled):hover {
  position: relative;
  z-index: 40;
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
  box-shadow: 8px 8px 0 #09090c;
}

.secret-selection-feedback {
  min-height: 24px;
  margin: -3px 0 8px;
  color: #2ee66b;
  font-family: "Reggae One", "Segoe UI", Arial, sans-serif;
  font-size: 10px;
  font-weight: 400;
  text-align: center;
}

.secret-selection-player.selection-confirm .secret-card-wrap.has-selection {
  animation: secret-confirm-pop .34s ease-out;
}

@keyframes secret-confirm-pop {
  0% {
    transform: scale(.96);
  }
  55% {
    transform: scale(1.035);
  }
  100% {
    transform: scale(1);
  }
}

/* En la cuadrícula de selección, el outline debe quedar por encima
   de la sombra negra y de las cartas vecinas. */
.secret-character-grid .character-card {
  position: relative;
  z-index: 0;
}

.secret-character-grid .character-card:hover {
  z-index: 50;
  outline: 4px solid var(--yellow);
  outline-offset: 2px;
  box-shadow: 7px 7px 0 #09090c;
}

@media (prefers-reduced-motion: reduce) {
  .secret-selection-player.selection-confirm .secret-card-wrap.has-selection {
    animation: none;
  }
}


/* Enfocar la fase activa sin volver a la cabecera */
#setup,
#editor,
#secretSelection,
#game {
  scroll-margin-top: 16px;
}


/* Acciones duplicadas al final de cada fase */

.section-bottom-action {
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 24px auto 4px;
  padding: 18px 14px 4px;
  border-top: 3px solid rgba(255,255,255,.10);
}

.section-bottom-action .primary,
.section-bottom-action .secondary {
  min-width: min(320px, 100%);
}

#secretSelection .section-bottom-action,
#game .section-bottom-action {
  max-width: 1260px;
}

#startGameBtnBottom:disabled {
  cursor: not-allowed;
  opacity: .42;
  filter: grayscale(.55);
}

@media (max-width: 720px) {
  .section-bottom-action {
    padding-right: 0;
    padding-left: 0;
  }

  .section-bottom-action .primary,
  .section-bottom-action .secondary {
    width: 100%;
  }
}

/* Selector de modos */
.game-mode-heading { margin-top: 32px; }
.game-mode-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin: 22px 0; }
.game-mode-button {
  display: flex; align-items: center; gap: 16px; min-width: 0; padding: 22px 18px;
  border: 3px solid var(--ink); background: var(--panel-2); color: var(--text);
  box-shadow: 6px 6px 0 var(--ink); text-align: left; cursor: pointer;
}
.game-mode-button strong { display: block; font: 16px "Reggae One", sans-serif; }
.game-mode-button small { display: block; margin-top: 8px; color: var(--muted); line-height: 1.5; }
.mode-symbol { flex-shrink: 0; font: 36px "Reggae One", sans-serif; color: var(--yellow); }
.mode-chevron { margin-left: auto; font-size: 24px; }
.game-mode-button[aria-expanded="true"] { outline: 3px solid var(--yellow); outline-offset: 0; background: #302b20; }
.game-mode-button[aria-expanded="true"] .mode-chevron { transform: rotate(180deg); }
.game-mode-button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.mode-options-panel { border-top: 1px solid var(--line); padding-top: 12px; }

@media (max-width: 700px) {
  .game-mode-options { grid-template-columns: 1fr; }
  .game-mode-button { padding: 18px 14px; }
}


/* Marca y ayuda de cada modo. */
.hero h1 { font-size: clamp(30px, 5.8vw, 76px); }
.game-help { margin: 14px 0 20px; border: 1px solid var(--line); border-left: 3px solid var(--orange); background: var(--panel); }
.game-help summary { padding: 12px 16px; cursor: pointer; color: var(--yellow); font-size: 14px; font-weight: 700; line-height: 1.5; }
.game-help summary:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }
.game-help-content { padding: 0 20px 18px; max-width: 90ch; line-height: 1.65; color: #d2d0d5; }
.game-help-content h3 { margin: 4px 0; color: var(--text); font-size: 20px; }
.game-help-count { margin: 4px 0 12px; font-weight: 700; }
.game-help-content ul { padding-left: 24px; }
.game-help-step { margin: 22px 0 8px; color: var(--yellow); font-size: 14px; line-height: 1.5; }
.game-help-content li + li { margin-top: 10px; }
.game-help-note { border-top: 1px solid var(--line); padding-top: 12px; margin-bottom: 0; }
@media (max-width: 480px) {
  .hero-title-wrap { gap: 6px; }
  .hero-slash { display: none; }
  .hero h1 { font-size: clamp(26px, 8vw, 38px); }
  .hero-kicker { font-size: 10px; letter-spacing: .04em; }
  .game-help-content { padding: 0 14px 14px; }
}

/* v6.50: la carta completa sigue siendo el botón; el icono solo es una pista. */
@media (max-width: 700px) {
  #editor .character-card.editor .reroll-badge {
    top: 2px;
    right: 2px;
    width: clamp(12px, 28%, 18px);
    height: auto;
    aspect-ratio: 1;
    border-width: 1px;
    box-shadow: none;
    opacity: .85;
    transform: none;
  }
  #editor .reroll-badge svg { width: 65%; height: 65%; }
}
