/* ORE. Une interface de jeu : bordures franches, aucun arrondi mou, la meme palette que le decor.
   Le texte reste du texte net (un vrai jeu pixel n'oblige personne a dechiffrer sa police), le
   dessin reste du pixel entier. */

:root {
  --sky:    #7DC4E8;
  --sea:    #1B5A8C;
  --deep:   #123C60;
  --night:  #0B1410;
  --panel:  #16221A;
  --panel2: #1E2E22;
  --line:   #2E4436;
  --ink:    #E8F4DC;
  --dim:    #92AC88;
  --faint:  #5E7458;
  --ore:    #9CDC2E;
  --ore-lo: #4E9410;
  --gold:   #E8B822;
  --hot:    #E0822E;
  --wood:   #6E461F;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  height: 100dvh;
  background: var(--night);
  color: var(--ink);
  font: 400 15px/1.6 ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;
  overflow-x: hidden;
}

img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

/* ── carcasse ──────────────────────────────────────────────────────────────
   Sur large ecran le jeu tient dans la fenetre et chaque colonne defile pour son compte : sans
   `minmax(0, 1fr)` et `min-height: 0` sur les enfants, le panneau allonge la page et la scene se
   centre hors de l'ecran. */
.shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: .55rem clamp(.8rem, 3vw, 1.6rem);
  background: var(--panel);
  border-bottom: 2px solid var(--line);
}

.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); }
.brand img { width: 30px; height: 30px; }
.brand b { font-size: 19px; letter-spacing: .14em; }
.brand span { color: var(--faint); font-size: 11px; letter-spacing: .1em; }

.stat-strip { display: flex; gap: 1.4rem; justify-content: center; flex-wrap: wrap; min-width: 0; }
.chip { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.chip i { font-style: normal; font-size: 10px; letter-spacing: .12em; color: var(--faint); text-transform: uppercase; }
.chip b { font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; }

/* ── boutons ───────────────────────────────────────────────────────────── */
.btn {
  font: 500 13px/1 ui-monospace, monospace;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: .55rem .8rem;
  color: var(--ink);
  background: var(--panel2);
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  cursor: pointer;
  transition: transform .06s, background .12s;
}
.btn:hover { background: #27392B; }
.btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.btn:focus-visible { outline: 2px solid var(--ore); outline-offset: 2px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btn--go { background: var(--ore-lo); border-color: #6EB014; color: #0B1410; font-weight: 700; }
.btn--x { display: inline-flex; align-items: center; gap: .45rem; text-decoration: none; }
.btn--x svg { display: block; flex: none; }
.btn--go:hover { background: #5CAB12; }

/* ── la scene et le dock ────────────────────────────────────────────────────
   L'ile prend toute la largeur, les commandes passent dessous en bande horizontale. Un panneau
   lateral qui defile oblige a chercher ses boutons ; un dock tient dans l'ecran d'un coup d'oeil,
   ce qui est ce qu'on attend d'un jeu. */
.play {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  min-height: 0;
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: .5rem;
  background:
    repeating-linear-gradient(180deg, #0E1A14 0 2px, #0B1410 2px 4px);
  min-height: 0;
}
/* La taille affichee est posee par le script, en multiple ENTIER de 448 x 252. Un agrandissement
   fractionnaire fait baver un pixel sur deux et ruine tout le dessin. */
#scene { display: block; max-width: 100%; cursor: pointer; border: 2px solid var(--line); }

/* le bandeau "demonstration", pose sur la scene plutot que dans le chemin des commandes */
.badge {
  position: absolute; top: .8rem; left: 50%; transform: translateX(-50%);
  max-width: min(92%, 640px);
  border: 2px solid var(--wood); background: rgba(42, 31, 18, .94);
  color: var(--gold); padding: .5rem .8rem;
  font-size: 11.5px; line-height: 1.5; text-align: center;
}
.badge b { letter-spacing: .12em; text-transform: uppercase; }

/* ── la veine : les six mines, en bande, triees par rendement ───────────── */
.seam {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 2px;
  padding: 0 clamp(.5rem, 2vw, 1rem) .4rem;
  background: var(--night);
}
.seam button {
  display: grid; gap: .14rem; padding: .4rem .5rem; text-align: left; cursor: pointer;
  color: var(--ink); background: var(--panel); border: 2px solid var(--line);
  border-bottom-width: 4px;
  font: 400 12px/1.25 ui-monospace, monospace;
  min-width: 0;
}
.seam button:hover { background: var(--panel2); }
.seam button.on { border-color: var(--ore); background: var(--panel2); }
.seam .nm { display: flex; align-items: center; gap: .35rem; overflow: hidden; }
.seam .nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seam .num { display: flex; justify-content: space-between; align-items: baseline; gap: .4rem; }
.seam .yl { font-size: 14px; color: var(--ore); font-variant-numeric: tabular-nums; }
.seam .fl { font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.seam .g { height: 4px; background: var(--night); border: 1px solid var(--line); }
.seam .g i { display: block; height: 100%; background: var(--ore); }
.seam .g i.warm { background: var(--gold); }
.seam .g i.hot { background: var(--hot); }

/* ── le dock ────────────────────────────────────────────────────────────── */
.dock {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 2px;
  background: var(--line);
  border-top: 2px solid var(--line);
}
.bay { background: var(--panel); padding: .6rem clamp(.6rem, 2vw, .9rem); min-width: 0; }
.bay > h3 {
  margin: 0 0 .4rem;
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
  font-weight: 500;
}

/* ── cartouches ────────────────────────────────────────────────────────── */
.card { border: 2px solid var(--line); background: var(--panel2); padding: .9rem; }
.card > h3 {
  margin: 0 0 .7rem;
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
  font-weight: 500;
}

.mine-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .2rem; }
.swatch { width: 14px; height: 14px; border: 2px solid var(--night); flex: none; }
.mine-head b { font-size: 15px; letter-spacing: .04em; }

.rows { display: grid; gap: .3rem; margin-top: .55rem; }
.row { display: flex; justify-content: space-between; gap: 1rem; font-size: 13px; }
.row span { color: var(--dim); }
.row b { font-weight: 500; font-variant-numeric: tabular-nums; }
.row b.up { color: var(--ore); }
.row b.warn { color: var(--hot); }

.bar { height: 8px; background: var(--night); border: 2px solid var(--line); margin-top: .7rem; position: relative; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--ore); display: block; }
.bar i.hot { background: var(--hot); }
.bar i.warm { background: var(--gold); }
.bar-note { display: flex; justify-content: space-between; margin-top: .35rem; font-size: 10px; letter-spacing: .1em; color: var(--faint); text-transform: uppercase; }

.field { display: flex; gap: .4rem; margin-top: .45rem; }
.field input {
  flex: 1; min-width: 0;
  font: 400 14px/1 ui-monospace, monospace;
  padding: .55rem .65rem;
  color: var(--ink); background: var(--night);
  border: 2px solid var(--line);
}
.field input:focus { outline: none; border-color: var(--ore-lo); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .6rem; }
.actions .btn { width: 100%; }

.hint { margin: .5rem 0 0; font-size: 11.5px; line-height: 1.5; color: var(--faint); }

.notlive {
  border: 2px solid var(--wood);
  background: #2A1F12;
  color: var(--gold);
  padding: .8rem .9rem;
  font-size: 12.5px;
  line-height: 1.55;
}
.notlive b { display: block; letter-spacing: .1em; text-transform: uppercase; font-size: 11px; margin-bottom: .3rem; }

/* la liste des six mines, triee par rendement */
.board { display: grid; gap: 2px; }
.board button {
  display: grid; grid-template-columns: 14px 1fr auto auto; align-items: center; gap: .6rem;
  padding: .5rem .55rem; text-align: left; cursor: pointer;
  color: var(--ink); background: var(--panel2); border: 2px solid transparent;
  font: 400 12.5px/1.2 ui-monospace, monospace;
}
.board button:hover { background: #27392B; }
.board button.on { border-color: var(--ore); }
.board .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .yl { font-variant-numeric: tabular-nums; color: var(--ore); }
.board .fl { font-variant-numeric: tabular-nums; color: var(--faint); font-size: 11px; }

/* ── etroit ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  body, .shell { height: auto; min-height: 100dvh; }
  .play { grid-template-rows: auto auto auto; }
  .stage { padding: .6rem; }
  .seam { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dock { grid-template-columns: 1fr; }
  /* Pose sur la scene, le bandeau couvre la moitie de l'ile sur un telephone : on le remet dans
     le flux, sous elle. */
  .badge {
    position: static; transform: none; max-width: none; width: 100%;
    margin-top: .5rem; font-size: 11px; text-align: left;
  }
  .stage { grid-auto-flow: row; }
  /* `minmax(0, 1fr)` et non `auto` : sinon la largeur mini du contenu de la barre de stats
     elargit toute la grille et la page deborde lateralement. */
  .topbar { grid-template-columns: minmax(0, 1fr) auto; row-gap: .55rem; }
  /* Sur un telephone la poignee prend la place d'un bouton entier : l'icone suffit. */
  .btn--x span { display: none; }
  .btn--x { padding: .62rem .7rem; }
  .stat-strip { grid-column: 1 / -1; justify-content: flex-start; gap: .5rem 1.1rem; }
  .chip i { font-size: 9px; }
  .chip b { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
