/* WONDRA — design inspiré de CodeCombat (MIT/CC-BY) : panneaux sombres,
   bordures dorées, boutons biseautés, portails lumineux. Local only. */
:root {
  --bg: #131619;
  --panel: #1d232a;
  --panel-2: #232b34;
  --ink: #e8e6df;
  --muted: #9aa5b1;
  --gold: #f5b83d;
  --gold-2: #d99a26;
  --blue: #4aa3df;
  --green: #59c86b;
  --red: #e05d5d;
  --border: #3a4552;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(1200px 500px at 70% -10%, #223041 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}
.hidden { display: none !important; }
.screen { display: none; height: 100vh; }
.screen.visible { display: flex; flex-direction: column; }

/* ---------- barre du haut ---------- */
.topbar, .gamebar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: linear-gradient(#242c35, #1a2027);
  border-bottom: 2px solid var(--border);
  box-shadow: 0 2px 14px rgba(0,0,0,.5);
}
.topbar h1 { font-size: 22px; letter-spacing: .5px; color: var(--gold); }
.topbar p { color: var(--muted); font-size: 13px; }
.logo-mark {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center;
  border: 2px solid var(--gold-2); border-radius: 12px;
  color: var(--gold); background: var(--panel-2);
  font-size: 22px; font-weight: 800;
  box-shadow: 0 0 14px rgba(245,184,61,.18);
}
.gamebar h2 { font-size: 18px; flex: 1; }
.hud { margin-left: auto; display: flex; gap: 8px; }
.hud-badge {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 12px; font-size: 13px;
}
.hud-badge b { color: var(--gold); }

/* ---------- boutons ---------- */
.btn {
  background: linear-gradient(#3a4552, #2c3540);
  color: var(--ink); border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px; font-size: 14px; cursor: pointer;
  transition: transform .05s, filter .15s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(var(--gold), var(--gold-2));
  border-color: #a8761d; color: #241a05; font-weight: 700;
}
.btn.big { padding: 10px 22px; font-size: 16px; }
.btn.ghost { background: transparent; }

/* ---------- carte du monde ---------- */
.world-map {
  position: relative; flex: 1; overflow: auto;
  display: flex; flex-wrap: wrap; align-content: center; justify-content: center;
  gap: 42px; padding: 40px;
}
.node {
  width: 200px; background: var(--panel);
  border: 2px solid var(--border); border-radius: 14px;
  padding: 18px 16px 14px; text-align: center; cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  position: relative;
}
.node:hover { transform: translateY(-4px); border-color: var(--gold); }
.node.done { border-color: var(--green); }
.node.current { border-color: var(--gold); }
.node.locked { opacity: .45; cursor: not-allowed; filter: grayscale(.6); }
.node .portal {
  width: 74px; height: 74px; margin: 0 auto 10px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #7fd0ff 0%, #2a6db3 45%, #16324f 100%);
  box-shadow: 0 0 18px rgba(90,180,255,.45), inset 0 0 12px rgba(0,0,0,.6);
  border: 3px solid #0e1822;
  display: flex; align-items: center; justify-content: center; font-size: 30px;
}
.node.done .portal { background:
    radial-gradient(circle at 35% 30%, #a8f0b0 0%, #3f9d4e 45%, #1d4d26 100%); }
.node h3 { font-size: 15px; margin-bottom: 2px; }
.node .meta { font-size: 12px; color: var(--muted); }
.node .stars { color: var(--gold); font-size: 14px; margin-top: 6px; letter-spacing: 2px; }
.node .state-tag {
  position: absolute; top: -10px; right: -8px;
  background: var(--gold); color: #241a05;
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}
.node.locked .state-tag { background: var(--border); color: var(--muted); }

/* ---------- écran de jeu ---------- */
.game-layout {
  flex: 1; display: grid;
  grid-template-columns: 300px 1fr 660px;
  gap: 0; min-height: 0;
}
.pane-instructions {
  background: var(--panel); border-right: 2px solid var(--border);
  padding: 16px; overflow: auto;
}
.pane-instructions h3 {
  color: var(--gold); font-size: 13px; text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 8px;
}
#level-brief { font-size: 14px; }
#level-brief code {
  background: #10141a; border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 5px; color: var(--blue); font-size: 13px;
}
.hint-box, .goal-box {
  margin-top: 14px; padding: 10px 12px;
  border-radius: var(--radius); font-size: 13px;
}
.hint-box { background: #2a2415; border: 1px solid #6b5a1e; }
.goal-box { background: #16281c; border: 1px solid #2c5a38; }

.pane-editor {
  display: flex; flex-direction: column;
  background: #10141a; border-right: 2px solid var(--border); min-width: 0;
}
.editor-tabs {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: #171c23; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.tab { color: var(--gold); font-weight: 700; }
.lang-tag {
  margin-left: auto; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px;
}
#editor { flex: 1; min-height: 0; }
.editor-foot {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; background: #171c23; border-top: 1px solid var(--border);
}
.run-state { color: var(--muted); font-size: 13px; }
.run-state.err { color: var(--red); }
.run-state.ok { color: var(--green); }

.pane-view { background: #0c0f13; display: flex; align-items: center; justify-content: center; position: relative; padding: 14px; }
#world {
  background: #101d15; border: 2px solid var(--border);
  border-radius: var(--radius); max-width: 100%; max-height: 100%;
}
#world.error-flash { animation: shake .3s; }
@keyframes shake {
  0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ---------- toast + modale ---------- */
.toast {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: rgba(20,24,30,.95); border: 1px solid var(--border);
  color: var(--ink); padding: 9px 16px; border-radius: 999px; font-size: 14px;
}
.toast.ok { border-color: var(--green); }
.toast.err { border-color: var(--red); }
.modal {
  position: absolute; inset: 0; background: rgba(5,8,12,.72);
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  width: min(480px, 90vw); background: var(--panel);
  border: 2px solid var(--gold); border-radius: 16px;
  padding: 26px; text-align: center;
  box-shadow: 0 10px 50px rgba(0,0,0,.6);
}
.modal-card h3 { color: var(--gold); font-size: 24px; margin-bottom: 6px; }
#win-stars { font-size: 34px; letter-spacing: 6px; margin: 10px 0; }
#win-stars .off { color: #4a5461; }
#win-msg { color: var(--muted); margin-bottom: 16px; }
.code-review { text-align: left; background: #10141a; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; }
.code-review h4 { font-size: 12px; color: var(--blue); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.code-review li { font-size: 13px; margin: 4px 0 4px 16px; }
.modal-card .btn { margin: 4px; }

/* responsive : tablette + mobile */
@media (max-width: 1400px) { .game-layout { grid-template-columns: 260px 1fr 1fr; } }
@media (max-width: 980px) {
  .game-layout { grid-template-columns: 1fr; grid-template-rows: auto auto auto; overflow: auto; }
  .pane-instructions { border-right: 0; border-bottom: 2px solid var(--border); max-height: 34vh; }
  .pane-view { border-top: 2px solid var(--border); order: -1; }
  #world { width: 100%; height: auto; }
  /* FIX MOBILE : l'editeur Ace s'ecrasait a 0px (flex:1 + min-height:0
     dans une grille auto) — hauteur min explicite, sinon invisible */
  .pane-editor { min-height: 300px; border-right: 0; }
  #editor { min-height: 210px; }
  .gamebar { flex-wrap: wrap; gap: 6px; }
  .gamebar-actions { flex-wrap: wrap; gap: 6px; }
}

/* ---------- barre de choix du personnage ---------- */
.char-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; border-top: 2px solid var(--border);
  background: var(--panel);
}
.char-label { color: var(--muted); font-size: 13px; white-space: nowrap; }
.char-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.char-chip {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: #10141a; border: 2px solid var(--border); border-radius: var(--radius);
  padding: 6px 10px 4px; cursor: pointer; color: var(--muted); font-size: 11px;
  font-family: inherit; transition: border-color .15s, transform .15s;
}
.char-chip:hover { transform: translateY(-2px); }
.char-chip.selected { border-color: var(--gold); color: var(--gold); }
.char-chip canvas { image-rendering: auto; }
/* ---------- bandeau marque WONDRA ---------- */
.brand-hero{width:min(980px,calc(100% - 32px));margin:28px auto 8px;padding:38px 38px 34px;border:1px solid rgba(255,255,255,.11);border-radius:22px;background:radial-gradient(circle at 82% 18%,rgba(118,83,255,.24),transparent 36%),linear-gradient(135deg,rgba(19,30,45,.97),rgba(11,17,28,.98));box-shadow:0 22px 70px rgba(0,0,0,.32);text-align:left}
.brand-kicker{margin:0 0 12px;color:#77e3ff;font-size:.78rem;font-weight:800;letter-spacing:.16em}
.brand-hero h2{max-width:790px;margin:0;color:#fff;font-size:clamp(2rem,5vw,4.15rem);line-height:1.02;letter-spacing:-.045em}
.brand-lead{margin:20px 0 8px;color:#e8eef7;font-size:clamp(1.05rem,2vw,1.35rem);font-weight:650}
.brand-copy{max-width:760px;margin:0 0 24px;color:#aebdce;font-size:1rem;line-height:1.65}
.brand-cta{display:inline-flex;text-decoration:none}
@media (max-width:640px){.brand-hero{margin-top:16px;padding:26px 22px 24px;border-radius:18px}.brand-copy{font-size:.94rem}}
