/* ═══════════════════════════════════════════
   Variables & Reset
═══════════════════════════════════════════ */
:root {
  --bg:       #0d1117;
  --surface:  #161b22;
  --surface2: #21262d;
  --border:   #30363d;
  --accent:   #eab308;
  --accent2:  #fbbf24;
  --green:    #3fb950;
  --red:      #f85149;
  --text:     #e6edf3;
  --muted:    #7d8590;
  --mono: 'Fira Code', 'Cascadia Code', 'Courier New', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 30% 20%, rgba(234,179,8,.07) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(251,191,36,.04) 0%, transparent 50%);
}

/* ═══════════════════════════════════════════
   Colonne centrale
═══════════════════════════════════════════ */
.main {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ═══════════════════════════════════════════
   Nav
═══════════════════════════════════════════ */
.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-back {
  color: var(--muted);
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  transition: color .15s;
}
.btn-back:hover { color: var(--text); }

.btn-back-game {
  color: var(--muted);
  font-size: .9rem;
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  transition: color .15s;
}
.btn-back-game:hover { color: var(--text); }

.btn-help {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 600;
  padding: 4px 11px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  font-family: inherit;
}
.btn-help:hover { border-color: var(--accent); color: var(--accent); }

/* ═══════════════════════════════════════════
   Titre
═══════════════════════════════════════════ */
.page-title { text-align: center; }

.title-name {
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: -.02em;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.title-sub { color: var(--muted); font-size: .9rem; }

/* ═══════════════════════════════════════════
   Écran de démarrage
═══════════════════════════════════════════ */
.start-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.start-label {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
}

/* Cartes de mode (Bullet / Blitz / Normal) */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mode-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-family: inherit;
}
.mode-card:hover { border-color: var(--accent); }
.mode-card.active {
  border-color: var(--accent);
  background: rgba(234,179,8,.08);
}

.mode-icon { font-size: 1.5rem; }
.mode-name { font-size: .88rem; font-weight: 700; color: var(--text); }
.mode-time { font-size: .82rem; color: var(--muted); }

/* Cartes de type de conversion */
.type-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.type-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-family: inherit;
}
.type-card:hover { border-color: var(--accent); }
.type-card.active {
  border-color: var(--accent);
  background: rgba(234,179,8,.08);
}

.type-card-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  font-family: var(--mono);
  display: block;
}
.type-card-sub {
  font-size: .82rem;
  color: var(--muted);
  display: block;
  margin-top: 1px;
}

.type-check {
  color: var(--accent);
  font-weight: 700;
  font-size: .9rem;
  opacity: 0;
  transition: opacity .15s;
}
.type-card.active .type-check { opacity: 1; }

.btn-start {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  border-radius: 10px;
}

/* ═══════════════════════════════════════════
   Timer & Score (écran de jeu)
═══════════════════════════════════════════ */
.game-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.timer-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.timer-display {
  font-size: 3.6rem;
  font-weight: 900;
  letter-spacing: -.02em;
  font-family: var(--mono);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  transition: color .3s;
}

.timer-display.urgent {
  background: none;
  -webkit-text-fill-color: #f87171;
  animation: pulse .5s ease infinite alternate;
}

@keyframes pulse {
  from { opacity: 1; }
  to   { opacity: .55; }
}

.timer-bar-track {
  width: 100%;
  height: 5px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}

.timer-bar {
  height: 100%;
  border-radius: 99px;
  transition: width 1s linear, background-color .5s;
  width: 100%;
}
.timer-bar.green  { background: var(--accent); }
.timer-bar.yellow { background: #f59e0b; }
.timer-bar.red    { background: var(--red); }

.score-display {
  font-size: .88rem;
  color: var(--muted);
}

.score-correct {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
}

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

.score-total {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.score-label {
  font-size: .88rem;
  color: var(--muted);
  margin-left: 4px;
}

/* ═══════════════════════════════════════════
   Carte challenge
═══════════════════════════════════════════ */
.challenge-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transition: border-color .3s;
}

.challenge-card.correct { border-color: rgba(63,185,80,.5); }
.challenge-card.wrong   { border-color: rgba(248,81,73,.5); }

/* Équation de conversion */
.conv-equation {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.conv-number {
  font-family: var(--mono);
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: .02em;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.conv-idx {
  font-family: var(--mono);
  font-size: .9rem;
  font-weight: 700;
  color: var(--muted);
  margin-right: 4px;
}

.conv-eq {
  font-size: 2rem;
  color: var(--muted);
  font-weight: 300;
  line-height: 1;
}

.conv-blank {
  display: inline-block;
  width: 64px;
  border-bottom: 3px solid #f47272;
  opacity: .7;
  vertical-align: baseline;
  margin-bottom: 6px;
}

.conv-idx-to { color: #f47272; }

/* ═══════════════════════════════════════════
   Zone de réponse
═══════════════════════════════════════════ */
.answer-row {
  display: flex;
  gap: 8px;
}

.answer-input {
  flex: 1;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
  padding: 11px 14px;
  outline: none;
  transition: border-color .15s;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.answer-input::placeholder { color: var(--muted); font-weight: 400; font-size: .95rem; text-transform: none; letter-spacing: 0; }
.answer-input:focus   { border-color: var(--accent); }
.answer-input.correct { border-color: var(--green); }
.answer-input.wrong   { border-color: var(--red); }

/* ═══════════════════════════════════════════
   Boutons
═══════════════════════════════════════════ */
.btn {
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: .88rem;
  padding: 11px 18px;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  font-family: inherit;
  white-space: nowrap;
}
.btn:hover  { opacity: .88; }
.btn:active { transform: scale(.97); }

.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.btn-next    { background: var(--surface2); border: 1px solid var(--accent); color: var(--accent); }

/* ═══════════════════════════════════════════
   Feedback & explication
═══════════════════════════════════════════ */
.feedback {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .88rem;
  font-weight: 600;
  display: none;
}
.feedback.show { display: block; }
.feedback.ok   { background: rgba(63,185,80,.1);  border: 1px solid rgba(63,185,80,.4);  color: #4ade80; }
.feedback.err  { background: rgba(248,81,73,.1);  border: 1px solid rgba(248,81,73,.4);  color: #f87171; }

.explanation {
  background: rgba(234,179,8,.07);
  border: 1px solid rgba(234,179,8,.2);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: .9rem;
  line-height: 1.7;
  color: #fde68a;
  display: none;
}
.explanation.show { display: block; }
.explanation strong { color: #fef08a; }
.explanation .expl-steps {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: .9rem;
}
.explanation .expl-step   { color: #fde68a; }
.explanation .expl-result { color: #a7f3d0; font-weight: 700; }

/* ═══════════════════════════════════════════
   Résultats (overlay)
═══════════════════════════════════════════ */
.gameover-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13,17,23,.9);
  backdrop-filter: blur(6px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.gameover-overlay.show { display: flex; }

.gameover-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px 48px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.gameover-icon { font-size: 3rem; }

.gameover-card h2 {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gameover-card p { color: var(--muted); font-size: .88rem; line-height: 1.6; }

.gameover-score {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0;
  flex-wrap: wrap;
  justify-content: center;
}

.gs-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }

.gs-val {
  font-size: 2.6rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.gs-lbl {
  font-size: .78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 700;
}

.gs-sep { color: var(--border); font-size: 1.2rem; }

.go-total-wrap {
  font-size: .88rem;
  color: var(--muted);
  margin-top: -4px;
}

.gameover-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.btn-restart { padding: 12px 36px; font-size: .95rem; }

.btn-ghost-go {
  background: none;
  border: none;
  color: var(--muted);
  font-size: .9rem;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  padding: 4px;
}
.btn-ghost-go:hover { color: var(--text); }

/* ═══════════════════════════════════════════
   Panneau d'aide
═══════════════════════════════════════════ */
.help-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13,17,23,.5);
  z-index: 100;
}
.help-overlay.show { display: block; }

.help-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  max-width: 95vw;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transition: right .3s ease;
  overflow: hidden;
}
.help-panel.open { right: 0; }

.help-panel-hdr {
  flex-shrink: 0;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: .92rem;
}

.help-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  transition: color .15s;
  font-family: inherit;
}
.help-close:hover { color: var(--text); }

.help-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.help-section h3 {
  font-size: .9rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.help-section p {
  font-size: .9rem;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 10px;
}

.conv-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.conv-table th {
  background: var(--surface2);
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 6px 10px;
  text-align: center;
  border: 1px solid var(--border);
}
.conv-table td {
  padding: 4px 10px;
  text-align: center;
  border: 1px solid var(--border);
  font-family: var(--mono);
}
.conv-table tbody tr:nth-child(even) { background: rgba(255,255,255,.02); }
.conv-table tbody tr:hover           { background: rgba(234,179,8,.07); }
.conv-table td:first-child  { color: var(--text); font-weight: 600; }
.conv-table td:nth-child(2) { color: #60a5fa; }
.conv-table td:nth-child(3) { color: #34d399; }

.method-example {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.method-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.method-steps {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: var(--mono);
  font-size: .9rem;
  color: #fde68a;
}
.method-steps .result {
  color: var(--green);
  font-weight: 700;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════
   Responsive
═══════════════════════════════════════════ */
@media (max-width: 500px) {
  .main { padding: 18px 16px 48px; gap: 18px; }
  .timer-display { font-size: 2.8rem; }
  .conv-number { font-size: 2.4rem; }
  .challenge-card { padding: 22px 18px; }
  .gameover-card { padding: 32px 24px; }
  .help-panel { width: 100%; right: -100%; }
}

/* ── Footer ─────────────────────────────── */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 6px 24px;
  font-size: .75rem;
  color: #7d8590;
  border-top: 1px solid #30363d;
  background: var(--bg);
  z-index: 1;
}
