/* ============ L'ÂGE DE SILEX — interface ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #141210; overscroll-behavior: none; }
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #e8dcc0;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: none;
}
.panel, #chatin, #mname { touch-action: auto; }
.ctl-mobile { display: none; }
body.touch .ctl-mobile { display: block; }
body.touch .ctl-desktop { display: none; }
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }

/* ============ MENU ============ */
#menu {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(224,160,16,.12), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(45,122,45,.10), transparent 50%),
    linear-gradient(180deg, #1a1610, #12100c 60%, #0d0b08);
  overflow-y: auto;
}
.menu-box { max-width: 720px; padding: 40px 30px; text-align: center; }
.menu-dino { font-size: 64px; filter: drop-shadow(0 6px 12px rgba(0,0,0,.6)); }
#menu h1 {
  font-size: clamp(38px, 7vw, 64px); letter-spacing: 8px; margin: 10px 0 4px;
  background: linear-gradient(180deg, #f4d78a, #c9862b 60%, #8a5a1a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 4px 24px rgba(224,160,16,.25);
}
.tagline { color: #b7a984; font-size: 17px; margin-bottom: 28px; letter-spacing: 1px; }
.menu-form { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#mname {
  padding: 13px 18px; font-size: 17px; width: 280px;
  background: #241f16; color: #f0e6c8; border: 2px solid #57492e; border-radius: 10px; outline: none;
}
#mname:focus { border-color: #c9862b; }
#mplay {
  padding: 13px 26px; font-size: 16px; font-weight: 700; letter-spacing: 1px;
  background: linear-gradient(180deg, #d99a33, #a5661d); color: #221a0c;
  border: 2px solid #f4d78a55; border-radius: 10px;
  box-shadow: 0 4px 18px rgba(217,154,51,.3);
}
#mplay:hover { filter: brightness(1.12); }
#mplay:disabled { filter: grayscale(.8); cursor: wait; }
.menu-status { min-height: 22px; margin-top: 10px; color: #e07a5b; font-size: 14px; }
/* lobby des mondes */
#lobby { max-width: 560px; margin: 6px auto 0; text-align: left; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.lobby-head h3 { color: #e8b04b; font-size: 16px; }
#lobby-refresh { background: none; border: 1px solid #3a3222; border-radius: 8px; color: #b7a984; padding: 5px 10px; font-size: 14px; }
#lobby-refresh:hover { border-color: #7a6a45; }
#world-list { display: flex; flex-direction: column; gap: 7px; max-height: 260px; overflow-y: auto; padding-right: 4px; }
.wrow {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #1e1a12cc; border: 1px solid #3a3222; border-radius: 11px; padding: 10px 14px;
}
.wrow:hover { border-color: #7a6a45; }
.winfo { flex: 1; min-width: 140px; }
.winfo b { font-size: 15px; color: #f0e6c8; }
.winfo .sub { display: block; font-size: 12px; color: #9a8f70; margin-top: 2px; }
.wjoin {
  padding: 9px 16px; font-weight: 700; font-size: 13px; border-radius: 9px;
  background: linear-gradient(180deg, #d99a33, #a5661d); color: #221a0c; border: 1px solid #f4d78a55;
}
.wjoin:hover { filter: brightness(1.12); }
.wpass-inline {
  padding: 8px 10px; font-size: 13px; width: 150px;
  background: #241f16; color: #f0e6c8; border: 1px solid #57492e; border-radius: 8px; outline: none;
}
.create-box { display: flex; gap: 7px; margin-top: 12px; flex-wrap: wrap; }
.create-box input {
  flex: 1; min-width: 140px; padding: 10px 13px; font-size: 14px;
  background: #241f16; color: #f0e6c8; border: 1px solid #57492e; border-radius: 9px; outline: none;
}
.create-box input:focus { border-color: #c9862b; }
.create-box button {
  padding: 10px 16px; font-weight: 700; font-size: 13.5px; border-radius: 9px;
  background: #2a3a22; color: #cfe8b8; border: 1px solid #4a6a3a;
}
.create-box button:hover { filter: brightness(1.2); }
.lobby-hint { text-align: center; margin-top: 8px; font-size: 12px; }

.menu-help { display: flex; gap: 24px; margin-top: 30px; text-align: left; flex-wrap: wrap; }
.mh-col { flex: 1 1 260px; background: #1e1a12aa; border: 1px solid #3a3222; border-radius: 12px; padding: 16px 18px; }
.mh-col h3 { color: #e8b04b; margin-bottom: 8px; font-size: 15px; }
.mh-col p { font-size: 13.5px; line-height: 1.55; color: #cabf9f; }
.menu-mp { margin-top: 22px; font-size: 13px; color: #8a8065; }

/* téléchargements application de bureau */
#dl-box { margin-top: 26px; padding: 16px 18px; background: #1e1a12aa; border: 1px solid #3a3222; border-radius: 12px; }
#dl-box h3 { color: #e8b04b; font-size: 15px; margin-bottom: 10px; }
.dl-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.dlbtn {
  display: inline-block; padding: 11px 20px; border-radius: 10px; text-decoration: none;
  background: #2a2318; color: #f0e6c8; border: 1px solid #57492e; font-size: 14px; font-weight: 600;
}
.dlbtn:hover { border-color: #c9862b; background: #38301f; }
.dlbtn .dl-size { color: #9a8f70; font-weight: 400; font-size: 12px; margin-left: 6px; }
.dl-hint { margin-top: 10px; font-size: 11.5px; line-height: 1.5; }

/* ============ JEU / CANVAS ============ */
#game { position: fixed; inset: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }

/* ============ HUD ============ */
#topbar {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center; z-index: 10;
}
#topbar > div {
  background: #16130dd9; border: 1px solid #3a3222; border-radius: 9px;
  padding: 6px 13px; font-size: 14px; white-space: nowrap;
}
#research-mini { color: #b78ae8; min-width: 180px; }
#research-mini .bar { height: 4px; background: #322a44; border-radius: 2px; margin-top: 4px; }
#research-mini .bar > div { height: 100%; background: #b78ae8; border-radius: 2px; }

#alerts { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); z-index: 11; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.alert {
  background: #331111ee; border: 1px solid #a04040; color: #f0c0b0;
  padding: 8px 18px; border-radius: 9px; font-size: 14px; font-weight: 600;
  animation: apop .25s ease-out;
}
.alert.info { background: #12281bee; border-color: #3e7a50; color: #bfe8c8; }
.alert.research { background: #221833ee; border-color: #7a5ba0; color: #d8c8f0; }
@keyframes apop { from { transform: scale(.85); opacity: 0; } }

#bottombar {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 10;
}
#hpwrap { width: 320px; }
#hpbar { position: relative; height: 20px; background: #241410; border: 1px solid #57492e; border-radius: 10px; overflow: hidden; }
#hpfill { height: 100%; width: 100%; background: linear-gradient(180deg, #6fce5c, #3d8a30); transition: width .2s; }
#hpfill.low { background: linear-gradient(180deg, #e05c4a, #8a2b20); }
#hptext { position: absolute; inset: 0; text-align: center; font-size: 12.5px; font-weight: 700; line-height: 20px; color: #fff; text-shadow: 0 1px 2px #000; }

#hotbar { display: flex; gap: 5px; }
.hslot {
  width: 52px; height: 52px; position: relative;
  background: #16130dd9; border: 2px solid #3a3222; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
}
.hslot:hover { border-color: #7a6a45; }
.hslot.sel { border-color: #e8b04b; box-shadow: 0 0 12px #e8b04b66; }
.hslot.empty { opacity: .38; }
.hslot canvas { width: 36px; height: 36px; image-rendering: pixelated; }
.hslot .cnt { position: absolute; bottom: 1px; right: 4px; font-size: 11px; font-weight: 700; color: #f0e6c8; text-shadow: 0 1px 2px #000; }
.hslot .key { position: absolute; top: 0px; left: 4px; font-size: 10px; color: #8a8065; }

#queue { display: flex; gap: 4px; min-height: 40px; }
.qslot { width: 40px; height: 40px; position: relative; background: #16130dd9; border: 1px solid #3a3222; border-radius: 7px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.qslot canvas { width: 28px; height: 28px; }
.qslot .cnt { position: absolute; bottom: 0; right: 3px; font-size: 10px; font-weight: 700; }
.qslot .qbar { position: absolute; bottom: 0; left: 0; height: 3px; background: #e8b04b; }

#minimap {
  position: absolute; right: 12px; top: 12px; z-index: 10;
  border: 2px solid #3a3222; border-radius: 10px; background: #0d0b08;
  cursor: pointer;
}

#chatbox { position: absolute; left: 12px; bottom: 12px; z-index: 10; width: 340px; }
#chatlog { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }
#chatlog div { background: #16130daa; padding: 4px 10px; border-radius: 7px; font-size: 13px; line-height: 1.35; word-wrap: break-word; }
#chatlog b { margin-right: 4px; }
#chatin {
  width: 100%; padding: 8px 12px; font-size: 14px;
  background: #241f16ee; color: #f0e6c8; border: 1px solid #57492e; border-radius: 8px; outline: none;
}

#tooltip {
  position: absolute; z-index: 30; pointer-events: none;
  background: #16130df2; border: 1px solid #57492e; border-radius: 8px;
  padding: 8px 12px; font-size: 13px; max-width: 260px; line-height: 1.4;
}
#tooltip b { color: #e8b04b; }
#tooltip .sub { color: #9a8f70; font-size: 12px; }
#cursor-hint { position: absolute; z-index: 9; left: 50%; bottom: 145px; transform: translateX(-50%); font-size: 12.5px; color: #b7a98499; pointer-events: none; text-shadow: 0 1px 3px #000; }

/* ============ PANNEAUX ============ */
.panel {
  position: absolute; z-index: 40; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: #1a1610f5; border: 2px solid #57492e; border-radius: 14px;
  padding: 16px 20px 20px; min-width: 520px; max-width: min(940px, 94vw);
  max-height: 88vh; overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0,0,0,.6);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel h2 { font-size: 19px; color: #e8b04b; letter-spacing: .5px; }
.panel h3 { font-size: 14px; color: #b7a984; margin: 8px 0; }
.pclose { background: none; border: none; color: #8a8065; font-size: 18px; }
.pclose:hover { color: #e8b04b; }
.hint { color: #7a6f55; font-weight: 400; font-size: 12px; }
.panel-cols { display: flex; gap: 22px; flex-wrap: wrap; }
.pcol { flex: 1 1 300px; }
.wbtn {
  display: block; width: 100%; margin-top: 10px; padding: 9px;
  background: #2a2318; color: #e8dcc0; border: 1px solid #57492e; border-radius: 8px; font-size: 13.5px;
}
.wbtn:hover { background: #38301f; border-color: #7a6a45; }
.wbtn.primary { background: linear-gradient(180deg, #d99a33, #a5661d); color: #221a0c; font-weight: 700; border-color: #f4d78a55; }
.wbtn:disabled { opacity: .45; cursor: not-allowed; }

/* inventaire */
.igrid { display: grid; grid-template-columns: repeat(6, 48px); gap: 5px; }
.islot { width: 48px; height: 48px; position: relative; background: #241f16; border: 1px solid #3a3222; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.islot canvas { width: 32px; height: 32px; }
.islot .cnt { position: absolute; bottom: 1px; right: 4px; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.islot.clickable { cursor: pointer; } .islot.clickable:hover { border-color: #e8b04b; }

/* craft */
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; }
.crecipe {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px;
  background: #241f16; border: 1px solid #3a3222; border-radius: 8px; cursor: pointer;
}
.crecipe:hover { border-color: #7a6a45; background: #2a2419; }
.crecipe.no { opacity: .45; cursor: not-allowed; }
.crecipe canvas { width: 30px; height: 30px; flex-shrink: 0; }
.crecipe .cr-name { font-size: 13px; font-weight: 600; }
.crecipe .cr-cost { font-size: 11.5px; color: #9a8f70; }
.cr-cost .ok { color: #9ac88a; } .cr-cost .ko { color: #e07a5b; }

/* recherche */
.tech-stock { display: flex; gap: 14px; margin-bottom: 12px; background: #241f16; padding: 9px 14px; border-radius: 9px; align-items: center; font-size: 13.5px; }
.tech-stock canvas { width: 24px; height: 24px; vertical-align: middle; }
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 9px; }
.tcard { background: #241f16; border: 1px solid #3a3222; border-radius: 10px; padding: 11px 13px; }
.tcard.done { border-color: #3e7a50; background: #16241a; }
.tcard.locked { opacity: .5; }
.tcard.current { border-color: #b78ae8; box-shadow: 0 0 12px #b78ae833; }
.tcard h4 { font-size: 14px; color: #e8dcc0; margin-bottom: 3px; }
.tcard.done h4 { color: #9ac88a; }
.tcard p { font-size: 12px; color: #9a8f70; line-height: 1.4; margin-bottom: 7px; }
.tcard .tcost { display: flex; gap: 9px; font-size: 12px; align-items: center; margin-bottom: 7px; }
.tcard .tcost canvas { width: 20px; height: 20px; }
.tbar { height: 5px; background: #322a44; border-radius: 3px; margin-bottom: 7px; }
.tbar > div { height: 100%; background: #b78ae8; border-radius: 3px; }
.tbtn { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; border: 1px solid #57492e; background: #2a2318; color: #e8dcc0; }
.tbtn:hover:not(:disabled) { border-color: #b78ae8; }
.tbtn:disabled { opacity: .5; cursor: not-allowed; }

/* machine */
#panel-machine { min-width: 460px; }
.mrow { display: flex; align-items: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.mlabel { font-size: 13px; color: #b7a984; min-width: 92px; }
.mslots { display: flex; gap: 5px; flex-wrap: wrap; }
.mbar { flex: 1; height: 14px; background: #241410; border: 1px solid #57492e; border-radius: 7px; overflow: hidden; min-width: 120px; }
.mbar > div { height: 100%; background: linear-gradient(180deg, #e8b04b, #a5661d); transition: width .15s; }
.mbtn { padding: 7px 13px; font-size: 12.5px; border-radius: 7px; border: 1px solid #57492e; background: #2a2318; color: #e8dcc0; }
.mbtn:hover:not(:disabled) { border-color: #e8b04b; }
.mbtn:disabled { opacity: .45; cursor: not-allowed; }
.mwarn { color: #e07a5b; font-size: 13px; }
.mok { color: #9ac88a; font-size: 13px; }
.mrecipes { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 5px; }

/* carte */
#bigmap { display: block; margin: 0 auto; border: 1px solid #3a3222; border-radius: 8px; image-rendering: pixelated; cursor: crosshair; max-width: 84vw; max-height: 68vh; }

/* aide */
.help-body { font-size: 13.5px; line-height: 1.6; color: #cabf9f; max-width: 640px; }
.help-body h3 { color: #e8b04b; margin: 14px 0 5px; font-size: 15px; }
.help-body b { color: #e8dcc0; }
.help-body kbd { background: #322a1c; border: 1px solid #57492e; border-radius: 4px; padding: 1px 6px; font-size: 12px; }

/* overlays */
.overlay {
  position: absolute; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(10, 6, 4, .82); text-align: center;
}
.overlay h1 { font-size: 46px; text-shadow: 0 4px 20px #000; }
#victory .vic-box { background: #1a1610f5; border: 2px solid #c9862b; border-radius: 18px; padding: 36px 48px; max-width: 560px; box-shadow: 0 0 80px rgba(224,160,16,.25); }
#victory h1 { background: linear-gradient(180deg, #f4d78a, #c9862b); -webkit-background-clip: text; background-clip: text; color: transparent; }
.vic-sub { color: #cabf9f; margin: 10px 0 18px; }
#vic-stats { text-align: left; font-size: 14px; background: #241f16; border-radius: 10px; padding: 14px 18px; margin-bottom: 14px; }
#vic-stats div { margin: 3px 0; }

/* scrollbars */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: #16130d; }
::-webkit-scrollbar-thumb { background: #3a3222; border-radius: 5px; }

/* ============ INTERFACE TACTILE ============ */
#mob-ui { display: none; }
body.touch #mob-ui { display: block; }
body.touch #cursor-hint, body.touch #tooltip { display: none !important; }

#joy {
  position: fixed; z-index: 20; width: 124px; height: 124px;
  border-radius: 50%; background: rgba(232, 220, 192, .07);
  border: 2px solid rgba(232, 220, 192, .22);
  pointer-events: none; transform: translate(-50%, -50%);
}
#joyknob {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px;
  border-radius: 50%; background: rgba(232, 176, 75, .38);
  border: 2px solid rgba(232, 176, 75, .65);
  transform: translate(-50%, -50%);
}
#mob-buttons {
  position: fixed; right: calc(8px + env(safe-area-inset-right)); top: 132px;
  display: flex; flex-direction: column; gap: 8px; z-index: 20;
}
#mob-buttons button, #mob-chat {
  width: 46px; height: 46px; font-size: 21px; border-radius: 12px;
  background: #16130dd9; border: 1px solid #57492e; color: #e8dcc0;
}
#mob-buttons button:active { background: #38301f; }
#btn-atk {
  position: fixed; z-index: 20;
  right: calc(18px + env(safe-area-inset-right)); bottom: calc(86px + env(safe-area-inset-bottom));
  width: 72px; height: 72px; border-radius: 50%; font-size: 30px;
  background: radial-gradient(circle at 35% 30%, #a5661d, #6e3f10);
  border: 2px solid #f4d78a66; color: #f0e6c8;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
}
#btn-atk:active { filter: brightness(1.25); transform: scale(.94); }
#btn-act {
  position: fixed; z-index: 20;
  right: calc(24px + env(safe-area-inset-right)); bottom: calc(172px + env(safe-area-inset-bottom));
  width: 62px; height: 62px; border-radius: 50%; font-size: 24px;
  background: radial-gradient(circle at 35% 30%, #3f6a35, #24421f);
  border: 2px solid #9ac88a66; color: #f0e6c8;
  box-shadow: 0 4px 14px rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
}
#btn-act:active { filter: brightness(1.3); transform: scale(.94); }
#btn-act canvas { width: 30px; height: 30px; display: none; }
#btn-act.res canvas, #btn-act.ent canvas { display: block; }
#btn-act.res span, #btn-act.ent span {
  position: absolute; bottom: -2px; right: -2px; font-size: 15px;
  background: #16130de6; border-radius: 50%; width: 24px; height: 24px; line-height: 24px;
}
#btn-act.none { opacity: .4; }
#btn-act.ent { border-color: #5bc6e8aa; background: radial-gradient(circle at 35% 30%, #2f5a6a, #1c3742); }
#placebar {
  position: fixed; z-index: 21; left: 50%; transform: translateX(-50%);
  bottom: calc(150px + env(safe-area-inset-bottom));
  display: flex; gap: 8px;
}
#placebar button {
  padding: 12px 18px; font-size: 16px; font-weight: 700; border-radius: 12px;
  background: #16130de6; border: 1px solid #57492e; color: #e8dcc0;
}
#placebar #pb-ok { background: linear-gradient(180deg, #d99a33, #a5661d); color: #221a0c; border-color: #f4d78a66; }
#placebar #pb-cancel { color: #e07a5b; }

/* ============ PETITS ÉCRANS ============ */
@media (max-width: 900px) {
  .panel { min-width: 94vw; max-width: 94vw; max-height: 92dvh; padding: 12px 12px 40px; }
  .pclose { font-size: 26px; padding: 6px 12px; }
  #minimap { width: 112px; height: 112px; top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); }
  #topbar { top: calc(6px + env(safe-area-inset-top)); left: 8px; transform: none; gap: 6px; }
  #topbar > div { padding: 4px 9px; font-size: 12px; }
  #research-mini { min-width: 110px; }
  #alerts { top: calc(46px + env(safe-area-inset-top)); width: 94vw; }
  .alert { font-size: 12.5px; padding: 6px 12px; }
  #bottombar { bottom: calc(8px + env(safe-area-inset-bottom)); width: 100vw; }
  #hpwrap { width: min(320px, 60vw); }
  #hpbar { height: 16px; } #hptext { font-size: 11px; line-height: 16px; }
  #hotbar { max-width: 96vw; overflow-x: auto; padding: 2px 4px; scrollbar-width: none; }
  #hotbar::-webkit-scrollbar { display: none; }
  .hslot { width: 46px; height: 46px; flex-shrink: 0; }
  .hslot canvas { width: 32px; height: 32px; }
  #chatbox { width: 44vw; bottom: calc(8px + env(safe-area-inset-bottom)); left: calc(8px + env(safe-area-inset-left)); }
  #chatlog { max-height: 84px; }
  #chatlog div { font-size: 11.5px; padding: 3px 8px; }
  .igrid { grid-template-columns: repeat(auto-fill, 46px); }
  #bigmap { max-width: 90vw; max-height: 58dvh; }
  .overlay h1 { font-size: 32px; }
  #victory .vic-box { padding: 22px 20px; max-width: 92vw; }
  .menu-box { padding: 24px 14px; }
  .menu-help { gap: 12px; margin-top: 18px; }
}
