:root {
  --navy: #161f38;
  --blue: #347ae1;
  --pink: #e41079;
  --bg: #0e1426;
  --surface: #161f38;
  --surface-2: #1c2744;
  --text: #f3f6ff;
  --muted: #93a4c7;
  --primary: #347ae1;
  --primary-hover: #4b8aef;
  --accent: #e41079;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --border: rgba(148, 173, 220, 0.16);
  --shadow: 0 12px 32px rgba(5, 10, 24, 0.35);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  --display: "Sora", "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(52, 122, 225, 0.28), transparent 55%),
    radial-gradient(700px 380px at 92% 0%, rgba(228, 16, 121, 0.18), transparent 50%),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.35;
  mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 40px;
  position: relative;
  z-index: 1;
}

.container.narrow {
  width: min(560px, calc(100% - 28px));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(22, 31, 56, 0.88);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  position: sticky;
  top: 12px;
  z-index: 20;
}

.brand-home {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo-img {
  display: block;
  height: 28px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
}

.brand-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-tag {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b8c8ea;
  font-weight: 700;
}

.auth-tabs,
.panel-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.auth-tab,
.panel-tab {
  border: 1px solid rgba(148, 173, 220, 0.28);
  background: rgba(10, 15, 28, 0.35);
  color: #dce8ff;
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 36px;
  font-size: 13px;
  box-shadow: none;
}

.auth-tab.active,
.panel-tab.active {
  background: rgba(52, 122, 225, 0.22);
  border-color: rgba(52, 122, 225, 0.55);
  color: #fff;
}

.auth-tab:hover,
.panel-tab:hover {
  background: rgba(52, 122, 225, 0.18);
}

.page-hero {
  margin-bottom: 18px;
}

.page-hero h1 {
  margin: 0 0 6px;
}

.page-hero p {
  margin: 0;
  max-width: 54ch;
}

.card {
  background: linear-gradient(160deg, rgba(22, 31, 56, 0.96), rgba(28, 39, 68, 0.94));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-header h1,
.card-header h2 {
  margin: 0;
}

.card-header p {
  margin: 4px 0 0;
}

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

.section-title h2 {
  margin: 0;
}

h1,
h2,
h3 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  text-transform: none;
}

h1 {
  font-size: clamp(1.6rem, 3.4vw, 2rem);
}

h2 {
  font-size: clamp(1.15rem, 2.2vw, 1.35rem);
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0 0 8px;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.center {
  text-align: center;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.row.spread {
  justify-content: space-between;
}

.control-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #c5d3ef;
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.actions.primary-row {
  margin-top: 4px;
}

button,
.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
}

button:hover,
.btn:hover {
  background: var(--primary-hover);
}

button:active,
.btn:active {
  transform: translateY(1px);
}

button.secondary,
.btn.secondary {
  background: rgba(52, 122, 225, 0.14);
  color: #dce8ff;
  border: 1px solid rgba(52, 122, 225, 0.35);
}

button.secondary:hover,
.btn.secondary:hover {
  background: rgba(52, 122, 225, 0.24);
}

button.ghost,
.btn.ghost {
  background: transparent;
  border: 1px solid rgba(148, 173, 220, 0.28);
  color: #dce8ff;
}

button.ghost:hover,
.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.04);
}

button.danger,
.btn.danger {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #ffc1c1;
}

button.danger:hover,
.btn.danger:hover {
  background: rgba(239, 68, 68, 0.24);
}

button.accent,
.btn.accent {
  background: var(--accent);
}

button.accent:hover,
.btn.accent:hover {
  background: #f0288a;
}

button.btn-sm,
.btn.btn-sm {
  min-height: 36px;
  padding: 7px 12px;
  font-size: 13px;
}

button.btn-block,
.btn.btn-block {
  width: 100%;
}

button:disabled,
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(148, 173, 220, 0.22);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: rgba(10, 15, 28, 0.72);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(52, 122, 225, 0.7);
  box-shadow: 0 0 0 3px rgba(52, 122, 225, 0.18);
}

textarea {
  min-height: 84px;
  resize: vertical;
}

input.correct-option {
  width: 18px;
  min-width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  margin-top: 12px;
  cursor: pointer;
  accent-color: var(--accent);
  box-shadow: none;
}

input::placeholder,
textarea::placeholder {
  color: #7f91b5;
}

.status-strip {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
  margin-bottom: 14px;
}

.status-pill {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(10, 15, 28, 0.45);
  border: 1px solid var(--border);
}

.status-pill .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.status-pill .value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(52, 122, 225, 0.16);
  color: #d9e6ff;
  border: 1px solid rgba(52, 122, 225, 0.3);
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  background: rgba(34, 197, 94, 0.12);
  color: #9ef0b8;
  border-color: rgba(34, 197, 94, 0.4);
}

.badge.warn {
  background: rgba(245, 158, 11, 0.14);
  color: #ffd58a;
  border-color: rgba(245, 158, 11, 0.4);
}

.badge.danger {
  background: rgba(228, 16, 121, 0.14);
  color: #ffb0d4;
  border-color: rgba(228, 16, 121, 0.4);
}

.hidden {
  display: none !important;
}

.mode-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(10, 15, 28, 0.35);
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
  min-height: 148px;
}

.mode-card:hover {
  border-color: rgba(52, 122, 225, 0.55);
  background: rgba(52, 122, 225, 0.08);
  transform: translateY(-2px);
}

.mode-card.accent:hover {
  border-color: rgba(228, 16, 121, 0.55);
  background: rgba(228, 16, 121, 0.08);
}

.mode-card h2 {
  margin: 0;
}

.mode-card p {
  margin: 0;
  flex: 1;
}

.mode-card .cta {
  margin-top: auto;
  font-size: 13px;
  font-weight: 800;
  color: #9ec2ff;
}

.mode-card.accent .cta {
  color: #ff9ec8;
}

.question-item {
  border: 1px solid rgba(52, 122, 225, 0.22);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  background: rgba(10, 15, 28, 0.4);
}

.option-item {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 10px;
  align-items: start;
  margin-bottom: 8px;
}

.preview-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: rgba(10, 15, 28, 0.35);
  max-height: min(60vh, 520px);
  overflow: auto;
}

.preview-box ol {
  margin: 8px 0 0;
  padding-left: 18px;
}

.preview-box li {
  margin-bottom: 10px;
}

.preview-box ul {
  margin: 6px 0 0;
  padding-left: 16px;
  color: var(--muted);
}

.preview-box .correct-mark {
  color: #9ef0b8;
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 22, 0.72);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(86vh, 820px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(22, 31, 56, 0.98), rgba(28, 39, 68, 0.98));
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  padding: 16px;
}

.modal-panel-wide {
  width: min(920px, 100%);
  max-height: min(90vh, 900px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 8px;
  background: linear-gradient(160deg, rgba(22, 31, 56, 0.98), rgba(28, 39, 68, 0.98));
}

.modal-header h2 {
  margin: 0;
}

.feedback {
  margin-top: 10px;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

.option-btn {
  width: 100%;
  text-align: left;
  min-height: 56px;
  padding: 14px 16px;
  font-size: 16px;
  background: rgba(52, 122, 225, 0.12);
  border: 1px solid rgba(52, 122, 225, 0.28);
  box-shadow: none;
}

.option-btn:hover:not(:disabled) {
  background: rgba(52, 122, 225, 0.22);
  border-color: rgba(52, 122, 225, 0.55);
}

.option-btn:disabled {
  opacity: 0.7;
}

.question-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.timer-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 14px;
}

.timer-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--pink));
  transform-origin: left center;
  transition: width 0.2s linear;
}

.welcome-panel {
  text-align: center;
  padding: 18px 8px 8px;
}

.welcome-panel .pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  margin: 0 auto 14px;
  box-shadow: 0 0 0 0 rgba(228, 16, 121, 0.55);
  animation: pulse 1.6s infinite;
}

.welcome-copy {
  margin-top: 14px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  color: #ffe08a;
}

.results-toolbar {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(10, 15, 28, 0.35);
}

.results-toolbar-actions .actions {
  flex-wrap: nowrap;
}

.metrics-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 14px;
}

.metric-card {
  background: rgba(10, 15, 28, 0.45);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.metric-card .metric-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.metric-card .metric-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
  word-break: break-word;
}

.metric-card.accent .metric-value {
  color: #7eb6ff;
}

.metric-card.ok .metric-value {
  color: #9ef0b8;
}

.metric-card.warn .metric-value {
  color: #ffb0d4;
}

.questions-breakdown {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(10, 15, 28, 0.28);
}

.questions-breakdown-title {
  margin: 0;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 800;
  border-bottom: 1px solid var(--border);
  background: rgba(52, 122, 225, 0.1);
}

.question-stat {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 173, 220, 0.1);
}

.question-stat:last-child {
  border-bottom: none;
}

.question-stat-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 6px;
}

.question-stat-head strong {
  font-size: 14px;
}

.question-stat-meta {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 6px;
}

.question-stat-options {
  margin: 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 12px;
}

.result-summary {
  margin-top: 12px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.result-summary > div,
.results-summary-grid > div {
  background: rgba(10, 15, 28, 0.45);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
}

.result-summary.success {
  outline: 1px solid rgba(34, 197, 94, 0.45);
}

.results-table-wrap,
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

th,
td {
  border-bottom: 1px solid rgba(148, 173, 220, 0.12);
  padding: 10px 12px;
  font-size: 13px;
  text-align: left;
  vertical-align: top;
}

th {
  background: rgba(52, 122, 225, 0.16);
  color: #eaf1ff;
  font-weight: 700;
  position: sticky;
  top: 0;
}

td {
  background: transparent;
}

tr:last-child td {
  border-bottom: none;
}

.dollar-rain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

#finishedCard {
  position: relative;
}

.dollar-drop {
  position: absolute;
  top: -40px;
  color: #58f1ab;
  text-shadow: 0 0 10px rgba(88, 241, 171, 0.6);
  animation: dollar-fall linear forwards;
  font-weight: 700;
}

.split-2 {
  display: grid;
  gap: 14px;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(228, 16, 121, 0.5);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(228, 16, 121, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(228, 16, 121, 0);
  }
}

@keyframes dollar-fall {
  0% {
    transform: translateY(-20px) rotate(0deg);
  }
  100% {
    transform: translateY(120vh) rotate(360deg);
  }
}

@media (min-width: 720px) {
  .mode-grid {
    grid-template-columns: 1fr 1fr;
  }

  .status-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .control-grid.cols-2 {
    grid-template-columns: 1.4fr 0.8fr;
  }

  .control-grid.cols-3 {
    grid-template-columns: 1.2fr 0.7fr auto;
  }

  .options-grid {
    grid-template-columns: 1fr 1fr;
  }

  .split-2 {
    grid-template-columns: 1.1fr 0.9fr;
  }

  .brand-subtitle {
    max-width: 320px;
  }

  .results-toolbar {
    grid-template-columns: 1.1fr 1.3fr 1fr auto;
    align-items: end;
  }

  .metrics-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 719px) {
  .topbar {
    position: static;
  }

  .brand-meta {
    display: none;
  }

  .actions,
  .row {
    width: 100%;
  }

  .actions button,
  .row > button,
  .row > select,
  .row > input {
    flex: 1 1 100%;
  }
}
