:root {
  color-scheme: light;
  --bg: #eef4fb;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --panel-border: #d8e3f0;
  --text: #132238;
  --muted: #5e6d83;
  --accent: #1f6fff;
  --accent-soft: #e8f0ff;
  --sky-soft: #ebf6ff;
  --coral: #c83f2c;
  --coral-soft: #fdebe8;
  --success: #1d7d4d;
  --success-soft: #e4f6eb;
  --shadow: 0 18px 42px rgba(20, 42, 74, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(31, 111, 255, 0.08), transparent 30%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
  color: var(--text);
}

body.modal-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
  letter-spacing: 0;
}

.app-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 32px;
  display: grid;
  gap: 16px;
}

.app-header,
.panel-head,
.summary-head,
.question-toolbar,
.auth-actions,
.jump-controls,
.metric-row,
.action-row,
.member-card,
.account-actions {
  display: flex;
  gap: 12px;
}

.app-header,
.panel-head,
.summary-head,
.member-card {
  align-items: center;
  justify-content: space-between;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.app-header h1 {
  font-size: clamp(30px, 6vw, 42px);
}

.header-user {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  backdrop-filter: blur(8px);
}

.menu-bar {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(216, 227, 240, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.menu-btn,
.primary-btn,
.ghost-btn,
.answer-option,
.jump-controls input {
  border-radius: 14px;
}

.menu-btn,
.primary-btn,
.ghost-btn {
  min-height: 46px;
  border: 1px solid transparent;
  cursor: pointer;
}

.menu-btn {
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.menu-btn.is-active {
  background: var(--panel-strong);
  color: var(--accent);
  border-color: #c9dbff;
  box-shadow: inset 0 0 0 1px rgba(31, 111, 255, 0.04);
}

.page-section,
.page-content {
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 18px;
}

.summary-panel,
.question-panel,
.image-panel,
.navigator-panel,
.account-panel {
  display: grid;
  gap: 16px;
}

.empty-state {
  text-align: center;
  justify-items: center;
  gap: 12px;
}

.empty-state h2 {
  font-size: 24px;
}

.empty-state p,
.muted {
  color: var(--muted);
}

.summary-kicker {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 4px;
}

.metric-row {
  flex-wrap: wrap;
}

.metric-card {
  flex: 1 1 0;
  min-width: 110px;
  padding: 14px 16px;
  border-radius: 18px;
  display: grid;
  gap: 4px;
  border: 1px solid transparent;
}

.metric-card span {
  font-size: 13px;
  color: var(--muted);
}

.metric-card strong {
  font-size: 28px;
}

.blue-card {
  background: var(--accent-soft);
  border-color: #d4e1ff;
}

.sky-card {
  background: var(--sky-soft);
  border-color: #d2ebff;
}

.coral-card {
  background: var(--coral-soft);
  border-color: #f6d5cf;
}

.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: #e5edf7;
  overflow: hidden;
}

.progress-bar > div {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #1f6fff, #5f97ff);
  transition: width 180ms ease;
}

.question-toolbar {
  justify-content: space-between;
}

.question-card {
  display: grid;
  gap: 16px;
}

.question-card h2,
.panel h2 {
  font-size: clamp(22px, 4.8vw, 30px);
  line-height: 1.32;
}

.answers {
  display: grid;
  gap: 12px;
}

.answer-option {
  border: 1px solid var(--panel-border);
  background: var(--panel-strong);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.answer-option:hover {
  transform: translateY(-1px);
  border-color: #bdd0e5;
}

.answer-option input {
  margin-top: 3px;
}

.answer-label {
  min-width: 24px;
  font-weight: 700;
}

.answer-option.correct {
  border-color: #9ad4b3;
  background: var(--success-soft);
}

.answer-option.incorrect {
  border-color: #f1b2a8;
  background: var(--coral-soft);
}

.action-row {
  justify-content: stretch;
}

.wide-btn {
  width: 100%;
}

.feedback {
  border-radius: 16px;
  padding: 14px 16px;
  font-weight: 700;
}

.feedback.correct {
  background: var(--success-soft);
  color: var(--success);
}

.feedback.incorrect {
  background: var(--coral-soft);
  color: var(--coral);
}

.image-placeholder,
.image-wrap {
  border-radius: 18px;
  border: 1px solid var(--panel-border);
  background: #f6f9fd;
}

.image-placeholder {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px;
  color: var(--muted);
}

.image-wrap {
  padding: 12px;
  overflow: auto;
}

.image-wrap img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  cursor: zoom-in;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
}

.image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 20, 38, 0.72);
  backdrop-filter: blur(6px);
}

.image-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  max-height: calc(100vh - 36px);
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(216, 227, 240, 0.95);
  box-shadow: 0 24px 52px rgba(7, 18, 38, 0.28);
}

.image-modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.image-modal-bar h2 {
  font-size: 18px;
}

.image-close-btn {
  min-width: 72px;
}

.image-modal-content {
  overflow: auto;
  border-radius: 16px;
  background: #f6f9fd;
}

.image-modal-content img {
  display: block;
  width: 100%;
  height: auto;
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.nav-chip {
  min-height: 38px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel-strong);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  padding: 6px 0;
}

.nav-chip.current {
  border-color: #c5d8ff;
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-chip.correct {
  background: var(--success-soft);
  border-color: #9bd2b2;
  color: var(--success);
}

.nav-chip.wrong {
  background: var(--coral-soft);
  border-color: #f1b2a8;
  color: var(--coral);
}

.jump-box {
  display: grid;
  gap: 6px;
}

.jump-box label,
.auth-form label {
  display: grid;
  gap: 6px;
}

.jump-controls input,
.auth-form input {
  min-height: 46px;
  border: 1px solid var(--panel-border);
  background: var(--panel-strong);
  padding: 11px 14px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-actions,
.account-actions {
  flex-wrap: wrap;
}

.account-guest,
.account-member {
  display: grid;
  gap: 16px;
}

.member-card {
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(31, 111, 255, 0.08), rgba(95, 151, 255, 0.04));
  border: 1px solid #d5e3ff;
}

.member-card h3 {
  font-size: 26px;
}

.inline-message {
  border-radius: 14px;
  padding: 13px 14px;
  font-weight: 700;
  background: var(--coral-soft);
  color: var(--coral);
}

.primary-btn {
  background: linear-gradient(135deg, #1f6fff, #3a84ff);
  color: #fff;
}

.ghost-btn {
  background: var(--panel-strong);
  color: var(--text);
  border-color: var(--panel-border);
}

.ghost-btn.is-active {
  border-color: #c5d8ff;
  background: var(--accent-soft);
  color: var(--accent);
}

.hidden {
  display: none !important;
}

@media (min-width: 900px) {
  .app-shell {
    padding: 28px 24px 48px;
  }

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

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

  .auth-actions {
    grid-column: 1 / -1;
  }

  .inline-message {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .menu-bar {
    gap: 6px;
    padding: 6px;
  }

  .menu-btn,
  .primary-btn,
  .ghost-btn {
    min-height: 42px;
  }

  .menu-btn {
    font-size: 14px;
    padding: 0 4px;
  }

  .question-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
  }

  .nav-chip {
    min-height: 34px;
    border-radius: 10px;
    font-size: 13px;
  }

  .image-modal {
    padding: 10px;
  }

  .image-modal-dialog {
    max-height: calc(100vh - 20px);
    padding: 12px;
    border-radius: 18px;
  }

  .image-modal-bar h2 {
    font-size: 16px;
  }

  .image-close-btn {
    min-width: 64px;
    padding: 0 12px;
  }
}
