/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --ink:      #0f0e17; --ink-soft: #3d3a52; --paper: #f7f5f2; --surface: #ffffff;
  --accent:   #6c47ff; --accent-2: #ff5c8a; --ok: #00c896; --warn: #ff6b35;
  --danger:   #ff3860; --radius: 14px; --shadow: 0 4px 24px rgba(108,71,255,0.10);
}
html, body { height: 100%; font-family: 'DM Sans', sans-serif; background: var(--paper); color: var(--ink); font-size: 16px; line-height: 1.5; }

/* ── Screens ──────────────────────────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; padding: 2rem 1.25rem 3rem; max-width: 560px; margin: 0 auto; flex-direction: column; gap: 2rem; }
.screen.active { display: flex; }

/* ── Home ─────────────────────────────────────────────────────────────────── */
.home-header { padding-top: 1rem; }
.logo { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 2.6rem; letter-spacing: -1px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.tagline { font-size: 0.95rem; color: var(--ink-soft); margin-top: 0.25rem; font-style: italic; }

.profile-section h2, .tense-section h2, .scores-section h2, .lang-section h2 {
  font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1rem;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); margin-bottom: 0.75rem;
}

.profile-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; min-height: 2rem; }
.profile-chip { display: flex; align-items: center; gap: 0.4rem; padding: 0.45rem 1rem; border-radius: 99px; border: 2px solid transparent; background: var(--surface); font-family: 'Syne', sans-serif; font-weight: 600; font-size: 0.9rem; cursor: pointer; transition: all .18s; box-shadow: var(--shadow); }
.profile-chip:hover { border-color: var(--accent); }
.profile-chip.selected { background: var(--accent); color: #fff; }
.profile-chip .del-chip { font-size: 0.75rem; opacity: 0.6; cursor: pointer; line-height: 1; }
.profile-chip.selected .del-chip { opacity: 0.8; }
.profile-chip .del-chip:hover { opacity: 1; }
.new-profile-row { display: flex; gap: 0.5rem; }
.tense-checkboxes { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tense-label { display: flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.9rem; background: var(--surface); border-radius: 99px; border: 2px solid var(--surface); font-size: 0.9rem; cursor: pointer; transition: border-color .15s; box-shadow: var(--shadow); }
.tense-label:has(input:checked) { border-color: var(--accent); background: #ede9ff; }
.tense-label input { accent-color: var(--accent); }

/* ── Langue tabs ──────────────────────────────────────────────────────────── */
.lang-section { background: var(--surface); border-radius: 20px; padding: 1.25rem; box-shadow: var(--shadow); }
.lang-tabs { display: flex; gap: 0.5rem; }
.lang-tab { flex: 1; padding: 0.65rem; border-radius: var(--radius); border: 2px solid #e0ddf5; background: var(--paper); font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1rem; cursor: pointer; transition: all .18s; text-align: center; }
.lang-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 4px 14px rgba(108,71,255,.3); }
.lang-tab:hover:not(.active) { border-color: var(--accent); background: #ede9ff; }

/* ── Module EN tabs ───────────────────────────────────────────────────────── */
.module-tabs { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.module-tab { flex: 1; padding: 0.55rem; border-radius: var(--radius); border: 2px solid #e0ddf5; background: var(--paper); font-family: 'Syne', sans-serif; font-weight: 700; font-size: 0.9rem; cursor: pointer; transition: all .18s; text-align: center; }
.module-tab.active { background: var(--accent-2); color: #fff; border-color: var(--accent-2); box-shadow: 0 4px 14px rgba(255,92,138,.3); }
.module-tab:hover:not(.active) { border-color: var(--accent-2); background: #ffeaf2; }

/* ── Streak alert ─────────────────────────────────────────────────────────── */
.streak-alert { background: #fff8e1; border: 2px solid #ffb300; border-radius: var(--radius); padding: 1rem 1.25rem; font-size: 0.95rem; color: #7a4f00; line-height: 1.6; }
.streak-alert strong { color: #e65100; }

/* ── Scores sections ──────────────────────────────────────────────────────── */
.scores-section { background: var(--surface); border-radius: 20px; padding: 1.25rem; box-shadow: var(--shadow); }
.scores-section h2 { margin-bottom: 0.75rem; }
.progress-bar-wrap { margin-top: 1rem; display: flex; align-items: center; gap: 0.75rem; }
.progress-label { font-family: 'Syne', sans-serif; font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.progress-track { flex: 1; height: 8px; background: #e0ddf5; border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; transition: width .4s ease; }

/* ── Inputs & buttons ─────────────────────────────────────────────────────── */
input[type="text"] { flex: 1; padding: 0.6rem 1rem; border: 2px solid #e0ddf5; border-radius: var(--radius); font-family: 'DM Sans', sans-serif; font-size: 1rem; outline: none; background: var(--surface); transition: border-color .15s; }
input[type="text"]:focus { border-color: var(--accent); }
.btn { padding: 0.65rem 1.4rem; border-radius: var(--radius); font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1rem; cursor: pointer; border: 2px solid transparent; transition: all .18s; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(108,71,255,.35); }
.btn-primary:hover:not(:disabled) { background: #5538e0; transform: translateY(-1px); box-shadow: 0 6px 18px rgba(108,71,255,.4); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-ghost:hover { background: #ede9ff; }
#btn-start { width: 100%; padding: 1rem; font-size: 1.1rem; }

/* ── Game screen ──────────────────────────────────────────────────────────── */
.game-topbar { display: flex; align-items: center; gap: 0.75rem; position: sticky; top: 0; background: var(--paper); padding: 0.5rem 0 0.75rem; z-index: 10; }
.game-info { display: flex; flex-direction: column; font-family: 'Syne', sans-serif; font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); white-space: nowrap; min-width: 52px; }
#game-score-display { color: var(--accent); font-size: 0.9rem; }
.timer-bar-wrap { flex: 1; height: 8px; background: #e0ddf5; border-radius: 99px; overflow: hidden; }
.timer-bar { height: 100%; width: 100%; background: var(--ok); border-radius: 99px; transition: width .25s linear, background .5s; }
.timer-bar.warn   { background: var(--warn); }
.timer-bar.danger { background: var(--danger); }
.timer-label { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 0.85rem; min-width: 30px; text-align: right; color: var(--ink-soft); }

/* ── Question card ────────────────────────────────────────────────────────── */
.question-card { background: var(--surface); border-radius: 20px; padding: 2rem 1.5rem; text-align: center; box-shadow: var(--shadow); border: 2px solid #ede9ff; }
.question-tense { font-family: 'Syne', sans-serif; font-size: 1.1rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em; color: var(--surface); background: var(--accent); display: inline-block; padding: 0.3rem 1rem; border-radius: 99px; margin-bottom: 1rem; }
.question-verb { font-family: 'Syne', sans-serif; font-size: 2.2rem; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.question-pronoun { margin-top: 0.75rem; font-size: 1.2rem; color: var(--ink-soft); font-weight: 500; }
.question-pronoun strong { color: var(--accent-2); font-weight: 700; }

/* ── Phrase à trous ───────────────────────────────────────────────────────── */
.phrase-text { font-family: 'DM Sans', sans-serif; font-size: 1.15rem; font-weight: 400; font-style: italic; line-height: 1.6; color: var(--ink); }
.phrase-blank { display: inline-block; min-width: 80px; border-bottom: 3px solid var(--accent-2); color: var(--accent-2); font-style: normal; font-weight: 700; letter-spacing: 2px; margin: 0 4px; }

/* ── Badge de niveau ──────────────────────────────────────────────────────── */
.mode-badge { display: inline-block; margin-top: 0.75rem; padding: 0.25rem 0.8rem; border-radius: 99px; font-family: 'Syne', sans-serif; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; }
.mode-badge.level1 { background: #e8f4ff; color: #2563eb; }
.mode-badge.level2 { background: #ede9ff; color: var(--accent); }
.mode-badge.level3 { background: #fff3e0; color: #e65100; }
.mode-badge.level4 { background: #ffeaf2; color: var(--accent-2); }
.mode-badge.level5 { background: #e6fff7; color: #00875a; }

/* ── Answers ──────────────────────────────────────────────────────────────── */
.answers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.answer-btn { padding: 1rem; border-radius: var(--radius); border: 2px solid #e0ddf5; background: var(--surface); font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1.05rem; cursor: pointer; transition: all .18s; box-shadow: var(--shadow); }
.answer-btn:hover:not(:disabled) { border-color: var(--accent); background: #ede9ff; transform: translateY(-2px); }
.answer-btn.correct  { background: #d4f7ed; border-color: var(--ok); color: #007a5e; }
.answer-btn.wrong    { background: #ffe5e5; border-color: var(--danger); color: #c0002a; }
.answer-btn:disabled { cursor: default; }
.answers-saisie { display: flex; gap: 0.5rem; }
.answers-saisie input { font-size: 1.05rem; }
.hidden { display: none !important; }
.feedback { text-align: center; font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1rem; padding: 0.75rem 1rem; border-radius: var(--radius); }
.feedback.ok    { background: #d4f7ed; color: #007a5e; }
.feedback.wrong { background: #ffe5e5; color: #c0002a; }

/* ── Results screen ───────────────────────────────────────────────────────── */
.results-hero { text-align: center; padding-top: 1rem; }
.results-emoji { font-size: 3.5rem; margin-bottom: 0.25rem; }
.results-score { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 4rem; letter-spacing: -2px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; line-height: 1; }
.results-label { font-size: 1rem; color: var(--ink-soft); font-weight: 500; }
.results-stats { display: flex; justify-content: center; gap: 2rem; background: var(--surface); border-radius: 20px; padding: 1.25rem; box-shadow: var(--shadow); }
.stat { text-align: center; }
.stat span { display: block; font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.8rem; letter-spacing: -0.5px; }
.stat label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); font-weight: 600; }
.history-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); }
#history-table-wrap, #player-scores-wrap, #global-scores-wrap { overflow-x: auto; border-radius: var(--radius); }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.history-table th { padding: 0.6rem 0.75rem; text-align: left; font-family: 'Syne', sans-serif; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-soft); border-bottom: 2px solid var(--paper); }
.history-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--paper); }
.history-table tr:last-child td { border-bottom: none; }
.history-table td:nth-child(3) { font-family: 'Syne', sans-serif; font-weight: 700; color: var(--accent); }
.history-table tr.new-session td { background: #ede9ff; }
.results-actions { display: flex; gap: 0.75rem; }
.results-actions .btn { flex: 1; text-align: center; }

/* ── PIN modal ────────────────────────────────────────────────────────────── */
.pin-overlay { position: fixed; inset: 0; background: rgba(15,14,23,0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 100; }
.pin-modal { background: var(--surface); border-radius: 24px; padding: 2rem 1.5rem; width: 320px; max-width: 90vw; text-align: center; box-shadow: 0 20px 60px rgba(15,14,23,0.3); display: flex; flex-direction: column; gap: 1rem; }
.pin-title { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.4rem; color: var(--ink); }
.pin-subtitle { font-size: 0.9rem; color: var(--ink-soft); margin-top: -0.5rem; }
.pin-display { font-family: 'Syne', sans-serif; font-size: 1.6rem; font-weight: 700; letter-spacing: 0.2em; color: var(--accent); background: #ede9ff; padding: 0.75rem 1rem; border-radius: var(--radius); min-height: 3rem; }
.pin-error { font-family: 'Syne', sans-serif; font-size: 0.85rem; font-weight: 700; color: var(--danger); background: #ffe5e5; padding: 0.5rem 1rem; border-radius: var(--radius); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.pin-key { padding: 1rem; border-radius: var(--radius); border: 2px solid #e0ddf5; background: var(--paper); font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1.3rem; cursor: pointer; transition: all .15s; }
.pin-key:hover:not(.pin-key-empty) { background: #ede9ff; border-color: var(--accent); transform: translateY(-1px); }
.pin-key:active:not(.pin-key-empty) { transform: translateY(0); }
.pin-key-empty { visibility: hidden; cursor: default; }
.pin-cancel { margin-top: 0.25rem; font-size: 0.9rem; padding: 0.5rem 1rem; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 400px) {
  .question-verb { font-size: 1.8rem; }
  .answers-grid  { grid-template-columns: 1fr 1fr; }
}
