/* BTCA Training — thème sombre "défense" */
:root {
  --bg: #0f1318;
  --bg-2: #161c24;
  --card: #1b232e;
  --card-hover: #222d3b;
  --border: #2c3947;
  --text: #e8edf2;
  --muted: #8b99a8;
  --accent: #9fb643;
  --accent-dark: #7d9032;
  --accent-text: #131a06;
  --danger: #d64545;
  --ok: #3d9a50;
  --warn: #f5c518;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

button { font-family: inherit; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #1c2733 0%, var(--bg) 60%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 30px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo { font-size: 44px; margin-bottom: 8px; }
.login-card h1 { font-size: 26px; letter-spacing: 1px; }
.login-sub { color: var(--muted); font-size: 14px; margin: 8px 0 24px; }
.login-card form { text-align: left; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 5px; }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font-size: 16px;
}
.login-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.login-error {
  margin-top: 14px;
  background: rgba(214, 69, 69, 0.12);
  border: 1px solid rgba(214, 69, 69, 0.4);
  color: #f0a0a0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 22px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, transform 0.05s;
  user-select: none;
  touch-action: manipulation;
}
.btn:hover { background: var(--card-hover); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-block { width: 100%; margin-top: 22px; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-danger { background: transparent; border-color: rgba(214,69,69,0.5); color: #e88; }
.btn kbd {
  font-family: inherit;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 5px;
  padding: 1px 6px;
  color: inherit;
  opacity: 0.75;
}
@media (hover: none) { .btn kbd { display: none; } }

/* ---------- Layout ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.5px;
  cursor: pointer;
}
.topbar .brand span.badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--accent-dark);
  padding: 2px 8px;
  border-radius: 20px;
}
.topbar .right { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.topbar .right .btn { padding: 7px 14px; font-size: 13px; }
@media (max-width: 560px) { .topbar .user-email { display: none; } }

.container { max-width: 860px; margin: 0 auto; padding: 22px 16px 60px; }

h2.page-title { font-size: 22px; margin-bottom: 4px; }
p.page-sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

/* ---------- Accueil : cartes de mode ---------- */
.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 30px; }
.mode-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.mode-card:hover { border-color: var(--accent); background: var(--card-hover); }
.mode-card .icon { font-size: 30px; }
.mode-card h3 { margin: 10px 0 6px; font-size: 17px; }
.mode-card p { color: var(--muted); font-size: 13.5px; }

/* ---------- Sélection de modules ---------- */
.module-list { display: flex; flex-direction: column; gap: 12px; }
.module-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.module-item:hover { border-color: var(--accent); }
.module-item.selected { border-color: var(--accent); background: rgba(159, 182, 67, 0.08); }
.module-item .icon { font-size: 26px; margin-top: 2px; }
.module-item h4 { font-size: 16px; }
.module-item h4 .num { color: var(--muted); font-weight: 500; }
.module-item p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.module-item .check { margin-left: auto; font-size: 20px; color: var(--accent); visibility: hidden; }
.module-item.selected .check { visibility: visible; }

.config-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 20px 0; }
.config-row label { color: var(--muted); font-size: 14px; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: none; background: transparent; color: var(--muted); padding: 9px 16px; font-size: 14px; cursor: pointer; }
.seg button.active { background: var(--accent); color: var(--accent-text); font-weight: 700; }

.actions-bar { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

/* ---------- Écran de jeu ---------- */
.run-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.run-header .module-name { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.run-header .stats { display: flex; gap: 14px; align-items: center; color: var(--muted); font-size: 14px; }
.run-header .stats b { color: var(--text); }
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 20px;
  color: var(--accent);
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 5px 14px;
  border-radius: 10px;
}
.timer.low { color: var(--danger); border-color: rgba(214, 69, 69, 0.5); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }

.stage {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 26px 18px;
  text-align: center;
  position: relative;
}
.stage .phase-label {
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 2px;
}
.memo-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  background: var(--accent);
  border-radius: 0 0 0 var(--radius);
  transition: none;
}

.big-op { font-size: clamp(40px, 9vw, 64px); font-weight: 800; letter-spacing: 2px; font-variant-numeric: tabular-nums; }
.big-question { font-size: clamp(22px, 5vw, 32px); font-weight: 700; max-width: 560px; }
.statement-line { font-size: clamp(20px, 4.5vw, 28px); font-weight: 600; margin: 8px 0; }
.rule-line { letter-spacing: 1px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 22px; }

.words-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.word-chip {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 700;
  min-width: 110px;
}
.word-chip .slot { display: block; font-size: 11px; color: var(--muted); font-weight: 500; margin-bottom: 3px; }
.word-chip.cat { color: var(--warn); }

.strings-block { width: 100%; max-width: 640px; display: flex; flex-direction: column; gap: 14px; }
.string-line { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 12px; }
.string-line .tag { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 2px; display: block; margin-bottom: 6px; }
.string-line .val {
  font-family: "Consolas", "Menlo", monospace;
  font-size: clamp(17px, 4.2vw, 24px);
  letter-spacing: 2px;
  word-break: break-all;
}
.string-line .val .diff { color: var(--danger); text-decoration: underline; font-weight: 700; }

/* Flèches (orientation spatiale) */
.arrow-pair { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.arrow-box {
  width: 92px;
  height: 92px;
  background: #f2f2ee;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.arrow-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; width: 100%; max-width: 620px; }
.arrow-option {
  background: var(--bg-2);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px 8px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: border-color 0.12s;
}
.arrow-option:hover { border-color: var(--accent); }
.arrow-option .arrow-box { width: 64px; height: 64px; }
.arrow-option .opt-label { color: var(--muted); font-size: 13px; font-weight: 700; }

/* ---------- Zone de réponses ---------- */
.answers {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}
.answers .btn { min-width: 108px; font-size: 18px; padding: 16px 24px; }
.answers.numeric .btn { min-width: 76px; }

/* ---------- Feedback (entraînement) ---------- */
.feedback {
  margin-top: 18px;
  border-radius: var(--radius);
  padding: 16px 18px;
  text-align: left;
  border: 1px solid;
}
.feedback.good { background: rgba(61, 154, 80, 0.1); border-color: rgba(61, 154, 80, 0.45); }
.feedback.bad { background: rgba(214, 69, 69, 0.1); border-color: rgba(214, 69, 69, 0.45); }
.feedback .fb-title { font-weight: 800; font-size: 16px; margin-bottom: 6px; }
.feedback.good .fb-title { color: #7fd694; }
.feedback.bad .fb-title { color: #f0a0a0; }
.feedback .fb-explain { color: var(--text); font-size: 15px; }
.feedback .fb-rule { margin-top: 12px; display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }

/* ---------- Interstitiel / résultats ---------- */
.inter-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 24px;
  text-align: center;
}
.inter-card .icon { font-size: 42px; }
.inter-card h3 { font-size: 22px; margin: 12px 0 6px; }
.inter-card p { color: var(--muted); max-width: 520px; margin: 0 auto 10px; font-size: 14.5px; }
.inter-card .hint { color: var(--warn); font-size: 13.5px; }

.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 18px 0; }
.result-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.result-card .icon { font-size: 24px; }
.result-card h4 { font-size: 14px; margin: 6px 0 10px; }
.result-card .score { font-size: 30px; font-weight: 800; color: var(--accent); }
.result-card .sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.total-banner {
  background: linear-gradient(120deg, rgba(159, 182, 67, 0.16), rgba(159, 182, 67, 0.04));
  border: 1px solid var(--accent-dark);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin-bottom: 8px;
}
.total-banner .big { font-size: 40px; font-weight: 800; color: var(--accent); }
.total-banner .lbl { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 2px; }

/* ---------- Historique ---------- */
.history-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 24px; }
.hs-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; text-align: center; }
.hs-card .icon { font-size: 20px; }
.hs-card .name { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.hs-card .best { font-size: 22px; font-weight: 800; color: var(--accent); }
.hs-card .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.history-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.history-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 12.5px; text-transform: uppercase; letter-spacing: 1px; }
.history-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.history-table .mode-tag { font-size: 11.5px; padding: 2px 9px; border-radius: 20px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.history-table .mode-tag.sim { border-color: var(--accent-dark); color: var(--accent); }
.history-table .runline { white-space: nowrap; color: var(--muted); font-size: 13px; }
.history-table .runline b { color: var(--text); }
@media (max-width: 640px) {
  .history-table th:nth-child(1), .history-table td:nth-child(1) { display: none; }
}

.empty-note { color: var(--muted); text-align: center; padding: 30px 0; }

/* ---------- Divers ---------- */
.spacer { height: 18px; }
.center { text-align: center; }
.mt { margin-top: 18px; }
