:root {
  --ink: #2a1d1a;
  --cream: #fff4e0;
  --sand: #f6cf94;
  --orange: #ff7a3d;
  --yellow: #ffcf33;
  --red: #e9473b;
  --green: #5cc85c;
  --blue: #3fa7ff;
  --teal: #38c6a8;
  --panel: #fff4e0;
  --shadow: 0 4px 0 var(--ink);
  --font: 'Lilita One', 'Trebuchet MS', system-ui, sans-serif;
  --body: 'Nunito', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f6cf94; font-family: var(--body); color: var(--ink); user-select: none; -webkit-user-select: none; }
canvas#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
canvas#overlay { position: fixed; inset: 0; pointer-events: none; }
#floaters { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.floater { position: absolute; left: 0; top: 0; font-family: var(--font); font-size: 20px; color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; white-space: nowrap; }
.floater.res-scrap::after { content: ' ⚙️'; } .floater.res-stone::after { content: ' 🪨'; } .floater.res-crystal::after { content: ' 💎'; }
.floater.res-fuel::after { content: ' 🛢️'; } .floater.res-plate::after { content: ' 🔩'; } .floater.res-circuit::after { content: ' 🔌'; }
#vignette { position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 160px 40px rgba(220, 30, 30, 0); transition: box-shadow .3s; }
[hidden] { display: none !important; }

kbd { display: inline-block; font-family: var(--font); font-size: 12px; padding: 1px 6px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; box-shadow: 0 2px 0 var(--ink); margin: 0 1px; line-height: 1.2; }

/* ------------------------------------------------ boutons & panneaux */
.btn { font-family: var(--font); font-size: 20px; letter-spacing: .5px; color: var(--ink); background: var(--yellow); border: 3px solid var(--ink); border-radius: 14px;
  padding: 10px 18px; box-shadow: 0 5px 0 var(--ink); cursor: pointer; transition: transform .08s, box-shadow .08s, filter .1s; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 6px 0 var(--ink); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { filter: grayscale(.8) brightness(.9); cursor: not-allowed; transform: none; }
.btn.small { font-size: 14px; padding: 5px 10px; border-radius: 10px; box-shadow: 0 3px 0 var(--ink); }
.btn.green { background: var(--green); } .btn.red { background: var(--red); color: #fff; } .btn.blue { background: var(--blue); color: #fff; }
.btn.teal { background: var(--teal); } .btn.cream { background: var(--cream); } .btn.orange { background: var(--orange); color: #fff; }
.panel { background: var(--panel); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 6px 0 var(--ink); padding: 14px; }
.bar { position: relative; height: 18px; background: #4a3a36; border: 3px solid var(--ink); border-radius: 10px; overflow: hidden; }
.bar > div { height: 100%; background: var(--green); transition: width .2s; }
.bar > span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--font); font-size: 12px; color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.title { font-family: var(--font); color: #fff; -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); }
h2 { font-family: var(--font); font-weight: 400; margin: 0 0 10px; font-size: 28px; }
input[type=text] { font-family: var(--font); font-size: 20px; padding: 8px 12px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; color: var(--ink); outline: none; width: 100%; user-select: text; }

/* ------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#phase { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; background: var(--cream); border: 3px solid var(--ink);
  border-radius: 999px; padding: 6px 10px 6px 8px; box-shadow: var(--shadow); }
#phase-icon { font-size: 30px; width: 44px; height: 44px; display: grid; place-items: center; background: var(--yellow); border: 3px solid var(--ink); border-radius: 50%; }
#phase-label { font-family: var(--font); font-size: 20px; line-height: 1; }
#phase-sub { font-weight: 900; font-size: 14px; opacity: .8; }
#phase.night { background: #2b2f63; color: #fff; } #phase.night #phase-icon { background: #6c6cff; }
#phase.dusk { background: #ff9a6b; } #phase.dusk #phase-icon { background: #ff6b4a; }
#core { position: absolute; top: 84px; left: 50%; transform: translateX(-50%); width: 300px; text-align: center; }
.core-label { font-family: var(--font); font-size: 15px; color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; margin-bottom: 2px; }
#core .bar { height: 20px; } #core-bar { background: linear-gradient(#ff8f6b, var(--red)) !important; }
#stock { position: absolute; top: 12px; left: 12px; display: grid; grid-template-columns: repeat(2, auto); gap: 6px; }
.res { display: flex; align-items: center; gap: 6px; background: var(--cream); border: 3px solid var(--ink); border-radius: 12px; padding: 3px 10px 3px 6px; box-shadow: 0 3px 0 var(--ink); font-family: var(--font); font-size: 18px; min-width: 96px; }
.res .ico { font-size: 18px; } .res small { font-family: var(--body); font-size: 10px; font-weight: 900; opacity: .6; display: block; line-height: 1; }
.res.flash { animation: flash .4s; }
@keyframes flash { 50% { transform: scale(1.12); background: #fff; } }
#room-box { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; align-items: center; }
#room-code { font-family: var(--font); font-size: 16px; background: var(--cream); border: 3px solid var(--ink); border-radius: 10px; padding: 4px 10px; box-shadow: 0 3px 0 var(--ink); }
#players-box { position: absolute; top: 58px; right: 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.pl { display: flex; align-items: center; gap: 6px; background: rgba(255,244,224,.92); border: 2px solid var(--ink); border-radius: 10px; padding: 2px 8px; font-weight: 900; font-size: 13px; }
.pl .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); }
.pl .tags { font-size: 12px; }
#minimap { position: absolute; bottom: 12px; right: 12px; width: 170px; height: 170px; border: 3px solid var(--ink); border-radius: 18px; box-shadow: var(--shadow); background: #e6b574; }
#me-box { position: absolute; bottom: 12px; left: 12px; width: 260px; display: flex; flex-direction: column; gap: 8px; }
#me-hp { height: 24px; } #me-hp > div { background: linear-gradient(#8ef08e, #3fae3f); }
#weapons { display: flex; gap: 6px; flex-wrap: wrap; }
.wpn { font-family: var(--font); font-size: 13px; background: var(--cream); border: 3px solid var(--ink); border-radius: 10px; padding: 4px 8px; box-shadow: 0 3px 0 var(--ink); cursor: pointer; opacity: .65; }
.wpn.on { background: var(--yellow); opacity: 1; transform: translateY(-2px); }
#hotbar { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; max-width: calc(100vw - 500px); flex-wrap: wrap; justify-content: center; }
.slot { position: relative; width: 66px; height: 70px; background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: var(--font); font-size: 11px; text-align: center; line-height: 1; padding: 2px; transition: transform .1s; }
.slot:hover { transform: translateY(-3px); }
.slot .ico { font-size: 26px; margin-bottom: 3px; }
.slot .key { position: absolute; top: -8px; left: -6px; background: var(--ink); color: #fff; border-radius: 6px; padding: 1px 5px; font-size: 11px; }
.slot.on { background: var(--yellow); transform: translateY(-6px); }
.slot.poor { background: #e9d9c0; color: #8a6a5a; }
.slot.locked { background: #b9aa98; color: #5a4a40; }
.slot.locked .ico { filter: grayscale(1) opacity(.6); }
.slot .lock { position: absolute; top: 2px; right: 3px; font-size: 13px; }
#build-info { position: absolute; bottom: 100px; left: 50%; transform: translateX(-50%); background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; padding: 8px 14px; box-shadow: var(--shadow);
  font-weight: 800; font-size: 14px; max-width: 420px; text-align: center; display: none; }
#build-info b { font-family: var(--font); font-weight: 400; font-size: 18px; }
#build-info .cost span { margin: 0 4px; white-space: nowrap; } #build-info .cost .no { color: var(--red); }
#prompt { position: absolute; top: 58%; left: 50%; transform: translateX(-50%); font-family: var(--font); font-size: 18px; color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; pointer-events: none; text-align: center; }
#progress { position: absolute; top: calc(58% + 30px); left: 50%; transform: translateX(-50%); width: 140px; height: 12px; border: 3px solid var(--ink); border-radius: 8px; background: #4a3a36; overflow: hidden; display: none; pointer-events: none; }
#progress > div { height: 100%; background: var(--yellow); }
#feed { position: absolute; left: 12px; bottom: 120px; width: 380px; display: flex; flex-direction: column; gap: 3px; pointer-events: none; }
.fl { background: rgba(42,29,26,.72); color: #fff; padding: 4px 10px; border-radius: 10px; font-weight: 800; font-size: 13px; animation: fadein .2s; transition: opacity .6s; }
.fl b { color: var(--yellow); } .fl.warn { background: rgba(233,71,59,.85); } .fl.good { background: rgba(56,140,80,.85); }
@keyframes fadein { from { transform: translateX(-20px); opacity: 0; } }
#chat-in { position: absolute; left: 12px; bottom: 90px; width: 380px; font-family: var(--body); font-weight: 800; font-size: 14px; padding: 6px 10px; border: 3px solid var(--ink); border-radius: 10px; display: none; user-select: text; }
#banner { position: absolute; top: 28%; left: 50%; transform: translate(-50%, -50%) scale(.6); font-family: var(--font); font-size: 72px; color: #fff; -webkit-text-stroke: 9px var(--ink); paint-order: stroke fill;
  text-shadow: 0 8px 0 var(--ink); pointer-events: none; opacity: 0; transition: opacity .3s, transform .4s cubic-bezier(.2,1.6,.4,1); text-align: center; white-space: nowrap; }
#banner small { display: block; font-size: 26px; -webkit-text-stroke: 5px var(--ink); text-shadow: 0 4px 0 var(--ink); }
#banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#plane-panel { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 420px; }
#plane-panel .row { display: flex; justify-content: space-between; font-weight: 900; padding: 3px 0; border-bottom: 2px dashed #e3cfae; }
#plane-panel .ok { color: #2f8f3f; } #plane-panel .no { color: var(--red); }
#help { position: absolute; top: 180px; left: 12px; font-size: 12px; font-weight: 800; padding: 10px 12px; max-width: 360px; line-height: 1.9; display: none; }
#help.show { display: block; }

/* ------------------------------------------------ menus */
#menu { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; overflow: auto; }
#menu.hidden { display: none; }
.home { display: grid; grid-template-columns: minmax(300px, 1fr) 360px; gap: 30px; width: min(1100px, 100%); align-items: center; }
.logo { font-size: clamp(64px, 11vw, 140px); line-height: .9; margin: 0; transform: rotate(-4deg); letter-spacing: 2px; }
.logo span { display: inline-block; animation: bob 2.4s ease-in-out infinite; }
.logo span:nth-child(2n) { animation-delay: -.6s; color: var(--yellow); } .logo span:nth-child(3n) { color: var(--orange); }
@keyframes bob { 50% { transform: translateY(-8px) rotate(3deg); } }
.tagline { font-family: var(--font); font-size: 22px; color: #fff; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; margin: 14px 0 22px; }
.menu-btns { display: flex; flex-direction: column; gap: 12px; max-width: 360px; }
.menu-btns .btn { font-size: 24px; text-align: left; }
.menu-row { display: flex; gap: 10px; }
.menu-row .btn { flex: 1; font-size: 17px; text-align: center; }
.card { background: var(--panel); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 0 7px 0 var(--ink); padding: 16px; }
.profile-card .preview { width: 100%; height: 240px; border-radius: 16px; background: radial-gradient(circle at 50% 70%, #ffe6b8, #f6b86a); border: 3px solid var(--ink); display: block; }
.pname { font-family: var(--font); font-size: 28px; margin-top: 10px; display: flex; justify-content: space-between; align-items: center; }
.lvl { font-family: var(--font); background: var(--blue); color: #fff; border: 3px solid var(--ink); border-radius: 10px; padding: 0 8px; font-size: 18px; }
.coins { font-family: var(--font); font-size: 22px; display: flex; align-items: center; gap: 6px; }
.xpbar { margin: 8px 0; } .xpbar > div { background: linear-gradient(#8fd0ff, var(--blue)) !important; }
.stats { font-weight: 800; font-size: 13px; opacity: .75; display: flex; gap: 10px; flex-wrap: wrap; }
.screen { width: min(1100px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; gap: 14px; }
.screen-head { display: flex; align-items: center; gap: 14px; }
.screen-head h1 { font-size: 46px; margin: 0; flex: 1; }
.screen-body { display: grid; grid-template-columns: 320px 1fr; gap: 18px; min-height: 0; flex: 1; }
.screen-body .scroll { overflow: auto; min-height: 0; padding: 4px 8px 12px 4px; }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs .btn { font-size: 15px; padding: 6px 12px; background: var(--cream); } .tabs .btn.on { background: var(--yellow); }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.item { background: var(--cream); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); padding: 10px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; transition: transform .1s; }
.item:hover { transform: translateY(-3px); }
.item.equipped { background: #d9f7c9; } .item.locked { opacity: .65; }
.item .nm { font-family: var(--font); font-size: 17px; } .item .ds { font-size: 12px; font-weight: 800; opacity: .75; flex: 1; }
.item .pr { font-family: var(--font); font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.item .stats2 { font-size: 11px; font-weight: 900; opacity: .7; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.sw { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--ink); cursor: pointer; box-shadow: 0 3px 0 var(--ink); }
.sw.on { outline: 4px solid #fff; outline-offset: -8px; transform: scale(1.12); }
label.lbl { font-family: var(--font); font-size: 16px; display: block; margin-top: 4px; }
.trees { display: grid; grid-template-columns: repeat(5, minmax(160px, 1fr)); gap: 12px; }
.tree { background: var(--cream); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 5px 0 var(--ink); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.tree h3 { font-family: var(--font); font-weight: 400; margin: 0; font-size: 20px; display: flex; gap: 6px; align-items: center; }
.node { border: 3px solid var(--ink); border-radius: 12px; padding: 8px; cursor: pointer; background: #fff; position: relative; transition: transform .1s; }
.node:hover { transform: scale(1.03); }
.node .nn { font-family: var(--font); font-size: 15px; } .node .nd { font-size: 11.5px; font-weight: 800; opacity: .75; }
.node.on { color: var(--ink); } .node.avail { border-style: dashed; } .node.lock { opacity: .45; }
.node .unl { position: absolute; top: -8px; right: -6px; background: var(--red); color: #fff; font-family: var(--font); font-size: 10px; padding: 1px 6px; border-radius: 8px; border: 2px solid var(--ink); }
.node + .node::before { content: ''; position: absolute; top: -11px; left: 50%; width: 4px; height: 8px; background: var(--ink); }
.points { font-family: var(--font); font-size: 22px; background: var(--yellow); border: 3px solid var(--ink); border-radius: 12px; padding: 4px 12px; box-shadow: 0 3px 0 var(--ink); }
.lb { width: 100%; border-collapse: collapse; font-weight: 900; } .lb td { padding: 4px 6px; border-bottom: 2px dashed #e3cfae; } .lb td:last-child { text-align: right; }
#modal { position: fixed; inset: 0; background: rgba(42,29,26,.45); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
#modal .panel { width: min(520px, 100%); max-height: 90vh; overflow: auto; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.linkbox { display: flex; gap: 8px; margin: 10px 0; } .linkbox input { font-size: 14px; font-family: var(--body); font-weight: 800; }
.sum { width: 100%; border-collapse: collapse; font-weight: 900; margin-top: 8px; } .sum td, .sum th { padding: 4px 6px; text-align: left; border-bottom: 2px dashed #e3cfae; }
#toasts { position: fixed; top: 140px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 30; pointer-events: none; }
.toast { font-family: var(--font); font-size: 17px; background: var(--cream); border: 3px solid var(--ink); border-radius: 12px; padding: 6px 14px; box-shadow: 0 4px 0 var(--ink); animation: pop .3s cubic-bezier(.2,1.6,.4,1); }
.toast.bad { background: #ffb8a8; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }
#loading { position: fixed; inset: 0; display: grid; place-items: center; font-family: var(--font); font-size: 30px; color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; background: #f6cf94; z-index: 50; }
#loading.gone { opacity: 0; pointer-events: none; transition: opacity .5s; }
.range { width: 100%; accent-color: var(--orange); }
.music-slots { font-size: 13px; font-weight: 800; line-height: 1.8; }
.music-slots .ok { color: #2f8f3f; } .music-slots .no { color: #a0705a; }

@media (max-width: 900px) {
  .home { grid-template-columns: 1fr; }
  .screen-body { grid-template-columns: 1fr; }
  .trees { grid-template-columns: repeat(2, 1fr); }
  #hotbar { max-width: 100vw; bottom: 200px; }
}

/* v0.2 */
#tip { position: fixed; display: none; pointer-events: none; z-index: 15; max-width: 290px; background: var(--cream); border: 3px solid var(--ink); border-radius: 12px; box-shadow: 0 4px 0 var(--ink); padding: 8px 10px; font-weight: 800; font-size: 12.5px; line-height: 1.45; }
#tip b { font-family: var(--font); font-weight: 400; font-size: 16px; display: block; }
#tip .bad, .bad { color: var(--red); } #tip .ok { color: #2f8f3f; } .hint { opacity: .65; font-size: 12px; }
.wpn { position: relative; padding-bottom: 8px; }
.wpn .dur { position: absolute; left: 6px; right: 6px; bottom: 3px; height: 4px; background: #4a3a36; border-radius: 3px; overflow: hidden; display: block; }
.wpn .dur b { display: block; height: 100%; }
.wpn.broken { background: #ffb8a8; }
#modal .panel.wide { width: min(900px, 100%); }
.guide-body { max-height: 60vh; overflow: auto; padding-right: 6px; }
.gt { width: 100%; border-collapse: collapse; font-weight: 800; font-size: 13.5px; }
.gt td { padding: 6px; border-bottom: 2px dashed #e3cfae; vertical-align: top; } .gt td:first-child { font-size: 22px; width: 34px; } .gt td:nth-child(2) { width: 170px; }
.gt small { opacity: .7; }
.guide-steps { font-weight: 800; line-height: 1.6; padding-left: 22px; } .guide-steps li { margin-bottom: 6px; }
#hotbar { max-width: calc(100vw - 480px); }
.slot { width: 60px; height: 64px; font-size: 10.5px; } .slot .ico { font-size: 22px; }
/* v0.2.1 : menu contextuel */
.ctx { position: fixed; z-index: 25; min-width: 190px; background: var(--cream); border: 3px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow); padding: 8px; font-weight: 800; font-size: 13px; display: flex; flex-direction: column; gap: 5px; }
.ctx[hidden] { display: none; }
.ctx b { font-family: var(--font); font-weight: 400; font-size: 16px; }
.ctx button { font: inherit; text-align: left; cursor: pointer; background: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 5px 8px; box-shadow: 0 2px 0 var(--ink); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.ctx button:hover:not(:disabled) { background: var(--yellow); }
.ctx button:disabled { opacity: .45; cursor: not-allowed; }
.ctx .cost span { margin-left: 4px; }
