/* Shared contest navigator + rules popup + contest rules grid styles */

/* ── Contest page layout (moved from contest.html inline) ── */

.contest-page-title {
  background: linear-gradient(135deg, #fffcf8 0%, #fff9e6 100%);
  padding: 0.9rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: #1e293b;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  width: 100%;
  box-sizing: border-box;
}

#mainContentSection,
#contestEntriesSection,
#contestRulesGridSection {
  width: 100%;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 1rem;
  box-sizing: border-box;
}

#mainContentSection.catalogPage {
  padding-top: 1.25rem;
}

#mainContentSection:not(.catalogPage) {
  padding-top: 3rem;
}

#contestRulesGridSection {
  margin-bottom: 2rem;
}

#contestRulesGridWrap {
  width: 100%;
  max-width: 1200px;
}

#contestRulesSection,
#contestRulesHeader {
  width: 100%;
}

#contestRulesSection {
  margin-bottom: 1rem;
}

.contest-rules-section,
#contestChatsGrid {
  border-radius: 14px;
  border: 1px solid var(--border-color);
  box-shadow:
    0 4px 18px rgba(15, 23, 42, 0.06),
    0 1px 3px rgba(15, 23, 42, 0.04);
  background:
    repeating-linear-gradient(100deg,
      #fbbf2410 0 2px,
      transparent 2px 18px,
      #f59e0b08 18px 20px,
      transparent 20px 36px),
    repeating-linear-gradient(0deg,
      #f59e0b08 0 2px,
      transparent 2px 18px,
      #fbbf2410 18px 20px,
      transparent 20px 36px),
    linear-gradient(145deg, #fffefb50 0%, #fffcf850 50%, #fffaee60 100%);
  position: relative;
  overflow: hidden;
}

.contest-rules-section {
  padding: 1.25rem 1.5rem;
  margin-top: 0;
  margin-bottom: 1rem;
}

#contestChatsGrid {
  width: 100%;
  padding: 1rem 1rem;
  margin-bottom: 2rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.contest-rules-content {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-secondary, #374151);
}

.contest-rules-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 0 1.25rem;
}

.contest-rules-left {
  min-width: 0;
  background: #fffdf9;
  padding: 1.1rem 1.35rem;
  border-radius: 0.75rem;
  border: 1px solid #f3e8c8;
  border-left: 4px solid #f59e0b;
  box-shadow: 0 1px 4px rgba(120, 85, 20, 0.06);
  color: #44403c;
}

.contest-rules-body {
  margin-bottom: 0.75rem;
  font-size: 1.02rem;
  line-height: 1.75;
}

.contest-rules-right-column {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-self: start;
}

.contest-rules-right-block {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-radius: 0.75rem;
  padding: 1rem 1.1rem 0.9rem;
  border: 1px solid #fde68a;
  box-shadow: 0 1px 4px rgba(245, 158, 11, 0.12);
}

.contest-rules-right-block h3 {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #92400e;
  margin: 0 0 0.65rem;
}

.contest-rules-right-block ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.contest-rules-right-block li {
  font-size: 0.9rem;
  color: #78350f;
  margin-bottom: 0.45rem;
  padding-left: 1.1rem;
  position: relative;
}

.contest-rules-right-block li::before {
  content: '🏅';
  position: absolute;
  left: 0;
  font-size: 0.75rem;
  top: 0.1rem;
}

.contest-rules-footer {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.5rem;
  margin: 0;
}

.contest-rules-footer-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  box-sizing: border-box;
  background: var(--surface-2, #f8fafc);
  border: 1.5px solid var(--border-color, #cbd5e1);
  border-radius: 0.625rem;
  color: var(--text-primary, #334155);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.contest-rules-footer-btn:hover {
  background: var(--surface-3, #f1f5f9);
  border-color: #94a3b8;
}

.contest-rules-accent-block {
  border-left: 3px solid #f59e0b;
  border-radius: 0 0.5rem 0.5rem 0;
  background: rgba(245, 158, 11, 0.06);
  padding: 0.65rem 1rem;
  margin-top: 0.75rem;
  font-size: 0.95rem;
  color: #78350f;
  font-style: italic;
}

.contest-rules-inline-craft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.6rem;
  padding: 0.55rem 1.25rem;
  border: 0;
  border-radius: 999px;
  background: var(--quizly-violet, #7c3aed);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 800;
  line-height: 1.25;
  cursor: pointer;
  vertical-align: middle;
  text-decoration: none;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.35);
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.contest-rules-inline-craft i {
  font-size: 0.95em;
  line-height: 1;
}

.contest-rules-inline-craft:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.contest-rules-body .contest-rules-inline-craft {
  margin: 0.35rem 0.75rem 0.35rem 0;
}

:is(.echo-cards-grid, #promotedSection) .contest-card-create-actions .contest-rules-inline-craft {
  width: 100%;
  max-width: 16rem;
  margin: 0;
  height: auto;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}

.contest-rules-book-link {
  color: #2563eb;
  font-weight: 600;
  text-decoration: none;
}

.contest-rules-book-link:hover {
  text-decoration: underline;
}

.contest-rules-book-text {
  font-weight: 600;
}

.contest-rules-popup-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color, #e2e8f0);
}

.contest-rules-popup-footer .contest-rules-inline-craft {
  width: auto;
  max-width: none;
  margin: 0;
}

/* ── Rules popup ── */

.contest-rules-popup-backdrop {
  position: fixed;
  inset: 0;
  z-index: 119;
  background: transparent;
}

.contest-rules-popup-modal {
  position: fixed;
  z-index: 120;
  top: 5rem;
  right: 1rem;
  left: 1rem;
  margin: 0 auto;
  max-width: 920px;
  max-height: calc(100vh - 6rem);
  display: flex;
  flex-direction: column;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
  background:
    repeating-linear-gradient(100deg, #fbbf2410 0 2px, transparent 2px 18px, #f59e0b08 18px 20px, transparent 20px 36px),
    repeating-linear-gradient(0deg, #f59e0b08 0 2px, transparent 2px 18px, #fbbf2410 18px 20px, transparent 20px 36px),
    linear-gradient(145deg, #fffefb 0%, #fffcf8 50%, #fffaee 100%);
  color: var(--text-primary, #1e293b);
}

.contest-rules-popup-modal--wide {
  left: auto;
  margin: 0;
  max-width: none;
}

.contest-rules-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  flex-shrink: 0;
}

.contest-rules-popup-header h5 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.contest-rules-popup-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary, #64748b);
  padding: 0 0.25rem;
}

.contest-rules-popup-close:hover {
  color: #dc2626;
}

.contest-rules-popup-scroll {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 1.25rem 1.5rem;
}

/* ── Contest navigator ── */

.contest-nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 119;
  background: transparent;
}

.contest-nav-modal {
  position: fixed;
  z-index: 120;
  top: 5rem;
  right: 1rem;
  left: 2rem;
  max-width: 480px;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 6rem);
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
}

.contest-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.contest-nav-header-title {
  min-width: 0;
  font-weight: 700;
  font-size: 0.95rem;
}

.contest-nav-contest-link {
  color: var(--text-primary);
  text-decoration: none;
}

.contest-nav-contest-link:hover {
  color: var(--accent, #2563eb);
  text-decoration: underline;
}

.contest-nav-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.contest-nav-close:hover {
  color: #dc2626;
}

.contest-nav-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 0.5rem;
}

.contest-nav-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-secondary);
  margin: 0;
}

.contest-nav-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.25rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
  box-sizing: border-box;
}

.contest-nav-row:hover:not(.contest-nav-row-current) {
  background: var(--surface-2);
}

.contest-nav-row-current {
  background: var(--surface-3);
  border-left: 3px solid var(--accent, #2563eb);
  cursor: default;
  padding-left: calc(0.65rem - 3px);
}

.contest-nav-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.contest-nav-thumb-scene {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  color: #888;
  font-size: 1.5rem;
}

.contest-nav-row-body {
  min-width: 0;
  flex: 1;
}

.contest-nav-row-title {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contest-nav-type {
  margin-right: 0.15rem;
}

.contest-nav-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.contest-nav-here {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent, #2563eb);
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.contest-nav-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.contest-nav-footer-btn {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.contest-nav-footer-btn:hover {
  background: var(--surface-3);
  border-color: var(--accent, #2563eb);
}

.contest-nav-footer-primary {
  background: var(--surface-3);
  font-weight: 700;
}

/* ── Chat info page: contest strip + actions ── */

:root {
  --middle-button-height: 46px;
  --middle-button-radius: 999px;
  --middle-button-padding-x: 1.25rem;
  --middle-button-font-size: 0.92rem;
  --middle-button-letter-spacing: 0.045em;
}

.theme-band-middle-inner .middle-actions-row,
.theme-band-middle-inner .middle-contest-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.theme-band-middle {
  --middle-light-btn-bg: rgba(255, 255, 255, 0.72);
  --middle-light-btn-bg-hover: rgba(255, 255, 255, 0.92);
  --middle-light-btn-border: #e4d9c8;
  --middle-light-btn-border-hover: #c9b99a;
  --middle-light-btn-text: #18151f;
  --middle-light-btn-shadow: 0 1px 3px rgba(24, 21, 31, 0.08);
}

.theme-band-middle-inner .middle-actions-row {
  justify-content: stretch;
  flex-wrap: nowrap;
}

.theme-band-middle-inner .middle-actions-row > .middle-band-btn:not(.scene-view-btn) {
  flex: 1 1 0;
  width: auto;
  max-width: none;
}

.theme-band-middle-inner .middle-actions-row .scene-view-btn {
  flex: 1 1 0;
  min-width: 11rem;
  margin-left: 0;
}

.theme-band-middle-inner .middle-contest-row {
  flex-wrap: nowrap;
  gap: 0.75rem;
  align-items: stretch;
  width: 100%;
}

@media (min-width: 721px) {
  .theme-band-middle-inner .middle-contest-row {
    justify-content: flex-end;
    margin-left: auto;
  }

  .middle-contest-controls {
    flex: 1 1 14rem;
    max-width: min(100%, 28rem);
  }
}

.contest-link-row-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  flex: 0 1 auto;
  width: auto;
  max-width: max-content;
  min-width: 0;
  min-height: var(--middle-button-height);
  padding: 0 1rem;
  font-weight: 700;
  font-size: var(--middle-button-font-size);
  text-transform: none;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease;
}

.contest-link-row-button .chat-contest-strip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  color: inherit;
}

.middle-contest-controls {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  flex: 1 1 auto;
  min-width: 0;
}

.middle-contest-controls .chat-contest-switch-btn.middle-band-btn {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.middle-band-btn,
.scene-view-btn {
  min-height: var(--middle-button-height);
  padding-inline: var(--middle-button-padding-x);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease;
}

/* Primary (filled) middle-band buttons */
.theme-band-middle .middle-band-btn[data-bind="toThePrivateChatBtn"],
.theme-band-middle .chat-contest-switch-btn.middle-band-btn {
  border: 1px solid var(--middle-button-border);
  background: var(--middle-button-bg);
  color: var(--middle-button-text);
  box-shadow: var(--middle-button-shadow, none);
}

.theme-band-middle .middle-band-btn[data-bind="toThePrivateChatBtn"]:hover,
.theme-band-middle .chat-contest-switch-btn.middle-band-btn:hover {
  background: var(--middle-button-bg-hover);
  transform: translateY(-1px);
}

/* Light middle-band buttons — unified ghost style (same as toTheChatBtn) */
.theme-band-middle :is(
  .middle-band-btn[data-bind="toTheChatBtn"],
  .middle-band-btn[data-bind="forumBtn"],
  .middle-band-btn.ghost,
  .middle-band-btn.btn-neon.ghost,
  .middle-band-btn.btn-retro.ghost,
  .middle-band-btn.btn-echo-o3,
  .middle-band-btn.btn-echo2-outline,
  .middle-band-btn.fantasy-button-outline,
  .middle-band-btn.btn-echo:not([data-bind="toThePrivateChatBtn"]),
  .contest-link-row-button,
  .scene-view-btn,
  .rules-btn
) {
  background: var(--middle-light-btn-bg);
  border: 1px solid var(--middle-light-btn-border);
  color: var(--middle-light-btn-text);
  box-shadow: var(--middle-light-btn-shadow);
}

.theme-band-middle :is(
  .middle-band-btn[data-bind="toTheChatBtn"],
  .middle-band-btn[data-bind="forumBtn"],
  .middle-band-btn.ghost,
  .middle-band-btn.btn-neon.ghost,
  .middle-band-btn.btn-retro.ghost,
  .middle-band-btn.btn-echo-o3,
  .middle-band-btn.btn-echo2-outline,
  .middle-band-btn.fantasy-button-outline,
  .middle-band-btn.btn-echo:not([data-bind="toThePrivateChatBtn"]),
  .contest-link-row-button,
  .scene-view-btn,
  .rules-btn
):hover {
  background: var(--middle-light-btn-bg-hover);
  border-color: var(--middle-light-btn-border-hover);
  color: var(--middle-light-btn-text);
  transform: translateY(-1px);
}

.theme-band-middle .middle-band-btn,
.theme-band-middle .contest-link-row-button,
.theme-band-middle .scene-view-btn,
.theme-band-middle .rules-btn {
  border-radius: var(--middle-button-radius) !important;
  font-size: var(--middle-button-font-size) !important;
  font-weight: var(--middle-button-font-weight, 700) !important;
  letter-spacing: var(--middle-button-letter-spacing) !important;
  text-transform: var(--middle-button-text-transform, uppercase) !important;
  font-family: inherit;
  white-space: nowrap;
}

.contest-link-row-button,
.theme-band-middle .rules-btn {
  text-transform: none !important;
}

.contest-link-row-button:hover {
  text-decoration: none;
}

.middle-band-btn:focus-visible,
.contest-link-row-button:focus-visible,
.scene-view-btn:focus-visible,
.rules-btn:focus-visible {
  outline: 3px solid var(--middle-button-focus-ring, rgba(109, 53, 242, 0.45));
  outline-offset: 2px;
}

.rules-btn {
  min-height: var(--middle-button-height);
  align-self: stretch;
  min-width: var(--middle-button-height);
  padding-inline: 0.75rem;
}

.scene-view-btn .welcome-scene-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid #e4d9c8;
  display: block;
}

@media (max-width: 720px) {
  :root {
    --middle-button-font-size: 0.63rem;
    --middle-button-padding-x: 0.4rem;
    --middle-button-height: 34px;
    --middle-button-letter-spacing: 0.02em;
  }

  .theme-band-middle {
    padding-top: calc(var(--band-overlap) + 0.25rem);
    padding-bottom: calc(var(--band-overlap) + 0.25rem);
  }

  .theme-band-middle-inner {
    flex-direction: column;
    overflow-x: visible;
    gap: 0.35rem;
    padding: 0.15rem 0.45rem;
  }

  .theme-band-middle .info-chat-actions,
  .theme-band-middle .chat-actions-retro,
  .theme-band-middle .middle-actions-row.info-chat-actions,
  .theme-band-middle .middle-actions-row.chat-actions-retro {
    flex-wrap: nowrap !important;
    gap: 0.35rem;
  }

  .theme-band-middle-inner .middle-actions-row > .middle-band-btn,
  .theme-band-middle-inner .middle-contest-row .chat-contest-switch-btn.middle-band-btn {
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    flex: 1 1 0 !important;
  }

  .theme-band-middle-inner .middle-actions-row > .middle-band-btn[data-bind="toThePrivateChatBtn"] {
    flex: 0.72 1 0 !important;
    padding-inline: 0.3rem;
    font-weight: 800 !important;
  }

  .theme-band-middle-inner .middle-contest-row .contest-link-row-button {
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
  }

  /* Row 1: chat actions — single compressed line */
  .theme-band-middle-inner .middle-actions-row {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
    gap: 0.35rem;
    margin-left: 0;
  }

  .theme-band-middle-inner .middle-actions-row > .middle-band-btn {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    white-space: normal;
    line-height: 1.12;
    text-transform: none !important;
    padding-inline: 0.35rem;
  }

  .theme-band-middle-inner .middle-actions-row .scene-view-btn {
    flex: 0.85 1 0;
    min-width: 0;
    gap: 0.3rem;
  }

  .scene-view-btn .welcome-scene-thumb {
    width: 20px;
    height: 20px;
  }

  /* Row 2: contest controls — single compressed line */
  .theme-band-middle-inner .middle-contest-row {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
    gap: 0.35rem;
    margin-left: 0;
    justify-content: stretch;
  }

  .theme-band-middle-inner .contest-link-row-button {
    flex: 0.75 1 0 !important;
    min-width: 0;
    max-width: none;
    padding-inline: 0.35rem;
    gap: 0.3rem;
    white-space: nowrap;
  }

  .theme-band-middle-inner .contest-link-row-button .chat-contest-strip-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .theme-band-middle-inner .contest-link-row-button .chat-contest-strip-open {
    display: none;
  }

  .theme-band-middle-inner .contest-link-row-button .chat-contest-strip-icon {
    display: none;
  }

  .theme-band-middle-inner .middle-contest-controls {
    display: contents;
  }

  .theme-band-middle-inner .chat-contest-switch-btn.middle-band-btn {
    flex: 1 1 0;
    min-width: 0;
    text-transform: none !important;
    white-space: normal;
    line-height: 1.12;
    padding-inline: 0.35rem;
    font-weight: 800 !important;
  }

  .theme-band-middle-inner .rules-btn {
    flex: 0 0 var(--middle-button-height);
    min-width: var(--middle-button-height);
    width: var(--middle-button-height);
    padding-inline: 0;
  }

  .theme-band-middle-inner .middle-contest-row:not(:has(.contest-link-row-button:not(.hidden), .chat-contest-bar:not(.hidden))) {
    display: none;
  }

  .middle-band-btn,
  .contest-link-row-button,
  .scene-view-btn,
  .rules-btn {
    min-height: 34px;
  }
}

.chat-contest-bar {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.chat-contest-strip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border-color, #cbd5e1);
  background: var(--surface-2, rgba(248, 250, 252, 0.9));
  color: var(--text-primary, #1f2937);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.chat-contest-strip:hover {
  background: var(--surface-3, #f1f5f9);
  border-color: var(--accent, #2563eb);
  text-decoration: none;
  color: var(--text-primary, #1f2937);
}

.chat-contest-strip-icon {
  flex-shrink: 0;
  font-size: 1.1rem;
}

.chat-contest-strip-label {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-contest-strip-open {
  display: none;
}

.chat-contest-switch-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  min-height: 42px;
  box-sizing: border-box;
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s ease;
}

/* Contest bar layout: keep compact sizing when primary theme button styles apply */
.theme-container3 .chat-contest-switch-btn {
  width: auto;
  padding: 0 0.85rem;
  font-size: 0.82rem;
  position: static;
  overflow: visible;
}

.theme-container4 .chat-contest-switch-btn {
  width: auto;
  min-width: 0;
  flex: none;
  padding: 0 0.85rem;
  display: inline-flex;
}

.theme-container5 .chat-contest-switch-btn {
  width: auto;
  min-width: 0;
  flex: none;
  padding: 0 0.85rem;
  display: inline-flex;
}

.chat-contest-rules-btn {
  flex-shrink: 0;
  width: 2.5rem;
  border-radius: 8px;
  border: 1px solid var(--border-color, #cbd5e1);
  background: var(--surface-2, #f8fafc);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  align-self: stretch;
}

.chat-contest-rules-btn:hover {
  background: var(--surface-3, #f1f5f9);
  border-color: var(--accent, #2563eb);
}

/* Dark chat themes: translucent strip (outside middle band only) */
.theme-container4 .chat-contest-strip:not(.contest-link-row-button),
.theme-container5 .chat-contest-strip:not(.contest-link-row-button),
.theme-container4 .chat-contest-rules-btn:not(.rules-btn),
.theme-container5 .chat-contest-rules-btn:not(.rules-btn) {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.22);
  color: #e8eaf2;
}

.theme-container4 .chat-contest-strip:not(.contest-link-row-button):hover,
.theme-container5 .chat-contest-strip:not(.contest-link-row-button):hover,
.theme-container4 .chat-contest-rules-btn:not(.rules-btn):hover,
.theme-container5 .chat-contest-rules-btn:not(.rules-btn):hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.theme-band-middle .contest-link-row-button.chat-contest-strip {
  flex: 0 1 auto;
  max-width: max-content;
}

.theme-band-middle .chat-contest-switch-btn.middle-band-btn {
  width: auto;
  min-width: 0;
  flex: 1 1 auto;
  padding-inline: var(--middle-button-padding-x);
  font-size: var(--middle-button-font-size);
}

.theme-band-middle .rules-btn.chat-contest-rules-btn {
  width: auto;
  min-width: var(--middle-button-height);
  padding-inline: 0.75rem;
}

.theme-band-middle .btn-neon,
.theme-band-middle .btn-retro-sm,
.theme-band-middle .btn-echo,
.theme-band-middle .btn-echo2,
.theme-band-middle .fantasy-button {
  width: auto !important;
  max-width: none !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

.page-description-collapsible .page-description-toggle--header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  margin: 0 0 6px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: inherit;
  color: inherit;
  font: inherit;
}

.page-description-collapsible.page-description-fits .page-description-toggle--header,
.page-description-collapsible.page-description-fits .page-description-toggle--corner {
  display: none;
}

.page-description-toggle--header.page-description-toggle--icon-only {
  justify-content: flex-end;
  margin-bottom: 4px;
  padding-right: 0;
}

.page-description-toggle--header .page-description-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  margin: 0;
}

.page-description-collapsible .page-description-toggle--header h3,
.page-description-collapsible .page-description-toggle--header label {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.page-description-chevron {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.page-description-collapsible:not(.collapsed) .page-description-chevron {
  transform: rotate(180deg);
}

.page-description-body {
  position: relative;
  overflow: hidden;
}

.page-description-collapsible.collapsed .page-description-body {
  overflow: hidden;
}

.page-description-collapsible:not(.collapsed) .page-description-body {
  max-height: none !important;
  overflow: visible;
}

.page-description-collapsible--chat.collapsed .page-description-body {
  max-height: 180px;
}

@media (min-width: 769px) {
  .page-description-collapsible--chat.collapsed .page-description-body {
    max-height: 150px;
  }
}

.page-description-collapsible--scene.collapsed .page-description-body {
  max-height: 60px;
}

.page-description-collapsible.page-description-overflows.collapsed .page-description-body::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2.75rem;
  pointer-events: none;
  z-index: 1;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.96));
}

.theme-container5 .page-description-collapsible.page-description-overflows.collapsed .page-description-body::after {
  background: linear-gradient(to bottom, rgba(15, 28, 49, 0), rgba(15, 28, 49, 0.96));
}

.theme-container4 .page-description-collapsible.page-description-overflows.collapsed .page-description-body::after {
  background: linear-gradient(to bottom, rgba(245, 235, 220, 0), rgba(245, 235, 220, 0.96));
}

.theme-container3 .page-description-collapsible.page-description-overflows.collapsed .page-description-body::after {
  background: linear-gradient(to bottom, rgba(250, 246, 236, 0), rgba(250, 246, 236, 0.96));
}

.page-description-toggle--corner {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  width: 1rem;
  border: none;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  color: inherit;
  font: inherit;
  line-height: 1;
}

.page-description-toggle--corner:hover,
.page-description-toggle--corner:focus-visible {
  background: transparent;
  border: none;
  box-shadow: none;
  outline: none;
}

.page-description-toggle--corner:focus-visible .page-description-chevron {
  outline: 2px solid rgba(59, 130, 246, 0.75);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Secondary chat buttons on info page */
.theme-container1 .info-chat-actions .btn-echo-o3,
.theme-container2 .info-chat-actions .btn-echo2-outline {
  background: transparent;
  border: 2px solid #4A3728;
  color: #4A3728;
  box-shadow: none;
}
.theme-container2 .info-chat-actions .btn-echo2-outline:hover {
  background: rgba(74, 55, 40, 0.08);
  transform: none;
}
.theme-container3 .info-chat-actions .fantasy-button-outline,
.theme-container4 .chat-actions-retro .btn-retro.ghost,
.theme-container5 .info-chat-actions .btn-neon.ghost {
  opacity: 0.92;
}

/* Chat info action buttons: uniform height, primary visually dominant */
.theme-container .info-chat-actions > button,
.theme-container4 .chat-actions-retro > button {
  width: auto;
  min-width: 128px;
  min-height: 42px;
  padding: 8px 20px;
}

.theme-container .info-chat-actions > button[data-bind="toThePrivateChatBtn"],
.theme-container4 .chat-actions-retro > button[data-bind="toThePrivateChatBtn"] {
  min-width: 170px;
  font-weight: 700;
}

/* "Watch scene" button beside the chat info title */
.chat-title-row .chat-title-scene-btn {
  flex: 0 1 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  padding: 0.3rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #2563eb;
  color: #2563eb;
  background: #fff;
  cursor: pointer;
  white-space: normal;
  text-align: center;
}

.chat-title-row .chat-title-scene-btn:hover {
  background: #eff6ff;
}

.chat-title-row .chat-title-scene-btn .welcome-scene-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid #e5e7eb;
  display: block;
}

.theme-container4 .chat-title-row .chat-title-scene-btn,
.theme-container5 .chat-title-row .chat-title-scene-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(122, 170, 255, 0.5);
  color: #9ec1ff;
}

.theme-container4 .chat-title-row .chat-title-scene-btn:hover,
.theme-container5 .chat-title-row .chat-title-scene-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Scene video popup (shared with echo page markup) */
.welcome-scene-video-backdrop {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.welcome-scene-video-backdrop.hidden {
  display: none;
}

.welcome-scene-video-modal {
  position: relative;
  width: min(960px, 100%);
  max-height: 90vh;
  background: #000;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.welcome-scene-video-modal video {
  width: 100%;
  max-height: 85vh;
  display: block;
  background: #000;
}

.welcome-scene-video-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 9999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

/* Echo contest nav button */
.contest-nav-echo-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.6rem;
  margin-left: 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border-color, #cbd5e1);
  background: var(--surface-2, rgba(255, 255, 255, 0.85));
  color: var(--text-primary, inherit);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.contest-nav-echo-btn:hover {
  background: var(--surface-3, #f1f5f9);
  border-color: var(--accent, #2563eb);
}

.contest-nav-smooth-entry .theme-container,
.contest-nav-smooth-entry .echo-container {
  animation: none !important;
}

/* ── Contest entry cards (contest / chat-author / chat-tag grids) ── */

:is(.echo-cards-grid, #promotedSection) .contest-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(120, 140, 170, 0.25);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.12s;
  position: relative;
  box-shadow: 0 8px 24px rgba(20, 30, 60, 0.08);
  opacity: 1;
}

:is(.echo-cards-grid, #promotedSection) .contest-card:hover {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

:is(.echo-cards-grid, #promotedSection) .contest-card-expanded {
  z-index: 30;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.3);
}

:is(.echo-cards-grid, #promotedSection) .contest-card-cover-wrap {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--surface-2, #111);
}

:is(.echo-cards-grid, #promotedSection) .contest-card-scene .contest-card-cover-wrap {
  aspect-ratio: auto;
  flex: 1;
  min-height: 200px;
}

:is(.echo-cards-grid, #promotedSection) .contest-card-scene .contest-card-body {
  flex: 0 0 auto;
}

:is(.echo-cards-grid, #promotedSection) .contest-card-cover-wrap > a {
  position: absolute;
  inset: 0;
  display: block;
}

:is(.echo-cards-grid, #promotedSection) .contest-card-cover,
:is(.echo-cards-grid, #promotedSection) .contest-card-cover-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

:is(.echo-cards-grid, #promotedSection) .contest-card-cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  color: #888;
  font-size: 2rem;
}

:is(.echo-cards-grid, #promotedSection) .contest-card-type-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

:is(.echo-cards-grid, #promotedSection) .contest-card-status {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--surface-1);
  color: var(--text-primary);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

:is(.echo-cards-grid, #promotedSection) .contest-card-body {
  padding: 0.75rem 0.85rem 0.5rem;
  flex: 1;
  min-height: 0;
}

:is(.echo-cards-grid, #promotedSection) .contest-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.35;
  margin: 0 0 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

:is(.echo-cards-grid, #promotedSection) .contest-card-author {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

:is(.echo-cards-grid, #promotedSection) .contest-card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

:is(.echo-cards-grid, #promotedSection) .contest-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem 0.75rem;
  border-top: 1px solid var(--border-color);
}

:is(.echo-cards-grid, #promotedSection) .contest-card-stats {
  display: flex;
  gap: 0.65rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

:is(.echo-cards-grid, #promotedSection) .contest-card-heart {
  color: #ef4444;
}

:is(.echo-cards-grid, #promotedSection) .contest-card-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--accent, #F97316);
  background: #ffffff;
  color: #1f2937;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

:is(.echo-cards-grid, #promotedSection) .contest-card-cta:hover {
  background: #fff7ed;
  border-color: var(--accent-hover, #EA6A00);
  color: #1f2937;
}

:is(.echo-cards-grid, #promotedSection) .contest-card-create {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 200px;
  border: 1.5px dashed #8b5cf6;
  background: rgba(15, 23, 42, 0.04);
  border-radius: 12px;
  padding: 1rem;
  color: var(--text-secondary);
  transition: border-color 0.15s, background 0.15s;
}

:is(.echo-cards-grid, #promotedSection) .contest-card-create:hover {
  border-color: #8b5cf6;
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-primary);
}

:is(.echo-cards-grid, #promotedSection) .contest-card-create-label {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--quizly-violet, #7c3aed);
}

:is(.echo-cards-grid, #promotedSection) .contest-card-create-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  width: min(100%, 16rem);
}

@media (max-width: 768px) {
  .contest-rules-grid {
    grid-template-columns: 1fr;
    gap: 1rem 0;
  }

  .contest-page-title {
    font-size: 1.25rem;
    padding: 0.75rem 1rem;
  }

  .contest-rules-right-column {
    align-self: stretch;
  }

  .contest-rules-section {
    padding: 0.85rem 1rem;
  }

  #contestChatsGrid,
  #authorChatsGrid,
  #tagChatsGrid {
    grid-template-columns: 1fr;
  }

  #mainContentSection,
  #contestEntriesSection,
  #contestRulesGridSection {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}

@media (max-width: 640px) {
  .contest-nav-modal {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: none;
    max-height: 75vh;
    border-radius: 12px 12px 0 0;
    margin-left: 0;
  }

  .contest-rules-popup-modal {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: none;
    max-height: 75vh;
    border-radius: 12px 12px 0 0;
    margin-left: 0;
  }
}
