/* Panel admin + animaciones de calificación */
html {
  -webkit-text-size-adjust: 100%;
}
::-webkit-scrollbar {
    display: none;
}
.admin-body {
  display: block;
  align-items: flex-start;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  padding: 10px;
  box-sizing: border-box;
}

.admin-wrap {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  min-width: 0;
}

.admin-card {
  width: min(100%, 420px);
}

.admin-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.admin-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
}

.admin-header p {
  margin: 6px 0 0;
  color: #aaa;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 18px;
  margin: 18px 0;
}

.content-form {
  display: grid;
  gap: 10px;
}

.content-form label {
  display: grid;
  gap: 5px;
  font-weight: 700;
}

.content-form input,
.content-form textarea,
.content-form select {
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font: inherit;
}

.crossword-helper {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
}

.crossword-helper-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.crossword-suggest {
  padding: 7px 10px;
  font-size: 0.8rem;
}

.crossword-status {
  min-height: 1.4em;
  margin: 8px 0;
  color: #64748b;
  font-size: 0.85rem;
}

.crossword-preview {
  display: grid;
  grid-template-columns: repeat(21, minmax(8px, 1fr));
  width: min(100%, 420px);
  aspect-ratio: 1;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
}

.crossword-preview span {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  color: #334155;
  font-size: clamp(0.35rem, 1.2vw, 0.65rem);
  font-weight: 700;
}

.crossword-preview .filled {
  background: #dbeafe;
}

.crossword-preview .candidate {
  background: #bbf7d0;
  color: #166534;
}

.crossword-preview .conflict {
  background: #fecaca;
  color: #991b1b;
}

.form-inline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.game-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #e2e8f0;
}

.game-row div {
  display: grid;
  gap: 4px;
}

.game-row small,
.content-list small {
  color: #64748b;
}

.content-list {
  padding-left: 20px;
  max-height: 280px;
  overflow: auto;
}

.recovery-link {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid #86efac;
  border-radius: 8px;
  background: #f0fdf4;
  color: #166534;
  overflow-wrap: anywhere;
}

.recovery-link small {
  color: #166534;
}

.btn-ghost {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

.toolbar {
  margin-bottom: 16px;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar button {
  width: auto;
  margin: 0;
  padding: 12px 18px;
  font-size: 0.95rem;
}

.btn-danger {
  background: linear-gradient(135deg, #e74c3c, #c0392b) !important;
  box-shadow: 0 8px 20px rgba(192, 57, 43, 0.35) !important;
}

.btn-danger-sm {
  width: auto;
  margin: 0;
  padding: 8px 10px;
  font-size: 0.75rem;
  border-radius: 10px;
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  box-shadow: none;
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 160px;
}

.ok-msg {
  background: rgba(40, 199, 111, 0.15);
  border-left: 4px solid #28c76f;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  color: #d4f4e2;
}

.legend-ratings {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

/* —— Rating chips + emoji hover animations —— */
.rating-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  cursor: default;
  font-family: inherit;
  font-size: 0.85rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button.rating-chip {
  cursor: pointer;
  width: auto;
  margin: 0;
  box-shadow: none;
}

.rating-chip .emoji {
  font-size: 1.35rem;
  display: inline-block;
  line-height: 1;
  transform-origin: center;
}

.rating-chip .stars {
  font-weight: 700;
  opacity: 0.9;
}

.rating-chip .lbl {
  text-transform: capitalize;
  opacity: 0.85;
}

.rating-chip.malo {
  border-color: rgba(255, 80, 80, 0.35);
  background: rgba(255, 60, 60, 0.12);
}

.rating-chip.regular {
  border-color: rgba(255, 193, 7, 0.4);
  background: rgba(255, 193, 7, 0.12);
}

.rating-chip.bueno {
  border-color: rgba(40, 199, 111, 0.4);
  background: rgba(40, 199, 111, 0.12);
}

.rating-chip:hover,
.rating-chip:focus-visible {
  transform: translateY(-2px);
  outline: none;
}

/* Malo: shake + frown pulse */
.rating-chip.malo:hover .emoji,
.rating-chip.malo:focus-visible .emoji {
  animation: emoji-malo 1s cubic-bezier(0.36, 0, 0.66, 1) infinite;
}

@keyframes emoji-malo {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); filter: saturate(1); }
  14% { transform: translateY(1px) rotate(-5deg) scale(1.07, 0.93); filter: saturate(0.9); }
  28% { transform: translateY(-1px) rotate(6deg) scale(0.97, 1.06); filter: saturate(0.72); }
  42% { transform: translateY(1px) rotate(-4deg) scale(1.04, 0.97); filter: saturate(0.78); }
  56% { transform: translateY(0) rotate(2deg) scale(1.01); filter: saturate(0.86); }
  72%, 100% { transform: translateY(0) rotate(0deg) scale(1); filter: saturate(1); }
}

/* Regular: mild bounce / shrug */
.rating-chip.regular:hover .emoji,
.rating-chip.regular:focus-visible .emoji {
  animation: emoji-regular 1.15s ease-in-out infinite;
}

@keyframes emoji-regular {
  0%, 100% { transform: translateX(0) rotate(0deg) scale(1); filter: brightness(1); }
  18% { transform: translateX(-2px) rotate(-6deg) scale(1.04, 0.97); }
  36% { transform: translateX(3px) rotate(5deg) scale(0.98, 1.04); }
  52% { transform: translateX(-1px) rotate(-3deg) scale(1.02, 0.99); }
  68%, 100% { transform: translateX(0) rotate(0deg) scale(1); filter: brightness(1); }
}

/* Bueno: celebrate bounce + spin sparkle feel */
.rating-chip.bueno:hover .emoji,
.rating-chip.bueno:focus-visible .emoji {
  animation: emoji-bueno 1.05s cubic-bezier(0.22, 0.8, 0.35, 1) infinite;
}

@keyframes emoji-bueno {
  0%, 100% { transform: translateY(0) scale(1) rotate(0deg); filter: brightness(1) saturate(1); }
  16% { transform: translateY(2px) scale(1.08, 0.9) rotate(-4deg); filter: brightness(1.08) saturate(1.1); }
  38% { transform: translateY(-10px) scale(1.16, 1.08) rotate(7deg); filter: brightness(1.22) saturate(1.2); }
  54% { transform: translateY(-4px) scale(1.04, 1.1) rotate(-4deg); filter: brightness(1.12) saturate(1.1); }
  70% { transform: translateY(0) scale(1.06, 0.94) rotate(2deg); filter: brightness(1.18) saturate(1.15); }
  82% { transform: translateY(0) scale(1) rotate(0deg); filter: brightness(1) saturate(1); }
}

.table-scroll {
  overflow-x: auto;
  max-width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  -webkit-overflow-scrolling: touch;
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-size: 0.92rem;
}

.score-table th,
.score-table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  vertical-align: middle;
}

.score-table th {
  background: rgba(0, 0, 0, 0.25);
  font-weight: 600;
  white-space: nowrap;
  color: #ccc;
}

.score-table .num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.score-table .sub {
  font-size: 0.78rem;
  color: #888;
  margin-top: 2px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.row-dq {
  background: rgba(255, 0, 80, 0.06);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: #ccc;
  white-space: nowrap;
}

.badge.ok {
  background: rgba(40, 199, 111, 0.2);
  color: #9ef0c2;
}

.badge.bad {
  background: rgba(255, 60, 80, 0.2);
  color: #ffb0bc;
}

.btn-retry {
  width: auto;
  margin: 0;
  padding: 8px 12px;
  font-size: 0.8rem;
  border-radius: 10px;
  background: linear-gradient(135deg, #00b894, #0984e3);
  box-shadow: none;
}

.inline-form {
  display: inline;
}

.muted { color: #777; }

.admins-box {
  margin-top: 28px;
  padding: 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.admins-box h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.admins-box ul {
  margin: 0;
  padding-left: 18px;
  color: #ccc;
  line-height: 1.8;
}

.tema-badge {
  display: inline-block;
  margin: 0 0 12px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 0, 127, 0.15);
  color: #ff7ab8;
  font-weight: 600;
  font-size: 0.9rem;
}

.tema-inline {
  margin: -8px 0 18px;
  color: #ff7ab8;
  font-weight: 600;
  font-size: 0.9rem;
}

.offline-banner {
  display: none;
  width: min(100%, 600px);
  margin: 0 auto 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255, 193, 7, 0.15);
  border-left: 4px solid #ffc107;
  color: #ffe08a;
  font-size: 0.9rem;
  text-align: center;
}

.offline-banner.show {
  display: block;
}

.live-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 8px 0 22px;
}

.live-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 16px;
  min-height: 280px;
}

.live-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.live-head h2 {
  margin: 0;
  font-size: 1.1rem;
  flex: 1;
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #28c76f;
  box-shadow: 0 0 0 0 rgba(40, 199, 111, 0.7);
  animation: pulse-live 1.4s ease infinite;
}

@keyframes pulse-live {
  0% { box-shadow: 0 0 0 0 rgba(40, 199, 111, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(40, 199, 111, 0); }
  100% { box-shadow: 0 0 0 0 rgba(40, 199, 111, 0); }
}

.live-meta {
  font-size: 0.78rem;
  color: #888;
}

.ranking-live,
.answers-live {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 420px;
  overflow: scroll;
}

.rank-row,
.answer-row {
  display: grid;
  grid-template-columns: 2.2em 1fr auto auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.rank-row.dq { opacity: 0.7; }
.rank-pos { font-weight: 800; text-align: center; }
.rank-name small { display: block; color: #888; font-size: 0.75rem; }
.rank-score { font-weight: 700; white-space: nowrap; }

.answer-row {
  display: block;
}

@media (max-width: 760px) {
  .admin-body {
    padding: 8px;
  }

  .admin-header {
    gap: 12px;
  }

  .admin-header > div,
  .admin-actions,
  .admin-actions .btn-ghost {
    width: 100%;
  }

  .admin-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-actions .btn-ghost {
    text-align: center;
  }

  .toolbar-row,
  .toolbar-row form,
  .toolbar-row button {
    width: 100%;
  }

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

  .live-card,
  .admins-box {
    min-width: 0;
    padding: 14px;
  }

  .game-row {
    align-items: stretch;
    flex-direction: column;
  }

  .game-row > *,
  .game-row button,
  .game-row .btn-ghost {
    width: 100%;
  }

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

  .table-scroll {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .score-table,
  .score-table thead,
  .score-table tbody,
  .score-table tr,
  .score-table td {
    display: block;
    width: 100%;
  }

  .score-table {
    min-width: 0;
  }

  .score-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .score-table tr {
    margin-bottom: 14px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
  }

  .score-table td {
    display: grid;
    grid-template-columns: minmax(82px, 36%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-width: 0;
  }

  .score-table td:last-child {
    border-bottom: 0;
  }

  .score-table td::before {
    content: attr(data-label);
    color: #aaa;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  .score-table td[data-label=""] {
    display: block;
  }

  .score-table td[data-label=""]::before {
    content: none;
  }

  .score-table .actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .score-table .actions-cell::before {
    width: 100%;
  }

  .score-table .actions-cell form,
  .score-table .actions-cell button,
  .score-table .rating-chip {
    width: 100%;
  }

  .score-table .rating-chip {
    justify-content: center;
  }
}

.answer-row.ok { border-left: 3px solid #28c76f; padding-left: 10px; }
.answer-row.bad { border-left: 3px solid #e74c3c; padding-left: 10px; }
.answer-top { display: flex; justify-content: space-between; gap: 8px; font-size: 0.9rem; }
.answer-top time { color: #888; font-size: 0.75rem; }
.answer-q, .answer-a { margin: 6px 0 0; font-size: 0.85rem; color: #ccc; }
.answer-row.ok .mark { color: #9ef0c2; font-weight: 700; }
.answer-row.bad .mark { color: #ffb0bc; font-weight: 700; }
.empty { color: #888; padding: 12px 0; }

.player-form {
  display: grid;
  gap: 8px;
  max-width: 420px;
}

.player-form button {
  width: auto;
  margin-top: 8px;
}

@media (max-width: 900px) {
  .live-grid { grid-template-columns: 1fr; }
  .rank-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  .rank-name {
    flex: 1 1 55%;
    min-width: 0;
  }
}

@media (max-width: 800px) {
  .score-table {
    min-width: 0;
  }

  .score-table thead {
    display: none;
  }

  .score-table,
  .score-table tbody,
  .score-table tr,
  .score-table td {
    display: block;
    width: 100%;
  }

  .score-table tr {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
  }

  .score-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border: 0;
    padding: 8px 0;
  }

  .score-table td::before {
    content: attr(data-label);
    color: #888;
    font-size: 0.75rem;
    font-weight: 600;
    flex: 0 0 36%;
  }

  .score-table td:not([data-label])::before {
    display: none;
  }

  .score-table td.actions-cell {
    flex-wrap: wrap;
  }

  .score-table td.actions-cell::before {
    flex: 1 1 100%;
  }

  .inline-form {
    display: block;
    width: 100%;
  }

  .btn-danger-sm,
  .btn-retry {
    width: 100%;
    margin-top: 6px;
  }

  .rating-chip {
    width: auto;
    max-width: 100%;
  }
}

@media (max-width: 700px) {
  .admin-header {
    flex-direction: column;
  }

  .admin-actions {
    width: 100%;
  }

  .btn-ghost {
    flex: 1;
    text-align: center;
  }

  .toolbar button {
    width: 100%;
  }

  .legend-ratings {
    justify-content: stretch;
  }

  .legend-ratings .rating-chip {
    flex: 1 1 100%;
    justify-content: center;
  }

  .live-card {
    min-height: 0;
    padding: 12px;
  }

  .rating-chip .lbl {
    display: none;
  }

  .rank-row .rating-chip {
    padding: 6px 8px;
    font-size: 0.75rem;
  }
}



@media (max-width: 700px) {
  /* Hacer que cada elemento del ranking sea flexible */
  .rank-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px;
  }

  .rank-pos {
    width: 24px;
  }

  .rank-name {
    flex: 1 1 calc(100% - 40px);
  }

  .rank-score {
    margin-left: 32px;
  }

  /* Ajustar tarjetas de respuestas agrupadas */
  .user-answers-card {
    margin-bottom: 12px;
    padding: 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  .user-answers-header {
    font-weight: bold;
    color: #fff;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 4px;
  }
}
@media (max-width: 700px) {
  .rank-row {
    display: grid;
    grid-template-columns: auto 1fr auto; /* 3 columnas principales */
    gap: 8px 12px;
    padding: 12px 10px;
  }

  /* Fila 1: Posición + Nombre + Puntaje */
  .rank-pos {
    grid-column: 1;
    grid-row: 1;
    font-size: 1.1rem;
  }

  .rank-name {
    grid-column: 2;
    grid-row: 1;
    min-width: 0; /* Evita desborde del email */
    word-break: break-word;
  }

  .rank-score {
    grid-column: 3;
    grid-row: 1;
    text-align: right;
    margin-left: 0; /* Anula el margin previo */
  }

  /* Fila 2: Chips y Badges organizados en una sub-línea */
  .rank-row .rating-chip,
  .rank-row .badge {
    grid-row: 2;
  }

  /* Hace que los botones y insignias ocupen la segunda fila de forma fluida */
  .rank-row {
    grid-template-areas:
      "pos name score"
      "details details details";
  }

  .rank-pos { grid-area: pos; }
  .rank-name { grid-area: name; }
  .rank-score { grid-area: score; }

  /* Envoltorio implícito para los elementos secundarios */
  .rank-row .rating-chip,
  .rank-row .badge {
    grid-area: details;
    justify-self: start;
    display: inline-flex;
  }

  /* Alternativa limpia con Flexbox para la segunda fila si hay varios badges */
  .rank-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }

  .rank-pos {
    order: 1;
    width: 28px;
    flex-shrink: 0;
  }

  .rank-name {
    order: 2;
    flex: 1 1 calc(100% - 110px);
    min-width: 0;
  }

  .rank-name small {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .rank-score {
    order: 3;
    margin-left: auto;
    font-size: 0.95rem;
  }

  .rank-row .rating-chip,
  .rank-row .badge {
    order: 4;
    margin-top: 4px;
  }
}