/* PixelPost : look Game Boy (4 verts). Aucun style en ligne dans le HTML. */
@font-face {
  font-family: "PS2P";
  src: url("fonts/press-start-2p.woff2") format("woff2");
  font-display: swap;
}
:root {
  --c0: #9bbc0f; /* fond clair */
  --c1: #8bac0f;
  --c2: #306230;
  --c3: #0f380f; /* encre */
  --u: 4px;      /* "gros pixel" */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--c3); }
body {
  font-family: "PS2P", ui-monospace, Consolas, monospace;
  font-size: 10px; line-height: 1.7; color: var(--c3);
  image-rendering: pixelated;
  overscroll-behavior: none;
}
#app {
  height: 100dvh; max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column;
  background: var(--c0);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  border-left: var(--u) solid var(--c2); border-right: var(--u) solid var(--c2);
}
.sprite { image-rendering: pixelated; display: block; }

/* ---------- onglets ---------- */
#topbar { background: var(--c3); padding: 6px 6px 0; flex: none; }
#tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; align-items: flex-end; }
#tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: flex; align-items: center; gap: 6px;
  font: inherit; font-size: 9px; color: var(--c0); background: var(--c2);
  border: 0; padding: 8px 10px; cursor: pointer; max-width: 150px;
  border-top: var(--u) solid var(--c1); border-left: var(--u) solid var(--c1); border-right: var(--u) solid var(--c3);
  position: relative;
}
.tab .nm { overflow: hidden; text-overflow: clip; white-space: nowrap; max-width: 80px; }
.tab.on { background: var(--c0); color: var(--c3); border-top-color: var(--c0); border-left-color: var(--c0); border-right-color: var(--c2); }
.tab .dot { width: 8px; height: 8px; background: var(--c0); animation: blink 0.8s steps(2) infinite; }
.tab.plus { padding: 8px 12px; font-size: 12px; }

.stat { margin-left: auto; flex: none; width: 10px; height: 10px; margin-bottom: 10px; margin-right: 4px; background: var(--c0); }
.stat.off { background: var(--c2); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.blink { animation: blink 1s steps(2) infinite; }
@keyframes bounce { 50% { transform: translateY(-4px); } }
.bounce { animation: bounce 1s steps(2) infinite; }

#who { display: flex; align-items: center; gap: 8px; color: var(--c0); font-size: 9px; padding: 2px 4px 6px; }
#who .stat { margin: 0 0 0 auto; }
#splash { position: fixed; inset: 0; z-index: 99; background: var(--c3); color: var(--c0); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; font-size: 14px; text-align: center; }
.box.warn { background: var(--c3); color: var(--c0); box-shadow: var(--u) var(--u) 0 var(--c2); display: flex; flex-direction: column; gap: 8px; }
.chk { cursor: pointer; font-size: 9px; align-items: flex-start; flex-wrap: nowrap; }
.box.warn .muted { color: var(--c1); }
.chk input { width: 20px; height: 20px; accent-color: var(--c3); flex: none; }
#busy { min-height: 0; }
.lbl { font-size: 8px; color: var(--c2); margin-top: 6px; }
.err { background: var(--c3); color: var(--c0); border: var(--u) solid var(--c3); padding: 10px; font-size: 10px; box-shadow: var(--u) var(--u) 0 var(--c2); }
#splashbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 9vh; width: min(88vw, 520px); z-index: 2147483647; text-align: center; color: var(--c0); font-size: 10px; display: flex; flex-direction: column; gap: 10px; }
#splashbar .sbtrack { height: 22px; border: var(--u) solid var(--c0); padding: 3px; background: var(--c3); }
#splashbar .sbtrack i { display: block; height: 100%; width: 0; background: var(--c0); }
.pindots { display: flex; gap: 10px; justify-content: center; padding: 6px; }
.pd { width: 16px; height: 16px; border: var(--u) solid var(--c3); background: transparent; }
.pd.on { background: var(--c3); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; width: 100%; margin: 0 auto; }
.keypad button { padding: 16px 0; font-size: 16px; }
#netbar { flex: none; display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--c3); color: var(--c0); font-size: 8px; padding: 4px 6px; }
#alertbar { flex: none; background: var(--c3); padding: 0 6px 6px; }
.alertbtn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--c0); color: var(--c3); box-shadow: none; border: var(--u) solid var(--c0); padding: 6px; font-size: 9px; }
.al { border-top: 2px dashed var(--c2); padding-top: 6px; display: flex; flex-direction: column; gap: 4px; }
#sec { display: flex; flex-direction: column; gap: 8px; }

/* ---------- vue ---------- */
#view { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px; gap: 10px; overflow-y: auto; }
h1, h2 { font-size: 12px; margin: 0; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
h1 { font-size: 14px; }
.box {
  border: var(--u) solid var(--c3); background: var(--c0); padding: 10px;
  box-shadow: var(--u) var(--u) 0 var(--c2);
}
.muted { color: var(--c2); font-size: 8px; line-height: 1.9; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.center { text-align: center; justify-content: center; }
.grow { flex: 1; }

button, .btn {
  font: inherit; font-size: 10px; text-transform: uppercase;
  color: var(--c0); background: var(--c3); border: 0; padding: 10px 12px; cursor: pointer;
  box-shadow: var(--u) var(--u) 0 var(--c2);
}
button:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--c2); }
button.alt { background: var(--c0); color: var(--c3); border: var(--u) solid var(--c3); padding: 6px 10px; }
button.danger { background: var(--c2); }
button:disabled { opacity: .5; }

input[type=text], input[type=password] {
  font-family: inherit; font-size: 16px; color: var(--c3); background: var(--c1);
  border: var(--u) solid var(--c3); padding: 8px; width: 100%; outline: none; border-radius: 0;
  caret-color: var(--c3);
}
input::placeholder { color: var(--c2); opacity: .7; }

/* grille d'avatars */
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.av { background: var(--c1); border: var(--u) solid transparent; padding: 4px; cursor: pointer; display: flex; justify-content: center; }
.av.on { border-color: var(--c3); background: var(--c0); }

.code { font-size: 20px; letter-spacing: 2px; background: var(--c3); color: var(--c0); padding: 12px; text-align: center; user-select: all; }

/* ---------- discussion ---------- */
#chat { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
#chathead { display: flex; align-items: center; gap: 8px; border-bottom: var(--u) solid var(--c3); padding-bottom: 6px; }
#chathead .t { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
#msgs { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; }
.m { max-width: 82%; padding: 8px 10px; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; position: relative; }
.m.me { align-self: flex-end; background: var(--c3); color: var(--c0); box-shadow: 4px 4px 0 var(--c2); }
.m.peer { align-self: flex-start; background: var(--c1); border: var(--u) solid var(--c3); box-shadow: 4px 4px 0 var(--c2); }
.m .meta { font-size: 7px; opacity: .8; margin-top: 4px; display: flex; gap: 6px; justify-content: flex-end; }
.m .bar { height: 4px; margin-top: 5px; background: var(--c2); }
.m .bar i { display: block; height: 100%; background: var(--c0); }
.m.peer .bar { background: var(--c1); border: 1px solid var(--c3); }
.m.peer .bar i { background: var(--c3); }
.m.wait { opacity: .6; }
.sys { align-self: center; font-size: 8px; color: var(--c2); text-align: center; }
#composer { display: flex; gap: 8px; align-items: stretch; flex: none; }
#composer input { flex: 1; min-width: 0; }
#bar2 { display: flex; gap: 8px; align-items: center; flex: none; flex-wrap: wrap; }
.empty { margin: auto; text-align: center; }
.fp { display: flex; gap: 6px; align-items: center; justify-content: center; background: var(--c1); padding: 8px; }

#toast {
  position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%);
  background: var(--c3); color: var(--c0); padding: 10px 14px; font-size: 9px; z-index: 9; max-width: 90%;
  box-shadow: var(--u) var(--u) 0 var(--c2); text-align: center;
}
[hidden] { display: none !important; }
