/* Wire Trivia — flip card + game UI */

.trivia-page {
  flex: 1 0 auto;
  padding: 24px 16px 100px;
}

.trivia-page-inner {
  max-width: 920px;
  margin: 0 auto;
}

.trivia-title {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  text-align: center;
  margin-bottom: 0.25rem;
  color: #fff;
}

.trivia-sub {
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  font-weight: 400;
}

/* 3D flip */
.flip-scene {
  perspective: 1400px;
  max-width: 720px;
  margin: 0 auto;
}

.flip-card {
  position: relative;
  min-height: min(52vh, 420px);
  transform-style: preserve-3d;
  transition: transform 0.85s cubic-bezier(0.4, 0.2, 0.2, 1);
  border-radius: 20px;
}

.flip-card.is-flipped {
  transform: rotateY(180deg);
}

.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(152, 186, 227, 0.2);
}

.flip-front {
  background: linear-gradient(160deg, rgba(15, 25, 40, 0.95), rgba(10, 18, 28, 0.9));
}

.flip-front-hit {
  display: block;
  width: 100%;
  height: 100%;
  min-height: min(52vh, 420px);
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: inherit;
  font: inherit;
  border-radius: 20px;
}

.flip-front-hit:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.flip-hero-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

.flip-back {
  transform: rotateY(180deg);
  background: linear-gradient(165deg, rgba(18, 30, 48, 0.98), rgba(10, 16, 26, 0.97));
  display: flex;
  flex-direction: column;
  padding: 20px 18px 14px;
  overflow: hidden;
  min-height: 0;
}

/* Scroll panels here; toolbar stays a fixed row at the bottom of the card */
.flip-back-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.trivia-flip-toolbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
  margin-top: 0;
  padding-top: 12px;
  border-top: 1px solid rgba(152, 186, 227, 0.12);
}

.trivia-flip-toolbar.is-game {
  justify-content: space-between;
}

.trivia-score-run--toolbar {
  margin: 0;
  flex: 1;
  min-width: 0;
  text-align: left;
}

.trivia-flip-toolbar-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.trivia-btn-next {
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 10px;
  border: 1px solid rgba(152, 186, 227, 0.45);
  background: rgba(89, 129, 177, 0.35);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.trivia-btn-next:hover:not(:disabled) {
  background: rgba(89, 129, 177, 0.55);
  border-color: rgba(152, 186, 227, 0.6);
}

.trivia-btn-next:disabled {
  opacity: 0.45;
  cursor: default;
}

.trivia-btn-next:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.trivia-exit {
  position: relative;
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 10px;
  border: 1px solid rgba(152, 186, 227, 0.35);
  background: rgba(14, 22, 35, 0.9);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.trivia-exit:hover {
  background: rgba(54, 84, 117, 0.55);
  border-color: rgba(152, 186, 227, 0.55);
}

.trivia-exit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.trivia-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

/* HTML hidden must win over display:flex above (otherwise every panel stacks visible). */
.flip-back .trivia-panel[hidden],
.flip-back .trivia-lb-search-wrap[hidden] {
  display: none !important;
}

.flip-back p.trivia-error[hidden] {
  display: none !important;
}

.trivia-panel-title {
  font-size: 1.35rem;
  margin-bottom: 4px;
  color: #fff;
}

.trivia-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 700;
}

.trivia-input {
  width: 100%;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(152, 186, 227, 0.25);
  background: rgba(5, 10, 18, 0.6);
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
}

.trivia-input:focus {
  outline: none;
  border-color: rgba(138, 180, 255, 0.55);
  box-shadow: 0 0 0 2px rgba(138, 180, 255, 0.2);
}

.trivia-input::placeholder {
  color: color-mix(in oklab, var(--muted) 55%, transparent);
}

.trivia-help {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.45;
}

.trivia-error {
  font-size: 0.88rem;
  color: #ffb4b4;
  font-weight: 700;
}

.trivia-menu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.trivia-page .btn {
  font-weight: 700;
}

.trivia-lb-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.trivia-lb-search-wrap {
  margin-bottom: 10px;
}

.trivia-lb-table-wrap {
  overflow: auto;
  max-height: min(45vh, 360px);
  border-radius: 12px;
  border: 1px solid rgba(152, 186, 227, 0.15);
}

.trivia-lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-weight: 400;
}

.trivia-lb-table th,
.trivia-lb-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(152, 186, 227, 0.1);
}

.trivia-lb-table th {
  background: rgba(14, 22, 35, 0.85);
  color: var(--muted);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

.trivia-lb-table tbody tr:hover td {
  background: rgba(89, 129, 177, 0.12);
}

/* Game — don’t flex-grow: avoids a tall empty band that separates answers from the toolbar */
.flip-back .trivia-panel.trivia-game {
  flex: 0 1 auto;
}

/* Game */
.trivia-game {
  gap: 12px;
}

.trivia-game-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.trivia-cat {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  font-weight: 700;
}

.trivia-q-num {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 700;
}

.trivia-timer-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trivia-timer-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
}

.trivia-timer-fill {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(1);
  border-radius: 999px;
  background: linear-gradient(90deg, #4ade80, #22c55e, #15803d);
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.35);
  transition: background 0.3s ease;
}

.trivia-timer-fill.is-low {
  background: linear-gradient(90deg, #fcd34d, #f59e0b, #d97706);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
}

.trivia-timer-fill.is-critical {
  background: linear-gradient(90deg, #fca5a5, #ef4444, #b91c1c);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.35);
}

.trivia-timer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.trivia-points-live {
  color: #fde68a;
  font-variant-numeric: tabular-nums;
}

.trivia-question {
  font-size: 1.05rem;
  line-height: 1.45;
  font-weight: 400;
  color: #f1f5f9;
  margin: 4px 0;
}

.trivia-answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}

.trivia-ans {
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(152, 186, 227, 0.25);
  background: rgba(5, 10, 18, 0.55);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 400;
  line-height: 1.35;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 2.75rem;
  word-break: break-word;
  hyphens: auto;
}

.trivia-ans:hover:not(:disabled) {
  background: rgba(89, 129, 177, 0.25);
  border-color: rgba(152, 186, 227, 0.45);
}

.trivia-ans:disabled {
  cursor: default;
  opacity: 0.95;
}

.trivia-ans.is-correct {
  border-color: #4ade80;
  background: rgba(34, 197, 94, 0.2);
}

.trivia-ans.is-wrong {
  border-color: #f87171;
  background: rgba(239, 68, 68, 0.15);
}

.trivia-feedback {
  min-height: 1.4em;
  font-size: 0.95rem;
  font-weight: 700;
}

.trivia-score-run {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: auto;
  font-weight: 400;
}

.trivia-score-run strong {
  color: #fff;
  font-weight: 900;
}

.trivia-loading-msg {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.trivia-result-score {
  font-size: 1.15rem;
  color: var(--text);
  font-weight: 400;
}

.trivia-result-score strong {
  color: #fde68a;
  font-size: 1.35rem;
  font-weight: 900;
}

.trivia-page footer a {
  color: var(--accent);
}

@media (max-width: 540px) {
  .flip-back {
    padding: 16px 14px 12px;
  }

  .trivia-lb-table {
    font-size: 0.8rem;
  }

  .trivia-lb-table th,
  .trivia-lb-table td {
    padding: 8px 8px;
  }
}

/* Wire homepage: soft leaderboard hints — glass card, restrained type */
.trivia-spotlight-bubbles {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: min(30vh, 200px);
  pointer-events: none;
  z-index: 18;
  overflow: hidden;
}

.trivia-spotlight-bubble {
  position: absolute;
  bottom: 12px;
  left: var(--spot-x, 50%);
  /* Hug content; cap width so cards stay compact */
  width: max-content;
  max-width: min(calc(100vw - 40px), 184px);
  padding: 10px 12px 11px;
  border-radius: 14px;
  background: rgba(15, 23, 36, 0.58);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.08),
    0 12px 40px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 6px;
  align-items: center;
  font-family: system-ui, -apple-system, 'Segoe UI', 'Roboto', sans-serif;
  font-size: 0.8125rem;
  line-height: 1.3;
  color: rgba(232, 238, 249, 0.92);
  transform: translateX(-50%);
  animation: triviaSpotlightDrift var(--spot-dur, 11s) cubic-bezier(0.22, 1, 0.36, 1) forwards;
  will-change: transform, opacity;
}

.trivia-spotlight-bubble__label {
  grid-column: 1 / -1;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(163, 186, 220, 0.75);
}

.trivia-spotlight-bubble__name {
  grid-column: 1;
  font-weight: 500;
  color: rgba(248, 250, 252, 0.94);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.trivia-spotlight-bubble__score {
  grid-column: 2;
  font-weight: 600;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: rgba(186, 210, 245, 0.98);
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  white-space: nowrap;
}

@keyframes triviaSpotlightDrift {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(0.98);
  }
  14% {
    opacity: 1;
  }
  76% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-36px) scale(1);
  }
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .trivia-spotlight-bubble {
    background: rgba(17, 26, 40, 0.94);
  }
}

@media (prefers-reduced-motion: reduce) {
  .trivia-spotlight-bubbles {
    display: none !important;
  }
}
