/* Fablejeux — style retro */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #14141c; --panel: #1e1e2a; --panel2: #262636; --border: #3a3a52;
  --txt: #e8e8f0; --dim: #9a9ab0; --acc: #58c470; --acc2: #e8c642; --err: #e46060;
}
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--txt);
  font-family: 'Segoe UI', system-ui, sans-serif; overflow: hidden;
  image-rendering: pixelated;
}
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; }

button, input, select, textarea { font-family: inherit; font-size: 14px; }
.btn {
  background: var(--panel2); color: var(--txt); border: 2px solid var(--border);
  padding: 8px 16px; border-radius: 6px; cursor: pointer; transition: 0.1s;
}
.btn:hover { border-color: var(--acc); transform: translateY(-1px); }
.btn.primary { background: #2c5c3a; border-color: var(--acc); }
.btn.warn { background: #5c442c; border-color: var(--acc2); }
.btn.small { padding: 4px 10px; font-size: 13px; }
input, select, textarea {
  background: #11111a; color: var(--txt); border: 2px solid var(--border);
  padding: 7px 10px; border-radius: 6px; outline: none; width: 100%;
}
input:focus { border-color: var(--acc); }

/* ---------- login ---------- */
#screen-login {
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 50% -10%, #24344a 0%, transparent 60%),
    radial-gradient(800px 500px at 80% 110%, #24402c 0%, transparent 55%),
    var(--bg);
}
.login-box {
  background: var(--panel); border: 2px solid var(--border); border-radius: 12px;
  padding: 34px 38px; width: 380px; box-shadow: 0 20px 60px #000a;
}
.logo {
  font-size: 42px; letter-spacing: 3px; text-align: center; color: var(--acc);
  text-shadow: 3px 3px 0 #163a20;
}
.logo span { color: var(--acc2); text-shadow: 3px 3px 0 #4a3a10; }
.tagline { text-align: center; color: var(--dim); font-size: 12px; margin: 6px 0 22px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
.row { display: flex; gap: 10px; margin-top: 16px; }
.row .btn { flex: 1; }
.row.spaced { justify-content: space-between; }
.err { color: var(--err); font-size: 13px; margin-top: 12px; min-height: 18px; text-align: center; }
.status { color: var(--dim); font-size: 12px; text-align: center; margin-top: 8px; }

/* ---------- mondes ---------- */
#screen-worlds { display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1000px 500px at 50% -10%, #24344a 0%, transparent 60%), var(--bg); }
.worlds-box {
  background: var(--panel); border: 2px solid var(--border); border-radius: 12px;
  padding: 26px 30px; width: 560px; max-height: 80vh; overflow: auto;
}
.worlds-box h2 { margin-bottom: 16px; color: var(--acc2); }
.world-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  background: var(--panel2); border: 2px solid var(--border); border-radius: 8px;
  margin-bottom: 10px; cursor: pointer; transition: 0.12s;
}
.world-row:hover { border-color: var(--acc); transform: translateX(3px); }
.world-ico { font-size: 26px; }
.world-info { flex: 1; }
.world-info b { font-size: 16px; }
.world-info .desc { color: var(--dim); font-size: 12px; }
.world-players { color: var(--acc); font-size: 13px; white-space: nowrap; }
.world-badge { font-size: 11px; background: #4a3a10; color: var(--acc2);
  padding: 2px 7px; border-radius: 10px; margin-left: 6px; }

/* ---------- jeu ---------- */
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
#hud { position: absolute; top: 10px; left: 12px; right: 12px; display: flex;
  justify-content: space-between; pointer-events: none; }
#hud-hearts img { width: 28px; height: 28px; margin-right: 2px;
  image-rendering: pixelated; filter: drop-shadow(1px 2px 0 #0008); }
#hud-right { display: flex; gap: 14px; align-items: center;
  background: #000a; padding: 6px 14px; border-radius: 8px; font-size: 15px; }
#hud-world { color: var(--acc2); }
#hud-buttons { position: absolute; top: 52px; left: 12px; display: flex; flex-direction: column; gap: 6px; }
#hud-buttons button {
  width: 40px; height: 40px; font-size: 19px; background: #000a; color: #fff;
  border: 2px solid var(--border); border-radius: 8px; cursor: pointer;
}
#hud-buttons button:hover { border-color: var(--acc); }

#chat-log {
  position: absolute; left: 12px; bottom: 52px; width: 44%; max-width: 560px;
  font-size: 13.5px; pointer-events: none; text-shadow: 1px 1px 0 #000;
}
#chat-log .line { margin-top: 3px; background: #0007; padding: 3px 8px;
  border-radius: 6px; width: fit-content; max-width: 100%; word-wrap: break-word; }
#chat-log .sys { color: #9adfae; }
#chat-log .line b { color: var(--acc2); }
#chat-bar { position: absolute; left: 12px; bottom: 12px; width: 44%; max-width: 560px; }
#announce {
  position: absolute; top: 15%; left: 50%; transform: translateX(-50%);
  background: #4a3a10ee; border: 2px solid var(--acc2); color: #ffe9a0;
  padding: 12px 26px; border-radius: 10px; font-size: 17px; z-index: 40;
}

/* ---------- panneau ---------- */
#panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(680px, 92vw); max-height: 82vh; background: var(--panel);
  border: 2px solid var(--border); border-radius: 12px; z-index: 30;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px #000c;
}
#panel-head { display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 2px solid var(--border); }
#panel-title { font-size: 17px; color: var(--acc2); }
#panel-close { background: none; border: none; color: var(--dim); font-size: 18px; cursor: pointer; }
#panel-body { padding: 14px 16px; overflow: auto; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { background: var(--panel2); border: 2px solid var(--border);
  color: var(--txt); padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.tabs button.sel { border-color: var(--acc); background: #2c5c3a; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.grid .cell {
  background: var(--panel2); border: 2px solid var(--border); border-radius: 8px;
  padding: 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center;
}
.grid .cell:hover { border-color: var(--acc); }
.grid .cell.sel { border-color: var(--acc2); background: #3a3320; }
.grid .cell.locked { opacity: 0.35; cursor: not-allowed; }
.grid .cell canvas { image-rendering: pixelated; }
.grid .cell .price { font-size: 10px; color: var(--acc2); }
.pager { display: flex; gap: 10px; justify-content: center; margin-top: 10px; align-items: center; }
.inv-row { display: flex; align-items: center; gap: 10px; padding: 7px 4px;
  border-bottom: 1px solid var(--border); }
.inv-row img { width: 32px; height: 32px; image-rendering: pixelated; }
.quest-row { padding: 9px 6px; border-bottom: 1px solid var(--border); }
.quest-row .qname { color: var(--acc2); }
.quest-row .qst { font-size: 12px; color: var(--dim); }
.quest-row.done .qname { color: var(--acc); }

/* ---------- dialogue ---------- */
#dialog {
  position: absolute; bottom: 90px; left: 50%; transform: translateX(-50%);
  width: min(560px, 90vw); background: #14141ce8; border: 2px solid var(--acc2);
  border-radius: 12px; padding: 14px 18px; z-index: 25;
}
#dialog-name { color: var(--acc2); font-weight: bold; margin-bottom: 6px; }
#dialog-text { white-space: pre-wrap; line-height: 1.45; margin-bottom: 10px; }
#dialog-options { display: flex; flex-direction: column; gap: 6px; }
#dialog-options button {
  background: var(--panel2); border: 2px solid var(--border); color: var(--txt);
  padding: 7px 12px; border-radius: 7px; cursor: pointer; text-align: left;
}
#dialog-options button:hover { border-color: var(--acc); }

/* ---------- editeur ---------- */
#screen-editor { background: #101018; display: flex; flex-direction: column; z-index: 50; }
#ed-top { display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--panel); border-bottom: 2px solid var(--border); flex-wrap: wrap; }
.ed-title { color: var(--acc2); }
#ed-top select { width: auto; }
#ed-status { color: var(--acc); font-size: 13px; }
#ed-main { flex: 1; display: flex; overflow: hidden; }
#ed-canvas-wrap { flex: 1; overflow: auto; background: #000; }
#ed-canvas { image-rendering: pixelated; cursor: crosshair; }
#ed-side { width: 320px; background: var(--panel); border-left: 2px solid var(--border);
  padding: 10px; overflow: auto; }
.ed-section { margin-bottom: 14px; font-size: 13px; }
.ed-section b { color: var(--acc2); }
.ed-section label { margin-right: 10px; }
#ed-tools { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
#ed-tools button { background: var(--panel2); border: 2px solid var(--border);
  color: var(--txt); padding: 4px 8px; border-radius: 6px; cursor: pointer; font-size: 12px; }
#ed-tools button.sel { border-color: var(--acc2); background: #3a3320; }
#ed-palette-wrap { max-height: 340px; overflow: auto; margin-top: 6px;
  border: 2px solid var(--border); }
#ed-palette { image-rendering: pixelated; cursor: pointer; display: block; }
#ed-extra .field { margin-bottom: 8px; }
#ed-extra textarea { min-height: 60px; }

/* table admin */
table.adm { width: 100%; border-collapse: collapse; font-size: 13px; }
table.adm th, table.adm td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; }
table.adm th { color: var(--acc2); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
h3.sec { color: var(--acc); margin: 14px 0 8px; font-size: 15px; }

/* ============ Atelier (créations in-game) ============ */
#atelier { position: fixed; inset: 0; background: rgba(8, 8, 14, 0.75);
  display: flex; align-items: center; justify-content: center; z-index: 60; }
#atelier.hidden { display: none; }
#atelier-box { background: var(--panel, #191b26); border: 2px solid var(--border, #33364a);
  border-radius: 10px; width: min(720px, 96vw); max-height: 92vh; overflow: auto; }
#atelier-head { display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border, #33364a);
  color: var(--acc, #ffd257); font-weight: bold; }
#atelier-head button { background: none; border: none; color: #ccc; font-size: 16px; cursor: pointer; }
#atelier-body { padding: 12px 14px; }
.at-main { display: flex; gap: 14px; flex-wrap: wrap; }
#at-canvas, #fg-sheet { image-rendering: pixelated; border: 2px solid var(--border, #33364a);
  cursor: crosshair; background: #232430; }
.at-side { flex: 1; min-width: 210px; display: flex; flex-direction: column; gap: 8px; }
.at-tools { display: flex; gap: 4px; flex-wrap: wrap; }
.at-tools button { width: 34px; height: 30px; background: #232637; color: #eee;
  border: 1px solid var(--border, #33364a); border-radius: 5px; cursor: pointer; }
.at-tools button.sel { border-color: var(--acc, #ffd257); background: #2e3147; }
.at-palette { display: grid; grid-template-columns: repeat(9, 20px); gap: 3px; }
.at-palette button { width: 20px; height: 20px; border: 1px solid #000;
  border-radius: 3px; cursor: pointer; padding: 0; }
.at-preview canvas { display: block; image-rendering: pixelated; background: #232430;
  border: 1px solid var(--border, #33364a); margin-top: 4px; }
#atelier .tabs button { margin-right: 4px; }
.cell.create { display: flex; flex-direction: column; align-items: center;
  justify-content: center; border-style: dashed; cursor: pointer; }

/* studio SFX */
.sfx-row { display: flex; gap: 4px; align-items: center; margin-bottom: 5px; }
.sfx-label { width: 105px; font-size: 12px; }
.sfx-row input[type=number] { width: 56px; }
.sfx-row select { width: 78px; }
