/* Les polices sont locales : aucun CDN et aucune connexion ne sont nécessaires. */
@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(assets/fonts/barlow-condensed-600.ttf) format('truetype');
}
@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(assets/fonts/barlow-condensed-700.ttf) format('truetype');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(assets/fonts/jetbrains-mono-500.ttf) format('truetype');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(assets/fonts/jetbrains-mono-700.ttf) format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(assets/fonts/plus-jakarta-sans-400.ttf) format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(assets/fonts/plus-jakarta-sans-600.ttf) format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(assets/fonts/plus-jakarta-sans-700.ttf) format('truetype');
}

/* Même palette, mêmes dimensions de cadre et mêmes familles que la version React. */
:root {
  --font-display: "Barlow Condensed", sans-serif;
  --font-sans: "Plus Jakarta Sans", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  color-scheme: dark;
  font-family: var(--font-sans);
  color: #f3ece1;
  background: #231817;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden; }
body { user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, canvas:focus-visible, input:focus-visible, .scores-table-wrap:focus-visible { outline: 2px solid #d97736; outline-offset: 2px; }
button:disabled { cursor: default; opacity: .4; pointer-events: none; }
[hidden] { display: none !important; }
p, h2 { margin: 0; }
.console { width: 100%; height: 100%; height: 100dvh; display: flex; flex-direction: column; }
.topbar, .bottom-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-shrink: 0; padding: 0 16px; background: #1b1211; }
.topbar { height: 44px; border-bottom: 1px solid #3d2b29; }
.nameplate { display: flex; align-items: center; gap: 12px; min-width: 0; }
.console-name { font: 700 18px/28px var(--font-display); letter-spacing: .05em; color: #e6dec8; white-space: nowrap; }
.subtitle { font-size: 12px; color: #9e9284; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.separator { color: #786a5e; }
.status { display: flex; align-items: center; gap: 8px; font: 12px/16px var(--font-mono); color: #d7cebe; white-space: nowrap; font-variant-numeric: tabular-nums; }
.difficulty-status { color: #c7b9a5; font: 12px/16px var(--font-sans); }
.hardware-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.hardware-button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 12px; line-height: 16px; font-weight: 600; border-radius: 4px; background: #2d201e; color: #e6dec8; border: 1px solid #4a3633; white-space: nowrap; }
.hardware-button:hover { background: #3a2927; }
.icon { width: 14px; height: 14px; flex-shrink: 0; }
.desktop-only { display: none; }
.main-area { display: flex; flex: 1; align-items: center; justify-content: center; padding: 8px; min-height: 0; }
.metal-frame { display: flex; flex-direction: column; position: relative; width: 100%; height: 100%; max-width: 1360px; padding: 6px; border-radius: 12px; background: #cfc7b4; border: 2px solid #9b927e; box-shadow: 0 25px 50px -12px #0004; }
.screen { position: relative; flex: 1; width: 100%; height: 100%; min-height: 0; border: 2px solid #8f2921; border-radius: 8px; background: #1e1a18; overflow: hidden; }
#game-canvas { display: block; width: 100%; height: 100%; cursor: pointer; touch-action: none; }
.overlay { position: absolute; inset: 0; }
.title-overlay { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; pointer-events: none; padding: 16px 16px 0; overflow: auto; }
.title-card { display: flex; flex-shrink: 0; flex-direction: column; align-items: center; text-align: center; max-width: 576px; background: #cbd4b8f2; border: 2px solid #2a3326; border-radius: 8px; padding: 16px 24px; box-shadow: 0 10px 15px -3px #0002; pointer-events: auto; color: #242e21; }
.title-logo { width: 256px; max-width: 100%; height: auto; margin-bottom: 8px; flex-shrink: 0; }
.title-instructions { max-width: 448px; margin-bottom: 12px; font-size: 12px; line-height: 1.375; text-wrap: balance; }
.start-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-bottom: 12px; }
.mode-selector { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; max-width: 100%; padding: 4px; border-radius: 6px; background: #b4bea0; border: 1px solid #3b433666; }
.mode { padding: 6px 8px; font-size: 12px; line-height: 16px; font-weight: 700; border: 0; border-radius: 4px; background: transparent; color: #242e21; white-space: nowrap; }
.mode.active { background: #1b2319; color: #e6dec8; }
.mode[data-mode="GAME_B"].active { background: #a92d24; color: #f7f3e8; }
.button { padding: 10px 20px; border-radius: 4px; border: 1px solid transparent; font-size: 14px; line-height: 20px; font-weight: 700; transition: background-color .15s, transform .15s; white-space: nowrap; }
.button.primary { background: #a92d24; color: #faf6ec; }
.button.primary:hover { background: #8e231b; }
.button.primary:active { transform: translateY(2px); }
.button.start { padding: 8px 20px; letter-spacing: .025em; border-radius: 6px; box-shadow: 0 1px 2px #0001; }
.key-hints { font: 11px/16px var(--font-mono); color: #3b4336; letter-spacing: -.025em; }
.modal-overlay { display: flex; align-items: center; justify-content: center; background: #181d16a6; padding: 16px; overflow: auto; }
.game-over-overlay { background: #181d16b3; }
.modal { width: 100%; max-width: 448px; background: #cbd4b8; color: #1b2319; border: 2px solid #1b2319; border-radius: 8px; padding: 24px; text-align: center; box-shadow: 0 20px 25px -5px #0003; margin: auto; }
.modal h2 { font: 700 30px/36px var(--font-display); letter-spacing: .025em; text-wrap: balance; }
.pause-card { max-width: 384px; }
.pause-card h2 { margin-bottom: 4px; }
.pause-summary, .record-summary { font: 12px/16px var(--font-mono); color: #3b4336; font-variant-numeric: tabular-nums; margin-bottom: 20px; }
.vertical-buttons { display: flex; flex-direction: column; gap: 10px; }
.button.dark { background: #1b2319; color: #e8e2ce; }
.button.dark:hover { background: #2b3728; }
.button.outlined { border: 1px solid #1b2319; color: #1b2319; background: transparent; font-weight: 600; }
.button.outlined:hover { background: #bcc7a6; }
.button.subtle { color: #3b4336; background: transparent; font-size: 12px; font-weight: 600; padding: 8px 16px; }
.button.subtle:hover { color: #1b2319; }
.game-over-card { border-color: #a92d24; }
.eyebrow { font: 700 12px/16px var(--font-mono); color: #a92d24; margin-bottom: 4px; }
.game-over-card h2 { margin-bottom: 12px; }
.statistics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 0; margin: 12px 0; border-top: 1px solid #1b231940; border-bottom: 1px solid #1b231940; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.statistics span { display: block; font-size: 11px; line-height: 16px; color: #3b4336; }
.statistics strong { display: block; font-size: 24px; line-height: 32px; }
.statistics .red { color: #a92d24; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; }
.button.replay { display: inline-flex; align-items: center; gap: 8px; padding: 10px 24px; }
.button.replay .icon { width: 16px; height: 16px; }
.victory-card h2 { font-size: 36px; line-height: 40px; margin-bottom: 8px; }
.victory-copy { font-size: 14px; line-height: 1.625; margin-bottom: 16px; }
.victory-card .statistics { margin-top: 0; margin-bottom: 20px; }
.bottom-bar { height: 56px; border-top: 1px solid #3d2b29; }
.direction-button { display: flex; align-items: center; justify-content: center; min-width: 124px; height: 40px; padding: 0 16px; background: #a92d24; color: #faf6ec; font: 700 16px/24px var(--font-display); letter-spacing: .05em; border: 0; border-bottom: 2px solid #6b1913; border-radius: 6px; touch-action: none; }
.direction-button:active { transform: translateY(2px); }
.bottom-hints { display: none; align-items: center; gap: 12px; font: 12px/16px var(--font-mono); color: #9e9284; white-space: nowrap; }
.fatal-error { position: absolute; inset: 0; padding: 24px; background: #cbd4b8; color: #1b2319; }
.connection-status { margin-bottom: 10px; color: #8e231b; font-size: 12px; }
/* Le décompte reprend l'encre et le fond du LCD et reste centré sur la surface de jeu. */
.countdown-overlay { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: #cbd4b84d; pointer-events: auto; }
.countdown-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: min(280px, 80%); padding: 18px 24px; border: 2px solid #1b2319; border-radius: 8px; background: #cbd4b8f2; color: #1b2319; box-shadow: 0 8px 20px #1b231933; }
.countdown-caption { font: 700 12px/18px var(--font-mono); letter-spacing: .08em; }
.countdown-value { font: 700 clamp(76px, 16vw, 160px)/1.1 var(--font-mono); text-shadow: 2px 3px #1b231933; }
.countdown-value.start-word { font-size: clamp(44px, 10vw, 92px); }
.final-score-label { margin-top: 18px; font: 700 13px var(--font-mono); letter-spacing: .1em; }
.final-score { font: 700 clamp(72px, 15vw, 112px)/1.2 var(--font-mono); color: #a92d24; margin: 4px 0 16px; }
.statistics { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) {
  .topbar { padding-inline: 24px; }
  .console-name { font-size: 20px; }
  .status { gap: 12px; font-size: 14px; line-height: 20px; }
  .main-area { padding: 12px; }
  .metal-frame { padding: 10px; }
  .title-overlay { padding-top: 28px; }
  .title-card { padding: 20px 32px; }
  .title-logo { width: 320px; }
  .title-instructions { font-size: 14px; }
  .key-hints { font-size: 12px; }
  .game-over-card h2 { font-size: 36px; line-height: 40px; }
  .bottom-bar { padding-inline: 32px; }
  .direction-button { min-width: 160px; }
}
@media (min-width: 768px) {
  .desktop-only { display: inline; }
  .bottom-hints { display: flex; }
  .main-area { padding: 16px; }
  .title-logo { width: 384px; }
}
/* Sur les petites largeurs, la barre garde ses boutons sans déborder. */
@media (max-width: 639px) {
  .topbar { gap: 8px; padding-inline: 8px; }
  .console-name { font-size: 16px; }
  .hardware-button { padding-inline: 8px; }
  .hardware-button .icon { display: none; }
  .nameplate { flex-shrink: 0; }
  .status { font-size: 10px; flex-direction: column; align-items: flex-start; gap: 0; line-height: 13px; }
  .status > .separator { display: none; }
  .record-mode { display: none; }
  .difficulty-status { display: none; }
}
/* En paysage sur téléphone, tous les boutons du titre restent visibles. */
@media (max-height: 500px) and (min-width: 600px) {
  .title-overlay { padding-top: 8px; }
  .title-card { padding: 8px 20px; }
  .title-logo { width: 280px; margin-bottom: 4px; }
  .title-instructions { max-width: 500px; font-size: 12px; line-height: 1.3; margin-bottom: 8px; }
  .start-controls { gap: 10px; margin-bottom: 6px; }
  .button.start { padding: 6px 16px; font-size: 12px; }
  .mode { font-size: 11px; }
  .key-hints { font-size: 10px; line-height: 14px; }
}
@media (max-width: 374px) {
  .topbar .status { flex-direction: column; align-items: flex-start; gap: 0; line-height: 13px; }
  .topbar .status > .separator { display: none; }
  .hardware-controls { gap: 4px; }
  .hardware-button { padding-inline: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Trois emplacements réservés dès le départ : les vignettes précédentes restent immobiles. */
.comic-intro { position: fixed; inset: 0; z-index: 100; background: #231817; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; }
.comic-stage { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: center; width: 100%; min-height: 0; flex: 1; overflow: hidden; }
.comic-panel { grid-row: 1; height: 100%; width: 100%; min-width: 0; min-height: 0; object-fit: contain; object-position: left center; transform-origin: left center; }
.comic-panel:nth-child(1) { grid-column: 1; }
.comic-panel:nth-child(2) { grid-column: 2; }
.comic-panel:nth-child(3) { grid-column: 3; }
.comic-enter { animation: comic-impact 650ms both; }
@keyframes comic-impact {
  0% { transform: translateX(100vw); }
  70% { transform: translateX(0) scaleX(1) rotate(0deg); }
  77% { transform: translateX(-12px) scaleX(.96) rotate(-.7deg); }
  87% { transform: translateX(9px) scaleX(1.02) rotate(.4deg); }
  94% { transform: translateX(-3px) rotate(-.2deg); }
  100% { transform: translateX(0) scaleX(1) rotate(0deg); }
}
@media (prefers-reduced-motion: reduce) { .comic-enter { animation-duration: 1ms; } }
.comic-intro .button { flex-shrink: 0; max-width: 100%; white-space: normal; font-size: 12px; }
