@font-face {
  font-family: "Libre Caslon Text";
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/librecaslon-700-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Share Tech Mono";
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/sharetechmono-latin.woff2") format("woff2");
}
/* Polices de la version 2 : Sorts Mill Goudy pour les menus du jeu, Gelasio pour le mot gravé sur la plaque */
@font-face {
  font-family: "Sorts Mill Goudy";
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/sortsmillgoudy-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Gelasio";
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/gelasio-700-latin.woff2") format("woff2");
}

/* Layout : un moniteur cardiaque seul au centre, commandes discrètes dessous. Pas de chiffres, la courbe fait le travail. */
:root {
  --bg: #060809;
  --bezel: #161d21;
  --bezel-hi: #2a363c;
  --screen: #030605;
  --ink: #c3cdd0;
  --muted: #66757a;
  --state: hsl(130, 95%, 58%);
  --pulse: 0;
  --font-plate: "Libre Caslon Text", "Times New Roman", Georgia, serif;
  --font-ui: "Share Tech Mono", ui-monospace, Consolas, "Courier New", monospace;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
input { -webkit-user-select: text; user-select: text; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  display: flex;
  padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px));
  padding-top: max(24px, env(safe-area-inset-top, 0px));
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, hsla(0, 100%, 35%, 0.55) 100%);
  opacity: var(--pulse);
}
/* margin auto plutôt que align-items: center, pour qu'un contenu trop haut défile au lieu d'être coupé en haut */
main { margin: auto; width: 100%; min-width: 0; max-width: 920px; display: flex; flex-direction: column; gap: 18px; }

.monitor {
  position: relative;
  background: linear-gradient(180deg, var(--bezel-hi), var(--bezel) 40%, #0d1214);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 0 0 1px #000, inset 0 1px 0 rgba(255,255,255,0.08), 0 20px 50px rgba(0,0,0,0.6);
}
.screen {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 6.4;
  background: var(--screen);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.9), inset 0 0 0 1px rgba(0,0,0,0.8);
}
.screen canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.screen::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.22) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.65) 100%);
}
.tag {
  position: absolute; top: 10px; z-index: 2;
  font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--state);
  opacity: 0.75;
  text-shadow: 0 0 6px var(--state);
}
.tag.center { left: 14px; right: 14px; text-align: center; }
/* État écrit dans l'écran, en bas à droite, comme dans les Resident Evil */
.status {
  position: absolute; right: 30px; bottom: 22px; z-index: 2;
  font-family: var(--font-plate);
  font-weight: 700;
  font-size: clamp(18px, 3.4vw, 34px);
  letter-spacing: 0.04em;
  color: var(--state);
  text-shadow: 0 0 12px var(--state), 0 0 2px #000;
}
.blink { animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; }
button {
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  background: linear-gradient(180deg, #1a2226, #0f1416);
  border: 1px solid var(--bezel-hi);
  border-radius: 3px;
  padding: 10px 16px;
  cursor: pointer;
  transition: border-color .2s, color .2s, box-shadow .2s;
}
button:hover:not(:disabled) { border-color: var(--state); color: #fff; box-shadow: 0 0 10px -2px var(--state); }
button:focus-visible { outline: 2px solid var(--state); outline-offset: 2px; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { min-width: 11em; border-color: var(--state); color: #fff; }
button[aria-pressed="true"] { border-color: var(--state); }

.sessions { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; }
.dots { display: flex; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--muted); }
.dot.done { background: var(--state); border-color: var(--state); box-shadow: 0 0 6px var(--state); }
.dot.now { border-color: var(--state); }

.hint { margin: 0; color: var(--muted); font-size: 12px; letter-spacing: 0.06em; }
kbd { font: inherit; border: 1px solid var(--bezel-hi); border-radius: 3px; padding: 0 5px; color: var(--ink); }

.settings {
  border: 1px solid var(--bezel-hi);
  border-radius: 4px;
  background: #0b1012;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px 22px;
}
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.field input[type="number"], .field select {
  font: inherit; font-size: 15px; letter-spacing: 0; color: var(--ink);
  background: #050708; border: 1px solid var(--bezel-hi); border-radius: 3px; padding: 7px 9px; width: 100%; box-sizing: border-box;
  font-variant-numeric: tabular-nums;
}
.check { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--ink); cursor: pointer; }
.check input { accent-color: var(--state); width: 16px; height: 16px; }
input:focus-visible { outline: 2px solid var(--state); outline-offset: 1px; }

/* Vue épurée pendant une session : seulement la courbe et l'état.
   Un toucher sur l'écran fait réapparaître le reste quelques secondes. */
body, .monitor, .screen { transition: background-color 0.6s, box-shadow 0.6s; }
.tag, .bar { transition: opacity 0.5s; }
.focus body { background: #000; }
.focus .monitor { background: transparent; box-shadow: none; border-radius: 0; }
.focus .screen { border-radius: 0; box-shadow: none; background: #000; }
.focus .hint, .focus .settings { display: none; }
.focus:not(.peek) .tag { opacity: 0; }
.focus .bar {
  position: fixed;
  z-index: 10;
  left: max(16px, env(safe-area-inset-left, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  max-width: 920px;
  margin-inline: auto;
  padding: 10px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.8);
  opacity: 0;
  pointer-events: none;
}
.focus.peek .bar, .focus .bar:has(:focus-visible) { opacity: 1; pointer-events: auto; }

/* Temps dépassé : Danger reste et clignote, le bord de l'écran pulse en rouge */
.overtime .status { animation: alarm 0.9s steps(1, end) infinite; }
.overtime body::after { animation: alarm-vignette 0.9s ease-in-out infinite; }
@keyframes alarm { 50% { opacity: 0.2; } }
@keyframes alarm-vignette { 0%, 100% { opacity: 0.25; } 50% { opacity: 0.85; } }

/* L'écran tient toujours dans la hauteur visible, en paysage notamment */
main { max-width: min(920px, calc((100vh - 190px) * 2.5 + 24px)); }
.focus main { max-width: min(1200px, calc((100vh - 64px) * 2.5 + 24px)); }
@supports (height: 100dvh) {
  main { max-width: min(920px, calc((100dvh - 190px) * 2.5 + 24px)); }
  .focus main { max-width: min(1200px, calc((100dvh - 64px) * 2.5 + 24px)); }
}
@media (max-height: 520px) {
  body { padding-top: max(8px, env(safe-area-inset-top, 0px)); padding-bottom: max(8px, env(safe-area-inset-bottom, 0px)); }
  main { gap: 10px; }
  .hint { display: none; }
}

@media (max-width: 560px) {
  .screen { aspect-ratio: 16 / 9; }
  .tag { font-size: 10px; top: 8px; }
  button.primary { flex: 1 1 100%; }
  main, .focus main { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  body::after { display: none; }
  .blink, .overtime .status { animation: none; }
  body, .monitor, .screen, .tag, .bar { transition: none; }
}


/* ---------- Version 2 : l'écran de statut de Resident Evil REmake ----------
   L'appareil est entièrement dessiné dans le canevas. Autour, l'interface reprend le menu du jeu :
   boutons ronds cerclés de laiton, plaque « Arsenal tactique », cases d'inventaire, boîte de texte à rouleau. */
.ico, .phase-plate { display: none; }
.theme-remake {
  --goudy: "Sorts Mill Goudy", "Goudy Old Style", Garamond, "Times New Roman", serif;
  --gill: "Gill Sans", "Gill Sans MT", Calibri, system-ui, sans-serif;
  --salmon: #eba58c;
  --silver: #a8a7a2;
  --copper: #f0d2b0;
  /* Crasse des pièces (taches, piqûres, rayures) : la texture est fabriquée par app.js, rien tant qu'elle manque */
  --crasse: linear-gradient(transparent, transparent);
}
.theme-remake body, .theme-remake.focus body { background: #000; }
.theme-remake main { gap: 16px; }
.theme-remake .monitor, .theme-remake.focus .monitor { padding: 0; background: none; box-shadow: none; border-radius: 0; }
.theme-remake .screen, .theme-remake.focus .screen {
  aspect-ratio: 338 / 207;
  background: none; box-shadow: none; border-radius: 0;
}
.theme-remake .screen::after, .theme-remake .tag { display: none; }

/* Le mot d'état, gravé dans la fenêtre de la plaque dessinée sous le papier */
.theme-remake .status {
  left: var(--plate-l); top: var(--plate-t); right: auto; bottom: auto;
  width: var(--plate-w); height: var(--plate-h);
  display: flex; align-items: center; justify-content: center;
  padding-top: calc(var(--plate-h) * 0.05);
  box-sizing: border-box;
  font-family: "Gelasio", Georgia, serif;
  font-weight: 700;
  font-size: calc(var(--plate-h) * 0.74);
  line-height: 1;
  letter-spacing: 0.07em;
  color: var(--ink-state);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4), 0 0 1px rgba(0, 0, 0, 0.4);
}

/* Plaque de la phase, comme « Arsenal tactique » : cadre argenté, fond noir, lettres saumon */
.theme-remake .phase-plate {
  display: block;
  align-self: center;
  min-width: min(100%, 13em);
  box-sizing: border-box;
  padding: 0.2em 1.4em 0.14em;
  text-align: center;
  font: 400 clamp(19px, 3.2vw, 25px)/1.25 var(--goudy);
  letter-spacing: 0.06em;
  color: var(--salmon);
  border: 3px solid transparent;
  background:
    linear-gradient(#030303, #030303) padding-box,
    var(--crasse) 0 0 / 128px 48px border-box,
    linear-gradient(100deg, #f4efe5 0%, #a19d96 7%, #3b3835 15%, #8f8b84 27%, #f7f2e8 33%, #e2ddd3 37%, #77736d 46%,
      #2a2826 58%, #6b6761 70%, #ece8e0 78%, #f7f2e8 81%, #8c8882 88%, #3a3734 95%, #c6c1b8 100%) border-box;
  box-shadow: 0 0 0 1px #000, 0 2px 6px rgba(0, 0, 0, 0.9), inset 0 0 0 1px #000, inset 0 0 14px rgba(0, 0, 0, 0.9);
  transition: opacity 0.5s;
}
.theme-remake.focus .phase-plate {
  position: fixed; z-index: 10;
  top: max(12px, env(safe-area-inset-top, 0px)); left: 50%;
  transform: translateX(-50%);
  opacity: 0; pointer-events: none;
}
.theme-remake.focus.peek .phase-plate { opacity: 1; }

/* Boutons du haut, comme « Quitter », « Fichier », « Carte » : médaillon rond et libellé à côté */
.theme-remake .bar { order: -1; justify-content: center; gap: 14px 22px; }
/* Barre noire vernie où sont posés les médaillons, liseré de lumière en haut et reflet en bas */
.theme-remake .controls {
  justify-content: center; gap: 12px 22px;
  padding: 7px 20px 7px 8px;
  border-radius: 30px;
  background:
    var(--crasse) 0 0 / 160px 40px,
    linear-gradient(180deg, rgba(255, 255, 255, 0) 55%, rgba(255, 255, 255, 0.07) 80%, rgba(255, 255, 255, 0) 100%),
    linear-gradient(180deg, #6d6b67 0, #262523 4%, #0c0c0c 30%, #050505 60%, #1e1d1c 88%, #4a4845 97%, #0a0a0a 100%);
  box-shadow: 0 0 0 1px #000, inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -1px 0 rgba(255, 255, 255, 0.2), 0 5px 12px rgba(0, 0, 0, 0.85);
}
.theme-remake button, .theme-remake button.primary {
  display: inline-flex; align-items: center; gap: 10px;
  min-width: 0;
  padding: 2px 6px 2px 0;
  background: none; border: 0; border-radius: 30px; box-shadow: none;
  font: 400 19px/1 var(--goudy);
  letter-spacing: 0.01em; text-transform: none;
  color: var(--silver);
}
.theme-remake button:hover:not(:disabled) { color: #e6e3da; border: 0; box-shadow: none; }
.theme-remake button[aria-pressed="true"] .lbl { color: var(--salmon); }
.theme-remake .ico {
  display: grid; place-items: center; flex: none;
  width: 46px; height: 46px; border-radius: 50%;
  background:
    var(--crasse) center / 64px 64px,
    radial-gradient(circle, #16120d 0 41%, #3a2c1d 41.5% 42.5%, rgba(0, 0, 0, 0) 43.5%),
    radial-gradient(circle, rgba(0, 0, 0, 0) 0 43.5%, rgba(0, 0, 0, 0.55) 44% 46%, rgba(0, 0, 0, 0) 47%),
    conic-gradient(from 200deg, #3a2c1d, #fff6df 22deg, #e2c793 40deg, #5e4730 75deg, #1b140c 115deg, #4a3a27 160deg,
      #e9d3a8 190deg, #fffaf0 205deg, #b8996a 230deg, #2c2116 290deg, #3a2c1d);
  box-shadow: 0 0 0 1px #000, 0 3px 6px rgba(0, 0, 0, 0.85), inset 0 0 0 1px rgba(0, 0, 0, 0.7), inset 0 1px 1px rgba(255, 245, 220, 0.4);
}
.theme-remake .ico svg {
  width: 23px; height: 23px;
  fill: url(#laiton);
  filter: drop-shadow(0 1.5px 0 rgba(0, 0, 0, 0.95)) drop-shadow(0 -0.5px 0 rgba(255, 240, 200, 0.35));
}
.ico .i-pause, [data-ico="pause"] .i-play { display: none; }
[data-ico="pause"] .i-pause { display: inline; }
.theme-remake.focus .bar { background: rgba(0, 0, 0, 0.9); box-shadow: 0 0 0 1px #2c2b29; }

/* Sessions : des cases d'inventaire, la case en cours entourée des coins cuivrés */
.theme-remake .sessions { gap: 12px; font: 400 18px var(--goudy); letter-spacing: 0.02em; text-transform: none; color: var(--silver); }
.theme-remake .dots { gap: 4px; }
.theme-remake .dot {
  position: relative;
  width: 38px; height: 38px;
  border: 0; border-radius: 0;
  background: var(--crasse) 0 0 / 96px 96px, linear-gradient(160deg, #34342f 0%, #232321 45%, #1a1a18 100%);
  box-shadow: inset 0 0 0 1px #3d3d3a, inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 0 10px rgba(0, 0, 0, 0.75);
}
.theme-remake .dot.done {
  background: #262624 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 28'%3E%3Crect x='1' y='3' width='38' height='22' fill='%239b9486' stroke='%235a5045'/%3E%3Cpath d='M1 15h8l2-1.5 2 1.5h2l2-10 2.5 14 1.5-4h4l2-2.5 2.5 2.5h10' fill='none' stroke='%23587a47' stroke-width='1.7' stroke-linejoin='round'/%3E%3C/svg%3E") center / 80% no-repeat;
  box-shadow: inset 0 0 0 1px #3d3d3a, inset 0 0 10px rgba(0, 0, 0, 0.75);
}
.theme-remake .dot.now::after {
  content: "";
  position: absolute; inset: -3px;
  --c: var(--copper);
  background:
    linear-gradient(var(--c), var(--c)) left top / 10px 2px,
    linear-gradient(var(--c), var(--c)) left top / 2px 10px,
    linear-gradient(var(--c), var(--c)) right top / 10px 2px,
    linear-gradient(var(--c), var(--c)) right top / 2px 10px,
    linear-gradient(var(--c), var(--c)) left bottom / 10px 2px,
    linear-gradient(var(--c), var(--c)) left bottom / 2px 10px,
    linear-gradient(var(--c), var(--c)) right bottom / 10px 2px,
    linear-gradient(var(--c), var(--c)) right bottom / 2px 10px,
    linear-gradient(rgba(224, 189, 152, 0.55), rgba(224, 189, 152, 0.55)) center top / 100% 1px,
    linear-gradient(rgba(224, 189, 152, 0.55), rgba(224, 189, 152, 0.55)) center bottom / 100% 1px,
    linear-gradient(rgba(224, 189, 152, 0.55), rgba(224, 189, 152, 0.55)) left center / 1px 100%,
    linear-gradient(rgba(224, 189, 152, 0.55), rgba(224, 189, 152, 0.55)) right center / 1px 100%;
  background-repeat: no-repeat;
}

/* La boîte de texte du bas, sous son rouleau de machine à écrire */
.theme-remake .hint, .theme-remake .settings {
  position: relative;
  border: 2px solid transparent;
  border-radius: 2px;
  background:
    linear-gradient(#000, #000) padding-box,
    var(--crasse) 0 0 / 128px 128px border-box,
    linear-gradient(180deg, #9d9993 0%, #3a3835 12%, #181716 45%, #55524e 75%, #1b1a19 100%) border-box;
  box-shadow: 0 0 0 1px #000, 0 6px 14px rgba(0, 0, 0, 0.8);
  font-family: var(--gill);
  color: #ece8db;
}
.theme-remake .hint {
  padding: 48px 18px 18px;
  min-height: 7.6em;
  font-size: 17px;
  line-height: 1.45;
  letter-spacing: 0.01em;
}
.theme-remake .hint::before, .theme-remake .hint::after {
  content: "";
  position: absolute; left: 8px; right: 8px; top: 9px;
  height: 26px; border-radius: 13px;
}
/* Le rouleau : chrome poli, bande blanche éclatante, chute nette vers le sombre strié, embouts en cuivre */
.theme-remake .hint::before {
  left: 24px; right: 24px; border-radius: 3px;
  background:
    var(--crasse) 0 0 / 150px 26px,
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.35) 0 1px, rgba(255, 255, 255, 0.07) 1px 2px, rgba(0, 0, 0, 0) 2px 3px) left bottom / 100% 58% no-repeat,
    linear-gradient(180deg, #050505 0%, #3d3d3c 7%, #d2d0ca 16%, #f8f4ea 24%, #ebe7dd 33%, #a3a3a0 39%, #2e2e2d 47%, #1b1b1a 70%, #3f3f3d 86%, #0a0a0a 100%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.9);
}
.theme-remake .hint::after {
  background:
    var(--crasse) left / 18px 26px no-repeat,
    var(--crasse) right / 18px 26px no-repeat,
    linear-gradient(90deg, rgba(0, 0, 0, 0.6) 0 1px, rgba(0, 0, 0, 0) 1px calc(100% - 1px), rgba(0, 0, 0, 0.6) calc(100% - 1px)) left / 18px 100% no-repeat,
    linear-gradient(90deg, rgba(0, 0, 0, 0.6) 0 1px, rgba(0, 0, 0, 0) 1px calc(100% - 1px), rgba(0, 0, 0, 0.6) calc(100% - 1px)) right / 18px 100% no-repeat,
    linear-gradient(180deg, #2c1611, #8a5546 10%, #f2c6b0 22%, #fff0e6 30%, #d79a83 40%, #8a5444 60%, #5a3328 80%, #24120d) left / 18px 100% no-repeat,
    linear-gradient(180deg, #2c1611, #8a5546 10%, #f2c6b0 22%, #fff0e6 30%, #d79a83 40%, #8a5444 60%, #5a3328 80%, #24120d) right / 18px 100% no-repeat;
}
.theme-remake kbd { border-color: #55534e; color: #ece8db; }
.theme-remake .field { font-size: 15px; letter-spacing: 0.02em; text-transform: none; color: var(--silver); }
.theme-remake .field input[type="number"], .theme-remake .field select {
  font: 400 17px var(--gill); color: #ece8db;
  background: #121211; border-color: #4a4843; border-radius: 0;
}
.theme-remake .check { font-size: 16px; color: #ece8db; }
.theme-remake .check input { accent-color: #c98c74; }

/* Taille : l'appareil entier tient dans la hauteur, surtout en paysage */
.theme-remake main { max-width: min(860px, max(300px, calc((100vh - 300px) * 1.633))); }
.theme-remake.focus main { max-width: min(1200px, calc((100vh - 40px) * 1.633)); }
@supports (height: 100dvh) {
  .theme-remake main { max-width: min(860px, max(300px, calc((100dvh - 300px) * 1.633))); }
  .theme-remake.focus main { max-width: min(1200px, calc((100dvh - 40px) * 1.633)); }
}
@media (max-height: 520px) {
  .theme-remake main { max-width: min(860px, calc((100dvh - 110px) * 1.633)); }
  .theme-remake .phase-plate { font-size: 18px; }
}
@media (max-width: 560px) {
  .theme-remake main, .theme-remake.focus main { max-width: 100%; }
  .theme-remake .controls { gap: 10px 14px; justify-content: flex-start; }
  .theme-remake button, .theme-remake button.primary { flex: 0 1 auto; font-size: 17px; }
  .theme-remake .ico { width: 42px; height: 42px; }
  .theme-remake .hint { font-size: 16px; }
}
