:root {
  --jeopardy-primary: #f09e0b;
  --jeopardy-secondary: #5dd0ff;
  --jeopardy-card-bg: #263549;
  --jeopardy-border: #475569;
  --jeopardy-text: #e5e7eb;
  --jeopardy-muted: #94a3b8;
  --generator-primary: var(--jeopardy-primary);
  --generator-panel-border: var(--jeopardy-border);
  --generator-panel-surface: linear-gradient(180deg, rgba(44, 63, 74, 0.96), rgba(20, 30, 39, 0.98));
  --generator-hero-note-gap: 0.85rem;
  --generator-hero-note-title-space: 0;
}

.jeopardy-generator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr);
  gap: 2rem;
  align-items: start;
}

.form-grid,
.form-group,
.topics-editor {
  display: grid;
  gap: 1rem;
}

.form-group label {
  color: #e2e8f0;
  font-weight: 600;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.9rem 1rem;
  background-color: #1a252f;
  color: #ffffff;
  border: 1px solid var(--jeopardy-border);
  border-radius: 10px;
  font-size: 0.98rem;
  font: inherit;
}

.form-group textarea {
  min-height: 130px;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--jeopardy-primary);
  box-shadow: 0 0 0 3px rgba(240, 158, 11, 0.14);
}

.section-head {
  margin-bottom: 1rem;
}

.section-head > *,
.topic-editor-head > *,
.question-editor-head > *,
.topics-modal-head > *,
.topics-modal-toolbar > * {
  min-width: 0;
}

.preview-head {
  margin-bottom: 1.25rem;
}

.helper-text,
.note {
  color: var(--jeopardy-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(93, 208, 255, 0.35);
  background: rgba(11, 32, 46, 0.55);
  color: #d6f5ff;
  font-weight: 700;
}

.topics-editor {
  margin-top: 1rem;
}

.generator-summary-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.status-badge-secondary {
  border-color: rgba(240, 158, 11, 0.28);
  background: rgba(240, 158, 11, 0.12);
  color: #ffe6b2;
}

.modal-launch-card {
  padding: 1rem 1.15rem;
  border-radius: 16px;
  border: 1px solid rgba(93, 208, 255, 0.18);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.48), rgba(22, 34, 45, 0.88));
  color: #d7dee8;
  line-height: 1.6;
}

.topic-editor {
  border: 1px solid rgba(93, 208, 255, 0.24);
  border-radius: 18px;
  padding: 1.25rem;
  background: linear-gradient(160deg, rgba(16, 32, 44, 0.92), rgba(36, 54, 66, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.topic-editor-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.topic-editor-title {
  margin: 0;
  color: #ffffff;
}

.topic-question-list {
  display: grid;
  gap: 0.9rem;
}

.question-editor-card {
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid rgba(240, 158, 11, 0.22);
  background: rgba(15, 23, 42, 0.46);
}

.question-editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.question-editor-head strong {
  color: #ffffff;
}

.point-badge {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(240, 158, 11, 0.18);
  color: #ffd88f;
  font-weight: 700;
}

.question-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.question-editor-grid textarea {
  min-height: 96px;
}

.question-editor-grid textarea[name^="answer"] {
  min-height: 76px;
}

.topic-actions,
.link-output {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.import-layout {
  display: grid;
  gap: 1rem;
}

.import-option {
  display: grid;
  gap: 0.85rem;
  padding: 1.1rem 1.15rem;
  border-radius: 18px;
  border: 1px solid rgba(93, 208, 255, 0.18);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.42), rgba(22, 34, 45, 0.88));
}

.import-option h3 {
  margin: 0;
  color: #ffffff;
  font-size: 1.05rem;
}

.import-option-csv {
  border-color: rgba(240, 158, 11, 0.38);
  background: linear-gradient(160deg, rgba(64, 39, 8, 0.55), rgba(27, 38, 49, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.import-option-json {
  border-color: rgba(93, 208, 255, 0.2);
}

.import-label {
  margin: 0;
  color: #ffd88f;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topic-actions {
  margin-top: 1rem;
}

.action-button,
.secondary-button,
.ghost-button,
.text-link-copy {
  min-height: 2.85rem;
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.button-link {
  min-height: 2.85rem;
}

.action-row > * {
  min-width: 0;
}

.export-panel .action-row {
  justify-content: space-between;
}

.action-button {
  background: linear-gradient(135deg, var(--jeopardy-primary), #ffb640);
  color: #17212b;
}

.secondary-button {
  background: #475569;
  color: #ffffff;
}

.ghost-button,
.text-link-copy {
  background: transparent;
  color: #ffd88f;
  border: 1px solid rgba(240, 158, 11, 0.45);
}

.danger-button {
  background: linear-gradient(135deg, #7f1d1d, #dc2626);
  color: #fff7f7;
  border-color: rgba(254, 202, 202, 0.3);
  box-shadow: 0 12px 24px rgba(127, 29, 29, 0.24);
}

.action-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.text-link-copy:hover {
  transform: translateY(-2px);
}

.danger-button:hover,
.danger-button:focus-visible {
  background: linear-gradient(135deg, #991b1b, #ef4444);
  box-shadow: 0 16px 28px rgba(127, 29, 29, 0.3);
}

.jeopardy-preview {
  overflow-x: auto;
}

.jeopardy-preview-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0.55rem;
}

.jeopardy-preview-table th,
.jeopardy-preview-table td {
  min-width: 120px;
  text-align: center;
  padding: 1rem 0.8rem;
  border-radius: 16px;
}

.jeopardy-preview-table th {
  background: linear-gradient(180deg, rgba(93, 208, 255, 0.25), rgba(34, 58, 76, 0.9));
  color: #ffffff;
  border: 1px solid rgba(93, 208, 255, 0.28);
}

.jeopardy-preview-table td {
  background: linear-gradient(180deg, rgba(240, 158, 11, 0.22), rgba(27, 38, 49, 0.96));
  color: #ffe6b2;
  border: 1px solid rgba(240, 158, 11, 0.25);
  font-size: 1.25rem;
  font-weight: 800;
}

.jeopardy-preview-table td.is-empty {
  background: rgba(15, 23, 42, 0.35);
  border: 1px dashed rgba(148, 163, 184, 0.28);
  color: #64748b;
}

.help-card {
  display: grid;
  gap: 0.8rem;
  color: #d7dee8;
}

.link-card,
.qr-card {
  flex: 1 1 220px;
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid var(--jeopardy-border);
  background: rgba(15, 23, 42, 0.38);
}

.link-card.hidden,
.qr-card.hidden,
.preview-panel.hidden,
.hidden {
  display: none;
}

.link-card a {
  overflow-wrap: anywhere;
  color: #ffffff;
}

body.modal-open {
  overflow: hidden;
}

.topics-modal {
  width: min(1120px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  margin: auto;
  padding: 0;
  border: 1px solid rgba(93, 208, 255, 0.28);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(12, 19, 27, 0.98), rgba(27, 39, 50, 0.98));
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
  color: var(--jeopardy-text);
}

.topics-modal::backdrop {
  background: rgba(5, 12, 18, 0.72);
  backdrop-filter: blur(6px);
}

.topics-modal-shell {
  display: grid;
  gap: 1.25rem;
  padding: 1.5rem;
}

.topics-modal-frame {
  padding: 1rem 1.15rem;
  border-radius: 18px;
  border: 1px solid rgba(93, 208, 255, 0.2);
  background: linear-gradient(180deg, rgba(14, 25, 34, 0.86), rgba(24, 37, 48, 0.94));
}

.topics-modal-section-title {
  margin: 0 0 1rem;
  color: #ffffff;
  font-size: 1.05rem;
}

.topics-modal-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.topics-modal-eyebrow {
  margin-bottom: 0.65rem;
}

.topics-modal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.csv-import-modal {
  width: min(680px, calc(100vw - 2rem));
}

.csv-import-frame {
  gap: 1rem;
}

.csv-upload-label {
  color: #e2e8f0;
  font-weight: 600;
}

.csv-upload-row {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  flex-wrap: wrap;
}

.csv-file-name {
  color: var(--jeopardy-muted);
  overflow-wrap: anywhere;
}

.csv-hint {
  margin: 0.45rem 0 0;
  color: #cbd5e1;
  font-size: 0.92rem;
  line-height: 1.5;
}

.csv-import-actions {
  display: flex;
  justify-content: flex-end;
}

.topics-editor-modal {
  max-height: calc(100vh - 15rem);
  overflow: auto;
  padding-right: 0.35rem;
}

.topics-editor-modal::-webkit-scrollbar {
  width: 10px;
}

.topics-editor-modal::-webkit-scrollbar-thumb {
  background: rgba(93, 208, 255, 0.28);
  border-radius: 999px;
}

.qr-card img {
  width: min(220px, 100%);
  border-radius: 14px;
  background: #ffffff;
  padding: 0.6rem;
}

@media (max-width: 1180px) {
  .jeopardy-generator-layout {
    gap: 1.5rem;
  }
}

@media (max-width: 980px) {
  .jeopardy-generator-layout,
  .question-editor-grid {
    grid-template-columns: 1fr;
  }

  .section-head,
  .topic-editor-head,
  .topics-modal-head,
  .topics-modal-toolbar,
  .question-editor-head {
    flex-direction: column;
    align-items: stretch;
  }

  .section-head .action-button,
  .status-badge {
    align-self: flex-start;
  }

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

  .generator-stack,
  .preview-stack,
  .link-output {
    gap: 1.25rem;
  }

  .topics-editor-modal {
    max-height: calc(100vh - 13rem);
  }
}

@media (max-width: 720px) {
  .action-row {
    grid-template-columns: 1fr;
  }

  .topic-actions,
  .csv-upload-row {
    flex-direction: column;
    align-items: stretch;
  }

  .action-row > *,
  .topic-actions > *,
  .csv-upload-row > * {
    width: 100%;
  }

  .topics-modal {
    width: min(100vw - 1rem, 100%);
    max-height: calc(100vh - 1rem);
    border-radius: 18px;
  }

  .csv-import-modal {
    width: min(100vw - 1rem, 100%);
  }

  .topics-modal-shell {
    padding: 1rem;
    gap: 1rem;
  }

  .topics-modal-frame,
  .topic-editor,
  .question-editor-card {
    padding: 1rem;
  }
}

@media (max-width: 560px) {
  .generator-panel,
  .preview-panel,
  .import-panel,
  .export-panel,
  .import-option,
  .topic-editor,
  .question-editor-card,
  .link-card,
  .qr-card,
  .topics-modal-frame {
    padding: 1rem;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .panel-title {
    margin-bottom: 0.75rem;
  }

  .action-button,
  .secondary-button,
  .ghost-button,
  .text-link-copy {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.7rem 0.9rem;
    font-size: 0.94rem;
  }

  .button-link {
    min-height: 2.75rem;
  }

  .status-badge {
    width: 100%;
    justify-content: center;
  }

  .jeopardy-preview-table th,
  .jeopardy-preview-table td {
    min-width: 100px;
    padding: 0.85rem 0.65rem;
  }
}

@media (max-width: 420px) {
  .import-option,
  .topic-editor,
  .question-editor-card,
  .link-card,
  .qr-card,
  .topics-modal-frame {
    border-radius: 14px;
  }

  .topics-modal,
  .csv-import-modal {
    width: calc(100vw - 0.5rem);
    max-height: calc(100vh - 0.5rem);
    border-radius: 16px;
  }
}