/* Fredoka (licence SIL OFL 1.1, voir assets/fonts/OFL.txt), police variable 300 à 700. */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../assets/fonts/fredoka-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../assets/fonts/fredoka-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Couleurs du thème Ardoise (clair), le thème de l'app. renderer/lib/theme.js réapplique
   les mêmes valeurs au démarrage. */
:root {
  --bg: #f4f5f6;
  --panel: #ffffff;
  --ink: #23272e;
  --muted: #5f6670;
  --line: #e1e4e8;
  --accent: #2a8576;      /* boutons et éléments actifs */
  --accent-2: #3fa796;    /* surbrillance : barre, survol, TEA */
  --accent-soft: #ddf2ee;
  --accent-ink: #24766a;  /* texte accentué sur fond clair */
  --btn-ink: #ffffff;     /* texte sur l'accent (onglets actifs, puces) */
  --btn-bg: #5b6573;      /* boutons pleins */
  --btn-fg: #ffffff;
  --bubble: #eceef1;      /* bulle de Chaussette et des habitants */
  --nav: #2b2f36;
  --nav-ink: #d9dde3;
  --nav-active: #4fc1ae;
  --nav-active-ink: #0f2420;
  --hot: #e39a5b;         /* série de jours */
  --ok: #4f8f6f;
  --ok-soft: #e4f1e9;
  --bad: #d6455d;
  --bad-soft: #fde7eb;
  --warn: #c27c10;
  --warn-soft: #fff3dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 6px 18px rgba(0, 0, 0, .06);
}
:root[data-mode="dark"] { --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
input, textarea, select { user-select: text; }
input[type=range], input[type=checkbox] { accent-color: var(--accent); }
button { font: inherit; color: inherit; }

#app { display: flex; height: 100vh; }

/* ---------- Navigation ---------- */
#nav {
  width: 228px; flex: none; background: var(--nav); color: var(--nav-ink);
  display: flex; flex-direction: column; padding: 18px 12px; border-right: 1px solid color-mix(in srgb, var(--nav-ink) 12%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 20px; }
.logo { width: 48px; height: auto; flex: none; image-rendering: pixelated; }
.wordmark { font-family: Fredoka, "Segoe UI", sans-serif; font-weight: 600; font-size: 21px; line-height: 1; color: var(--nav-ink); letter-spacing: .01em; }
.wordmark .tea { color: var(--accent-2); }
.wordmark .ch { font-size: 14px; }
.slogan { font-family: Fredoka, "Segoe UI", sans-serif; font-size: 12px; font-weight: 500; color: color-mix(in srgb, var(--nav-ink) 68%, transparent); margin-top: 5px; letter-spacing: .03em; }
#nav nav { display: flex; flex-direction: column; gap: 4px; }
#nav nav button {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: none; border: 0; border-radius: 10px; padding: 10px 12px; cursor: pointer; color: var(--nav-ink); font-weight: 500;
}
#nav nav button:hover { background: color-mix(in srgb, var(--nav-ink) 8%, transparent); }
/* Rubrique active : léger fond et trait de couleur à gauche, plutôt qu'un gros pavé. */
#nav nav button.active {
  background: color-mix(in srgb, var(--nav-ink) 12%, transparent); color: var(--nav-ink); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--nav-active); border-radius: 4px 10px 10px 4px;
}
#nav nav button.active .ico { color: var(--nav-active); opacity: 1; }
#nav .ico { width: 18px; display: grid; place-items: center; opacity: .8; }
.nav-foot { margin-top: auto; padding: 12px; font-size: 13px; color: color-mix(in srgb, var(--nav-ink) 70%, transparent); }
.nav-foot b { color: var(--hot); font-size: 22px; display: block; }
.mascot { image-rendering: pixelated; display: block; }

/* Apparence (Réglages) */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.theme-tile {
  text-align: left; border: 2px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 12px; padding: 8px; cursor: pointer;
}
.theme-tile:hover { border-color: var(--accent-2); }
.theme-tile.sel { border-color: var(--accent); }
.theme-prev { display: flex; height: 62px; border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.theme-prev > div:first-child { width: 30%; }
.theme-prev-main { flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.theme-prev-main span { display: block; height: 7px; border-radius: 9px; border: 1px solid transparent; }
.theme-prev-main span:first-child { width: 70%; }
.theme-prev-main span:nth-child(2) { height: 14px; }
.theme-prev-main i { display: block; width: 48%; height: 10px; border-radius: 5px; }
.theme-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 5px; }
.theme-name .i { color: var(--accent-ink); }
.theme-hint { font-size: 12px; color: var(--muted); }
input[type=color] { width: 46px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); cursor: pointer; }

/* Icônes SVG (renderer/lib/icons.js) */
.i { flex: none; vertical-align: -0.2em; }
.streak { display: inline-flex; align-items: center; gap: 6px; }
.nav-foot .streak { display: flex; }
.card-ico {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.modal-head h2 { display: flex; align-items: center; gap: 10px; }
.modal-head h2 .i { color: var(--accent-2); }
#lockinfo { display: inline-flex; align-items: center; gap: 6px; }
#lockbanner .msg .i { vertical-align: -0.25em; margin-right: 4px; color: var(--accent-2); }
.x { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; }
.x:hover { background: var(--accent-soft); color: var(--ink); }
.speak-btn { display: inline-grid; place-items: center; }
.i.star { color: var(--accent-2); }
.stat b .i { color: var(--hot); }
.game-hud .pill { display: inline-flex; align-items: center; gap: 4px; }
.game-hud .pill .i { color: var(--hot); }

main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- Barre du haut ---------- */
#topbar {
  display: flex; align-items: center; gap: 24px; padding: 14px 28px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.quota { flex: 1; max-width: 520px; }
.quota-text { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.quota-text b { color: var(--ink); font-size: 17px; }
.bar { height: 10px; background: var(--accent-soft); border-radius: 99px; overflow: hidden; }
.bar .fill { height: 100%; width: 0; background: var(--accent-2); border-radius: 99px; transition: width .4s; }
.bar .fill.done { background: var(--ok); }
#lockinfo { margin-left: auto; font-size: 13px; color: var(--muted); text-align: right; }

#lockbanner {
  display: flex; align-items: center; gap: 16px; padding: 12px 28px;
  background: var(--nav); color: var(--nav-ink);
}
#lockbanner[hidden] { display: none; }
#lockbanner .msg { flex: 1; }
#lockbanner b { color: var(--accent-2); }

#view { flex: 1; overflow: auto; padding: 26px 28px 40px; }
#view.full { padding: 0; overflow: hidden; }

/* ---------- Éléments communs ---------- */
h1, h2, h3, .result-big, .stat b { font-family: Fredoka, "Segoe UI", sans-serif; font-weight: 600; }
h1 { font-size: 27px; margin: 0 0 6px; }
h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-size: 16.5px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.sub { color: var(--muted); margin-bottom: 22px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.card.click { cursor: pointer; transition: transform .12s, border-color .12s; }
.card.click:hover { transform: translateY(-2px); border-color: var(--accent-2); }
.card .tag { display: inline-block; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid var(--line); background: var(--panel); border-radius: 10px;
  padding: 9px 16px; cursor: pointer; font-weight: 600;
}
.btn:hover { border-color: var(--accent-2); }
.btn.primary { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--btn-fg); }
.btn.primary:hover { background: color-mix(in srgb, var(--btn-bg) 85%, #000); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.big { padding: 13px 22px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.rec { background: var(--bad); border-color: var(--bad); color: #fff; }

.tag {
  font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent-ink);
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

input[type=text], input[type=password], input[type=number], input[type=time], input[type=email], input[type=url], textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font: inherit; background: var(--panel); color: var(--ink); outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 160px; resize: vertical; line-height: 1.6; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* ---------- Statistiques ---------- */
.stat b { font-size: 30px; display: block; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 10px; }
/* Le graphique prend la hauteur disponible, à côté de la carte du Quartier. */
.chart-card { display: flex; flex-direction: column; }
.chart-card .chart { flex: 1; height: auto; min-height: 120px; }

/* Carte du Quartier sur l'accueil */
.quartier-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.q-banner {
  display: block; width: 100%; height: auto;
  image-rendering: pixelated; cursor: pointer; border-bottom: 1px solid var(--line);
}
.q-body { padding: 16px 20px 18px; }
.q-people { display: flex; gap: 8px; flex-wrap: wrap; }
.q-person {
  position: relative; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink); border: 1px solid transparent;
}
.q-person.done { background: var(--accent); color: var(--btn-ink); }
.q-check {
  position: absolute; right: -3px; bottom: -3px; width: 16px; height: 16px; border-radius: 50%;
  display: grid; place-items: center; background: var(--panel); color: var(--ok); border: 1px solid var(--line);
}
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart .b { width: 100%; background: var(--accent-soft); border-radius: 6px 6px 2px 2px; min-height: 3px; }
.chart .b.met { background: var(--accent-2); }
.chart .col span { font-size: 11px; color: var(--muted); }

/* ---------- Fenêtre modale ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(8, 10, 14, .55); display: grid; place-items: center;
  z-index: 50; animation: fade .15s;
}
.modal {
  background: var(--panel); border-radius: 18px; width: min(720px, calc(100vw - 40px));
  max-height: calc(100vh - 60px); overflow: auto; padding: 24px 26px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { margin: 0; flex: 1; }
.x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Quiz ---------- */
.q-progress { display: flex; gap: 6px; margin-bottom: 18px; }
.q-progress i { flex: 1; height: 6px; border-radius: 99px; background: var(--line); }
.q-progress i.ok { background: var(--ok); }
.q-progress i.bad { background: var(--bad); }
.q-progress i.cur { background: var(--accent-2); }
.q-progress { flex-wrap: wrap; }
.q-progress i { min-width: 14px; }
.chat { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; max-height: 320px; overflow-y: auto; padding-right: 4px; }
.bubble-line { display: flex; }
.bubble-line.me { justify-content: flex-end; }
.bubble-line .b { max-width: 75%; padding: 10px 14px; border-radius: 14px; background: var(--bubble); display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.bubble-line.me .b { background: var(--accent-soft); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.bubble-line.npc .b { border-bottom-left-radius: 4px; }
.bubble-line .b .small { flex-basis: 100%; }
.task { padding: 10px 14px; border-left: 3px solid var(--accent-2); background: var(--panel); }
.streak-box { display: inline-flex; align-items: center; gap: 8px; }
.streak-box .pips { display: inline-flex; gap: 4px; }
.streak-box .pips i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent-2); }
.streak-box .pips i.on { background: var(--accent-2); }
.q-text { font-size: 19px; font-weight: 600; margin-bottom: 18px; line-height: 1.45; }
.q-text .gap { display: inline-block; min-width: 70px; border-bottom: 2px solid var(--accent-2); margin: 0 3px; }
.choices { display: grid; gap: 10px; }
.choice {
  text-align: left; border: 2px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 12px;
  padding: 12px 16px; cursor: pointer; font-size: 16px; display: flex; gap: 12px; align-items: center;
}
.choice:hover:not(:disabled) { border-color: var(--accent-2); }
.choice .k { width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.choice.ok { border-color: var(--ok); background: var(--ok-soft); }
.choice.bad { border-color: var(--bad); background: var(--bad-soft); }
.choice:disabled { cursor: default; }
.explain { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); }
.explain.ok { background: var(--ok-soft); }
.explain.bad { background: var(--bad-soft); }
.explain .script { margin-top: 8px; font-style: italic; color: var(--muted); }
.result-big { font-size: 46px; font-weight: 800; text-align: center; margin: 10px 0; }

/* ---------- Cours ---------- */
.lesson-body { font-size: 16px; line-height: 1.7; max-width: 820px; }
.lesson-body ul { padding-left: 22px; margin: 0 0 12px; }
.example { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.example .en { font-weight: 600; }
.example .fr { color: var(--muted); font-size: 14px; }
.speak-btn {
  border: 0; background: var(--accent-soft); color: var(--accent-ink); width: 32px; height: 32px; border-radius: 9px;
  cursor: pointer; flex: none; font-size: 14px;
}
.speak-btn:hover { background: var(--accent); color: var(--btn-ink); }
.lesson-body b { color: var(--accent-ink); }

/* ---------- Mémoriser ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.tabs button { display: inline-flex; align-items: center; gap: 6px; }
.tabs button { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 99px; padding: 7px 14px; cursor: pointer; font-weight: 600; font-size: 14px; }
.tabs button.active { background: var(--accent); color: var(--btn-ink); border-color: var(--accent); }
.memo-text { font-size: 19px; line-height: 2; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; }
.memo-text .w { padding: 1px 2px; border-radius: 4px; }
.memo-text .hid { background: var(--accent-soft); color: transparent; cursor: pointer; border-bottom: 2px solid var(--accent-2); }
.memo-text .shown { background: var(--warn-soft); }
.memo-text .ok { background: var(--ok-soft); color: var(--ok); }
.memo-text .miss { background: var(--bad-soft); color: var(--bad); text-decoration: underline wavy; }
.memo-text .sent { border-radius: 6px; transition: background .2s; }
.memo-text .sent.cur { background: var(--accent-soft); color: var(--accent-ink); }
.memo-text.gaps { line-height: 2.4; }
.memo-text input.gap-input { display: inline-block; width: auto; height: auto; padding: 0 4px; margin: 0 2px; font-size: 18px; line-height: 1.4; border: 0; border-bottom: 2px solid var(--accent-2); border-radius: 5px 5px 0 0; background: var(--accent-soft); color: var(--ink); box-shadow: none; vertical-align: baseline; }
.memo-text input.gap-input:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.memo-text input.gap-input.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.memo-text input.gap-input.miss { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); text-decoration: line-through; }
.memo-text .fix { margin-left: 4px; padding: 0 4px; border-radius: 5px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.memo-text .ok { color: var(--ok); }
.memo-text .miss { color: var(--bad); }
.path-map { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.path-unit { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.path-unit.done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.path-unit.cur { background: var(--accent); color: var(--btn-ink); border-color: transparent; font-weight: 600; }
.path-steps { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.path-step.done { color: var(--ok); }
.path-step.cur { color: var(--accent-ink); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; min-height: 48px; padding: 10px; border: 2px dashed var(--line); border-radius: 12px; background: var(--panel); }
.chip { background: var(--accent-soft); color: var(--accent-ink); border: 0; border-radius: 9px; padding: 7px 12px; cursor: pointer; font-size: 16px; font-weight: 600; }
.chip.placed { background: var(--accent); color: var(--btn-ink); }

/* ---------- Vocabulaire ---------- */
.flash {
  height: 220px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: grid; place-items: center; font-size: 30px; font-weight: 700; cursor: pointer; text-align: center; padding: 20px;
}
.flash small { display: block; font-size: 14px; color: var(--muted); font-weight: 400; margin-top: 8px; }
table.list { width: 100%; border-collapse: collapse; }
table.list td, table.list th { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.list th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Oral ---------- */
.sentence { font-size: 22px; font-weight: 600; line-height: 1.5; }
.sentence .ok { color: var(--ok); }
.sentence .miss { color: var(--bad); text-decoration: underline wavy; }
.heard { margin-top: 10px; color: var(--muted); font-style: italic; }
.level-meter { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; width: 160px; }
.level-meter div { height: 100%; background: var(--bad); width: 0; transition: width .08s; }

/* ---------- Jeu ---------- */
.game-wrap { position: relative; width: 100%; height: 100%; background: var(--nav); display: grid; place-items: center; overflow: hidden; }
.game-wrap canvas { image-rendering: pixelated; display: block; }
.game-wrap .game-screen { position: absolute; inset: 0; cursor: pointer; }
.game-wrap:focus { outline: none; }
.game-hud {
  position: absolute; top: 14px; left: 14px; right: 14px; display: flex; gap: 10px; pointer-events: none;
}
.game-hud .pill { background: color-mix(in srgb, var(--nav) 92%, transparent); color: var(--nav-ink); padding: 7px 14px; border-radius: 99px; font-weight: 600; font-size: 14px; }
.game-hud .pill b { color: var(--accent-2); }
.game-prompt {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: color-mix(in srgb, var(--nav) 95%, transparent); color: var(--nav-ink); padding: 12px 20px; border-radius: 14px; font-weight: 600;
  pointer-events: none; text-align: center;
}
.game-prompt kbd { background: var(--nav-active); color: var(--nav-active-ink); border-radius: 6px; padding: 1px 8px; margin: 0 4px; }
.game-help {
  position: absolute; right: 14px; bottom: 14px; background: color-mix(in srgb, var(--nav) 85%, transparent); color: var(--nav-ink);
  padding: 6px 12px; border-radius: 99px; font-size: 12px; pointer-events: none;
}
.npc-talk { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.npc-talk canvas { image-rendering: pixelated; border-radius: 12px; background: var(--accent-soft); flex: none; }
.bubble { background: var(--bubble); border-radius: 14px; padding: 12px 16px; font-size: 16px; }

/* ---------- Assistant ---------- */
.setup { max-width: 640px; margin: 30px auto; }
.setup .card { padding: 28px 30px; }
.rules li { margin-bottom: 6px; }

/* ---------- Notifications ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--nav); color: var(--nav-ink); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow); animation: fade .2s; font-weight: 600; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.bad { background: var(--bad); }

/* ---------- Version web : iPhone et iPad ---------- */
body.web { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body.web #app { height: 100vh; height: 100dvh; }
body.web button, body.web .card.click, body.web .chip { touch-action: manipulation; }
body.web #topbar { padding-top: calc(14px + env(safe-area-inset-top)); }
body.web #nav { padding-top: calc(18px + env(safe-area-inset-top)); }
body.web .modal { max-height: calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
@media (hover: none) {
  .card.click:hover, .choice:hover:not(:disabled) { transform: none; }
}
@media (max-width: 1100px) and (min-width: 901px) {
  body.web #nav { width: 196px; }
}

/* Téléphone et iPad en portrait : barre d'onglets en bas, une seule colonne. */
@media (max-width: 900px) {
  #app { flex-direction: column; }
  #nav {
    order: 2; width: auto; flex-direction: row; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)) !important;
    border-right: 0; border-top: 1px solid color-mix(in srgb, var(--nav-ink) 12%, transparent);
  }
  #nav .brand, #nav .nav-foot { display: none; }
  #nav nav { flex-direction: row; flex: 1; gap: 0; justify-content: space-around; }
  #nav nav button { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 3px; padding: 7px 1px 6px; font-size: 10.5px; line-height: 1.1; border-radius: 10px; text-align: center; }
  #nav nav button.active { box-shadow: none; border-radius: 10px; }
  #nav nav button .lbl { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #nav .ico { width: auto; }
  main { order: 1; min-height: 0; }
  #topbar { gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px !important; }
  .quota-text { font-size: 13px; margin-bottom: 4px; }
  .quota-text b { font-size: 16px; }
  #lockinfo { font-size: 12px; max-width: 34%; }
  #view { padding: 18px 16px 28px; -webkit-overflow-scrolling: touch; }
  h1 { font-size: 23px; }
  .sub { margin-bottom: 16px; }
  .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { gap: 12px; }
  .card { padding: 16px; }
  .overlay { align-items: flex-end; padding: 0; }
  .modal { width: 100vw !important; max-width: 100vw; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: calc(100dvh - 24px - env(safe-area-inset-top)); }
  /* Safari zoome sur les champs en dessous de 16 px. */
  input[type=text], input[type=password], input[type=number], input[type=email], input[type=url], input[type=time], textarea, select, .memo-text input.gap-input { font-size: 16px; }
  .memo-text { font-size: 17px; padding: 14px 16px; line-height: 1.9; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px 4px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: none; }
  .choice { padding: 12px 14px; }
  .sentence { font-size: 20px; }
  .bubble-line .b { max-width: 88%; }
  .btn.big { width: 100%; justify-content: center; }
  #toasts { right: 12px; left: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); align-items: center; }
  .setup { margin: 8px auto; }
  .setup .card { padding: 20px 18px; }
  .game-help { display: none; }
}

/* ---------- Jeu : commandes tactiles ---------- */
.touchpad { position: absolute; left: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px); gap: 4px; z-index: 5; user-select: none; -webkit-user-select: none; }
.touchpad button, .touch-act { border: 0; border-radius: 14px; background: color-mix(in srgb, var(--nav) 70%, transparent); color: var(--nav-ink); display: grid; place-items: center; touch-action: none; -webkit-user-select: none; user-select: none; }
.touchpad button.on, .touch-act.on { background: var(--nav-active); color: var(--nav-active-ink); }
.touchpad .up { grid-column: 2; grid-row: 1; }
.touchpad .left { grid-column: 1; grid-row: 2; }
.touchpad .right { grid-column: 3; grid-row: 2; }
.touchpad .down { grid-column: 2; grid-row: 3; }
.touch-act { position: absolute; right: 18px; bottom: calc(30px + env(safe-area-inset-bottom)); width: 76px; height: 76px; border-radius: 50%; font-weight: 700; font-size: 14px; z-index: 5; }
/* Libellés courts dans la barre d'onglets du téléphone. */
.lbl-s { display: none; }
@media (max-width: 900px) {
  #nav nav button:has(.lbl-s) .lbl { display: none; }
  #nav nav button .lbl-s { display: block; }
}
/* Téléphone : une colonne (les petites cartes de chiffres restent par deux). */
@media (max-width: 600px) {
  .grid.c2, .grid.c3 { grid-template-columns: minmax(0, 1fr); }
}

/* Bouton « Continuer avec Google » (page de connexion). */
.btn.google { width: 100%; justify-content: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); font-weight: 600; padding: 11px 16px; }
.btn.google .g-logo { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-family: Fredoka, sans-serif; font-weight: 700; font-size: 14px; }
.or-line { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; color: var(--muted); font-size: 13px; }
.or-line::before, .or-line::after { content: ''; flex: 1; height: 1px; background: var(--line); }
/* Réglages tout en bas du menu, sous la série de jours. */
#nav .nav-end { margin-top: 6px; padding-top: 8px; border-top: 1px solid color-mix(in srgb, var(--nav-ink) 12%, transparent); }
.nav-foot { padding-bottom: 4px; }
@media (max-width: 900px) {
  #nav nav:not(.nav-end) { flex: 6 1 0; }
  #nav .nav-end { flex: 1 1 0; margin-top: 0; padding-top: 0; border-top: 0; }
}