/*
  Bad Ink Tower : la page est une feuille du jeu. Papier, encre noire, et le rouge sang
  seulement quand quelque chose saigne ou se rature (docs/02 : « la couleur doit être un événement »).
  Lettrage au feutre (Permanent Marker, le même que dans le jeu), texte en SF Rounded comme l'interface.
*/
@font-face {
  font-family: "Permanent Marker";
  src: url("PermanentMarker-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  --paper: #eee8dc;
  --paper-deep: #e2d9c8;
  --ink: #121110;
  --ink-soft: #4a4640;
  --blood: #d81e1e;
  --marker: "Permanent Marker", "Marker Felt", "Chalkboard SE", cursive;
  --text: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  --gutter: clamp(20px, 5vw, 72px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 500 17px/1.55 var(--text);
  -webkit-font-smoothing: antialiased;
}
.defs { position: absolute; }
a { color: inherit; text-decoration-thickness: 2px; text-underline-offset: 0.2em; }
a:hover { text-decoration-color: var(--blood); }
:focus-visible { outline: 3px solid var(--blood); outline-offset: 3px; }
img { max-width: 100%; }

h1, h2, h3, .logo { font-family: var(--marker); font-weight: 400; line-height: 1.02; text-wrap: balance; }
h2 { font-size: clamp(2.2rem, 1.4rem + 3.4vw, 4rem); margin: 0 0 clamp(24px, 4vw, 48px); }

/* En-tête : le logo au feutre, trois liens. */
.top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 24px;
  padding: max(16px, env(safe-area-inset-top)) var(--gutter) 16px;
}
.logo { font-size: 1.7rem; text-decoration: none; transform: rotate(-2deg); }
.top nav { display: flex; gap: 6px 22px; flex-wrap: wrap; font-weight: 700; }
.top nav a { text-decoration: none; padding: 10px 0; }
@media (max-width: 560px) {
  .top { gap: 0 16px; }
  .logo { font-size: 1.45rem; }
  .top nav { gap: 0 16px; font-size: 0.95rem; }
}
.top nav a:hover, .top nav a[aria-current] {
  text-decoration: underline wavy var(--blood);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35em;
}

/* Menu des langues : un <details> dont la liste flotte par-dessus la page, sans rien décaler. */
.lang-menu { position: relative; }
.lang-menu summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu .globe { flex: none; }
.lang-menu .chevron { flex: none; transition: transform 0.15s ease; }
.lang-menu[open] .chevron { transform: rotate(180deg); }
.lang-menu ul {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  min-width: 190px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 3px 4px 0 var(--ink);
}
.top nav .lang-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.top nav .lang-menu a:hover { background: var(--paper-deep); text-decoration: none; }
.top nav .lang-menu a[aria-current] { font-weight: 800; text-decoration: none; }
.lang-menu .check { flex: none; color: var(--blood); }
/* Sur téléphone, le menu passe à la ligne sous le logo : la liste s'aligne sur la marge droite de
   l'en-tête, pour ne jamais dépasser de l'écran. */
@media (max-width: 560px) {
  .top { position: relative; }
  .lang-menu { position: static; }
  .lang-menu ul { top: calc(100% - 8px); right: var(--gutter); }
}
@media (prefers-reduced-motion: reduce) {
  .lang-menu .chevron { transition: none; }
}

/* Japonais et coréen : Permanent Marker n'a que l'alphabet latin, le reste prend une police ronde du système. */
:lang(ja) { --marker: "Permanent Marker", "Hiragino Maru Gothic ProN", "Hiragino Sans", sans-serif; }
:lang(ko) { --marker: "Permanent Marker", "Apple SD Gothic Neo", sans-serif; }

/* Scène d'ouverture : la tour au centre, les monstres qui convergent, une flaque d'encre rouge. */
.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: center;
  gap: 24px;
  padding: clamp(16px, 4vw, 48px) var(--gutter) clamp(48px, 7vw, 96px);
  overflow: hidden;
}
.title {
  margin: 0;
  font-size: clamp(3.6rem, 1.6rem + 8.5vw, 9.5rem);
  line-height: 0.86;
  transform: rotate(-3deg);
  transform-origin: left bottom;
}
.pitch { font-size: clamp(1.15rem, 1rem + 0.6vw, 1.45rem); max-width: 22em; margin: 1.6rem 0 1.8rem; }
.platform { margin: 0.9rem 0 0; color: var(--ink-soft); font-size: 0.95rem; }

.store {
  display: inline-block;
  margin: 0;
  padding: 0.85rem 1.3rem;
  border: 3px solid var(--ink);
  border-radius: 14px 18px 12px 20px;
  background: var(--ink);
  color: var(--paper);
  font: 1.2rem/1.2 var(--marker);
  text-decoration: none;
  filter: url(#wobble);
}
.store.soon { background: none; color: var(--ink); transform: rotate(1.5deg); }
/* App Store et Google Play côte à côte ; le second penche un peu, comme posé à la main. */
.stores { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem 1rem; margin: 0; }
.stores .store:nth-child(2) { transform: rotate(-1.2deg); }

.arena { position: relative; aspect-ratio: 1 / 0.92; min-height: 280px; }
.splat { position: absolute; left: 14%; top: 26%; width: 72%; fill: var(--blood); opacity: 0.92; filter: url(#wobble-big); }
.tower {
  position: absolute;
  left: 50%;
  top: 6%;
  width: 54%;
  aspect-ratio: 1;
  translate: -50% 0;
  background: url("tower-idle.png") 0 0 / 400% 100% no-repeat;
  animation: tower-idle 5.2s infinite step-end;
}
/* Comme en jeu : la tour attend, sourit, cligne de l'œil. */
@keyframes tower-idle {
  0% { background-position-x: 0%; }
  38% { background-position-x: 33.333%; }
  46% { background-position-x: 0%; }
  78% { background-position-x: 66.667%; }
  81% { background-position-x: 0%; }
  92% { background-position-x: 100%; }
  97% { background-position-x: 0%; }
}
.foe { position: absolute; height: auto; }
.foe-1 { width: 23%; left: -2%; top: 58%; rotate: 8deg; }
.foe-2 { width: 22%; left: 78%; top: 52%; scale: -1 1; }
.foe-3 { width: 19%; left: 6%; top: 8%; rotate: -10deg; }
.foe-4 { width: 19%; left: 80%; top: 6%; scale: -1 1; rotate: 6deg; }
.foe-5 { width: 17%; left: 66%; top: 74%; }
.foe-6 { width: 30%; left: 20%; top: 66%; rotate: -4deg; }

@media (max-width: 760px) {
  .stage { grid-template-columns: 1fr; }
  .arena { margin: 8px calc(var(--gutter) * -0.5) 0; }
}

/* La boucle de jeu : une vraie suite, donc numérotée, au feutre. */
.loop { padding: clamp(56px, 8vw, 112px) var(--gutter); background: var(--ink); color: var(--paper); }
.loop ol { list-style: none; counter-reset: step; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(28px, 4vw, 56px); margin: 0; padding: 0; }
.loop li { counter-increment: step; }
.loop li::before {
  content: counter(step);
  display: block;
  font: 5rem/0.9 var(--marker);
  color: var(--blood);
  margin-bottom: 0.4rem;
}
.loop h3 { font-size: 1.7rem; margin: 0 0 0.6rem; }
.loop p { margin: 0; color: #d9d3c6; max-width: 26em; }
@media (max-width: 760px) { .loop ol { grid-template-columns: 1fr; } }

/* Bestiaire : des griffonnages épinglés au hasard sur la feuille, pas une grille de cartes. */
.bestiary { padding: clamp(56px, 8vw, 112px) var(--gutter); }
.foes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 48px 28px; }
@media (max-width: 860px) { .foes { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.foes li, .bosses li { text-align: center; }
.foes img { width: 132px; height: auto; transition: rotate 220ms cubic-bezier(0.3, 1.6, 0.5, 1); }
.foes li:nth-child(odd) img { rotate: -5deg; }
.foes li:nth-child(even) img { rotate: 4deg; }
.foes li:nth-child(4n + 2), .foes li:nth-child(4n + 3) { translate: 0 22px; }
.foes li:hover img { rotate: 0deg; }
.foes h3, .bosses h3 { font-size: 1.55rem; margin: 0.2rem 0 0.3rem; }
.foes p, .bosses p { margin: 0 auto; max-width: 15em; color: var(--ink-soft); }
.bosses-title { font-size: clamp(1.8rem, 1.3rem + 2vw, 2.8rem); margin: clamp(64px, 9vw, 112px) 0 24px; }
.bosses { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 32px 72px; }
.bosses li { flex: 1 1 260px; }
.bosses img { width: 220px; height: auto; }
.bosses h3 { color: var(--blood); font-size: 2rem; }

/* Ce qu'on ne fait pas : raturé au rouge, comme le Correcteur. */
.deal { padding: clamp(56px, 8vw, 112px) var(--gutter); background: var(--paper-deep); }
.crossed-intro { margin: 0 0 0.6rem; font-size: 1.15rem; }
.crossed { list-style: none; margin: 0 0 2rem; padding: 0; }
.crossed li { font: clamp(1.6rem, 1.1rem + 2.2vw, 2.9rem)/1.25 var(--marker); }
.crossed li:nth-child(2) { margin-left: 1.2em; }
.crossed li:nth-child(3) { margin-left: 0.5em; }
.crossed del { text-decoration: line-through var(--blood); text-decoration-thickness: 0.14em; }
.deal > p { max-width: 34em; font-size: 1.15rem; margin: 0; }

.last {
  display: flex;
  align-items: center;
  gap: clamp(20px, 4vw, 56px);
  padding: clamp(48px, 7vw, 96px) var(--gutter);
}
.last img { width: clamp(140px, 22vw, 240px); height: auto; flex: none; rotate: -4deg; }
.last h2 { margin: 0 0 0.3rem; }
.last p { margin: 0 0 1.4rem; font-size: 1.15rem; }
@media (max-width: 560px) { .last { flex-direction: column; align-items: flex-start; } }

/* Pages longues : même feuille, colonne de lecture, sommaire au feutre. */
.doc-head { padding: clamp(24px, 5vw, 64px) var(--gutter) 8px; }
.doc-head h1 {
  margin: 0;
  font-size: clamp(2.8rem, 1.4rem + 5.5vw, 6.5rem);
  line-height: 0.92;
  transform: rotate(-1.5deg);
  transform-origin: left bottom;
  max-width: 13ch;
}
.updated { margin: 1.2rem 0 0; color: var(--ink-soft); }
.reading {
  display: grid;
  grid-template-columns: minmax(11rem, 15rem) minmax(0, 40rem);
  gap: clamp(32px, 6vw, 96px);
  padding: clamp(32px, 5vw, 56px) var(--gutter) clamp(56px, 8vw, 112px);
}
.toc { position: sticky; top: 20px; align-self: start; }
.toc > p { margin: 0 0 0.6rem; font: 1.3rem/1 var(--marker); }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; padding: 0.3rem 0; color: var(--ink-soft); text-decoration: none; font-size: 0.95rem; line-height: 1.35; }
.toc a:hover { color: var(--ink); text-decoration: underline wavy var(--blood); }
@media (max-width: 860px) {
  .reading { grid-template-columns: 1fr; }
  .toc { position: static; }
}
.prose { font-size: 1.08rem; line-height: 1.7; }
.prose > :first-child { margin-top: 0; }
.prose .lede { font-size: 1.3rem; line-height: 1.5; font-weight: 600; }
.prose h2 { font-size: clamp(1.7rem, 1.3rem + 1.4vw, 2.3rem); margin: 3rem 0 0.8rem; scroll-margin-top: 20px; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin-bottom: 0.45rem; }
.prose li::marker { color: var(--blood); }
.prose strong { font-weight: 800; }
.prose a { text-decoration-color: var(--blood); }
.prose .hint { color: var(--ink-soft); font-size: 0.98rem; }
.prose .contact { margin: 1.8rem 0 0.8rem; }
.prose .button {
  display: inline-block;
  padding: 0.85rem 1.3rem;
  border-radius: 14px 18px 12px 20px;
  background: var(--ink);
  color: var(--paper);
  font: 1.15rem/1.2 var(--marker);
  text-decoration: none;
  filter: url(#wobble);
}
.prose .button:hover { background: var(--blood); }

/* Pied de page : l'encre referme la feuille ; un rampant passe la tête par-dessus. */
.bottom {
  position: relative;
  margin-top: 40px;
  padding: 56px var(--gutter) max(32px, env(safe-area-inset-bottom));
  background: var(--ink);
  color: var(--paper);
}
.bottom::before {
  content: "";
  position: absolute;
  right: 12%;
  top: -58px;
  width: 92px;
  height: 92px;
  background: url("enemy-rampant.png") center / contain no-repeat;
}
.bottom nav { display: flex; flex-wrap: wrap; gap: 6px 32px; font: 1.5rem/1.3 var(--marker); }
.bottom nav a { text-decoration: none; padding: 6px 0; }
.bottom nav a:hover { color: var(--blood); }
.bottom p { margin: 1.4rem 0 0; color: #bdb6a8; font-size: 0.92rem; }

@media (prefers-reduced-motion: reduce) {
  .tower { animation: none; }
  .foes img { transition: none; }
}

/* Titres d'un seul long mot (« Datenschutzerklärung ») : coupés avec un trait d'union plutôt que de dépasser de l'écran. */
.doc-head h1 { hyphens: auto; overflow-wrap: break-word; }
