/* LE DÉFI SILENCE — feuille de style.
   Pensée pour un tableau numérique : lisible du fond de la classe, gros boutons
   au doigt, rien qui clignote. Polices et violet du site toplings.com (Fredoka,
   Nunito, sous licence libre OFL, embarquées : un PC d'école n'a ni l'une ni
   l'autre, et la page ne doit rien demander à un autre serveur). */
@font-face { font-family: 'Fredoka'; src: url('fonts/Fredoka-variable.ttf') format('truetype'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url('fonts/Nunito-variable.ttf') format('truetype'); font-weight: 200 1000; font-display: swap; }

:root {
  --bg: #f6f1ff; --surface: #ffffff; --surface-2: #f0e8fd; --ink: #2c1a4a; --muted: #5b4a7d; --faint: #8577a3; --line: #e2d6f4;
  --accent: #7c3aed; --accent-ink: #ffffff; --accent-soft: #ece3ff; --accent-deep: #5b21b6;
  --ok: #16a34a; --warn: #d97706; --loud: #dc2626; --gold: #f59e0b; --danger: #be123c;
  --hud: rgba(255, 255, 255, 0.9); --hud-ink: #2c1a4a;
  --display: 'Fredoka', ui-rounded, 'SF Pro Rounded', 'Segoe UI Variable Display', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #130e21; --surface: #1d1631; --surface-2: #261d40; --ink: #efe8ff; --muted: #bcaedb; --faint: #9a8db8; --line: #3a2f57;
    --accent: #a78bfa; --accent-ink: #160d2b; --accent-soft: #2c2252; --accent-deep: #c4b5fd;
    --hud: rgba(24, 17, 42, 0.86); --hud-ink: #efe8ff;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 17px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
h1, h2, h3, .display { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0; text-wrap: balance; }
p { margin: 0; }
.fatal { padding: 40px; font-weight: 700; }

/* --- Écrans de la maîtresse ------------------------------------------- */
.screen { min-height: 100vh; padding-bottom: 48px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 max(18px, env(safe-area-inset-left, 0px)) 0 max(18px, env(safe-area-inset-right, 0px)); display: grid; gap: 18px; }
.wrap.narrow { max-width: 760px; }
.top { display: flex; align-items: center; gap: 14px; padding: 18px max(18px, env(safe-area-inset-left, 0px)); max-width: 1180px; margin: 0 auto; }
.top-title { font-size: clamp(1.5rem, 3vw, 2.1rem); flex: 1; min-width: 0; overflow-wrap: anywhere; }
.brand { font: 600 1rem var(--display); color: var(--accent); }
.back { border: 0; background: var(--surface); width: 48px; height: 48px; border-radius: 14px; font-size: 1.8rem; line-height: 1; cursor: pointer; box-shadow: 0 2px 0 var(--line); }
.card { background: var(--surface); border-radius: var(--radius); padding: clamp(16px, 2.4vw, 26px); display: grid; gap: 14px; align-content: start; box-shadow: 0 1px 0 var(--line), 0 10px 30px -22px rgba(44, 26, 74, 0.5); min-width: 0; }
.lede { font-size: 1.08rem; color: var(--muted); max-width: 62ch; }
.hint { color: var(--faint); font-size: 0.94rem; }
.hint.center { text-align: center; }
.privacy { background: var(--accent-soft); border-radius: 14px; padding: 12px 14px; font-size: 0.95rem; }

.btn { border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 800; padding: 12px 22px; min-height: 48px; cursor: pointer; box-shadow: 0 4px 0 var(--accent-deep); }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--accent-deep); }
.btn[disabled] { opacity: 0.45; cursor: default; transform: none; }
.btn.big { font: 600 clamp(1.15rem, 2.4vw, 1.45rem) var(--display); padding: 16px 30px; min-height: 60px; }
.btn.small { padding: 8px 14px; min-height: 40px; font-size: 0.92rem; }
.btn.ghost { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.btn.danger { background: var(--danger); color: #fff; box-shadow: 0 4px 0 #881337; }
.link { border: 0; background: none; color: var(--accent); font-weight: 800; cursor: pointer; padding: 8px 4px; }
.link.small { font-size: 0.88rem; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.actions.column { flex-direction: column; align-items: stretch; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field { display: grid; gap: 8px; }
.field > span, .setting .label { font-weight: 800; font-size: 0.92rem; color: var(--muted); }
input[type="text"], input:not([type]), .field input { font: inherit; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface-2); color: var(--ink); min-height: 48px; width: 100%; max-width: 420px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { border: 0; border-radius: 999px; padding: 9px 16px; min-height: 44px; background: var(--surface-2); font-weight: 800; cursor: pointer; }
.pill.on { background: var(--accent); color: var(--accent-ink); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; background: var(--surface-2); padding: 6px; border-radius: 999px; justify-self: start; }
.tabs button { border: 0; background: none; border-radius: 999px; padding: 10px 18px; min-height: 44px; font-weight: 800; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: 0 2px 6px rgba(44, 26, 74, 0.15); }

.dots { display: flex; gap: 8px; justify-content: center; margin: 22px 0 12px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--accent); }
.welcome { text-align: center; justify-items: center; }
.welcome .display { font-size: clamp(2rem, 5vw, 3rem); }
.hero-sprites { display: flex; gap: 6px; justify-content: center; }
.points { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; text-align: left; max-width: 600px; }
.points li { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
.starters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.starter { border: 3px solid transparent; background: var(--surface-2); border-radius: 18px; padding: 12px; display: grid; justify-items: center; gap: 6px; cursor: pointer; }
.starter.on { border-color: var(--accent); background: var(--accent-soft); }

.home-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.head-links { display: flex; gap: 6px; flex-wrap: wrap; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .home-grid { grid-template-columns: 1fr; } }
.launch .display { font-size: 1.6rem; }
.launch-btn { justify-self: center; margin-top: 6px; }
.scenes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.scene { border: 3px solid transparent; border-radius: 14px; padding: 0; background: var(--surface-2); overflow: hidden; display: grid; cursor: pointer; text-align: left; position: relative; }
.scene img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; image-rendering: pixelated; display: block; }
.scene span { font-weight: 800; padding: 6px 10px 2px; }
.scene small { padding: 0 10px 8px; color: var(--faint); font-size: 0.8rem; }
.scene.on { border-color: var(--accent); }
.scene.locked { cursor: default; }
.scene.locked img { filter: grayscale(1) brightness(0.8); opacity: 0.55; }
.scenes.static .scene { cursor: default; }
.side { display: grid; gap: 14px; }
.stat, .tile { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; box-shadow: 0 1px 0 var(--line); }
.stat > div { flex: 1; display: grid; gap: 6px; min-width: 0; }
.tile { flex-direction: column; align-items: flex-start; border: 0; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.tile.promo { cursor: default; background: linear-gradient(160deg, var(--surface), var(--accent-soft)); }
.tile.promo .sep { margin-top: 6px; }
.tile small, .stat small { color: var(--faint); font-size: 0.86rem; }
.peek { display: flex; gap: 2px; min-height: 56px; }
.bar { height: 12px; border-radius: 8px; background: var(--surface-2); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, #fb7185, var(--gold)); border-radius: 8px; transition: width 1.4s cubic-bezier(.3, .8, .3, 1); }
.bar.week span { background: linear-gradient(90deg, #34d399, var(--ok)); }
.party-banner { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 16px 20px; border-radius: var(--radius); background: linear-gradient(120deg, #fde68a, #fbcfe8, #c4b5fd); color: #2c1a4a; }
.party-banner b { font: 600 1.25rem var(--display); }
/* La classe d'essai, à nommer (`trialCard`) : en tête de l'accueil, jusqu'à ce qu'on la garde. */
.card.trial { border: 2px solid var(--accent); }

.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.member { justify-items: center; text-align: center; gap: 4px; }
.member b { font: 600 1.15rem var(--display); }
.member span { color: var(--muted); font-weight: 700; font-size: 0.9rem; }
.member small { color: var(--faint); font-size: 0.82rem; }
.member .traits { color: var(--accent); font-weight: 700; }
.member.rare { box-shadow: 0 0 0 3px var(--gold), 0 10px 30px -22px rgba(44, 26, 74, 0.5); }
.member.egg { background: var(--surface-2); }
.rename input { max-width: 150px; min-height: 40px; padding: 6px 10px; }

.notebook { background-color: var(--surface); background-image: linear-gradient(90deg, transparent 46px, #e5484d 46px, #e5484d 48px, transparent 48px), linear-gradient(rgba(124, 58, 237, .14) 1px, transparent 1px); background-size: 100% 100%, 100% 32px; padding-left: 64px; }
.week-chart { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; height: 220px; align-items: end; }
.week-chart .col { display: grid; grid-template-rows: auto 1fr auto; height: 100%; justify-items: center; gap: 6px; }
.week-chart .col i { align-self: end; width: 70%; max-width: 64px; min-height: 4px; border-radius: 10px 10px 4px 4px; background: linear-gradient(180deg, #a78bfa, var(--accent)); }
.week-chart .col.today i { background: linear-gradient(180deg, #fde68a, var(--gold)); }
.week-chart .value { font-weight: 800; font-variant-numeric: tabular-nums; }
.week-chart small { font-weight: 800; color: var(--muted); text-transform: capitalize; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat-tile { background: var(--surface); border-radius: var(--radius); padding: 16px; display: grid; gap: 4px; box-shadow: 0 1px 0 var(--line); }
.stat-tile b { font: 600 1.6rem var(--display); font-variant-numeric: tabular-nums; }
.stat-tile span { color: var(--muted); font-weight: 700; font-size: 0.9rem; }

.setting { display: grid; gap: 8px; padding: 6px 0; }
.setting .help { color: var(--faint); font-size: 0.88rem; }
.setting.toggle { grid-template-columns: auto 1fr; align-items: start; gap: 12px; cursor: pointer; }
.setting.toggle input { width: 24px; height: 24px; margin-top: 2px; accent-color: var(--accent); }
.setting.toggle span { display: grid; gap: 2px; }
.danger h2 { color: var(--danger); }
.class-list { display: grid; gap: 10px; }
.class-row { grid-template-columns: auto 1fr; align-items: center; text-align: left; border: 3px solid transparent; cursor: pointer; font: inherit; color: inherit; }
.class-row.on { border-color: var(--accent); }
.class-row b { font: 600 1.2rem var(--display); display: block; }
.class-row small { color: var(--faint); }
.code { font: 700 clamp(1.8rem, 5vw, 2.6rem) var(--display); letter-spacing: 0.08em; background: var(--surface-2); border-radius: 14px; padding: 10px 18px; justify-self: start; user-select: all; }

.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-weight: 800; z-index: 50; max-width: min(90vw, 640px); text-align: center; }

/* --- Le défi projeté ------------------------------------------------------ */
.screen.run { position: fixed; inset: 0; min-height: 0; padding: 0; background: #0b0814; overflow: hidden; }
.stage { position: absolute; inset: 0; }
#scene { display: block; width: 100%; height: 100%; touch-action: manipulation; }
body.quiet-cursor .screen.run { cursor: none; }
.hud { position: absolute; inset: max(14px, env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) auto max(14px, env(safe-area-inset-left, 0px)); display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; pointer-events: none; }
.hud-box { background: var(--hud); color: var(--hud-ink); border-radius: 18px; padding: 10px 16px; box-shadow: 0 6px 20px -10px rgba(0, 0, 0, .5); }
.clock { display: grid; gap: 8px; min-width: min(360px, 42vw); }
.track { position: relative; height: 14px; border-radius: 8px; background: rgba(124, 58, 237, .18); }
.track .fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 8px; background: linear-gradient(90deg, #fde68a, var(--gold)); }
.track .sun { position: absolute; top: 50%; left: 0; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; background: radial-gradient(circle at 40% 40%, #fff7cc, #fbbf24 58%, #f59e0b); box-shadow: 0 0 0 5px rgba(251, 191, 36, .32); }
.clock-text { font: 600 clamp(1rem, 2.1vw, 1.6rem) var(--display); font-variant-numeric: tabular-nums; }
.hud-right { display: flex; gap: 12px; align-items: flex-start; }
.hud-egg { display: flex; align-items: center; gap: 10px; }
.egg-dot { width: 24px; height: 30px; border-radius: 50% 50% 46% 46% / 58% 58% 42% 42%; background: radial-gradient(circle at 38% 30%, #ccfbf1, #2dd4bf 60%, #0f766e); }
.hud-egg .bar { width: clamp(70px, 9vw, 130px); }
.gauge { display: grid; justify-items: center; gap: 8px; min-width: 110px; }
.gauge-bar { position: relative; width: clamp(28px, 2.6vw, 40px); height: clamp(120px, 22vh, 230px); border-radius: 20px; background: rgba(0, 0, 0, .1); overflow: hidden; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6); }
.gauge-bar .level { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(0deg, #15803d, #4ade80); transition: background .2s; }
.gauge[data-state="near"] .level { background: linear-gradient(0deg, #b45309, #fbbf24); }
.gauge[data-state="loud"] .level { background: linear-gradient(0deg, #b91c1c, #f87171); }
.gauge-bar .mark { position: absolute; left: -4px; right: -4px; height: 4px; background: var(--hud-ink); border-radius: 2px; }
.gauge-text { font: 600 clamp(.95rem, 1.6vw, 1.25rem) var(--display); text-align: center; max-width: 9em; }
.banner { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); background: var(--hud); color: var(--hud-ink); font: 600 clamp(1.1rem, 2.6vw, 2rem)/1.25 var(--display); padding: 12px 26px; border-radius: 999px; box-shadow: 0 10px 28px -12px rgba(0, 0, 0, .55); opacity: 0; transition: opacity .3s; pointer-events: none; max-width: 86%; text-align: center; }
.banner.show { opacity: 1; }
/* La consigne au tableau (`paintNote`), au milieu du bandeau, entre le chrono
   et la jauge : grande, lisible du fond de la classe. */
.note { flex: 1 1 0; min-width: 0; margin: 0; align-self: flex-start; text-align: center; background: var(--hud); color: var(--hud-ink); border-radius: 18px; padding: 10px 18px; font: 600 clamp(1.15rem, 2.8vw, 2.4rem)/1.2 var(--display); box-shadow: 0 6px 20px -10px rgba(0, 0, 0, .5); overflow-wrap: anywhere; }
.note[hidden] { display: none; }
.count-in { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; color: #fff; text-shadow: 0 4px 24px rgba(0, 0, 0, .55); background: radial-gradient(ellipse at center, rgba(20, 12, 38, .35), transparent 70%); pointer-events: none; }
.count-in b { font: 600 clamp(4rem, 14vw, 10rem)/1 var(--display); }
.count-in small { font: 600 clamp(1rem, 2.4vw, 1.6rem) var(--display); }
.teacher-bar { position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 140%); display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 8px; border-radius: 22px; background: var(--hud); box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .6); transition: transform .35s ease; max-width: calc(100% - 24px); }
.teacher-bar.show { transform: translate(-50%, 0); }
.teacher-bar button { border: 0; border-radius: 14px; padding: 10px 14px; min-height: 48px; font-weight: 800; background: var(--surface-2); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.teacher-bar button.stop { background: var(--ink); color: var(--bg); }
.teacher-bar button.noise[aria-pressed="true"] { background: var(--loud); color: #fff; }
.teacher-bar .note-edit { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.teacher-bar .note-edit input { width: min(60vw, 460px); max-width: none; background: var(--surface); }
kbd { font: 800 .72rem/1 var(--body); border: 1.5px solid currentColor; border-bottom-width: 3px; border-radius: 6px; padding: 3px 6px; opacity: .7; }
.result { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(15, 9, 30, .5); padding: 16px; overflow: auto; }
.result-card { background: var(--surface); color: var(--ink); border-radius: 24px; padding: clamp(18px, 3vw, 30px); width: min(560px, 100%); display: grid; gap: 14px; justify-items: center; text-align: center; box-shadow: 0 30px 60px -24px rgba(0, 0, 0, .7); }
.result-card .display { font-size: clamp(1.6rem, 3.6vw, 2.4rem); }
.facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-weight: 800; color: var(--muted); }
.egg-row { display: flex; gap: 14px; align-items: center; width: 100%; }
.egg-canvas { width: 104px; height: 104px; flex: none; }
.egg-meter { flex: 1; display: grid; gap: 8px; text-align: left; min-width: 0; }
.egg-meter .bar { height: 16px; }
#hatch-zone { display: grid; gap: 10px; justify-items: center; width: 100%; }
.hatch-title, .welcome-new, .rare-kept { font: 600 1.25rem var(--display); }
.rare-kept { color: #b45309; }
#hatch-zone input { max-width: 200px; }
/* --- Sur la leçon : la fenêtre devient un petit tableau de bord ------------
   La leçon reste à l'écran et les Toplings sont sur ses fenêtres (l'app les
   montre) : la page ne garde que le chrono, la jauge, l'œuf, une ligne de
   nouvelles et les boutons de la maîtresse, toujours visibles. */
.screen.run.lesson { background: var(--bg); overflow: auto; }
.screen.run.lesson .stage { position: static; }
.screen.run.lesson #scene, .screen.run.lesson .count-in, .screen.run.lesson #b-full, .screen.run.lesson .note { display: none; }
.screen.run.lesson .hud { position: static; padding: 10px 12px 0; align-items: center; gap: 8px; flex-direction: row; }
.screen.run.lesson .hud-box { padding: 6px 12px; border-radius: 12px; box-shadow: none; background: var(--surface-2); color: var(--ink); }
.screen.run.lesson .clock { min-width: 0; flex: 1; gap: 4px; }
.screen.run.lesson .track { height: 10px; }
.screen.run.lesson .track .sun { width: 20px; height: 20px; margin: -10px 0 0 -10px; box-shadow: 0 0 0 3px rgba(251, 191, 36, .32); }
.screen.run.lesson .clock-text { font-size: .95rem; }
.screen.run.lesson .hud-right { gap: 8px; align-items: center; }
.screen.run.lesson .hud-egg .bar { width: 56px; }
.screen.run.lesson .egg-dot { width: 16px; height: 20px; }
.screen.run.lesson .gauge { grid-template-columns: auto auto; align-items: center; gap: 6px; min-width: 0; }
.screen.run.lesson .gauge-bar { width: 14px; height: 40px; }
.screen.run.lesson .gauge-text { font-size: .9rem; max-width: 7em; }
.screen.run.lesson .banner { position: static; transform: none; margin: 6px 12px 0; padding: 4px 12px; font-size: .95rem; box-shadow: none; max-width: none; background: transparent; color: var(--muted); text-align: left; }
.screen.run.lesson .teacher-bar { position: static; transform: none; margin: 4px 12px 10px; padding: 0; background: none; box-shadow: none; justify-content: flex-start; max-width: none; transition: none; }
.screen.run.lesson .teacher-bar button { min-height: 34px; padding: 6px 10px; border-radius: 10px; font-size: .9rem; }
.screen.run.lesson .teacher-bar kbd { display: none; }
body.quiet-cursor .screen.run.lesson { cursor: auto; }
@media (max-width: 640px) {
  .hud { flex-direction: column; align-items: stretch; }
  .clock { min-width: 0; }
  .hud-right { justify-content: space-between; }
  .gauge { grid-template-columns: auto 1fr; justify-items: start; align-items: center; }
  .gauge-bar { width: 22px; height: 70px; }
  .starters { grid-template-columns: 1fr; }
  .notebook { padding-left: 24px; background-image: linear-gradient(rgba(124, 58, 237, .14) 1px, transparent 1px); background-size: 100% 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .bar span, .teacher-bar, .banner, .gauge-bar .level { transition: none; }
}
