/* N08 — Démineur · pixel art, palette PICO-8 */

/* ------------------------------------------------------------------ polices auto-hébergées (OFL) */
@font-face {
  font-family: 'Press Start 2P';
  src: url(fonts/PressStart2P-latin.woff2) format('woff2');
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Press Start 2P';
  src: url(fonts/PressStart2P-latin-ext.woff2) format('woff2');
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Pixelify Sans';
  src: url(fonts/PixelifySans-latin.woff2) format('woff2');
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Pixelify Sans';
  src: url(fonts/PixelifySans-latin-ext.woff2) format('woff2');
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ------------------------------------------------------------------ palette */
:root {
  --noir: #000000;
  --nuit: #1D2B53;
  --bordeaux: #7E2553;
  --sapin: #008751;
  --brun: #AB5236;
  --gris-fonce: #5F574F;
  --gris: #C2C3C7;
  --creme: #FFF1E8;
  --rouge: #FF004D;
  --orange: #FFA300;
  --jaune: #FFEC27;
  --vert: #00E436;
  --ciel: #29ADFF;
  --lavande: #83769C;
  --rose: #FF77A8;
  --peche: #FFCCAA;

  /* chiffres : couleurs classiques, assombries pour le contraste sur fond crème */
  --n1: #1E5BD6;
  --n2: #00753F;
  --n3: #D10040;
  --n4: #1D2B53;
  --n5: #7E2553;
  --n6: #00757A;
  --n7: #000000;
  --n8: #5F574F;

  --titre: 'Press Start 2P', ui-monospace, monospace;
  --texte: 'Pixelify Sans', ui-rounded, system-ui, sans-serif;

  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  background-color: var(--nuit);
  background-image: repeating-conic-gradient(#22315c 0 25%, var(--nuit) 0 50%);
  background-size: 8px 8px;
  color: var(--creme);
  font-family: var(--texte);
  font-size: 18px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
  image-rendering: pixelated;
}
img { image-rendering: pixelated; }
a { color: var(--jaune); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--jaune); outline-offset: 2px; }

/* reliefs façon Windows 95, en pixels francs */
.relief, .fenetre, .gros-bouton, .bouton, .petit-bouton, .visage, .panneau, .mode {
  background: var(--gris);
  color: var(--noir);
  border: 3px solid var(--noir);
  box-shadow: inset -3px -3px 0 var(--gris-fonce), inset 3px 3px 0 var(--creme);
}
.creux {
  box-shadow: inset 3px 3px 0 var(--gris-fonce), inset -3px -3px 0 var(--creme);
}

.ecran {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* ------------------------------------------------------------------ accueil */
#accueil { gap: 20px; justify-content: center; }

.logo { display: flex; align-items: center; gap: 14px; }
.logo img { width: 64px; height: 64px; }
.logo h1 {
  margin: 0;
  font-family: var(--titre);
  font-size: clamp(20px, 6vw, 36px);
  font-weight: normal;
  color: var(--jaune);
  text-shadow: 3px 3px 0 var(--rouge), 6px 6px 0 var(--noir);
  letter-spacing: 1px;
}

.pseudo-box { width: min(100%, 360px); padding: 14px 16px 10px; }
.pseudo-box label, .fin-pseudo label {
  display: block;
  font-family: var(--titre);
  font-size: 10px;
  margin-bottom: 8px;
}
input[type="text"] {
  width: 100%;
  font: 20px var(--texte);
  padding: 8px 10px;
  color: var(--noir);
  background: var(--creme);
  border: 0;
  border-radius: 0;
  box-shadow: inset 3px 3px 0 var(--gris-fonce), inset -3px -3px 0 var(--blanc, #fff);
  outline-offset: 0;
}
input.invalide { box-shadow: inset 3px 3px 0 var(--rouge), inset -3px -3px 0 var(--rouge); }
.aide { min-height: 1.35em; margin: 4px 0 0; font-size: 15px; color: var(--gris-fonce); }
input.invalide + .aide { color: #B0002F; }

.difficultes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  width: min(100%, 360px);
}
@media (min-width: 760px) {
  .difficultes { grid-template-columns: repeat(3, 220px); width: auto; }
}
.choix { display: flex; flex-direction: column; align-items: stretch; }
.gros-bouton {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px 14px;
  cursor: pointer;
  user-select: none;
}
.gros-bouton .nom { font-family: var(--titre); font-size: 16px; }
.gros-bouton .detail { font-size: 15px; color: var(--gris-fonce); }
.gros-bouton:hover { background: var(--jaune); }
.gros-bouton:active, .bouton:active, .petit-bouton:active, .visage:active {
  box-shadow: inset 3px 3px 0 var(--gris-fonce), inset -3px -3px 0 var(--creme);
}
.gros-bouton:active > * { transform: translate(2px, 2px); }
.record { margin: 6px 0 0; text-align: center; font-size: 15px; color: var(--peche); }
.record b { color: var(--creme); font-weight: 600; }

.aide-jeu { width: min(100%, 680px); font-size: 16px; color: var(--peche); }
.aide-jeu summary { cursor: pointer; font-family: var(--titre); font-size: 10px; color: var(--creme); text-align: center; }
.aide-jeu ul { padding-left: 1.2em; }
.aide-jeu b { color: var(--creme); }
.pied { font-size: 14px; color: var(--lavande); }
.pied a { color: var(--peche); }

/* ------------------------------------------------------------------ publicité */
#pub { justify-content: center; gap: 10px; }
.pub-etiquette {
  margin: 0;
  font-family: var(--titre);
  font-size: 8px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--lavande);
}
.pub-slot {
  width: 300px;
  height: 250px;
  overflow: hidden;
  outline: 3px solid var(--noir);
  background: var(--nuit);
  position: relative;
}
.pub-slot .ad-image { display: block; width: 300px; height: 250px; object-fit: cover; image-rendering: auto; }
.pub-slot .ad-html { width: 300px; height: 250px; overflow: hidden; }
.pub-barre {
  width: 300px;
  height: 18px;
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--noir);
}
.pub-barre .seg { flex: 1; background: #2a2f45; }
.pub-barre .seg.plein { background: var(--jaune); box-shadow: inset 0 -3px 0 var(--orange); }

/* annonce « maison » : la pelle enterre des mines */
.ad-maison { position: absolute; inset: 0; }
.ad-scene {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 176px;
  overflow: hidden;
  background:
    linear-gradient(var(--ciel) 0 0) 0 0 / 100% 100% no-repeat;
}
.ad-scene::before { /* nuage pixel */
  content: '';
  position: absolute;
  left: 30px; top: 22px;
  width: 12px; height: 6px;
  background: var(--creme);
  box-shadow: 6px -6px 0 var(--creme), 12px -6px 0 var(--creme), 12px 0 0 var(--creme), 18px 0 0 var(--creme), 24px 0 0 var(--creme), 18px -6px 0 var(--creme),
              180px 20px 0 var(--creme), 186px 14px 0 var(--creme), 192px 14px 0 var(--creme), 192px 20px 0 var(--creme), 198px 20px 0 var(--creme);
}
.ad-sol {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 52px;
  background: var(--brun);
  box-shadow: inset 0 6px 0 var(--sapin), inset 0 -6px 0 #8a3f28;
  z-index: 2;
}
.ad-trou { position: absolute; left: 126px; top: 0; width: 48px; height: 9px; background: #3b1d12; }
.ad-mine {
  position: absolute;
  left: 126px; top: -48px;
  width: 48px; height: 48px;
  z-index: 1;
  animation: ad-tombe 3s steps(15, end) infinite;
}
.ad-mine-2 { animation-delay: 1s; }
.ad-mine-3 { animation-delay: 2s; }
@keyframes ad-tombe {
  0%   { transform: translateY(0); }
  30%  { transform: translateY(132px); }
  55%  { transform: translateY(132px); }
  80%  { transform: translateY(180px); }
  100% { transform: translateY(180px); }
}
.ad-pelle {
  position: absolute;
  left: 170px; top: 64px;
  width: 64px; height: 64px;
  z-index: 3;
  transform-origin: 8px 56px;
  animation: ad-creuse 0.5s steps(1, end) infinite;
}
@keyframes ad-creuse {
  0%   { transform: rotate(0deg) translate(0, 0); }
  50%  { transform: rotate(-22deg) translate(-4px, 6px); }
}
.ad-motte {
  position: absolute;
  left: 178px; top: 120px;
  width: 6px; height: 6px;
  background: var(--brun);
  box-shadow: 0 0 0 2px #5a2a1a;
  z-index: 3;
  animation: ad-motte 1s steps(5, end) infinite;
}
.ad-motte-2 { animation-delay: .25s; left: 184px; }
.ad-motte-3 { animation-delay: .5s; left: 172px; }
.ad-motte-4 { animation-delay: .75s; left: 190px; }
@keyframes ad-motte {
  0%   { transform: translate(0, 0); opacity: 1; }
  50%  { transform: translate(18px, -30px); }
  100% { transform: translate(36px, 6px); opacity: 0; }
}
.ad-msg {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 74px;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 0 16px;
  text-align: center;
  font-family: var(--titre);
  font-size: 10px;
  line-height: 1.8;
  color: var(--creme);
  background: var(--nuit);
  border-top: 3px solid var(--noir);
}

/* ------------------------------------------------------------------ partie */
#jeu {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  gap: 8px;
  overflow: hidden;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

.jeu-nav {
  width: 100%;
  max-width: 1200px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}
.petit-bouton {
  padding: 6px 10px 5px;
  font-family: var(--titre);
  font-size: 9px;
  cursor: pointer;
}
.jeu-difficulte { font-size: 15px; color: var(--peche); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.panneau {
  flex: 0 1 auto;
  min-height: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 7px;
}

.bandeau {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px;
  box-shadow: inset 3px 3px 0 var(--gris-fonce), inset -3px -3px 0 var(--creme);
}
.lcd {
  position: relative;
  min-width: 5.2ch;
  padding: 7px 6px 5px;
  font-family: var(--titre);
  font-size: 18px;
  line-height: 1;
  text-align: right;
  color: var(--rouge);
  background: var(--noir);
  border: 2px solid var(--gris-fonce);
  text-shadow: 0 0 6px rgba(255, 0, 77, .45);
  font-variant-numeric: tabular-nums;
}
.lcd::before {
  content: attr(data-fantome);
  position: absolute;
  right: 6px;
  color: rgba(255, 0, 77, .08);
  text-shadow: none;
}
.visage {
  width: 46px;
  height: 46px;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}
.visage img { width: 32px; height: 32px; }
.visage:active img { transform: translate(1px, 1px); }

.cadre {
  flex: 0 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.grille {
  --case: 24px;
  --biseau: 2px;
  display: grid;
  grid-template-columns: repeat(var(--cols, 9), var(--case));
  grid-auto-rows: var(--case);
  width: max-content;
  margin: 0 auto;
  border: 3px solid;
  border-color: var(--gris-fonce) var(--creme) var(--creme) var(--gris-fonce);
  background: var(--gris);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.grille > button {
  width: var(--case);
  height: var(--case);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  appearance: none;
  display: grid;
  place-items: center;
  font-family: var(--titre);
  font-size: max(9px, calc(var(--case) * 0.5));
  line-height: 1;
  color: var(--noir);
  background-color: var(--gris);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 76%;
  box-shadow: inset calc(var(--biseau) * -1) calc(var(--biseau) * -1) 0 var(--gris-fonce), inset var(--biseau) var(--biseau) 0 var(--creme);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.grille > button:focus-visible { outline: 3px solid var(--jaune); outline-offset: -3px; position: relative; z-index: 1; }
@media (hover: hover) {
  .grille > .cachee:hover { background-color: #d3d4d8; }
}
.grille > .cachee.enfoncee:not(.drapeau) {
  background-color: var(--creme);
  box-shadow: inset 1px 1px 0 var(--gris);
}
.grille > .drapeau { background-image: url(sprites/flag.svg); }
.grille > .revelee {
  background-color: var(--creme);
  box-shadow: inset -1px -1px 0 var(--gris);
  cursor: default;
}
.grille > .revelee[class*=" n"] { cursor: pointer; }
.grille > .mine { background-image: url(sprites/mine.svg); }
.grille > .boum { background-image: url(sprites/mine-boom.svg); background-color: var(--rouge); background-size: 100%; }
.grille > .faux { background-image: url(sprites/flag-wrong.svg); background-color: var(--peche); }

.n1 { color: var(--n1) !important; }
.n2 { color: var(--n2) !important; }
.n3 { color: var(--n3) !important; }
.n4 { color: var(--n4) !important; }
.n5 { color: var(--n5) !important; }
.n6 { color: var(--n6) !important; }
.n7 { color: var(--n7) !important; }
.n8 { color: var(--n8) !important; }

.grille > .cascade { animation: cascade 160ms steps(3, end) backwards; }
@keyframes cascade {
  from { transform: scale(.4); background-color: var(--gris); }
  to   { transform: scale(1); }
}

.panneau.secousse { animation: secousse 420ms steps(1, end); }
@keyframes secousse {
  0%   { transform: translate(0, 0); }
  15%  { transform: translate(-6px, 3px); }
  30%  { transform: translate(6px, -3px); }
  45%  { transform: translate(-4px, -3px); }
  60%  { transform: translate(4px, 3px); }
  75%  { transform: translate(-2px, 0); }
  90%  { transform: translate(0, 0); }
}

/* bascule Pelle / Drapeau : visible seulement sur écran tactile */
.jeu-bas { flex: none; display: none; }
@media (pointer: coarse) {
  .jeu-bas { display: flex; justify-content: center; width: 100%; }
}
.mode {
  display: flex;
  gap: 4px;
  padding: 5px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mode .opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px 8px;
  font-family: var(--titre);
  font-size: 11px;
  color: var(--gris-fonce);
}
.mode .opt img { width: 20px; height: 20px; opacity: .55; }
.mode[data-mode="pelle"] .opt-pelle,
.mode[data-mode="drapeau"] .opt-drapeau {
  color: var(--noir);
  background: var(--jaune);
  box-shadow: inset 3px 3px 0 var(--orange);
}
.mode[data-mode="pelle"] .opt-pelle img,
.mode[data-mode="drapeau"] .opt-drapeau img { opacity: 1; }

/* confettis carrés */
.confettis { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confettis span {
  position: absolute;
  top: -12px;
  animation-name: confetti;
  animation-timing-function: steps(18, end);
  animation-fill-mode: both;
}
@keyframes confetti {
  to { transform: translate(var(--dx, 0), 105vh); }
}

/* ------------------------------------------------------------------ fenêtre de fin */
dialog.fin {
  padding: 0;
  border: 0;
  background: transparent;
  width: min(440px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow: auto;
  color: var(--noir);
}
dialog.fin::backdrop { background: rgba(29, 43, 83, .72); }
.fenetre { padding: 3px; }
.fenetre-barre {
  padding: 7px 8px 6px;
  font-family: var(--titre);
  font-size: 9px;
  color: var(--creme);
  background: var(--nuit);
}
.fin[data-issue="perdu"] .fenetre-barre { background: var(--bordeaux); }
.fenetre-corps { padding: 14px 14px 16px; text-align: center; }
.fin h2 {
  margin: 4px 0 10px;
  font-family: var(--titre);
  font-size: 26px;
  font-weight: normal;
  color: var(--sapin);
  text-shadow: 3px 3px 0 var(--creme);
}
.fin[data-issue="perdu"] h2 { color: var(--rouge); text-shadow: 3px 3px 0 var(--noir); }
.fin-temps {
  display: inline-block;
  margin: 0 0 10px;
  padding: 8px 10px 6px;
  font-family: var(--titre);
  font-size: 18px;
  color: var(--rouge);
  background: var(--noir);
}
.fin-message { min-height: 1.35em; margin: 6px 0 12px; font-size: 18px; }
.fin-message sup { font-size: .65em; }
.fin-pseudo { text-align: left; margin: 6px 0 4px; }
.fin-pseudo .ligne { display: flex; gap: 8px; }
.fin-pseudo input { flex: 1; min-width: 0; }
.erreur { min-height: 1.2em; margin: 4px 0 0; font-size: 15px; color: #B0002F; }
.fin h3 { margin: 6px 0 8px; font-family: var(--titre); font-size: 10px; font-weight: normal; }

.top10 {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
  background: var(--creme);
  box-shadow: inset 3px 3px 0 var(--gris-fonce);
}
.top10 th {
  padding: 7px 6px 5px;
  font-family: var(--titre);
  font-size: 8px;
  font-weight: normal;
  text-align: left;
  color: var(--creme);
  background: var(--gris-fonce);
}
.top10 th:nth-child(3) { text-align: right; }
/* Press Start 2P : chiffres nets et à chasse fixe, bien plus lisibles que Pixelify en petit. */
.top10 td {
  padding: 7px 6px 6px;
  font-family: var(--titre);
  font-size: 10px;
  line-height: 1.4;
  text-align: left;
  white-space: nowrap;
}
/* La colonne Pseudo prend la place restante et se coupe avec « … » si besoin. */
.top10 td:nth-child(2) { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; }
.top10 td:nth-child(3) { text-align: right; }
.top10 tbody tr:nth-child(even) { background: #f3e4d8; }
.top10 tr.moi { background: var(--jaune) !important; }
.top10 tr.moi td { color: var(--noir); }
.top10 tr.moi td:first-child::before { content: '▶ '; }
.top10 tr.mon-pseudo td:nth-child(2) { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* onglets pixel (difficulté, période) : petits, mais toujours visibles */
.onglets {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 6px;
}
.onglets button {
  padding: 6px 8px 5px;
  font-family: var(--titre);
  font-size: 8px;
  color: var(--gris-fonce);
  background: var(--gris);
  border: 2px solid var(--gris-fonce);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.onglets button:hover { color: var(--noir); }
.onglets button[aria-pressed="true"] {
  color: var(--noir);
  background: var(--jaune);
  border-color: var(--noir);
  box-shadow: inset 2px 2px 0 var(--orange);
}
.onglets-periode button { font-size: 7px; padding: 5px 7px 4px; }
.periode-info { min-height: 1.2em; margin: 2px 0 8px; font-size: 14px; color: var(--gris-fonce); }
.fin-rangs { min-height: 0; margin: -6px 0 12px; font-size: 15px; color: var(--gris-fonce); }
.fin-rangs:empty { display: none; }
.fin-rangs sup { font-size: .65em; }

/* bouton Classements de l'accueil */
.btn-classements {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 6px;
}
.btn-classements img { width: 16px; height: 16px; }
.btn-classements:hover { background: var(--jaune); }

/* fenêtre Classements */
.classements h2 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 16px;
  color: var(--noir);
  text-shadow: none;
  margin: 2px 0 12px;
}
.classements h2 img { width: 24px; height: 24px; }

.top10-vide { margin: 8px 0; font-size: 16px; color: var(--gris-fonce); }

.fin-boutons { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
.bouton {
  padding: 10px 14px 8px;
  font-family: var(--titre);
  font-size: 11px;
  cursor: pointer;
}
.bouton-carre {
  width: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: none;
}
.bouton-carre img { width: 20px; height: 20px; }
.bouton-carre:hover { background: var(--jaune); }
.fin-partage-info { min-height: 1.3em; margin: 8px 0 0; font-size: 15px; color: var(--sapin); }
.fin-partage-info:empty { min-height: 0; margin: 0; }
.bouton-principal { background: var(--jaune); box-shadow: inset -3px -3px 0 var(--orange), inset 3px 3px 0 var(--creme); }

/* ------------------------------------------------------------------ mouvement réduit */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
