.puzzle-symbols {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.puzzle-journey-room {
  --world-tone: #3f7f9d;
  --board-height-reserve: 150px;
  position: relative;
}

.puzzle-journey-title {
  margin-bottom: 1rem;
}

.puzzle-actions svg {
  width: 18px;
  height: 18px;
}

.workspace-page .puzzle-journey-layout {
  display: grid;
  grid-template-columns: minmax(575px, 1.8fr) minmax(215px, .65fr) minmax(290px, .9fr);
  grid-template-areas:
    "board controls route"
    "board daily route";
  align-items: start;
  gap: .85rem;
}

.puzzle-journey-room .puzzle-board-stage {
  grid-area: board;
  min-width: 0;
  width: min(100%, calc(100dvh - var(--board-height-reserve)));
  justify-self: start;
}

.puzzle-quest-card {
  grid-area: controls;
  overflow: visible;
}

.puzzle-daily-card {
  grid-area: daily;
  padding: 1rem !important;
}

.puzzle-route-card {
  grid-area: route;
  min-width: 0;
  max-height: none;
  padding: 1.1rem !important;
  overflow: visible;
  border-color: color-mix(in srgb, var(--world-tone) 28%, var(--theme-border));
}

.puzzle-quest-card .puzzle-card-topline {
  display: grid;
  grid-template-columns: auto 1fr auto;
}

.puzzle-difficulty-badge {
  padding: .28rem .48rem;
  color: var(--theme-text);
  font-size: .7rem;
  font-weight: 800;
  background: var(--theme-surface-alt);
  border: 1px solid var(--theme-border);
  border-radius: 7px;
}

.puzzle-reward-preview {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .5rem;
  margin: .15rem 0 .8rem;
  color: var(--theme-text-muted);
  font-size: .77rem;
}

.puzzle-reward-preview > span {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}

.puzzle-reward-preview svg {
  width: 15px;
  height: 15px;
  color: var(--theme-gold);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.puzzle-result-panel {
  margin: .8rem 0;
  padding: .85rem;
  background: color-mix(in srgb, var(--puzzle-positive) 13%, var(--theme-surface));
  border: 1px solid color-mix(in srgb, var(--puzzle-positive) 35%, var(--theme-border));
  border-radius: 13px;
}

.puzzle-result-panel[hidden],
.puzzle-next-action[hidden],
.puzzle-action-row[hidden] {
  display: none !important;
}

.puzzle-result-heading {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .65rem;
}

.puzzle-result-check {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--theme-surface);
  background: var(--puzzle-positive);
  border-radius: 50%;
}

.puzzle-result-check svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
}

.puzzle-result-heading > div {
  display: flex;
  flex-direction: column;
  gap: .1rem;
}

.puzzle-result-heading span {
  color: var(--theme-text-muted);
  font-size: .72rem;
  font-weight: 750;
}

.puzzle-result-total {
  color: var(--puzzle-positive) !important;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.puzzle-bonus-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .35rem;
  margin: .75rem 0 0;
}

.puzzle-bonus-list > div {
  min-width: 0;
  padding-top: .5rem;
  border-top: 1px solid color-mix(in srgb, var(--theme-border) 70%, transparent);
}

.puzzle-bonus-list dt {
  overflow: hidden;
  color: var(--theme-text-muted);
  font-size: .62rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.puzzle-bonus-list dd {
  margin: .12rem 0 0;
  color: var(--theme-text);
  font-size: .78rem;
  font-weight: 800;
}

.puzzle-result-note {
  margin: .65rem 0 0;
  color: var(--theme-text-muted);
  font-size: .72rem;
}

.puzzle-action-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem;
}

.puzzle-action-row .btn {
  min-width: 0;
}

.puzzle-route-jump {
  display: none;
}

.puzzle-next-action {
  background: var(--puzzle-positive);
  border-color: color-mix(in srgb, var(--puzzle-positive) 75%, var(--theme-border));
}

.puzzle-route-header,
.puzzle-section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: .65rem;
}

.puzzle-route-header h2 {
  margin: .1rem 0 0;
  font-family: "DM Serif Display", Georgia, serif;
  font-size: 1.6rem;
}

.puzzle-route-stage,
.puzzle-mission-reward {
  flex: 0 0 auto;
  padding: .3rem .5rem;
  color: color-mix(in srgb, var(--world-tone) 70%, var(--theme-text));
  font-size: .7rem;
  font-weight: 850;
  background: color-mix(in srgb, var(--world-tone) 13%, var(--theme-surface));
  border: 1px solid color-mix(in srgb, var(--world-tone) 28%, var(--theme-border));
  border-radius: 7px;
}

.puzzle-route-intro {
  margin: .55rem 0 .35rem;
  color: var(--theme-text-muted);
  font-size: .76rem;
  line-height: 1.45;
}

.puzzle-route {
  margin: 0;
  padding: .25rem 0 .6rem;
  list-style: none;
}

.puzzle-route-node {
  position: relative;
  height: 88px;
}

.puzzle-route-connector {
  position: absolute;
  z-index: 0;
  inset: -47px 0 auto;
  width: 100%;
  height: 94px;
  overflow: visible;
}

.puzzle-route-connector path {
  fill: none;
  stroke: color-mix(in srgb, var(--theme-border) 82%, transparent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 5 6;
}

.puzzle-route-node.is-completed .puzzle-route-connector path,
.puzzle-route-node.is-current .puzzle-route-connector path {
  stroke: color-mix(in srgb, var(--node-tone) 68%, var(--theme-border));
  stroke-dasharray: none;
}

.puzzle-route-node-shell {
  position: absolute;
  z-index: 1;
  top: 50%;
  display: flex;
  align-items: center;
  gap: .55rem;
  width: min(72%, 210px);
  transform: translateY(-50%);
}

.puzzle-route-node.lane-left .puzzle-route-node-shell {
  left: 5%;
}

.puzzle-route-node.lane-right .puzzle-route-node-shell {
  right: 5%;
  flex-direction: row-reverse;
  text-align: right;
}

.puzzle-route-medallion {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 58px;
  height: 58px;
  color: color-mix(in srgb, var(--node-tone) 76%, var(--theme-text));
  background: color-mix(in srgb, var(--node-tone) 12%, var(--theme-surface-alt));
  border: 2px solid color-mix(in srgb, var(--node-tone) 38%, var(--theme-border));
  border-radius: 50%;
  box-shadow: 0 5px 14px color-mix(in srgb, #000 16%, transparent);
}

.puzzle-route-medallion svg {
  width: 29px;
  height: 29px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.puzzle-route-node.is-current .puzzle-route-medallion {
  color: var(--theme-surface);
  background: color-mix(in srgb, var(--node-tone) 84%, var(--theme-text));
  border-color: color-mix(in srgb, var(--node-tone) 85%, var(--theme-text));
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--node-tone) 18%, transparent);
}

.puzzle-route-node.is-completed .puzzle-route-medallion {
  color: var(--theme-surface);
  background: color-mix(in srgb, var(--node-tone) 65%, var(--theme-text));
}

.puzzle-route-node.is-locked {
  opacity: .62;
}

.puzzle-route-node.is-portal {
  height: 102px;
}

.puzzle-route-node.is-portal .puzzle-route-medallion {
  width: 62px;
  height: 62px;
  border-radius: 18px;
}

.puzzle-route-node.is-portal .puzzle-route-medallion svg {
  width: 36px;
  height: 36px;
}

.puzzle-route-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: .06rem;
}

.puzzle-route-state {
  color: color-mix(in srgb, var(--node-tone) 72%, var(--theme-text));
  font-size: .59rem;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.puzzle-route-copy strong {
  overflow: hidden;
  color: var(--theme-text);
  font-family: "DM Serif Display", Georgia, serif;
  font-size: 1.03rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.puzzle-route-copy small {
  color: var(--theme-text-muted);
  font-size: .68rem;
  font-variant-numeric: tabular-nums;
}

.puzzle-daily-card .card-title {
  font-size: 1rem;
}

.puzzle-mission-reward {
  color: color-mix(in srgb, var(--theme-gold) 75%, var(--theme-text));
  background: color-mix(in srgb, var(--theme-gold) 13%, var(--theme-surface));
  border-color: transparent;
}

.puzzle-daily-card > p {
  margin: .55rem 0;
  color: var(--theme-text-muted);
  font-size: .78rem;
}

.puzzle-mission-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.puzzle-mission-pips {
  display: flex;
  align-items: center;
  flex: 1;
}

.puzzle-mission-pips span {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--theme-text-muted);
  font-size: .72rem;
  font-weight: 850;
  background: var(--theme-surface-alt);
  border: 1px solid var(--theme-border);
  border-radius: 50%;
}

.puzzle-mission-pips span:not(:last-child) {
  margin-right: 24px;
}

.puzzle-mission-pips span:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 100%;
  width: 25px;
  height: 2px;
  background: var(--theme-border);
}

.puzzle-mission-pips span.is-complete {
  color: var(--theme-surface);
  background: var(--puzzle-positive);
  border-color: var(--puzzle-positive);
}

.puzzle-mission-pips svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}

.puzzle-mission-progress > strong,
.puzzle-session-stats strong {
  color: var(--theme-text);
  font-variant-numeric: tabular-nums;
}

.puzzle-session-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .35rem;
  margin-top: .8rem;
}

.puzzle-session-stats span {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  padding: .45rem;
  color: var(--theme-text-muted);
  font-size: .63rem;
  background: var(--theme-surface-alt);
  border: 1px solid var(--theme-border);
  border-radius: 8px;
}

.puzzle-save-note {
  padding-top: .65rem;
  border-top: 1px solid var(--theme-border);
}

.puzzle-save-note a {
  color: var(--theme-link);
  font-weight: 750;
}

.puzzle-promotion-dialog {
  position: relative;
  width: min(430px, calc(100vw - 2rem));
  padding: 2rem;
  overflow: hidden;
  color: var(--theme-text);
  text-align: center;
  background: var(--theme-surface);
  border: 1px solid var(--theme-border);
  border-radius: 24px;
  box-shadow: 0 26px 80px color-mix(in srgb, #000 35%, transparent);
}

.puzzle-promotion-dialog::backdrop {
  background: color-mix(in srgb, #101817 70%, transparent);
  backdrop-filter: blur(5px);
}

.puzzle-promotion-dialog h2 {
  margin: .15rem 0 .25rem;
  font-family: "DM Serif Display", Georgia, serif;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
}

.puzzle-promotion-dialog > p:not(.workspace-kicker) {
  margin: 0;
  color: var(--theme-text-muted);
}

.puzzle-promotion-emblem {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  margin: 0 auto 1rem;
  color: var(--world-tone);
  background: color-mix(in srgb, var(--world-tone) 14%, var(--theme-surface));
  border: 1px solid color-mix(in srgb, var(--world-tone) 42%, var(--theme-border));
  border-radius: 28px;
}

.puzzle-promotion-emblem svg {
  width: 56px;
  height: 56px;
}

.puzzle-promotion-dialog .btn {
  min-height: 46px;
  margin-top: 1.25rem;
}

.puzzle-promotion-dialog[open] {
  animation: puzzle-promotion-in .32s cubic-bezier(.2, .9, .3, 1.15);
}

@keyframes puzzle-promotion-in {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (min-width: 1161px) {
  .puzzle-journey-title {
    min-height: 0;
    margin-bottom: .5rem;
  }

  .puzzle-journey-title .puzzle-page-lead {
    display: none;
  }

  .puzzle-journey-title .puzzle-heading-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

  .puzzle-journey-title h1 {
    font-size: clamp(1.7rem, 2.2vw, 2.2rem);
  }

}

@media (max-width: 1260px) {
  .workspace-page .puzzle-journey-layout {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    grid-template-areas:
      "board controls"
      "route daily";
  }

  .puzzle-route-card {
    max-height: none;
    overflow: visible;
  }

  .puzzle-route {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .5rem;
    padding-top: .75rem;
  }

  .puzzle-route-node,
  .puzzle-route-node.is-portal {
    height: 82px;
  }

  .puzzle-route-connector {
    display: none;
  }

  .puzzle-route-node-shell,
  .puzzle-route-node.lane-left .puzzle-route-node-shell,
  .puzzle-route-node.lane-right .puzzle-route-node-shell {
    position: static;
    width: 100%;
    height: 100%;
    padding: .45rem;
    flex-direction: row;
    text-align: left;
    background: color-mix(in srgb, var(--theme-surface-alt) 72%, transparent);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    transform: none;
  }

  .puzzle-route-medallion,
  .puzzle-route-node.is-portal .puzzle-route-medallion {
    width: 48px;
    height: 48px;
    border-radius: 50%;
  }
}

@media (max-width: 1100px) {
  .workspace-page .puzzle-journey-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "board"
      "controls"
      "route"
      "daily";
  }
}

@media (max-width: 900px) {
  .puzzle-route {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .puzzle-bonus-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .puzzle-journey-title {
    grid-template-columns: auto 1fr;
  }

  .puzzle-journey-title .puzzle-availability {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .puzzle-route {
    display: block;
    padding-left: .2rem;
  }

  .puzzle-route-node,
  .puzzle-route-node.is-portal {
    height: 88px;
  }

  .puzzle-route-node-shell,
  .puzzle-route-node.lane-left .puzzle-route-node-shell,
  .puzzle-route-node.lane-right .puzzle-route-node-shell {
    position: absolute;
    width: min(76%, 250px);
    height: auto;
    padding: .4rem;
    transform: translateY(-50%);
  }

  .puzzle-route-node.lane-left .puzzle-route-node-shell {
    right: auto;
    left: 2%;
  }

  .puzzle-route-node.lane-right .puzzle-route-node-shell {
    right: 2%;
    left: auto;
    flex-direction: row-reverse;
    text-align: right;
  }

  .puzzle-route-connector {
    display: block;
    inset: -44px 0 auto;
    height: 88px;
  }

  .puzzle-route-medallion,
  .puzzle-route-node.is-portal .puzzle-route-medallion {
    width: 48px;
    height: 48px;
  }

  .puzzle-result-heading {
    grid-template-columns: auto 1fr;
  }

  .puzzle-result-total {
    grid-column: 2;
  }

  .puzzle-bonus-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .puzzle-action-row {
    grid-template-columns: 1fr 1fr;
  }

  .puzzle-route-jump {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    margin-top: .7rem;
    padding: .55rem .7rem;
    color: var(--theme-accent-text);
    font-size: .78rem;
    font-weight: 800;
    text-decoration: none;
    background: color-mix(in srgb, var(--theme-accent) 10%, var(--theme-surface-alt));
    border: 1px solid color-mix(in srgb, var(--theme-accent) 28%, var(--theme-border));
    border-radius: 10px;
  }

  .puzzle-route-jump svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
  }
}

/* En teléfono apaisado el límite decisivo es la altura, no el ancho. Esta
   regla vive junto al componente porque puzzle_journey.css se carga después
   de la escala compartida de main.css. */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 520px) {
  .puzzle-workspace .puzzle-game-layout,
  .custom-trainer-room .custom-training-layout,
  .custom-study-layout {
    width: min(100%, calc(100dvh - 88px));
    margin-inline: auto;
  }

  .puzzle-workspace .board-col,
  .puzzle-board-stage,
  .custom-trainer-room .custom-training-board,
  .custom-study-layout .puzzle-board-stage {
    width: min(100%, calc(100dvh - 88px));
    max-width: calc(100dvh - 88px);
    justify-self: center;
  }
}

/* Problemas personalizados: una mesa de trabajo compacta. La configuración
   conserva los filtros reales del servidor; al iniciar, el tablero queda a la
   izquierda y los controles de resolución a la derecha. */
.custom-trainer-room {
  --custom-board-size: min(690px, calc(100dvh - 182px), calc(100vw - 29rem));
  width: min(100%, 1220px);
  margin-inline: auto;
}

.custom-trainer-room .puzzle-page-header,
.custom-trainer-room .puzzle-mode-nav,
.custom-trainer-room .custom-config-card,
.custom-trainer-room .custom-empty-state,
.custom-trainer-room .custom-training {
  width: 100%;
}

.custom-trainer-room .custom-config-card {
  max-width: 980px;
  margin: .75rem auto 0;
}

.custom-trainer-room .custom-training-layout {
  grid-template-columns: minmax(0, var(--custom-board-size)) minmax(18rem, 22rem);
  gap: clamp(1rem, 2vw, 1.5rem);
  align-items: center;
  justify-content: start;
}

.custom-trainer-room .custom-training-board {
  width: min(100%, var(--custom-board-size));
}

.custom-trainer-room .custom-training-board .puzzle-board-frame,
.custom-trainer-room .custom-training-board .cg-wrap {
  width: 100%;
  aspect-ratio: 1;
}

.custom-trainer-room .custom-training-board .cg-wrap {
  overflow: visible;
}

.custom-trainer-room .custom-training-board cg-board {
  overflow: hidden;
}

.custom-trainer-room .custom-training-panel {
  display: grid;
  gap: .8rem;
  padding: clamp(1rem, 2vw, 1.35rem);
  background: var(--theme-surface);
  border: 1px solid var(--theme-border);
  border-radius: 18px;
  box-shadow: var(--theme-shadow-sm);
}

.custom-trainer-room .custom-training-meta {
  padding-bottom: .7rem;
}

.custom-trainer-room .custom-training-status {
  min-height: 0;
  margin: 0;
  padding: .85rem .9rem;
  font-size: .95rem;
}

.custom-trainer-room .custom-active-themes,
.custom-trainer-room .custom-solution-line {
  margin-top: 0;
}

.custom-trainer-room .custom-training-actions {
  gap: .55rem;
}

.custom-trainer-room .custom-training-actions .btn {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
}

.custom-trainer-room .custom-training-actions [data-custom-next],
.custom-trainer-room .custom-training-actions [data-custom-copy-fen] {
  grid-column: 1 / -1;
}

.custom-study-layout {
  grid-template-columns: minmax(0, min(690px, calc(100dvh - 200px))) minmax(18rem, 22rem);
  align-items: start;
  justify-content: center;
}

.custom-study-layout .puzzle-board-stage {
  width: min(100%, min(690px, calc(100dvh - 200px)));
}

.custom-study-rail {
  display: grid;
  gap: .8rem;
}

.custom-study-rail .card {
  margin: 0;
}

@media (max-width: 1100px), (max-height: 760px) {
  .custom-trainer-room {
    --custom-board-size: min(700px, calc(100vw - 3rem));
  }

  .custom-trainer-room .custom-training-layout,
  .custom-study-layout {
    grid-template-columns: minmax(0, var(--custom-board-size));
  }

  .custom-trainer-room .custom-training-panel,
  .custom-study-rail,
  .custom-study-layout .puzzle-board-stage {
    width: min(100%, var(--custom-board-size));
  }
}

@media (max-width: 560px) {
  .custom-trainer-room {
    --custom-board-size: calc(100vw - 1.5rem);
  }

  .custom-trainer-room .custom-training-layout {
    gap: .85rem;
  }

  .custom-trainer-room .custom-training-panel {
    padding: .9rem;
    border-radius: 14px;
  }

  .custom-trainer-room .custom-training-actions {
    grid-template-columns: 1fr;
  }

  .custom-trainer-room .custom-training-actions [data-custom-next],
  .custom-trainer-room .custom-training-actions [data-custom-copy-fen] {
    grid-column: auto;
  }
}

/* Ajuste final: estas reglas van al final porque los estilos heredados del
   antiguo entrenador se declaraban después de su primera versión. */
@media (min-width: 1101px) and (min-height: 761px) {
  .custom-trainer-room:not(.is-training-active) {
    --custom-board-size: min(690px, calc(100dvh - 182px), calc(100vw - 29rem));
  }

  .custom-trainer-room.is-training-active {
    --custom-board-size: min(690px, calc(100dvh - 142px), calc(100vw - 29rem));
  }

  .custom-trainer-room .custom-training-layout {
    grid-template-columns: minmax(0, var(--custom-board-size)) minmax(18rem, 22rem);
    gap: clamp(1rem, 2vw, 1.5rem);
  }

  .custom-trainer-room .custom-training-panel {
    display: grid;
    gap: .8rem;
    padding: clamp(1rem, 2vw, 1.35rem);
    border-radius: 18px;
  }
}

@media (max-width: 1100px), (max-height: 760px) {
  .custom-trainer-room {
    --custom-board-size: min(700px, calc(100vw - 3rem));
  }

  .custom-trainer-room .custom-training-layout,
  .custom-study-layout {
    grid-template-columns: minmax(0, var(--custom-board-size));
  }
}

@media (max-width: 560px) {
  .custom-trainer-room .custom-training-actions {
    grid-template-columns: 1fr;
  }

  .custom-trainer-room .custom-training-actions [data-custom-next],
  .custom-trainer-room .custom-training-actions [data-custom-copy-fen] {
    grid-column: auto;
  }
}

/* Camino táctico ilustrado v2. El arte es estático; toda la progresión,
   numeración, estados y avatar permanecen como HTML accesible. */
.puzzle-journey-room .puzzle-journey-layout {
  grid-template-columns: minmax(540px, 1.55fr) minmax(220px, .62fr) minmax(350px, 1fr);
  gap: .75rem;
}

.puzzle-journey-room .puzzle-route-card {
  height: min(760px, calc(100dvh - 142px));
  min-height: 580px;
  padding: 0 !important;
  overflow: hidden;
  background: color-mix(in srgb, var(--theme-surface) 94%, var(--world-tone));
  border-color: color-mix(in srgb, var(--world-tone) 42%, var(--theme-border));
  box-shadow: 0 16px 34px color-mix(in srgb, var(--theme-shadow) 82%, transparent);
}

.puzzle-journey-room .puzzle-route-header {
  position: relative;
  z-index: 8;
  min-height: 78px;
  padding: .85rem .9rem .75rem;
  align-items: center;
  background: color-mix(in srgb, var(--theme-surface) 94%, transparent);
  border-bottom: 1px solid var(--theme-border);
  backdrop-filter: blur(14px);
}

.puzzle-journey-room .puzzle-route-header h2 {
  max-width: 15rem;
  font-size: clamp(1.28rem, 1.8vw, 1.7rem);
  line-height: 1.05;
}

.puzzle-route-header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .35rem;
}

.puzzle-route-stage {
  white-space: nowrap;
}

.puzzle-route-home {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: .35rem;
  padding: .45rem .6rem;
  color: var(--theme-accent-text);
  font: inherit;
  font-size: .68rem;
  font-weight: 850;
  background: var(--theme-accent-soft);
  border: 1px solid color-mix(in srgb, var(--theme-accent) 35%, var(--theme-border));
  border-radius: 9px;
  cursor: pointer;
}

.puzzle-route-home svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* En la columna del mapa el icono conserva el área táctil sin comprimir el título. */
.puzzle-route-home span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.puzzle-route-home {
  width: 44px;
  justify-content: center;
  padding: 0;
}

.puzzle-route-home:hover {
  background: color-mix(in srgb, var(--theme-accent) 18%, var(--theme-surface));
}

.puzzle-route-home:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--theme-accent) 52%, transparent);
  outline-offset: 2px;
}

.puzzle-map-viewport {
  height: calc(100% - 78px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: color-mix(in srgb, var(--world-tone) 64%, var(--theme-border)) transparent;
  scrollbar-width: thin;
}

.puzzle-map {
  width: 100%;
  background: #071521;
}

.puzzle-map-world {
  position: relative;
  width: 100%;
  aspect-ratio: 793 / 1983;
  isolation: isolate;
  content-visibility: auto;
  contain-intrinsic-size: auto 875px;
}

.puzzle-map-world::after {
  position: absolute;
  z-index: 1;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--theme-surface) 7%, transparent),
    transparent 12% 88%,
    color-mix(in srgb, var(--theme-surface) 7%, transparent)
  );
}

.puzzle-map-world.is-current-world {
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--theme-gold) 75%, white);
}

.puzzle-map-art {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.puzzle-map-world-name {
  position: absolute;
  z-index: 4;
  top: 2.3%;
  left: 50%;
  max-width: 84%;
  margin: 0;
  padding: .45rem .7rem;
  color: #f7f1e3;
  font-family: "DM Serif Display", Georgia, serif;
  font-size: clamp(1rem, 1.55vw, 1.35rem);
  line-height: 1.05;
  text-align: center;
  text-wrap: balance;
  background: color-mix(in srgb, #071521 82%, transparent);
  border: 1px solid color-mix(in srgb, var(--node-tone) 55%, #f1ede1);
  border-radius: 12px;
  box-shadow: 0 8px 24px #0008;
  transform: translateX(-50%);
  backdrop-filter: blur(7px);
}

.puzzle-route-world {
  position: absolute;
  z-index: 3;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.puzzle-journey-room .puzzle-route-node,
.puzzle-journey-room .puzzle-route-node.is-portal,
.puzzle-journey-room .puzzle-route-node.is-final {
  position: absolute;
  bottom: calc(6.2% + (var(--route-order) - 1) * 4.55%);
  width: 58px;
  height: 58px;
  transform: translate(-50%, 50%);
}

.puzzle-journey-room .puzzle-route-node.lane-left {
  left: 36%;
}

.puzzle-journey-room .puzzle-route-node.lane-right {
  left: 64%;
}

.puzzle-journey-room .puzzle-route-medallion {
  position: absolute;
  z-index: 3;
  inset: 7px;
  width: 44px;
  height: 44px;
  color: #d9e1e5;
  background: color-mix(in srgb, #0b2033 88%, var(--node-tone));
  border: 3px solid #71808a;
  border-radius: 50%;
  box-shadow: 0 5px 12px #0009, inset 0 1px 0 #fff2;
}

.puzzle-journey-room .puzzle-route-medallion svg {
  width: 22px;
  height: 22px;
}

.puzzle-journey-room .puzzle-route-node.is-completed .puzzle-route-medallion {
  color: #f7f1e3;
  background: color-mix(in srgb, var(--node-tone) 72%, #173647);
  border-color: #d8e7df;
}

.puzzle-journey-room .puzzle-route-node.is-available .puzzle-route-medallion {
  color: #0b2033;
  background: #f1ede1;
  border-color: color-mix(in srgb, var(--theme-gold) 70%, white);
}

.puzzle-journey-room .puzzle-route-node.is-current .puzzle-route-medallion {
  inset: 3px;
  width: 52px;
  height: 52px;
  color: #0b2033;
  background: #e5a640;
  border-color: #fff3ce;
  box-shadow: 0 0 0 7px #e5a64042, 0 8px 20px #000b;
  animation: puzzle-current-breathe 2.8s ease-in-out infinite;
}

.puzzle-route-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #0b2033;
  font-size: .9rem;
  font-weight: 900;
  background: #f8f2e5;
  border-radius: 50%;
}

.puzzle-journey-room .puzzle-route-node.is-milestone .puzzle-route-medallion,
.puzzle-journey-room .puzzle-route-node.is-portal .puzzle-route-medallion,
.puzzle-journey-room .puzzle-route-node.is-final .puzzle-route-medallion {
  inset: 1px;
  width: 56px;
  height: 56px;
  border-width: 3px;
}

.puzzle-journey-room .puzzle-route-node.is-portal .puzzle-route-medallion,
.puzzle-journey-room .puzzle-route-node.is-final .puzzle-route-medallion {
  border-radius: 17px;
}

.puzzle-journey-room .puzzle-route-node.is-portal .puzzle-route-medallion svg,
.puzzle-journey-room .puzzle-route-node.is-final .puzzle-route-medallion svg {
  width: 34px;
  height: 34px;
}

.puzzle-route-medallion [data-milestone-number] {
  color: inherit;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.puzzle-journey-room .puzzle-route-node.is-locked {
  opacity: .74;
}

.puzzle-journey-room .puzzle-route-copy {
  position: absolute;
  z-index: 2;
  top: 50%;
  display: none;
  width: max-content;
  max-width: 145px;
  gap: .05rem;
  padding: .32rem .48rem;
  background: color-mix(in srgb, #071521 84%, transparent);
  border: 1px solid #f1ede140;
  border-radius: 8px;
  box-shadow: 0 5px 12px #0008;
  transform: translateY(-50%);
  backdrop-filter: blur(7px);
}

.puzzle-journey-room .lane-left .puzzle-route-copy {
  left: 54px;
}

.puzzle-journey-room .lane-right .puzzle-route-copy {
  right: 54px;
  text-align: right;
}

.puzzle-journey-room :is(.is-current, .is-milestone, .is-portal, .is-final) .puzzle-route-copy {
  display: flex;
}

.puzzle-journey-room .puzzle-route-copy strong {
  color: #fff8e8;
  font-family: inherit;
  font-size: .7rem;
  line-height: 1.15;
  white-space: normal;
}

.puzzle-journey-room .puzzle-route-copy small {
  color: #d5dce0;
  font-size: .6rem;
}

.puzzle-route-node.is-just-unlocked .puzzle-route-medallion {
  animation: puzzle-portal-unlock .8s cubic-bezier(.2, .8, .25, 1);
}

@keyframes puzzle-current-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@keyframes puzzle-portal-unlock {
  0% { transform: scale(.75); filter: brightness(.8); }
  55% { transform: scale(1.14); filter: brightness(1.35); }
  100% { transform: scale(1); filter: none; }
}

@media (max-width: 1260px) {
  .puzzle-journey-room .puzzle-journey-layout {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 350px);
    grid-template-areas:
      "board controls"
      "route daily";
  }

  .puzzle-journey-room .puzzle-route-card {
    width: min(100%, 680px);
    height: auto;
    min-height: 0;
  }

  .puzzle-journey-room .puzzle-map-viewport {
    height: auto;
    overflow: visible;
  }
}

@media (max-width: 1100px) {
  .puzzle-journey-room .puzzle-journey-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "board"
      "controls"
      "route"
      "daily";
  }

  .puzzle-journey-room .puzzle-route-card,
  .puzzle-journey-room .puzzle-daily-card,
  .puzzle-journey-room .puzzle-quest-card {
    width: min(100%, 720px);
  }
}

@media (max-width: 560px) {
  .puzzle-journey-room .puzzle-route-header {
    min-height: 72px;
    padding: .7rem;
  }

  .puzzle-journey-room .puzzle-route-header-actions {
    gap: .25rem;
  }

  .puzzle-route-home span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .puzzle-route-home {
    width: 44px;
    justify-content: center;
    padding: 0;
  }

  .puzzle-map-world {
    contain-intrinsic-size: auto 900px;
  }

  .puzzle-map-world-name {
    max-width: 78%;
    font-size: 1rem;
  }

  .puzzle-journey-room .puzzle-route-node,
  .puzzle-journey-room .puzzle-route-node.is-portal,
  .puzzle-journey-room .puzzle-route-node.is-final {
    width: 52px;
    height: 52px;
  }

  .puzzle-journey-room .puzzle-route-medallion {
    inset: 4px;
  }

  .puzzle-journey-room .puzzle-route-node.is-current .puzzle-route-medallion,
  .puzzle-journey-room .puzzle-route-node.is-milestone .puzzle-route-medallion,
  .puzzle-journey-room .puzzle-route-node.is-portal .puzzle-route-medallion,
  .puzzle-journey-room .puzzle-route-node.is-final .puzzle-route-medallion {
    inset: 0;
    width: 52px;
    height: 52px;
  }

  .puzzle-journey-room .puzzle-route-copy {
    max-width: 112px;
  }

  .puzzle-journey-room .lane-left .puzzle-route-copy {
    left: 48px;
  }

  .puzzle-journey-room .lane-right .puzzle-route-copy {
    right: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .puzzle-journey-room .puzzle-route-node.is-current .puzzle-route-medallion,
  .puzzle-route-node.is-just-unlocked .puzzle-route-medallion {
    animation: none;
  }
}

/* Selector de coronación del entrenador personalizado. */
.custom-promotion-dialog {
  width: min(34rem, calc(100vw - 1.5rem));
  padding: clamp(1rem, 2.5vw, 1.5rem);
  border-radius: 20px;
}

.custom-promotion-dialog .play-promotion-options {
  gap: .65rem;
}

.custom-promotion-dialog .play-promotion-options button {
  min-width: 0;
  min-height: 126px;
  color: var(--theme-title);
  background: var(--theme-surface-alt);
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--theme-border) 75%, transparent);
}

.custom-promotion-piece.cg-wrap {
  display: grid;
  width: 64px;
  height: 64px;
  aspect-ratio: 1;
  place-items: center;
}

.custom-promotion-piece.cg-wrap piece {
  position: static;
  display: block;
  width: 64px;
  height: 64px;
  background-position: center;
  background-size: contain;
  filter: drop-shadow(0 3px 2px color-mix(in srgb, var(--theme-shadow) 70%, transparent));
  transform: none;
}

.custom-promotion-dialog .play-promotion-options button:hover {
  color: var(--theme-accent-text);
  background: var(--theme-accent-soft);
}

@media (max-width: 520px) {
  .custom-promotion-dialog .play-promotion-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .custom-promotion-dialog .play-promotion-options button {
    min-height: 108px;
  }
}

/* Problemas personalizados: panel de preparación compacto y mesa protagonista.
   Los controles se agrupan por decisión para no dejar tarjetas aisladas. */
.custom-trainer-room {
  --custom-board-size: min(720px, calc(100dvh - 210px));
}

.custom-trainer-room .puzzle-page-header {
  width: min(100%, 1180px);
  margin-inline: auto;
}

.custom-config-card,
.custom-empty-state {
  width: min(100%, 1180px);
  margin-top: .8rem;
}

.custom-config-card {
  padding: clamp(1rem, 1.8vw, 1.4rem);
  box-shadow: 0 14px 32px var(--theme-shadow);
}

.custom-config-heading {
  align-items: center;
  padding-bottom: .85rem;
}

.custom-config-heading h2 {
  font-size: clamp(1.25rem, 1.8vw, 1.55rem);
  letter-spacing: -.02em;
}

.custom-filter-form {
  grid-template-columns: minmax(0, .78fr) minmax(0, 1.22fr);
  gap: .75rem;
  padding-top: .85rem;
}

.custom-filter-section {
  padding: .9rem;
  background: var(--theme-surface-alt);
  border: 1px solid var(--theme-border);
  border-radius: 14px;
}

.custom-filter-section legend {
  margin-bottom: .7rem;
  color: var(--theme-title);
}

.custom-theme-section {
  grid-column: 1 / -1;
}

.custom-theme-grid {
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: .5rem;
}

.custom-theme-chip > span {
  background: var(--theme-surface);
}

.custom-form-error,
.custom-config-actions {
  grid-column: 1 / -1;
}

.custom-form-error:not(:empty) {
  min-height: 0;
  padding: .65rem .8rem;
  background: color-mix(in srgb, var(--theme-danger, #d85c5c) 10%, var(--theme-surface));
  border: 1px solid color-mix(in srgb, var(--theme-danger, #d85c5c) 35%, var(--theme-border));
  border-radius: 10px;
}

.custom-config-actions {
  justify-content: space-between;
  padding-top: .15rem;
}

.custom-config-actions .btn {
  min-width: min(100%, 15rem);
}

.custom-training {
  width: min(100%, 1180px);
  margin: .45rem auto 0;
}

.custom-training-topbar {
  justify-content: space-between;
  min-height: 36px;
  padding-inline: .15rem;
}

.custom-training-topbar > span {
  overflow: hidden;
  color: var(--theme-muted);
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-training-layout {
  grid-template-columns: minmax(0, var(--custom-board-size)) minmax(18rem, 21rem);
  gap: clamp(.85rem, 1.5vw, 1.25rem);
  align-items: center;
  justify-content: start;
}

.custom-training-panel {
  padding: 1rem;
  border-radius: 16px;
}

.custom-training-status {
  margin: .8rem 0;
}

.custom-training-actions {
  gap: .45rem;
}

.custom-training-actions .btn {
  min-height: 44px;
}

@media (max-width: 1100px), (max-height: 760px) {
  .custom-trainer-room {
    --custom-board-size: min(700px, calc(100vw - 3rem));
  }

  .custom-training-layout {
    grid-template-columns: minmax(0, var(--custom-board-size));
  }
}

@media (max-width: 720px) {
  .custom-filter-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .custom-theme-section,
  .custom-form-error,
  .custom-config-actions {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .custom-trainer-room {
    --custom-board-size: calc(100vw - 1.5rem);
  }

  .custom-config-card {
    padding: .8rem;
  }

  .custom-filter-section {
    padding: .75rem;
  }

  .custom-theme-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .custom-config-actions .btn {
    width: 100%;
  }
}

/* La resoluci\u00f3n es una mesa de trabajo, no una p\u00e1gina de lectura. En
   escritorio se reserva el alto visible para tablero y controles; al volver a
   configurar, la clase se elimina y la p\u00e1gina recupera su flujo habitual. */
@media (min-width: 901px) {
  body:has(.custom-trainer-room.is-training-active) {
    overflow: hidden;
  }

  body:has(.custom-trainer-room.is-training-active) .shell,
  main:has(.custom-trainer-room.is-training-active) {
    height: 100dvh;
    overflow: hidden;
  }

  main:has(.custom-trainer-room.is-training-active) {
    width: 100%;
    max-width: none;
    padding: clamp(.55rem, 1.15dvh, .9rem) clamp(.75rem, 1.6vw, 1.6rem);
  }

  .custom-trainer-room.is-training-active {
    /* La resolución es la tarea: en una pantalla de escritorio el tablero
       ocupa la mayor parte del alto disponible y los controles acompañan,
       sin una franja vacía alrededor. */
    --custom-board-size: min(760px, calc(100dvh - 142px), calc(100vw - 31rem));

    display: grid;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .custom-trainer-room.is-training-active .custom-trainer-header,
  .custom-trainer-room.is-training-active .puzzle-mode-nav {
    display: none;
  }

  .custom-trainer-room.is-training-active .custom-training {
    display: grid;
    min-height: 0;
    margin-top: 0;
    grid-template-rows: 38px minmax(0, 1fr);
  }

  .custom-trainer-room.is-training-active .custom-training-topbar {
    min-height: 38px;
  }

  .custom-trainer-room.is-training-active .custom-training-layout {
    grid-template-columns: minmax(0, var(--custom-board-size)) minmax(290px, 360px);
    gap: clamp(.8rem, 1.35vw, 1.25rem);
    align-items: center;
    min-height: 0;
  }

  .custom-trainer-room.is-training-active .custom-training-panel {
    width: 100%;
    align-self: center;
    padding: .95rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .puzzle-promotion-dialog[open] {
    animation: none;
    transition: none;
  }
}

/* Entrenamiento personalizado */
.custom-trainer-room {
  --custom-board-size: min(660px, calc(100vh - 190px));
}

.custom-trainer-room [hidden] {
  display: none !important;
}

.custom-trainer-header {
  align-items: center;
}

.custom-header-link {
  min-height: 44px;
  margin-left: auto;
  padding: .7rem .9rem;
  color: var(--theme-accent-text);
  font-size: .8rem;
  font-weight: 800;
  text-decoration: none;
  background: var(--theme-accent-soft);
  border: 1px solid color-mix(in srgb, var(--theme-accent) 32%, var(--theme-border));
  border-radius: 10px;
}

.custom-header-link:hover {
  background: color-mix(in srgb, var(--theme-accent) 18%, var(--theme-surface));
}

.custom-header-link:focus-visible,
.custom-training-topbar button:focus-visible,
.custom-reset-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--theme-accent) 52%, transparent);
  outline-offset: 2px;
}

.puzzle-study-room .puzzle-control-rail {
  max-height: none;
  overflow: visible;
}

.custom-config-card,
.custom-empty-state {
  width: min(100%, 1040px);
  margin: 1rem auto 0;
  padding: clamp(1rem, 2vw, 1.5rem);
  color: var(--theme-text);
  background: var(--theme-surface);
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-lg, 18px);
  box-shadow: var(--theme-shadow-sm);
}

.custom-config-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--theme-border);
}

.custom-config-heading h2,
.custom-empty-state h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.6rem);
}

.custom-config-heading p,
.custom-empty-state p {
  margin: .25rem 0 0;
  color: var(--theme-muted);
  font-size: .84rem;
}

.custom-filter-count {
  padding: .35rem .6rem;
  color: var(--theme-accent-text);
  font-size: .72rem;
  font-weight: 850;
  background: var(--theme-accent-soft);
  border-radius: 999px;
}

.custom-filter-form {
  display: grid;
  grid-template-columns: minmax(220px, .7fr) minmax(300px, 1fr);
  gap: 1.1rem 1.5rem;
  padding-top: 1.15rem;
}

.custom-filter-section {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.custom-filter-section legend {
  margin-bottom: .55rem;
  padding: 0;
  color: var(--theme-text);
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .035em;
}

.custom-segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 3px;
  background: var(--theme-surface-alt);
  border: 1px solid var(--theme-border);
  border-radius: 12px;
}

.custom-segmented label {
  min-width: 0;
}

.custom-segmented input,
.custom-theme-chip input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.custom-segmented span {
  display: grid;
  min-height: 44px;
  place-items: center;
  padding: .5rem;
  color: var(--theme-muted);
  font-size: .82rem;
  font-weight: 800;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
}

.custom-segmented input:checked + span {
  color: var(--theme-text);
  background: var(--theme-surface);
  border-color: var(--theme-border);
  box-shadow: var(--theme-shadow-xs);
}

.custom-segmented input:focus-visible + span,
.custom-theme-chip input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--theme-accent) 50%, transparent);
  outline-offset: 1px;
}

.custom-segmented input:disabled + span {
  cursor: not-allowed;
  opacity: .48;
}

.custom-auth-note,
.custom-range-note {
  margin: .35rem 0 0;
  color: var(--theme-faint);
  font-size: .72rem;
}

.custom-auth-note a {
  color: var(--theme-accent-text);
  font-weight: 750;
}

.custom-rating-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: .55rem;
  align-items: end;
}

.custom-rating-row label span {
  display: block;
  margin-bottom: .3rem;
  color: var(--theme-muted);
  font-size: .7rem;
  font-weight: 750;
}

.custom-rating-row input {
  width: 100%;
  min-height: 44px;
  padding: .55rem .7rem;
  color: var(--theme-text);
  font-variant-numeric: tabular-nums;
  background: var(--theme-surface-alt);
  border: 1px solid var(--theme-border);
  border-radius: 10px;
}

.custom-rating-row > span {
  padding-bottom: .7rem;
  color: var(--theme-faint);
}

.custom-theme-section {
  grid-column: 1 / -1;
}

.custom-theme-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .45rem;
  margin-top: .45rem;
}

.custom-theme-chip {
  min-width: 0;
}

.custom-theme-chip > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .35rem;
  min-height: 44px;
  padding: .55rem .7rem;
  color: var(--theme-muted);
  font-size: .75rem;
  font-weight: 760;
  line-height: 1.15;
  background: var(--theme-surface-alt);
  border: 1px solid var(--theme-border);
  border-radius: 10px;
  cursor: pointer;
}

.custom-theme-chip > span:hover {
  color: var(--theme-text);
  border-color: color-mix(in srgb, var(--theme-accent) 35%, var(--theme-border));
}

.custom-theme-chip input:checked + span {
  color: var(--theme-accent-text);
  background: var(--theme-accent-soft);
  border-color: color-mix(in srgb, var(--theme-accent) 42%, var(--theme-border));
}

.custom-theme-chip small {
  color: var(--theme-faint);
  font-size: .65rem;
  font-variant-numeric: tabular-nums;
}

.custom-theme-all {
  display: block;
  width: fit-content;
}

.custom-form-error {
  min-height: 1.1rem;
  margin: 0;
  color: var(--theme-danger, #d85c5c);
  font-size: .78rem;
}

.custom-config-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .8rem;
}

.custom-config-actions .btn {
  min-height: 46px;
}

.custom-reset-button,
.custom-training-topbar button {
  min-height: 44px;
  padding: .55rem .35rem;
  color: var(--theme-muted);
  font: inherit;
  font-size: .78rem;
  font-weight: 750;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.custom-reset-button:hover,
.custom-training-topbar button:hover {
  color: var(--theme-text);
}

.custom-empty-state {
  display: grid;
  min-height: 260px;
  place-content: center;
  text-align: center;
}

.custom-empty-state > div {
  display: flex;
  justify-content: center;
  gap: .6rem;
  margin-top: 1rem;
}

.custom-training {
  margin-top: .7rem;
}

.custom-training-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .7rem;
  min-height: 44px;
  color: var(--theme-muted);
  font-size: .76rem;
}

.custom-training-layout {
  display: grid;
  grid-template-columns: minmax(0, var(--custom-board-size)) minmax(280px, 340px);
  gap: clamp(.9rem, 2vw, 1.4rem);
  align-items: start;
  justify-content: center;
}

.custom-training-board {
  width: min(100%, var(--custom-board-size));
  min-width: 0;
}

.custom-training-board .puzzle-board-frame {
  width: 100%;
}

.custom-training-board .board-frame {
  width: 100%;
}

.custom-training-board .cg-wrap {
  width: 100%;
  aspect-ratio: 1;
  overflow: visible;
}

.custom-training-board cg-board {
  overflow: hidden;
}

.custom-training-panel {
  padding: 1.1rem;
  color: var(--theme-text);
  background: var(--theme-surface);
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-lg, 18px);
  box-shadow: var(--theme-shadow-sm);
}

.custom-training-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--theme-border);
}

.custom-training-meta span {
  color: var(--theme-muted);
  font-size: .74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.custom-training-meta strong {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.custom-active-themes,
.custom-solution-line {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .8rem;
}

.custom-active-themes span,
.custom-solution-line span {
  padding: .32rem .5rem;
  color: var(--theme-muted);
  font-size: .7rem;
  font-weight: 750;
  background: var(--theme-surface-alt);
  border: 1px solid var(--theme-border);
  border-radius: 999px;
}

.custom-solution-line span {
  color: var(--theme-text);
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

.custom-training-status {
  min-height: 2.8rem;
  margin: 1rem 0;
  padding: .72rem .8rem;
  color: var(--theme-text);
  font-size: .9rem;
  font-weight: 800;
  background: var(--theme-surface-alt);
  border-left: 3px solid var(--theme-accent);
  border-radius: 8px;
}

.custom-training-status.is-ok {
  color: var(--theme-success, #4f9b67);
}

.custom-training-status.is-fail {
  color: var(--theme-danger, #d85c5c);
}

.custom-training-status.is-loading {
  color: var(--theme-muted);
}

.custom-training-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
}

.custom-training-actions .btn {
  min-width: 0;
  min-height: 46px;
  padding-inline: .65rem;
}

.custom-training-actions [data-custom-next] {
  grid-column: 1 / -1;
}

.custom-training-actions [data-custom-copy-fen] {
  grid-column: 1 / -1;
}

.custom-training-actions [data-custom-copy-fen].is-copied {
  color: var(--theme-success, #4f9b67);
  border-color: color-mix(in srgb, var(--theme-success, #4f9b67) 55%, var(--theme-border));
  background: color-mix(in srgb, var(--theme-success, #4f9b67) 10%, var(--theme-surface-alt));
}

@media (max-width: 1100px), (max-height: 760px) {
  .custom-trainer-room {
    --custom-board-size: min(700px, calc(100vw - 3rem));
  }

  .custom-training-layout {
    grid-template-columns: minmax(0, var(--custom-board-size));
  }

  .custom-training-panel {
    width: min(100%, 700px);
  }
}

@media (max-width: 720px) {
  .custom-trainer-header {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .custom-trainer-header .custom-header-link {
    grid-column: 1 / -1;
    width: 100%;
    margin-left: 0;
    text-align: center;
  }

  .custom-filter-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .custom-theme-section {
    grid-column: auto;
  }

  .custom-theme-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .custom-form-error,
  .custom-config-actions {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .custom-trainer-room {
    --custom-board-size: calc(100vw - 1.5rem);
    padding-inline: .75rem;
  }

  .custom-config-card {
    margin-top: .65rem;
    padding: .9rem;
    border-radius: 14px;
  }

  .custom-config-heading {
    align-items: center;
  }

  .custom-theme-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .custom-training {
    margin-top: .25rem;
  }

  .custom-training-topbar {
    justify-content: space-between;
  }

  .custom-training-layout {
    gap: .65rem;
  }

  .custom-training-panel {
    padding: .85rem;
    border-radius: 14px;
  }

  .custom-empty-state > div,
  .custom-config-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
