/* ============================================
   Biences Quiz — DA Biences corporate
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700;900&family=Cormorant+Garamond:wght@500;600;700&display=swap');

:root {
  --b-orange: #E87722;
  --b-orange-dark: #c65500;
  --b-orange-light: rgba(232, 119, 34, 0.1);
  --b-brown: #43372C;
  --b-brown-light: #6A4B3C;
  --b-taupe: #7A6D64;
  --b-beige: #F1E8DE;
  --b-beige-dark: #e8ddd0;
  --b-bg: #FBF8F6;
  --b-white: #ffffff;
  --b-border: #DEDEDE;
  --b-border-hover: #c8bfb3;
  --b-green: #2e7d5b;
  --b-green-light: rgba(46, 125, 91, 0.12);
  --b-red: #c0392b;
  --b-red-light: rgba(192, 57, 43, 0.12);
  --b-accent-fiches: #C47A52;

  --b-font: "Lato", system-ui, -apple-system, sans-serif;
  --b-font-serif: "Cormorant Garamond", Georgia, serif;

  --b-radius-sm: 8px;
  --b-radius-md: 12px;
  --b-radius-lg: 16px;
  --b-radius-pill: 999px;

  --b-shadow-sm: 0 2px 8px rgba(67, 55, 44, 0.04);
  --b-shadow-md: 0 4px 16px rgba(67, 55, 44, 0.06);
  --b-shadow-lg: 0 8px 28px rgba(67, 55, 44, 0.08);
  --b-shadow-xl: 0 12px 40px rgba(67, 55, 44, 0.12);
  --b-shadow-orange: 0 4px 14px rgba(232, 119, 34, 0.25);
  --b-shadow-orange-lg: 0 6px 20px rgba(232, 119, 34, 0.35);

  --b-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --b-ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--b-font);
  font-size: 15px;
  color: var(--b-brown);
  background: var(--b-beige);
  background-image:
    radial-gradient(ellipse at top right, rgba(232, 119, 34, 0.08), transparent 60%),
    radial-gradient(ellipse at bottom left, rgba(196, 122, 82, 0.06), transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}
.brand img { height: 44px; width: auto; display: block; }
.brand-tagline {
  font-family: var(--b-font-serif);
  font-style: italic;
  font-size: 18px;
  color: var(--b-brown-light);
  margin-left: auto;
}

/* ====== Screen system ====== */
.screen { display: none; animation: b-fadeUp 350ms var(--b-ease-out) both; }
.screen.active { display: block; }

/* ====== Card ====== */
.card {
  background: var(--b-white);
  border-radius: var(--b-radius-lg);
  box-shadow: var(--b-shadow-lg);
  padding: 36px 32px;
}

h1, h2, h3 {
  font-family: var(--b-font-serif);
  font-weight: 600;
  color: var(--b-brown);
  margin: 0 0 8px;
  letter-spacing: 0.01em;
}
h1 { font-size: 38px; line-height: 1.15; }
h2 { font-size: 26px; }
h3 { font-size: 20px; }

.subtitle {
  color: var(--b-taupe);
  font-size: 15px;
  margin: 0 0 28px;
}

/* ====== Welcome screen ====== */
.field {
  display: block;
  margin-bottom: 20px;
}
.field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--b-brown-light);
  margin-bottom: 8px;
}
.input {
  width: 100%;
  padding: 14px 18px;
  border: 1.5px solid var(--b-border);
  border-radius: var(--b-radius-pill);
  font-size: 16px;
  background: var(--b-bg);
  color: var(--b-brown);
  transition: border-color 200ms, background 200ms, box-shadow 200ms;
  outline: none;
}
.input:focus { border-color: var(--b-orange); background: var(--b-white); box-shadow: 0 0 0 4px var(--b-orange-light); }
.input.uppercase { text-transform: uppercase; letter-spacing: 0.15em; text-align: center; font-weight: 700; }
.input.shake { animation: b-shake 380ms; border-color: var(--b-red); }
.input.ok { border-color: var(--b-green); background: var(--b-green-light); }

.captcha-hint {
  font-size: 12px;
  color: var(--b-taupe);
  margin: 6px 0 0;
  font-style: italic;
}
.captcha-hint.error { color: var(--b-red); font-style: normal; font-weight: 600; }
.captcha-hint.ok { color: var(--b-green); font-weight: 600; }

.levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.level-btn {
  background: var(--b-white);
  border: 1.5px solid var(--b-border);
  border-radius: var(--b-radius-md);
  padding: 18px 14px;
  text-align: center;
  font-weight: 700;
  color: var(--b-brown);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: all 200ms var(--b-ease-out);
}
.level-btn:hover { border-color: var(--b-orange); transform: translateY(-2px); box-shadow: var(--b-shadow-md); }
.level-btn .lvl-emoji { display: block; font-size: 26px; margin-bottom: 6px; }
.level-btn .lvl-desc { display: block; font-size: 11px; font-weight: 400; color: var(--b-taupe); text-transform: none; letter-spacing: 0; margin-top: 6px; }
.level-btn.selected {
  background: var(--b-orange);
  color: var(--b-white);
  border-color: var(--b-orange);
  box-shadow: var(--b-shadow-orange);
}
.level-btn.selected .lvl-desc { color: rgba(255,255,255,0.85); }

/* ====== Primary button ====== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 24px;
  padding: 16px 28px;
  border: none;
  border-radius: var(--b-radius-pill);
  background: var(--b-orange);
  color: var(--b-white);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: var(--b-shadow-orange);
  transition: all 200ms var(--b-ease-out);
}
.btn-primary:hover:not(:disabled) { background: var(--b-orange-dark); transform: translateY(-2px); box-shadow: var(--b-shadow-orange-lg); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border: 1.5px solid var(--b-brown);
  border-radius: var(--b-radius-pill);
  background: transparent;
  color: var(--b-brown);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: all 200ms var(--b-ease-out);
}
.btn-secondary:hover { background: var(--b-brown); color: var(--b-white); transform: translateY(-2px); }

.actions-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 28px; }

.link-btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--b-brown-light);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: color 180ms;
}
.link-btn:hover { color: var(--b-orange); text-decoration: underline; }

/* ====== Quiz screen ====== */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--b-brown-light);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: linear-gradient(135deg, #ff7e5f, #feb47b);
  color: var(--b-white);
  border-radius: var(--b-radius-pill);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  box-shadow: 0 4px 12px rgba(255, 126, 95, 0.4);
  opacity: 0;
  transform: scale(0.7);
  transition: all 250ms var(--b-ease-bounce);
}
.streak-badge.show { opacity: 1; transform: scale(1); }
.streak-badge.bump { animation: b-bump 350ms var(--b-ease-bounce); }

.timer-bar-wrap {
  position: relative;
  height: 10px;
  background: var(--b-beige-dark);
  border-radius: var(--b-radius-pill);
  overflow: hidden;
  margin-bottom: 8px;
}
.timer-bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--b-orange), var(--b-accent-fiches));
  border-radius: var(--b-radius-pill);
  width: 100%;
  transition: width 100ms linear;
}
.timer-bar.danger { background: linear-gradient(90deg, var(--b-red), #e85a4f); }
.timer-text {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--b-taupe);
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 22px;
}
.timer-text .pts { color: var(--b-orange); }

.q-text {
  font-family: var(--b-font-serif);
  font-size: 26px;
  line-height: 1.3;
  color: var(--b-brown);
  margin: 0 0 24px;
  font-weight: 600;
}
.q-text em { color: var(--b-orange); font-style: italic; }

.choices { display: grid; gap: 10px; }
.choice {
  display: block;
  width: 100%;
  text-align: left;
  padding: 16px 20px;
  border: 1.5px solid var(--b-border);
  border-radius: var(--b-radius-md);
  background: var(--b-white);
  color: var(--b-brown);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  transition: all 180ms var(--b-ease-out);
}
.choice:hover:not(:disabled) { border-color: var(--b-orange); transform: translateY(-1px); box-shadow: var(--b-shadow-md); }
.choice:disabled { cursor: default; }
.choice .choice-letter {
  display: inline-block;
  width: 26px; height: 26px;
  line-height: 26px;
  text-align: center;
  border-radius: 50%;
  background: var(--b-beige);
  color: var(--b-brown);
  font-weight: 700;
  font-size: 12px;
  margin-right: 12px;
  transition: all 200ms;
}
.choice.correct { border-color: var(--b-green); background: var(--b-green-light); animation: b-scaleIn 350ms var(--b-ease-bounce); }
.choice.correct .choice-letter { background: var(--b-green); color: var(--b-white); }
.choice.wrong { border-color: var(--b-red); background: var(--b-red-light); animation: b-shake 380ms; }
.choice.wrong .choice-letter { background: var(--b-red); color: var(--b-white); }
.choice.dim { opacity: 0.4; }

.feedback {
  margin-top: 20px;
  padding: 16px 20px;
  border-radius: var(--b-radius-md);
  font-size: 15px;
  text-align: center;
  display: none;
}
.feedback.show { display: block; animation: b-fadeUp 300ms var(--b-ease-out); }
.feedback.good { background: var(--b-green-light); color: var(--b-green); border: 1px solid var(--b-green); }
.feedback.bad { background: var(--b-red-light); color: var(--b-red); border: 1px solid var(--b-red); }
.feedback .gain {
  display: block;
  font-family: var(--b-font-serif);
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 4px;
}
.feedback .quip { font-style: italic; font-size: 14px; opacity: 0.9; }

/* ====== Result screen ====== */
.score-display {
  font-family: var(--b-font-serif);
  font-size: 72px;
  font-weight: 700;
  color: var(--b-orange);
  text-align: center;
  line-height: 1;
  margin: 12px 0 4px;
  letter-spacing: -0.02em;
}
.score-suffix { font-size: 22px; color: var(--b-taupe); margin-left: 6px; }
.score-meta {
  text-align: center;
  color: var(--b-brown-light);
  font-size: 14px;
  margin-bottom: 22px;
}
.verdict {
  text-align: center;
  font-family: var(--b-font-serif);
  font-style: italic;
  font-size: 22px;
  color: var(--b-brown);
  margin: 8px 0 24px;
  padding: 0 20px;
  line-height: 1.4;
}
.score-breakdown {
  background: var(--b-bg);
  border-radius: var(--b-radius-md);
  padding: 18px 22px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  text-align: center;
}
.score-breakdown .stat .lbl { font-size: 11px; color: var(--b-taupe); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.score-breakdown .stat .val { font-family: var(--b-font-serif); font-size: 24px; color: var(--b-brown); font-weight: 600; }

/* ====== Leaderboard screen ====== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--b-bg);
  padding: 4px;
  border-radius: var(--b-radius-pill);
}
.tab {
  flex: 1;
  padding: 10px 14px;
  border: none;
  background: transparent;
  border-radius: var(--b-radius-pill);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--b-brown-light);
  transition: all 200ms;
}
.tab:hover { color: var(--b-brown); }
.tab.active { background: var(--b-white); color: var(--b-orange); box-shadow: var(--b-shadow-sm); }

.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th, .lb-table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--b-border);
  font-size: 14px;
}
.lb-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--b-taupe);
  font-weight: 700;
}
.lb-table .rank { width: 40px; font-family: var(--b-font-serif); font-size: 18px; color: var(--b-brown-light); }
.lb-table tr:nth-child(1) .rank { color: #d4a017; font-weight: 700; }
.lb-table tr:nth-child(2) .rank { color: #b0b0b0; font-weight: 700; }
.lb-table tr:nth-child(3) .rank { color: #cd7f32; font-weight: 700; }
.lb-table .pts { font-weight: 700; color: var(--b-orange); }
.lb-table tr.you { background: var(--b-orange-light); }
.lb-table tr.you td { font-weight: 700; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--b-taupe);
  font-style: italic;
}

/* ====== Animations ====== */
@keyframes b-fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes b-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
@keyframes b-scaleIn {
  0% { transform: scale(0.9); opacity: 0.7; }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes b-bump {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}
@keyframes b-pulse-good {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 125, 91, 0); }
  50% { box-shadow: 0 0 0 8px rgba(46, 125, 91, 0.2); }
}

/* ====== Responsive ====== */
@media (max-width: 720px) {
  .app { padding: 20px 14px 60px; }
  .card { padding: 24px 18px; }
  h1 { font-size: 30px; }
  .q-text { font-size: 22px; }
  .levels { grid-template-columns: 1fr; }
  .score-display { font-size: 54px; }
  .verdict { font-size: 18px; }
  .lb-table th, .lb-table td { padding: 10px 6px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
