@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&family=EB+Garamond:ital,wght@0,500;0,600;1,500&family=Petit+Formal+Script&display=swap');

:root {
  --navy: #1b2a6b;
  --navy-dark: #10194a;
  --purple: #5b3aa0;
  --purple-deep: #2e1760;
  --teal: #1fa7a0;
  --gold: #c9a227;
  --gold-light: #e9cf7a;
  --bg-top: #eef1fb;
  --bg-bottom: #e4e9fb;
  --card-bg: #ffffff;
  --text-main: #262b45;
  --text-soft: #6b7094;
  --danger: #d1495b;
  --success: #1f9d6f;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow-soft: 0 20px 45px -20px rgba(27, 42, 107, 0.35);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Poppins', sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 15% 10%, rgba(91, 58, 160, 0.16), transparent 45%),
    radial-gradient(circle at 85% 0%, rgba(31, 167, 160, 0.14), transparent 40%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px 60px;
}

.app-shell {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- Header / brand ---------- */
.brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 4px;
}

.brand-logo-img {
  height: 54px;
  width: auto;
  display: block;
}

@media (max-width: 560px) {
  .brand-logo-img { height: 42px; }
}

/* ---------- Language switch ---------- */
.lang-switch {
  margin-left: auto;
  display: flex;
  background: rgba(91, 58, 160, 0.09);
  border: 1px solid rgba(91, 58, 160, 0.2);
  border-radius: 99px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}
.lang-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  background: transparent;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.74rem;
  letter-spacing: 0.03em;
  color: var(--text-soft);
  padding: 7px 14px;
  border-radius: 99px;
  transition: background 0.15s ease, color 0.15s ease;
}
.lang-btn.active {
  background: linear-gradient(135deg, var(--navy), var(--purple));
  color: #fff;
  box-shadow: 0 6px 14px -6px rgba(46, 23, 96, 0.55);
}

/* ---------- Progress ---------- */
.progress-wrap {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 0 4px;
}
.progress-wrap.active { display: flex; }

.progress-track {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: rgba(91, 58, 160, 0.12);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--purple), var(--teal));
  transition: width 0.45s cubic-bezier(.65,.05,.36,1);
}
.progress-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-soft);
  white-space: nowrap;
}

.attempt-chip {
  display: none;
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--purple-deep);
  background: rgba(91, 58, 160, 0.1);
  border: 1px solid rgba(91, 58, 160, 0.25);
  padding: 5px 12px;
  border-radius: 99px;
}
.attempt-chip.active { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Card ---------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 38px 34px;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--navy), var(--purple), var(--teal));
}

@media (max-width: 560px) {
  .card { padding: 28px 20px; }
}

.step {
  animation: stepIn 0.42s cubic-bezier(.22,.9,.3,1.1);
}
.step.leaving {
  animation: stepOut 0.22s ease forwards;
}
@keyframes stepIn {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes stepOut {
  to { opacity: 0; transform: translateY(-10px) scale(0.99); }
}

/* ---------- Welcome ---------- */
.welcome-icon {
  width: 86px; height: 86px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy), var(--purple));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 14px 30px -12px rgba(46, 23, 96, 0.55);
}
.welcome-icon svg { width: 46px; height: 46px; color: #fff; }

h1.headline {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--navy);
  margin: 0 0 6px;
}
p.subheadline {
  text-align: center;
  color: var(--text-soft);
  font-size: 0.95rem;
  margin: 0 0 24px;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 26px;
}
@media (max-width: 560px) {
  .rules-grid { grid-template-columns: 1fr; }
}
.rule-chip {
  background: rgba(31,167,160,0.08);
  border: 1px solid rgba(31,167,160,0.22);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: center;
}
.rule-chip .num {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--purple-deep);
  display: block;
}
.rule-chip .lbl {
  font-size: 0.74rem;
  color: var(--text-soft);
  font-weight: 600;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.96rem;
  border-radius: 99px;
  padding: 14px 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--navy), var(--purple));
  color: #fff;
  box-shadow: 0 12px 26px -10px rgba(46, 23, 96, 0.55);
  width: 100%;
}
.btn-primary:not(:disabled):hover { box-shadow: 0 16px 30px -10px rgba(46, 23, 96, 0.65); }

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid rgba(107,112,148,0.3);
}

.btn-row {
  display: flex;
  gap: 12px;
  margin-top: 26px;
}
.btn-row .btn-primary { flex: 1; }
.btn-row .btn-back { flex: 0 0 auto; }

@media (max-width: 420px) {
  .btn-row .btn-back span.full { display: none; }
}

/* ---------- Name step ---------- */
.field-label {
  font-weight: 700;
  color: var(--navy);
  font-size: 1.05rem;
  margin-bottom: 8px;
  display: block;
}
.field-hint {
  color: var(--text-soft);
  font-size: 0.86rem;
  margin: -2px 0 16px;
}
input.text-input {
  width: 100%;
  font-family: inherit;
  font-size: 1.05rem;
  padding: 15px 18px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(91, 58, 160, 0.18);
  background: rgba(238, 241, 251, 0.6);
  color: var(--text-main);
  font-weight: 600;
  transition: border-color 0.15s ease, background 0.15s ease;
}
input.text-input:focus {
  outline: none;
  border-color: var(--purple);
  background: #fff;
}

/* ---------- Question ---------- */
.q-eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 8px;
}
h2.q-text {
  font-size: 1.22rem;
  line-height: 1.45;
  color: var(--navy);
  margin: 0 0 22px;
  font-weight: 700;
}

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

.option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(38, 43, 69, 0.1);
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 0.98rem;
  color: var(--text-main);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.option:hover {
  border-color: rgba(91, 58, 160, 0.4);
  transform: translateX(2px);
}
.option .badge {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(27, 42, 107, 0.07);
  color: var(--navy);
  font-weight: 800;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.option.selected {
  border-color: var(--purple);
  background: linear-gradient(90deg, rgba(91,58,160,0.08), rgba(31,167,160,0.06));
}
.option.selected .badge {
  background: linear-gradient(135deg, var(--navy), var(--purple));
  color: #fff;
}

/* review state (after submit, correctness shown) */
.option.correct-answer {
  border-color: var(--success);
  background: rgba(31,157,111,0.08);
}
.option.correct-answer .badge { background: var(--success); color: #fff; }
.option.wrong-answer {
  border-color: var(--danger);
  background: rgba(209,73,91,0.08);
}
.option.wrong-answer .badge { background: var(--danger); color: #fff; }

/* ---------- Results ---------- */
.score-ring-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}
.score-ring {
  position: relative;
  width: 148px; height: 148px;
}
.score-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.score-ring .bg { fill: none; stroke: rgba(38,43,69,0.08); stroke-width: 10; }
.score-ring .fg { fill: none; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 0.9s cubic-bezier(.22,.9,.3,1.1); }
.score-ring .label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-ring .label .big { font-size: 2rem; font-weight: 800; color: var(--navy); line-height: 1; }
.score-ring .label .small { font-size: 0.75rem; color: var(--text-soft); font-weight: 600; }

.result-title {
  text-align: center;
  font-weight: 800;
  font-size: 1.3rem;
  margin: 4px 0 6px;
}
.result-title.pass { color: var(--success); }
.result-title.fail { color: var(--danger); }
.result-sub {
  text-align: center;
  color: var(--text-soft);
  font-size: 0.92rem;
  margin: 0 0 22px;
}

.remember-box {
  background: rgba(201, 162, 39, 0.1);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 8px;
}
.remember-box h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--purple-deep);
  display: flex; align-items: center; gap: 8px;
}
.remember-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.remember-list li {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-main);
  padding-left: 18px;
  position: relative;
}
.remember-list li::before {
  content: "✦";
  position: absolute;
  left: 0;
  color: var(--gold);
}

/* ---------- Certificate ---------- */
.cert-preview-wrap {
  margin: 10px 0 22px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 16px 36px -18px rgba(27,42,107,0.45);
  border: 1px solid rgba(27,42,107,0.1);
}
.cert-preview-wrap canvas,
.cert-preview-wrap img {
  width: 100%;
  display: block;
}

.download-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.download-row .btn { flex: 1; min-width: 160px; }

.contact-box {
  margin-top: 22px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-soft);
  line-height: 1.6;
}
.contact-box strong { color: var(--navy); }

/* footer note */
.footnote {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-soft);
  opacity: 0.75;
  margin-top: 6px;
}
