/* Polices au choix (Réglages > Options) ; voir fonts/LISEZMOI.txt. */
@font-face { font-family: "Fixedsys Excelsior"; src: url("fonts/fixedsys-excelsior.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "VT323"; src: url("guide/fonts/vt323-latin-400-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/jetbrains-mono-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2c313c;
  --text: #d7dae0;
  --muted: #8b93a3;
  --accent: #e8b64c;
  --accent-text: #1a1406;
  --danger: #e5484d;
  --hp: #e5484d;
  --mana: #3e8ef7;
  --mv: #3fb950;
  --focus: #e8b64c;
  --term-font: ui-monospace, "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --ui-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-size: 15px;

  /* ANSI 0-7 then bright 8-15 */
  --c0: #3b4048; --c1: #d9534f; --c2: #5cb85c; --c3: #d4a72c;
  --c4: #4a7fd1; --c5: #b565c9; --c6: #3aa9b8; --c7: #c8ccd4;
  --c8: #6b7280; --c9: #ff6b6b; --c10: #7ee787; --c11: #f5d76e;
  --c12: #79b8ff; --c13: #e39cf5; --c14: #6fe0ee; --c15: #ffffff;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f5f1; --surface: #ffffff; --surface-2: #efede7; --border: #d9d6cc;
    --text: #1f2328; --muted: #5f6672; --accent: #9a6700; --accent-text: #ffffff;
    --focus: #9a6700;
    --c0: #24292f; --c1: #c0262d; --c2: #1a7f37; --c3: #8a6100;
    --c4: #0a57c2; --c5: #8e3aa8; --c6: #0b7285; --c7: #57606a;
    --c8: #6e7781; --c9: #d1242f; --c10: #116329; --c11: #7d4e00;
    --c12: #0550ae; --c13: #8250df; --c14: #1b7c83; --c15: #000000;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f6f5f1; --surface: #ffffff; --surface-2: #efede7; --border: #d9d6cc;
  --text: #1f2328; --muted: #5f6672; --accent: #9a6700; --accent-text: #ffffff;
  --focus: #9a6700;
  --c0: #24292f; --c1: #c0262d; --c2: #1a7f37; --c3: #8a6100;
  --c4: #0a57c2; --c5: #8e3aa8; --c6: #0b7285; --c7: #57606a;
  --c8: #6e7781; --c9: #d1242f; --c10: #116329; --c11: #7d4e00;
  --c12: #0550ae; --c13: #8250df; --c14: #1b7c83; --c15: #000000;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--ui-font);
}
button, input, select {
  font: inherit;
  color: inherit;
}
button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  min-height: 34px;
}
button:hover { border-color: var(--muted); }
/* Lien présenté comme un bouton (le guide du joueur) */
.link-button {
  display: inline-flex; align-items: center; min-height: 34px; padding: 6px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  color: inherit; text-decoration: none;
}
.link-button:hover { border-color: var(--muted); }
button.primary, .input-bar button {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
button.danger { color: var(--danger); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.topbar h1 {
  font-size: 16px;
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.spacer { flex: 1; }
.status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.status[data-state="on"] { color: var(--mv); border-color: var(--mv); }
.status[data-state="wait"] { color: var(--accent); border-color: var(--accent); }
.who { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main {
  display: grid;
  grid-template-columns: 1fr 240px;
  min-height: 0;
}
.term-wrap { position: relative; min-height: 0; min-width: 0; }
.output {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 16px;
  font: var(--font-size)/1.35 var(--term-font);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.line { min-height: 1.35em; }
.line.gagged { display: none; }
.line.info { color: var(--accent); font-style: italic; }
.line.error { color: var(--danger); }
.echo { color: var(--muted); }
.output a { color: inherit; text-decoration: underline; }
.hl { border-radius: 3px; }

.b { font-weight: 700; }
/* Pixel fonts have no bold: a synthesized one would smear them (bold text
   already uses the bright colors). */
:root[data-pixel-font] .b { font-weight: 400; }
.fg0 { color: var(--c0); } .fg1 { color: var(--c1); } .fg2 { color: var(--c2); } .fg3 { color: var(--c3); }
.fg4 { color: var(--c4); } .fg5 { color: var(--c5); } .fg6 { color: var(--c6); } .fg7 { color: var(--c7); }
.fg8 { color: var(--c8); } .fg9 { color: var(--c9); } .fg10 { color: var(--c10); } .fg11 { color: var(--c11); }
.fg12 { color: var(--c12); } .fg13 { color: var(--c13); } .fg14 { color: var(--c14); } .fg15 { color: var(--c15); }
.bg0 { background: var(--c0); } .bg1 { background: var(--c1); } .bg2 { background: var(--c2); } .bg3 { background: var(--c3); }
.bg4 { background: var(--c4); } .bg5 { background: var(--c5); } .bg6 { background: var(--c6); } .bg7 { background: var(--c7); }

.to-bottom {
  position: absolute;
  right: 16px;
  bottom: 12px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.3);
}

.side {
  border-left: 1px solid var(--border);
  background: var(--surface);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.panel { display: flex; flex-direction: column; gap: 8px; }
.bar {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.bar .label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .val { font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.track { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.fill { height: 100%; width: 0; border-radius: 4px; transition: width 0.25s ease; }
.bar[data-kind="hp"] .fill { background: var(--hp); }
.bar[data-kind="mana"] .fill { background: var(--mana); }
.bar[data-kind="mv"] .fill { background: var(--mv); }
.bar.enemy .fill { background: var(--c5); }
.room-title { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.exits { display: flex; flex-wrap: wrap; gap: 6px; }
.exits button { min-height: 30px; padding: 3px 10px; font-size: 13px; }

.buttons {
  display: flex;
  gap: 6px;
  padding: 6px 16px 0;
  overflow-x: auto;
  background: var(--bg);
}
.buttons:empty { display: none; }
.buttons button { white-space: nowrap; font-size: 13px; }

.input-bar {
  display: flex;
  gap: 8px;
  padding: 8px 16px 10px;
  background: var(--bg);
}
.input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font: var(--font-size) var(--term-font);
}
.input.password { letter-spacing: 0.2em; }

/* Settings */
.settings {
  width: min(880px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}
.settings[open] { display: flex; flex-direction: column; }
.settings::backdrop { background: rgb(0 0 0 / 0.5); }
.settings-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  margin: 0;
}
.settings-head h2 { font-size: 16px; margin: 0; }
.settings-head button { margin-left: auto; }
.muted { color: var(--muted); font-size: 13px; }
.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}
.tabs button {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
}
.tabs button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--accent); }
.tab-body { padding: 12px 16px 16px; overflow-y: auto; }
.tab-help { color: var(--muted); margin: 0 0 12px; }
.tab-help code, .tab-body code { background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.rows { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px;
  background: var(--surface-2);
  border-radius: 8px;
}
.row input[type="text"] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: var(--term-font);
  font-size: 13px;
  min-width: 0;
}
.row .grow { flex: 1 1 200px; }
.row .small { flex: 0 1 110px; }
.row label { display: inline-flex; gap: 4px; align-items: center; font-size: 13px; white-space: nowrap; }
.row input[type="color"] { width: 32px; height: 28px; padding: 0; border: none; background: none; }
.row input.invalid { border-color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.options { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; align-items: center; }
.options input[type="text"], .options input[type="number"], .options select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  width: 120px;
}
.key-capture { font-family: var(--term-font); }

@media (max-width: 760px) {
  .main { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side {
    order: -1;
    border-left: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px 16px;
  }
  .vitals { flex: 1 1 100%; flex-direction: row; flex-wrap: wrap; gap: 6px 12px; }
  .vitals .bar { flex: 1 1 140px; grid-template-columns: auto 1fr auto; }
  .bar .val { min-width: 0; }
  .room { flex: 1 1 100%; flex-direction: row; align-items: center; }
  .room-title { display: none; }
  .output { padding: 8px 16px; }
  .topbar h1 { font-size: 15px; }
  .who { display: none; }
  .options { grid-template-columns: 1fr; }
}

/* Petits écrans : la barre du haut doit tenir sur une ligne. L'état de la
   connexion devient une pastille de couleur (le texte reste lu par les
   lecteurs d'écran). */
@media (max-width: 480px) {
  .topbar { gap: 8px; padding: 8px 10px; }
  .topbar button, .topbar .link-button { padding: 6px 9px; white-space: nowrap; }
  .status { font-size: 0; width: 12px; height: 12px; padding: 0; flex: none; background: currentColor; }
}
