:root {
  --ft-red: #ee3124;
  --ft-red-strong: #c72b20;
  --ft-red-deep: #9f2219;
  --ft-ink: #1f2430;
  --ft-ink-soft: #546071;
  --ft-border: #d8dde5;
  --ft-paper: #f3f5f8;
  --ft-surface: #ffffff;
  --ft-surface-soft: #f9fafb;
  --ft-success: #0f7a4a;
  --ft-warn: #9a4f06;
  --ft-danger: #ad2119;
  --shadow-lg: 0 24px 44px rgba(24, 32, 48, 0.15);
  --shadow-md: 0 14px 26px rgba(24, 32, 48, 0.1);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Barlow", "Segoe UI", sans-serif;
  color: var(--ft-ink);
  background:
    radial-gradient(circle at 10% 16%, rgba(238, 49, 36, 0.2) 0%, rgba(238, 49, 36, 0) 42%),
    radial-gradient(circle at 92% 10%, rgba(60, 72, 90, 0.2) 0%, rgba(60, 72, 90, 0) 45%),
    linear-gradient(150deg, #f6f7f9 0%, #edf1f5 56%, #f7f3f3 100%);
  padding: 30px 16px 56px;
}

.brand-ribbon {
  position: fixed;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--ft-red) 0%, #ff5f55 44%, var(--ft-red-deep) 100%);
  z-index: 20;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  z-index: -1;
}

.shape-a {
  width: 340px;
  height: 340px;
  left: -120px;
  top: 36%;
  background: radial-gradient(circle at 32% 36%, rgba(238, 49, 36, 0.2), rgba(238, 49, 36, 0));
}

.shape-b {
  width: 270px;
  height: 270px;
  right: -80px;
  top: 16%;
  background: radial-gradient(circle at 40% 30%, rgba(31, 36, 48, 0.2), rgba(31, 36, 48, 0));
}

.app-shell {
  width: min(1160px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.card {
  border: 1px solid var(--ft-border);
  border-radius: var(--radius-xl);
  background: var(--ft-surface);
  box-shadow: var(--shadow-md);
}

.app-header {
  position: relative;
  overflow: hidden;
  padding: 30px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.6s ease;
}

.app-header::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(130deg, rgba(255, 255, 255, 0) 0%, rgba(238, 49, 36, 0.08) 58%, rgba(238, 49, 36, 0.18) 100%);
}

.brand-mark {
  margin: 0;
  font-family: "Sora", "Segoe UI", sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ft-red);
}

.app-header h1 {
  position: relative;
  margin: 10px 0 10px;
  font-family: "Sora", "Segoe UI", sans-serif;
  font-size: clamp(1.8rem, 3.5vw, 2.7rem);
  line-height: 1.08;
  z-index: 1;
}

.subtitle {
  position: relative;
  margin: 0;
  max-width: 760px;
  color: var(--ft-ink-soft);
  font-size: 1.04rem;
  z-index: 1;
}

.header-tags {
  position: relative;
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  z-index: 1;
}

.header-tag {
  border: 1px solid rgba(199, 43, 32, 0.25);
  background: rgba(255, 255, 255, 0.85);
  color: var(--ft-red-strong);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.82rem;
  font-family: "Sora", "Segoe UI", sans-serif;
  font-weight: 600;
}

.module-switch {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  background: linear-gradient(120deg, #ffffff 0%, #f6f8fb 100%);
}

.tab-btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 14px;
  background: transparent;
  color: var(--ft-ink-soft);
  font-family: "Sora", "Segoe UI", sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  border-color: rgba(238, 49, 36, 0.25);
  background: #fff6f5;
  color: var(--ft-red-strong);
}

.tab-btn.is-active {
  border-color: rgba(238, 49, 36, 0.34);
  background: linear-gradient(135deg, var(--ft-red) 0%, var(--ft-red-strong) 100%);
  color: #ffffff;
  box-shadow: 0 8px 16px rgba(199, 43, 32, 0.35);
}

.module {
  display: none;
  padding: 24px;
  animation: rise 0.45s ease;
}

.module.is-visible {
  display: block;
}

#admin-module {
  border-top: 5px solid var(--ft-red);
}

#auth-module {
  border-top: 5px solid #3a4657;
}

#exam-module {
  border-top: 5px solid #273445;
}

#leaderboard-module {
  border-top: 5px solid #2e5d9f;
}

.module-title-wrap h2 {
  margin: 0;
  font-family: "Sora", "Segoe UI", sans-serif;
  font-size: 1.45rem;
}

.module-title-wrap p {
  margin: 7px 0 18px;
  color: var(--ft-ink-soft);
}

.grid-form {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

label {
  font-weight: 700;
  color: #273445;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--ft-border);
  background: #ffffff;
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  color: var(--ft-ink);
}

input[type="file"] {
  padding: 10px;
}

input[type="radio"] {
  accent-color: var(--ft-red);
}

input[type="checkbox"] {
  accent-color: var(--ft-red);
}

textarea:focus,
input:focus,
select:focus {
  outline: 2px solid rgba(238, 49, 36, 0.2);
  border-color: var(--ft-red);
}

.image-preview-wrap {
  display: none;
  border: 1px dashed rgba(238, 49, 36, 0.4);
  border-radius: var(--radius-md);
  padding: 10px;
  background: #fff8f7;
}

.image-preview-wrap.is-visible {
  display: block;
}

.preview-title {
  margin: 0 0 8px;
  color: var(--ft-ink-soft);
  font-weight: 700;
}

.field-group {
  display: grid;
  gap: 10px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.choice-toggle {
  border: 1px solid var(--ft-border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #ffffff;
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 600;
}

.choice-toggle input {
  width: auto;
  margin: 0;
}

.field-hint {
  margin: -2px 0 0;
  color: var(--ft-ink-soft);
  font-size: 0.92rem;
}

.auth-status {
  border: 1px dashed #cfd6df;
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 14px;
  font-weight: 700;
  background: #f8fafc;
  color: var(--ft-ink-soft);
}

.auth-status[data-tone="success"] {
  border-color: #8ec7a8;
  background: #eaf8f0;
  color: var(--ft-success);
}

.auth-status[data-tone="error"] {
  border-color: #e8a8a2;
  background: #fff3f2;
  color: var(--ft-danger);
}

.auth-status[data-tone="warn"] {
  border-color: #f1c89f;
  background: #fff6ec;
  color: var(--ft-warn);
}

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

.auth-form {
  border: 1px solid var(--ft-border);
  border-radius: var(--radius-lg);
  background: linear-gradient(150deg, #ffffff 0%, #f9fbfd 100%);
  padding: 16px;
  display: grid;
  gap: 10px;
}

.auth-form h3 {
  margin: 0;
  font-family: "Sora", "Segoe UI", sans-serif;
}

.user-banner {
  display: none;
  border: 1px solid rgba(199, 43, 32, 0.26);
  border-radius: 12px;
  background: #fff6f5;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.user-banner p {
  margin: 0;
}

.question-image-slot {
  display: none;
  margin: 10px 0 14px;
}

.question-image-slot.is-visible {
  display: block;
}

.question-media {
  margin: 10px 0 12px;
}

.question-image {
  width: min(100%, 640px);
  max-height: 360px;
  object-fit: contain;
  display: block;
  border: 1px solid var(--ft-border);
  border-radius: 12px;
  background: #f7fafc;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-family: "Sora", "Segoe UI", sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--ft-red) 0%, var(--ft-red-strong) 100%);
  color: #ffffff;
  box-shadow: 0 9px 16px rgba(199, 43, 32, 0.34);
}

.btn-soft {
  background: #eef2f6;
  color: #253243;
}

.btn-danger {
  background: linear-gradient(135deg, #bf2a21 0%, #951f18 100%);
  color: #ffffff;
}

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

.list-head h3 {
  margin: 0;
  font-family: "Sora", "Segoe UI", sans-serif;
}

.question-list {
  display: grid;
  gap: 12px;
}

.question-card {
  position: relative;
  border: 1px solid var(--ft-border);
  border-radius: var(--radius-lg);
  padding: 14px 14px 14px 18px;
  background: #ffffff;
}

.question-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  border-radius: 16px 0 0 16px;
  background: linear-gradient(180deg, var(--ft-red) 0%, var(--ft-red-deep) 100%);
}

.question-card h4 {
  margin: 0 0 8px;
}

.question-options {
  margin: 0;
  padding-left: 18px;
  color: var(--ft-ink-soft);
}

.question-options li + li {
  margin-top: 4px;
}

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

.question-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  border-radius: 999px;
  background: #ffe8e5;
  color: var(--ft-red-strong);
  padding: 4px 10px;
  font-weight: 700;
  font-size: 0.85rem;
}

.badge-neutral {
  background: #edf2f7;
  color: #344255;
}

.empty-state {
  border: 1px dashed #cfd7e0;
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 16px;
  background: #f8fafc;
  color: var(--ft-ink-soft);
}

.inline-empty {
  margin-bottom: 10px;
}

.inline-empty p {
  margin: 0;
}

.start-form {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.exam-panel,
.exam-result {
  display: none;
}

.exam-panel.is-visible,
.exam-result.is-visible {
  display: block;
}

.exam-head {
  margin-bottom: 10px;
}

.exam-head p {
  margin: 0;
  font-family: "Sora", "Segoe UI", sans-serif;
  color: var(--ft-red-strong);
  font-weight: 700;
}

.exam-head h3 {
  margin: 6px 0 0;
  line-height: 1.32;
}

.question-type-note {
  margin: 8px 0 0;
  color: var(--ft-ink-soft);
  font-weight: 700;
}

.answer-form {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.answer-item {
  border: 1px solid var(--ft-border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #ffffff;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  transition: transform 0.16s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.answer-item:hover {
  border-color: rgba(238, 49, 36, 0.4);
  background: #fff7f6;
  transform: translateX(1px);
}

.answer-item input {
  width: auto;
  margin-top: 2px;
}

.result-box {
  border: 1px solid var(--ft-border);
  border-radius: var(--radius-lg);
  background: #ffffff;
  padding: 16px;
}

.result-title {
  margin: 0;
  font-family: "Sora", "Segoe UI", sans-serif;
}

.score {
  margin: 8px 0 12px;
  font-size: 1.08rem;
  font-weight: 700;
}

.review-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ft-ink-soft);
}

.review-list li + li {
  margin-top: 8px;
}

.is-correct {
  color: #0f7a4a;
  font-weight: 700;
}

.is-wrong {
  color: #a91f19;
  font-weight: 700;
}

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

.leaderboard-head p {
  margin: 0;
  color: var(--ft-ink-soft);
  font-weight: 700;
}

.leaderboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.leaderboard-card {
  border: 1px solid var(--ft-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  background: #ffffff;
}

.leaderboard-card h3 {
  margin: 0;
  font-family: "Sora", "Segoe UI", sans-serif;
}

.leaderboard-note {
  margin: 6px 0 10px;
  color: var(--ft-ink-soft);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 420px;
}

.leaderboard-table th,
.leaderboard-table td {
  border-bottom: 1px solid #e6ebf2;
  padding: 9px 8px;
  text-align: left;
  font-size: 0.92rem;
}

.leaderboard-table th {
  font-family: "Sora", "Segoe UI", sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #4a5a6f;
}

.rank-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  border-radius: 999px;
  padding: 3px 8px;
  font-family: "Sora", "Segoe UI", sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  background: #e6eefc;
  color: #214a8d;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1060px) {
  .module-switch {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 900px) {
  .auth-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 740px) {
  body {
    padding-top: 20px;
  }

  .app-header,
  .module {
    padding: 18px;
  }

  .module-switch {
    grid-template-columns: 1fr;
  }

  .list-head,
  .leaderboard-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions {
    width: 100%;
  }

  .btn {
    width: 100%;
    text-align: center;
  }
}
