.protocol-replaced,
.has-protocol-header .exp-nav,
.has-protocol-header .floating-menu,
.protocol-sleep-saver #app .header > .brand { display: none !important; }

html.has-protocol-navigation { scroll-padding-top: calc(var(--protocol-header-offset, 104px) + 8px); }
.protocol-header-spacer { height: var(--protocol-header-offset, 104px); }
:is(.earth-home,.red-pill,.protocol-sleep-saver) > .protocol-header-spacer { display: none; }
.red-pill.is-revealed > .protocol-header-spacer { display: block; }
body.protocol-sleep-saver { min-width: 0; }
.protocol-sleep-saver #app .app { padding-top: var(--protocol-header-offset, 104px); }
.protocol-sleep-saver #app .header:not(:has(.night-controls)) { display: none; }
.protocol-sleep-saver #app .night-controls { margin-inline-start: auto; }

.protocol-header {
  --header-ink: #19143e;
  --header-surface: #fffcf7;
  --header-edge: #ddd6e4;
  --header-accent: #a62857;
  --header-cross: #946201;
  --header-gear: #ad2748;
  --header-gear-fill: #f9dbe5;
  box-sizing: border-box;
  position: fixed;
  z-index: 100;
  inset: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  padding: calc(8px + env(safe-area-inset-top)) max(clamp(8px, 2.5vw, 36px), env(safe-area-inset-right)) 6px max(clamp(8px, 2.5vw, 36px), env(safe-area-inset-left));
  color: var(--header-ink);
  font: 650 1rem/1 Fredoka,system-ui,sans-serif;
  pointer-events: none;
}
html:is([data-theme="dark"],[data-dark]) .protocol-header,
.red-pill:not(.is-revealed) .protocol-header {
  --header-ink: #fff7ff;
  --header-surface: #221c2e;
  --header-edge: #5a506d;
  --header-accent: #ff9abc;
  --header-cross: #ffdb75;
  --header-gear: #ff9db5;
  --header-gear-fill: #643448;
}
.protocol-header-left { display: grid; justify-items: start; gap: 5px; min-width: 0; }
.protocol-actions { position: relative; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.protocol-identity {
  display: flex;
  align-items: center;
  min-height: 44px;
  background: transparent;
  color: var(--header-ink);
  font-size: clamp(1.35rem, 3.4vw, 2.6rem);
  white-space: nowrap;
  pointer-events: auto;
}
.protocol-header :is(a,button,summary,.language-menu,.protocol-settings-nav) { pointer-events: auto; }
.protocol-header .protocol-wordmark { display: flex; align-items: center; gap: .24em; align-content: center; min-height: 44px; color: inherit; font-weight: 700; text-decoration: none; }
.protocol-wordmark span { color: var(--header-accent); }
.protocol-header .protocol-spark { display: grid; place-items: center; width: 44px; height: 44px; color: var(--header-cross); font-size: 1.08em; text-decoration: none; }
.protocol-header-hero ~ main .earth-hero .hero-left { top: calc(clamp(58px, 8vw, 101px) + env(safe-area-inset-top)); }
@media (min-width: 431px) {
  .protocol-header .protocol-wordmark { display: flex; align-items: center; gap: .24em; }
}
.protocol-header .protocol-menu-trigger,
.protocol-header .site-preferences > button,
.protocol-header .site-preferences .protocol-calendar,
.protocol-header .protocol-rewards,
.protocol-header .site-preferences .language-cycle,
.protocol-header .protocol-settings summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto !important;
  min-width: 44px;
  min-height: 44px;
  height: 44px !important;
  margin: 0;
  padding: 0 9px;
  border: 0 !important;
  border-radius: 12px !important;
  background: var(--header-surface) !important;
  box-shadow: inset 0 0 0 1px var(--header-edge) !important;
  color: var(--header-ink) !important;
  font: 650 .95rem/1 Fredoka,system-ui,sans-serif !important;
  cursor: pointer;
}
.protocol-toolbar, .protocol-progress, .protocol-shortcuts { display: flex; align-items: center; gap: 4px; }
.protocol-menu-trigger { gap: 7px; }
.protocol-header .site-preferences {
  --control-size: 44px;
  position: static;
  display: grid;
  grid-template-columns: repeat(2,var(--control-size));
  align-items: center;
  gap: 4px;
  padding: 0;
}
.protocol-header :is(.theme-toggle, .language-cycle, .protocol-calendar, .protocol-rewards, .protocol-settings summary) {
  box-sizing: border-box;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px;
  padding: 0;
}
.protocol-header .site-preferences .protocol-calendar,
.protocol-header .protocol-rewards {
  text-decoration: none;
}
.protocol-header .protocol-settings summary { color: var(--header-gear) !important; }
.protocol-header .protocol-settings summary svg {
  width: 27px;
  height: 27px;
  transform: rotate(-11deg);
  fill: var(--header-gear-fill);
  stroke-width: 1.8;
}
@media (prefers-reduced-motion: no-preference) {
  .protocol-header .protocol-settings summary svg { transition: transform .18s ease; }
  .protocol-header .protocol-settings:is(:hover,[open]) summary svg { transform: rotate(14deg); }
}
html[data-simple-profile] .protocol-header #wheel-controls,
html[data-simple-profile] .wheel-dock { display: none; }
.protocol-header-hero .protocol-progress .motion-toggle svg { width: 26px; height: 26px; }
.protocol-header-hero .protocol-progress .motion-toggle svg :is(rect,path) {
  fill: currentColor;
  stroke: none;
}
.protocol-header-hero .motion-toggle[data-playing="true"] .motion-play,
.protocol-header-hero .motion-toggle:not([data-playing="true"]) .motion-pause { display: none; }
.protocol-header .site-preferences .language-wrap { position: relative; }
.protocol-header :is(.site-preferences, .protocol-shortcuts) svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.protocol-settings summary::-webkit-details-marker { display: none; }
.protocol-header .protocol-settings[open] summary { outline: 1px solid #aea1c4; }
.protocol-header .language-menu,.protocol-settings-nav {
  position: absolute;
  z-index: 2;
  top: calc(100% + 7px);
  right: 0;
  min-width: 148px;
  padding: 5px;
  border: 1px solid #cbd2e7;
  border-radius: 14px;
  background: #fff;
  color: #19143e;
  box-shadow: 0 8px 24px #19143e20;
}
.protocol-header .language-menu button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 44px;
  padding: 6px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  font: 600 1rem/1.2 Fredoka,system-ui,sans-serif;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.protocol-header .language-menu button[aria-current="true"],.protocol-header .language-menu button:hover { background: #e5efff; color: #19143e; }
.protocol-settings-nav {
  box-sizing: border-box;
  width: min(310px, calc(100vw - 32px));
  max-height: calc(100dvh - var(--protocol-header-offset, 104px) - env(safe-area-inset-bottom) - 12px);
  overflow: auto;
  padding: 12px;
  border-color: #d7c8e5;
  border-radius: 19px;
  background: #fcf7f1;
}
.protocol-settings-nav h2 {
  margin: 0 0 9px;
  padding-inline: 2px;
  font: 650 1.16rem/1.2 Fredoka,system-ui,sans-serif;
}
.protocol-settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.protocol-header .protocol-settings-grid .protocol-tool {
  display: flex;
  align-items: center;
  min-height: 52px;
  min-width: 0;
  gap: 7px;
  padding: 5px 6px;
  border: 1px solid #d9cee2;
  border-radius: 12px;
  background: #fff;
  color: #211838;
  font: 550 .88rem/1.16 Fredoka,system-ui,sans-serif;
  text-decoration: none;
}
.protocol-tool-icon {
  display: grid;
  width: 29px;
  height: 29px;
  flex: 0 0 29px;
  place-items: center;
  border-radius: 8px;
  background: var(--tool-tint,#efe5fa);
  color: inherit;
}
.protocol-tool-profil { --tool-tint: #fce6eb; }
.protocol-tool-preferences { --tool-tint: #eae3f8; }
.protocol-tool-roue { --tool-tint: #e5effe; }
.protocol-tool-boutique { --tool-tint: #fff0ca; }
.protocol-tool-outils { --tool-tint: #e3f2e6; }
.protocol-header .protocol-settings-grid .protocol-tool-outils { grid-column: 1 / -1; }
.protocol-header .protocol-settings .protocol-tool-icon svg { width: 18px; height: 18px; }
.protocol-header .protocol-settings-grid .protocol-tool:hover { border-color: #9578af; background: #f5ecff; }
html:is([data-theme="dark"],[data-dark]) .protocol-settings-nav { background: #231d2d; color: #f9f4ff; border-color: #575064; }
html:is([data-theme="dark"],[data-dark]) .protocol-header .protocol-settings-grid .protocol-tool { background: #312a3d; color: #fff; border-color: #615570; }
html:is([data-theme="dark"],[data-dark]) .protocol-header .protocol-tool-icon { color: #221a31; }
html:is([data-theme="dark"],[data-dark]) .protocol-header .protocol-settings-grid .protocol-tool:hover { background: #443554; }
.protocol-header :is(a,button,summary):focus-visible { outline: 2px solid #a23575; outline-offset: 2px; }
.protocol-header #wheel-controls { width: auto; }
.protocol-header #wheel-controls :is([data-action="language"],[data-action="theme"]) { display: none; }
.protocol-header ~ :is(.score-header,.shop2-header) { justify-content: flex-end; padding-top: 0; }

.protocol-header .site-preferences .language-menu[hidden] { display: none; }

html:is([data-theme="dark"],[data-dark]) .protocol-header .language-menu {
  background: #231d2d;
  color: #f9f4ff;
  border-color: #575064;
}
html:is([data-theme="dark"],[data-dark]) .protocol-header .language-menu button:is(:hover,[aria-current="true"]) {
  background: #443554;
  color: #fff;
}

.protocol-menu {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font: 600 1.05rem/1.2 Fredoka,system-ui,sans-serif;
}
.protocol-menu:not([open]) { display: none; }
.protocol-menu::backdrop { background: #100d1c88; }
body.menu-open { overflow: hidden; }
.protocol-menu-panel {
  --menu-paper: #fffaf5;
  --menu-ink: #19143e;
  --menu-edge: #ded6e4;
  --menu-hover: #f3eafb;
  --menu-accent: #a62857;
  --menu-cross: #946201;
  box-sizing: border-box;
  width: min(410px, 94vw);
  padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) 16px;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--menu-paper);
  color: var(--menu-ink);
}
html:is([data-theme="dark"],[data-dark]) .protocol-menu-panel {
  --menu-paper: #221c2e;
  --menu-ink: #fff7ff;
  --menu-edge: #5a506d;
  --menu-hover: #3c2e50;
  --menu-accent: #ff9abc;
  --menu-cross: #ffdb75;
}
.protocol-menu-panel header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.protocol-menu-brand { display: flex; align-items: end; gap: 3px; font-weight: 700; font-size: clamp(1.1rem, 4.5vw, 1.65rem); }
.protocol-menu-brand a { display: grid; align-items: center; min-height: 44px; color: inherit; text-decoration: none; }
.protocol-menu-brand a:first-child { display: grid; align-content: center; line-height: .95; }
.protocol-menu-brand a:last-child { min-width: 44px; justify-items: start; align-items: end; padding-bottom: 2px; line-height: .95; }
.protocol-menu-brand span { color: var(--menu-accent); }
.protocol-menu-brand b { color: inherit; font-size: .9em; }
.protocol-menu nav { display: grid; gap: 7px; }
.protocol-menu nav a {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  min-height: 48px;
  padding: 7px 12px;
  border: 1px solid var(--menu-edge);
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}
.protocol-menu nav i { font-style: normal; }
.protocol-menu nav a:is(:hover,:focus-visible), .protocol-menu-close:hover { background: var(--menu-hover); }
.protocol-menu-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--menu-edge);
  border-radius: 50%;
  background: var(--menu-paper);
  color: var(--menu-ink);
  font: 600 1.6rem/1 Fredoka,system-ui,sans-serif;
  cursor: pointer;
}

.protocol-theme-modes {
  min-width: 0;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}
.protocol-theme-modes legend { margin: 0 0 6px; padding: 0 2px; font-size: .88rem; }
.protocol-theme-modes > div {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 4px;
}
.protocol-theme-modes button {
  min-width: 0;
  min-height: 44px;
  padding: 3px;
  border: 1px solid var(--header-edge);
  border-radius: 9px;
  background: var(--header-surface);
  color: var(--header-ink);
  font: 600 .9rem/1.15 Fredoka,system-ui,sans-serif;
  cursor: pointer;
}
.protocol-theme-modes button[aria-pressed="true"] { background: #ffd96b; color: #21203a; border-color: #a47326; }
.protocol-tool-jeu { --tool-tint: #ffebba; }
.protocol-header .protocol-settings-grid .protocol-tool-outils { grid-column: auto; }

.protocol-header-hero .protocol-identity {
  color: #fff;
  --header-accent: #ff9abc;
  --header-cross: #ffd66b;
  text-shadow: 0 1px 7px #19143e;
}
@media (prefers-reduced-motion: no-preference) {
  .protocol-header :is(.protocol-menu-trigger, .site-preferences > button, .language-cycle, .protocol-calendar, .protocol-rewards) {
    transition: transform .18s ease;
  }
  .protocol-header :is(.protocol-menu-trigger, .site-preferences > button, .language-cycle, .protocol-calendar, .protocol-rewards):hover {
    transform: translateY(-2px) rotate(-4deg);
  }
}

.protocol-header .protocol-wordmark {
  display: grid;
  align-content: center;
  gap: 0;
  line-height: .9;
}
.protocol-header .protocol-spark { align-self: end; align-items: end; width: 36px; line-height: .9; font-size: .72em; }
:is(.sleep-night, .protocol-welcome-night) .protocol-identity {
  color: #fff;
  --header-accent: #ff9abc;
  --header-cross: #ffd66b;
}
.protocol-header .site-preferences :is(button, summary, a),
.protocol-header .protocol-menu-trigger {
  box-shadow: none !important;
}
.cursor-spark {
  position: fixed;
  z-index: 110;
  pointer-events: none;
  width: 5px;
  height: 5px;
  background: #ffcc30;
  clip-path: polygon(50% 0, 66% 34%, 100% 50%, 66% 66%, 50% 100%, 34% 66%, 0 50%, 34% 34%);
  animation: protocol-spark-fade .65s ease-out forwards;
}
@keyframes protocol-spark-fade { to { opacity: 0; transform: translateY(9px) scale(.3); } }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .protocol-header :is(.protocol-wordmark, .protocol-spark, summary),
  :is(.hero-shop, .home-explore a, .home-play a, .protocol-menu nav a, .sleep-choice, .red-stop) {
    transition: transform .18s ease;
  }
  .protocol-header :is(.protocol-wordmark, .protocol-spark, summary):hover,
  :is(.hero-shop, .home-explore a, .home-play a, .protocol-menu nav a, .sleep-choice, .red-stop):hover {
    transform: translateY(-3px) rotate(-2deg);
  }
}

body.protocol-welcome-night {
  min-height: 100svh;
  margin: 0;
  background: #08070d;
  color: #fff6ff;
  font-family: Fredoka, system-ui, sans-serif;
}
.protocol-welcome-night main {
  max-width: 42rem;
  margin: clamp(65px, 16svh, 160px) auto 0;
  padding: 24px;
  text-align: center;
}
.protocol-welcome-night h1 { font-size: clamp(2rem, 6vw, 3.75rem); line-height: 1; }
.protocol-welcome-night main a {
  display: inline-block;
  margin-top: 14px;
  padding: 12px 18px;
  border-radius: 99px;
  background: #ffd66b;
  color: #211b3c;
  text-decoration: none;
}

.protocol-menu-trigger > span[aria-hidden] { letter-spacing: .12em; line-height: 1; }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .protocol-header .protocol-progress .motion-toggle { transition: transform .18s ease; }
  .protocol-header :is(.theme-toggle, .motion-toggle, .language-cycle, .protocol-rewards):hover {
    transform: translateY(-3px) rotate(-6deg);
  }
}

.protocol-header .protocol-identity { font-size: clamp(1.75rem, 5vw, 4.75rem); }
.protocol-header .protocol-spark { font-size: .92em; width: .95em; }
.protocol-header-hero ~ main .earth-hero .hero-left {
  top: calc(clamp(75px, 10vw, 154px) + env(safe-area-inset-top));
}
.protocol-header .protocol-progress .motion-toggle {
  position: static;
  inline-size: 44px !important;
  block-size: 44px !important;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--header-surface);
  color: var(--header-ink);
  cursor: pointer;
}
.protocol-header .protocol-progress .motion-toggle svg { width: 24px; fill: currentColor; }
.protocol-header .protocol-back {
  color: inherit;
  font-size: .95rem;
  text-decoration: none;
  padding: 7px 0;
}
.protocol-header-film ~ .protocol-header-spacer { display: none; }
.protocol-header-film .protocol-identity {
  color: #fff;
  --header-accent: #ff9abc;
  --header-cross: #ffd66b;
  text-shadow: 0 2px 6px #19143e;
}
.protocol-header-film .protocol-back { color: #fff; text-shadow: 0 2px 6px #19143e; }
.cursor-spark { width: var(--spark-size, 5px); height: var(--spark-size, 5px); }
@media (max-width: 420px) {
  .protocol-header .protocol-identity { font-size: clamp(1.7rem, 6vw, 2rem); }
  .protocol-header .protocol-spark { width: 32px; }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .protocol-header .protocol-rewards:hover { transform: none; }
  .protocol-header .protocol-rewards svg { transition: transform .2s ease; }
  .protocol-header .protocol-rewards:hover svg { transform: rotate(-15deg) scale(1.14); }
}

.protocol-header .protocol-wordmark .protocol-wordmark-the,
.protocol-menu-brand .protocol-wordmark-the { color: #ff80b3; }
.protocol-header .protocol-wordmark .protocol-wordmark-name,
.protocol-menu-brand .protocol-wordmark-name {
  color: #fff;
  -webkit-text-stroke: .075em #000;
  paint-order: stroke fill;
}
.protocol-header .protocol-spark, .protocol-menu-brand b { color: #ffda43; }
.protocol-header .protocol-wordmark, .protocol-header .protocol-spark {
  text-shadow: 0 1px 2px #19163d, 0 0 5px #19163d55;
}
.protocol-level {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding-inline: 10px;
  border-radius: 12px;
  color: #541536;
  background: #ffd1e5;
  border: 1px solid #eba9c8;
  font-size: .85rem;
  white-space: nowrap;
  text-decoration: none;
}
.protocol-header #wheel-controls { display: none; }
.protocol-header .protocol-play-entry {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--header-surface);
  color: var(--header-ink);
  box-shadow: inset 0 0 0 1px var(--header-edge);
}
.protocol-play-entry svg { width: 25px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.protocol-play-entry:focus-visible { outline: 3px solid #7c59d1; outline-offset: 3px; }
html:has(.reward-intro[data-phase="search"]) .cursor-spark { width: max(5px,var(--spark-size)); height: max(5px,var(--spark-size)); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .protocol-play-entry svg { transition: transform .2s ease; }
  .protocol-play-entry:hover svg { transform: rotate(-12deg) scale(1.12); }
}
@media (max-width: 430px) {
  .protocol-header .protocol-identity { font-size: clamp(1.4rem, 5.6vw, 1.7rem); }
}

.protocol-shortcuts .protocol-game-entry {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  background: #ffda43;
  color: #19163d;
  text-decoration: none;
  font-size: 1.42rem;
}
.protocol-game-entry:focus-visible { outline: 3px solid #7c59d1; outline-offset: 2px; }
@media (hover:hover) and (prefers-reduced-motion:no-preference) {
  .protocol-game-entry { transition: transform .2s ease; }
  .protocol-game-entry:hover { transform: translateY(-2px) rotate(8deg); }
}

.hero-shops .hero-learning { background: #eee4ff; color: #35205f; }
.hero-shops .hero-learning:hover { background: #ddc8ff; }
.menu-learning { --menu-hover: #eee4ff; }
@media (max-width: 600px) {
  .hero-shops { flex-wrap: wrap; max-width: min(100%, calc(100vw - 150px)); }
  .hero-shops .hero-learning { flex-basis: max-content; }
}
