/* =====================================================================
   Subnet Trainer — Charte graphique "Arcade"
   Ambiance : jeu d'arcade néo-brutaliste. Crème, bordures noires
   épaisses, ombres franches décalées, jaune + violet.
   Les chiffres restent en monospace (ce sont les héros du jeu).
   ===================================================================== */

:root {
  --bg: #fdf6e3;            /* crème */
  --card: #ffffff;
  --encre: #1a1a1a;         /* noir des bordures et du texte */
  --accent: #7c5cff;        /* violet : action principale */
  --jaune: #ffd93d;         /* badges, pastille chrono */
  --ok: #1a9e4b;
  --ko: #e23b3b;
  --orange: #d85a30;        /* chrono, urgence */
  --text: #1a1a1a;
  --muted: #6a675f;
  --police-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --police-mono: "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--police-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
}

/* ===== EN-TÊTE ===== */
header { text-align: center; margin-bottom: 24px; }
header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
header h1 span {
  background: var(--jaune);
  border: 2px solid var(--encre);
  padding: 0 8px;
  display: inline-block;
  transform: rotate(-2deg);
  box-shadow: 3px 3px 0 var(--encre);
}
header p { color: var(--muted); font-size: 0.9rem; margin-top: 10px; font-weight: 600; }

/* ===== BARRE TOUT EN HAUT : langue à gauche, compte à droite ===== */
.barre-haut {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 900px;
  margin-bottom: 12px;
  position: relative;
}

/* Petit menu du compte (s'ouvre sous le pseudo) */
#menu-compte {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--card);
  border: 2px solid var(--encre);
  border-radius: 6px;
  box-shadow: 3px 3px 0 var(--encre);
  padding: 8px;
  z-index: 10;
}
#menu-compte button {
  width: auto;
  margin: 0;
  padding: 8px 14px;
  font-size: 0.85rem;
  background: var(--card);
  color: var(--encre);
  box-shadow: none;
}
#menu-compte button:hover { background: var(--jaune); transform: none; }
#menu-compte a {
  display: block;
  color: var(--encre);
  font-size: 0.85rem;
  font-weight: 800;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 4px;
  margin-bottom: 4px;
}
#menu-compte a:hover { background: var(--jaune); }

/* ===== BARRE DES CONTRÔLES : type, difficulté, chrono | score ===== */
.topbar {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 480px;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar #score { margin-left: auto; }
.etiquette-mode { font-size: 0.85rem; font-weight: 800; color: var(--muted); }
#lien-classement { color: var(--encre); font-size: 0.85rem; font-weight: 800; text-decoration: none; }
#lien-classement:hover { color: var(--accent); }
#panneau-classement { padding: 16px 20px; }

select {
  background: var(--card);
  color: var(--text);
  border: 2px solid var(--encre);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-family: var(--police-ui);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--encre);
}
select:focus { outline: none; border-color: var(--accent); }

#score {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
#score strong { color: var(--encre); }

/* Lien compte / pseudo dans la barre du haut */
#lien-compte {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 800;
  text-decoration: none;
  border: 2px solid var(--encre);
  background: var(--card);
  padding: 6px 10px;
  border-radius: 6px;
  box-shadow: 2px 2px 0 var(--encre);
}
#lien-compte:hover { background: var(--jaune); }

/* Pastille glissante du mode chrono */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  user-select: none;
}
.switch input { display: none; }
.switch .pastille {
  width: 46px; height: 26px;
  background: var(--card);
  border: 2px solid var(--encre);
  border-radius: 13px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
  box-shadow: 2px 2px 0 var(--encre);
}
.switch .pastille::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--encre);
  transition: left 0.2s, background 0.2s;
}
.switch input:checked + .pastille { background: var(--jaune); }
.switch input:checked + .pastille::after { left: 22px; }

/* ===== CARTE PRINCIPALE ===== */
.card {
  background: var(--card);
  border: 3px solid var(--encre);
  border-radius: 10px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  margin-bottom: 16px;
  box-shadow: 6px 6px 0 var(--encre);
}

/* Compte à rebours du chrono */
#chrono-temps {
  display: none;
  text-align: center;
  font-family: var(--police-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--orange);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
#chrono-temps.urgent { color: var(--ko); }

/* Énoncé */
.enonce {
  text-align: center;
  font-family: var(--police-mono);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 12px 0 20px;
}
.enonce small {
  display: inline-block;
  font-family: var(--police-ui);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--encre);
  background: var(--jaune);
  border: 2px solid var(--encre);
  padding: 2px 10px;
  transform: rotate(-1.5deg);
  margin-bottom: 12px;
}
/* Le badge sur sa ligne, l'adresse centrée en dessous */
#enonce-ip { display: block; }

/* ===== CHAMPS DE SAISIE ===== */
.champ { margin-bottom: 14px; }
.champ label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}
.champ input {
  width: 100%;
  background: var(--card);
  color: var(--encre);
  border: 2px solid var(--encre);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--police-mono);
  font-size: 1rem;
  box-shadow: 3px 3px 0 var(--encre);
}
.champ input::placeholder { color: #b5b1a4; }
.champ input:focus { outline: none; border-color: var(--accent); box-shadow: 3px 3px 0 var(--accent); }
.champ input.ok { border-color: var(--ok); box-shadow: 3px 3px 0 var(--ok); }
.champ input.ko { border-color: var(--ko); box-shadow: 3px 3px 0 var(--ko); }

/* ===== BOUTONS ===== */
button {
  width: 100%;
  background: var(--accent);
  color: #ffffff;
  border: 2px solid var(--encre);
  border-radius: 6px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 800;
  font-family: var(--police-ui);
  letter-spacing: 0.5px;
  cursor: pointer;
  margin-top: 10px;
  box-shadow: 4px 4px 0 var(--encre);
  transition: transform 0.05s, box-shadow 0.05s;
}
button:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--encre); }
button:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--encre); }

/* ===== CORRECTION ===== */
#correction { display: none; }
.ligne-correction {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 2px dotted #d8d3c4;
  font-size: 0.9rem;
  font-weight: 600;
  align-items: baseline;
}
.ligne-correction:last-of-type { border-bottom: none; }
.ligne-correction .icone { flex-shrink: 0; }
.ligne-correction .attendu { font-family: var(--police-mono); font-weight: 700; }
.ligne-correction .saisie {
  font-family: var(--police-mono);
  color: var(--ko);
  text-decoration: line-through;
}
.ligne-correction .fleche { color: var(--muted); }
.ok-txt { color: var(--ok); }
.ko-txt { color: var(--ko); }

.explication {
  background: var(--bg);
  border: 2px solid var(--encre);
  border-radius: 6px;
  padding: 12px;
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.55;
  box-shadow: 3px 3px 0 var(--encre);
}
.explication code {
  font-family: var(--police-mono);
  font-weight: 700;
  background: var(--jaune);
  padding: 0 3px;
  border-radius: 3px;
}

/* ===== ÉCRAN DE FIN DE CHRONO ===== */
#chrono-resultat { display: none; text-align: center; padding: 12px 0; }
#chrono-resultat .gros-score {
  font-family: var(--police-mono);
  font-size: 3rem;
  font-weight: 800;
  margin: 8px 0;
  color: var(--accent);
}
#chrono-resultat .record { color: var(--muted); font-weight: 700; margin-bottom: 8px; }
#chrono-resultat .nouveau-record {
  display: inline-block;
  color: var(--encre);
  background: var(--jaune);
  border: 2px solid var(--encre);
  padding: 4px 12px;
  font-weight: 800;
  transform: rotate(-1.5deg);
  margin-bottom: 10px;
  box-shadow: 3px 3px 0 var(--encre);
}

/* ===== CLASSEMENT (écran de fin de chrono connecté) ===== */
.classement {
  background: var(--bg);
  border: 2px solid var(--encre);
  border-radius: 6px;
  padding: 12px;
  margin: 14px 0 4px;
  box-shadow: 3px 3px 0 var(--encre);
  text-align: left;
}
.classement-titre {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  text-align: center;
}
.ligne-classement {
  display: flex;
  gap: 10px;
  padding: 5px 8px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 4px;
}
.ligne-classement .rang { width: 34px; color: var(--muted); }
.ligne-classement .joueur { flex: 1; }
.ligne-classement .points { font-family: var(--police-mono); font-weight: 700; }
.ligne-classement.moi { background: var(--jaune); border: 2px solid var(--encre); }
.ton-rang { text-align: center; font-weight: 800; margin-top: 8px; font-size: 0.9rem; }
.carotte { margin: 12px 0 4px; }
.carotte a {
  display: inline-block;
  background: var(--jaune);
  color: var(--encre);
  border: 2px solid var(--encre);
  padding: 8px 14px;
  font-weight: 800;
  font-size: 0.9rem;
  text-decoration: none;
  transform: rotate(-1deg);
  box-shadow: 3px 3px 0 var(--encre);
}
.carotte a:hover { transform: rotate(-1deg) translate(-1px, -1px); box-shadow: 4px 4px 0 var(--encre); }

footer { color: #b5b1a4; font-size: 0.75rem; font-weight: 600; margin-top: auto; padding-top: 24px; }
