/* Gamins — « carnet de chantier » : papier quadrillé, encre, redstone.
   Base volontairement simple : tout passe par les variables ci-dessous. */
:root {
  --paper: #efe9dc;
  --paper-2: #e6dfcf;
  --grid: rgba(40, 60, 90, .09);
  --ink: #1c1a17;
  --ink-soft: #5b564c;
  --rule: #1c1a17;
  --redstone: #c2321f;
  --redstone-glow: #ff5a3c;
  --emerald: #1f7a4d;
  --gold: #c58b16;
  --term-bg: #15140f;
  --term-ink: #d9d3c2;
  --shadow: 4px 4px 0 var(--ink);
  --display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1a17; --paper-2: #24221e; --grid: rgba(220, 200, 160, .06);
    --ink: #ece4d2; --ink-soft: #a39b88; --rule: #ece4d2;
    --term-bg: #0d0c0a; --shadow: 4px 4px 0 #000;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font: 15px/1.5 var(--mono);
  min-height: 100vh;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }

/* ── bandeau ── */
.masthead {
  display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap;
  padding: 1.2rem clamp(16px, 4vw, 48px) .8rem;
  border-bottom: 3px solid var(--rule);
}
.masthead h1 {
  font: 900 clamp(2.6rem, 8vw, 4.6rem)/.85 var(--display);
  letter-spacing: .02em; text-transform: uppercase; margin: 0;
}
.masthead .stamp {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .15em;
  border: 2px solid var(--ink); padding: .15rem .5rem; transform: rotate(-3deg);
}
.masthead .who { margin-left: auto; display: flex; align-items: center; gap: .6rem; font-size: .85rem; }
.masthead .who img { width: 28px; height: 28px; image-rendering: pixelated; border: 2px solid var(--ink); }

/* ── grille principale ── */
main {
  display: grid; gap: 28px;
  grid-template-columns: minmax(280px, 360px) 1fr;
  padding: 28px clamp(16px, 4vw, 48px) 64px;
}
@media (max-width: 860px) { main { grid-template-columns: 1fr; } }

.card {
  background: var(--paper); border: 2px solid var(--ink); box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem; position: relative;
}
.card > h2 {
  font: 800 1.35rem/1 var(--display); text-transform: uppercase; letter-spacing: .06em;
  margin: 0 0 .9rem; display: flex; align-items: center; gap: .5rem;
}
.card > h2::before { content: "§"; color: var(--redstone); font-family: var(--mono); font-weight: 400; }
.col { display: flex; flex-direction: column; gap: 28px; min-width: 0; }

/* ── état + levier ── */
.state-word {
  font: 900 clamp(2.4rem, 7vw, 3.4rem)/.9 var(--display); text-transform: uppercase; margin: .2rem 0 .6rem;
}
.state-word[data-phase="online"] { color: var(--emerald); }
.state-word[data-phase="starting"], .state-word[data-phase="stopping"] { color: var(--gold); }
.meta { display: grid; grid-template-columns: auto 1fr; gap: .15rem 1rem; font-size: .85rem; color: var(--ink-soft); }
.meta b { color: var(--ink); font-weight: 500; }

.lever-row { display: flex; align-items: center; gap: 1.2rem; margin: 1.2rem 0 .4rem; }
.lever {
  --on: 0;
  width: 92px; height: 92px; border: 2px solid var(--ink); background: var(--paper-2);
  position: relative; cursor: pointer; padding: 0; flex: none;
}
.lever::before { /* socle */
  content: ""; position: absolute; left: 22px; right: 22px; bottom: 14px; height: 18px;
  background: #7d7466; border: 2px solid var(--ink);
}
.lever .stick {
  position: absolute; left: 41px; bottom: 26px; width: 10px; height: 52px;
  background: #8a6a3f; border: 2px solid var(--ink); transform-origin: 50% 100%;
  transform: rotate(calc(-40deg + var(--on) * 80deg)); transition: transform .25s cubic-bezier(.5, 1.8, .5, 1);
}
.lever .stick::after { /* pointe redstone */
  content: ""; position: absolute; top: -8px; left: -4px; width: 14px; height: 10px;
  background: var(--redstone); border: 2px solid var(--ink);
  box-shadow: 0 0 calc(var(--on) * 14px) var(--redstone-glow);
}
.lever[aria-pressed="true"] { --on: 1; }
.lever:disabled { cursor: wait; opacity: .7; }
.lever:focus-visible { outline: 3px dashed var(--redstone); outline-offset: 4px; }
.lever-label { font-size: .8rem; color: var(--ink-soft); }

.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
.btn {
  border: 2px solid var(--ink); background: var(--paper); padding: .35rem .8rem; cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink); text-transform: lowercase;
}
.btn:hover { background: var(--paper-2); }
.btn:active { transform: translate(2px, 2px); box-shadow: none; }
.btn.danger { color: var(--redstone); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── adresses ── */
.addr { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .45rem 0; border-top: 1px dashed var(--ink-soft); }
.addr:first-of-type { border-top: 0; }
.addr small { display: block; color: var(--ink-soft); font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; }
.addr code { font-size: .95rem; word-break: break-all; }

/* ── joueurs ── */
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.players li { display: flex; align-items: center; gap: .4rem; border: 2px solid var(--ink); padding: .2rem .5rem .2rem .2rem; background: var(--paper-2); }
.players img { width: 24px; height: 24px; image-rendering: pixelated; }
.empty { color: var(--ink-soft); font-style: italic; }

/* ── console ── */
.terminal {
  background: var(--term-bg); color: var(--term-ink); border: 2px solid var(--ink); box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-height: 420px; height: 62vh;
}
.terminal header {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .45rem .8rem; border-bottom: 1px solid #3a372e; font-size: .75rem; text-transform: uppercase; letter-spacing: .15em; color: #8f887a;
}
.terminal header .dot { width: 9px; height: 9px; background: #555; display: inline-block; margin-right: .4rem; }
.terminal header .dot.live { background: var(--redstone-glow); box-shadow: 0 0 8px var(--redstone-glow); }
.log { flex: 1; overflow: auto; padding: .6rem .8rem; font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.log .warn { color: #e8b44a; }
.log .err { color: #ff6b57; }
.log .chat { color: #9fd3a5; }
.log .join { color: #7fb7ff; }
.log .ts { color: #6d675a; }
.prompt { display: flex; border-top: 1px solid #3a372e; }
.prompt span { padding: .55rem .2rem .55rem .8rem; color: var(--redstone-glow); }
.prompt input { flex: 1; background: transparent; border: 0; padding: .55rem .6rem; color: var(--term-ink); outline: none; min-width: 0; }
.prompt.locked { color: #6d675a; padding: .55rem .8rem; font-size: .8rem; }

/* ── whitelist ── */
.wl { width: 100%; border-collapse: collapse; font-size: .85rem; }
.wl td { padding: .3rem .2rem; border-top: 1px dashed var(--ink-soft); }
.wl td:last-child { text-align: right; }
.tag { font-size: .65rem; border: 1px solid currentColor; padding: 0 .3rem; margin-left: .3rem; text-transform: uppercase; }
.tag.op { color: var(--redstone); }
.tag.be { color: var(--emerald); }
.wl-form { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .8rem; }
.wl-form input[type=text] { flex: 1; min-width: 120px; border: 2px solid var(--ink); background: var(--paper); padding: .3rem .5rem; }
.wl-form label { display: flex; align-items: center; gap: .3rem; font-size: .8rem; }

/* ── pages simples (login, liaison, message) ── */
.sheet { max-width: 560px; margin: clamp(24px, 8vh, 90px) auto; padding: 0 16px; }
.sheet .card { padding: 1.6rem; }
.sheet h1 { font: 900 clamp(3.2rem, 14vw, 5.5rem)/.8 var(--display); text-transform: uppercase; margin: 0 0 .2rem; }
.sheet .sub { color: var(--ink-soft); margin: 0 0 1.4rem; }
.ms-btn { display: inline-flex; align-items: center; gap: .7rem; text-decoration: none; font-size: 1rem; padding: .7rem 1.1rem; }
.ms-btn svg { width: 20px; height: 20px; }
details { margin-top: 1.6rem; font-size: .85rem; color: var(--ink-soft); }
details form { display: flex; gap: .4rem; margin-top: .6rem; }
details input { flex: 1; border: 2px solid var(--ink); background: var(--paper); padding: .35rem .5rem; min-width: 0; }
.code {
  font: 900 3.4rem/1 var(--display); letter-spacing: .25em; text-align: center;
  border: 3px dashed var(--redstone); padding: .8rem; margin: 1rem 0; user-select: all;
}
.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper);
  padding: .5rem 1rem; font-size: .85rem; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; }
