/* DesertWorld — habillage de l'interface
 * Direction : console militaire de terrain, plaques d'acier brun-umbre, chiffres au pochoir,
 * accent ambre « sable chaud ». Un seul univers sombre, assumé. */
:root {
  /* Couleurs */
  --ground: #120d09;      /* fond derrière la carte */
  --panel: #1b1510;       /* plaques de l'interface */
  --panel-2: #241c15;
  --line: #3b2f22;        /* bordures */
  --ink: #e9dcc4;         /* texte principal */
  --ink-dim: #a8977c;     /* texte secondaire */
  --amber: #e8a33a;       /* accent */
  --metal: #cfd2bd;
  --energy: #ffd23a;
  --crystal: #6cb8ff;
  --good: #8ee07a;
  --alert: #ff6a52;
  --violet: #c07ce0;
  /* Typographie */
  --f-display: 'Saira Stencil One', 'Impact', 'Arial Narrow', sans-serif;
  --f-ui: 'Chakra Petch', 'Segoe UI', 'Trebuchet MS', sans-serif;
  --f-num: 'Share Tech Mono', 'Consolas', 'Courier New', monospace;
  --sidebar: 300px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--ground); color: var(--ink); font: 14px/1.4 var(--f-ui); overflow: hidden; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
kbd { font: 12px var(--f-num); background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; color: var(--ink); }

/* ───────── Disposition ───────── */
#app { position: fixed; inset: 0; display: flex; padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
#viewport { position: relative; flex: 1; min-width: 0; overflow: hidden; background: var(--ground); }
#view { display: block; position: absolute; inset: 0; }
#sidebar { width: var(--sidebar); flex: none; background: linear-gradient(180deg, var(--panel-2), var(--panel)); border-left: 2px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }

/* ───────── Barre de ressources ───────── */
#topbar { position: absolute; top: 0; left: 0; right: 0; height: 40px; display: flex; align-items: center; gap: 18px; padding: 0 12px;
  background: linear-gradient(180deg, rgba(27,21,16,0.97), rgba(27,21,16,0.88)); border-bottom: 1px solid var(--line); z-index: 2; }
.res { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.res .ico { width: 14px; height: 14px; flex: none; }
.res.metal .ico { background: var(--metal); clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); }
.res.energy .ico { background: var(--energy); clip-path: polygon(55% 0, 10% 58%, 45% 58%, 35% 100%, 90% 40%, 55% 40%); }
.res.crystal .ico { background: var(--crystal); clip-path: polygon(50% 0, 90% 35%, 50% 100%, 10% 35%); }
.res-name { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); }
.res-val { font: 16px var(--f-num); color: var(--ink); font-variant-numeric: tabular-nums; }
.res-val small { color: var(--ink-dim); font-size: 12px; }
.res-bar { display: inline-block; width: 64px; height: 5px; background: #0006; margin: 0 8px; vertical-align: middle; border: 1px solid var(--line); }
.res-bar i { display: block; height: 100%; background: var(--metal); }
.res-bar.e i { background: var(--energy); }
.res-rate { font: 12px var(--f-num); }
.res-rate.pos { color: var(--good); } .res-rate.neg { color: var(--alert); }
.warn { margin-left: 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: #1b1510; background: var(--alert); padding: 1px 6px; animation: blink 0.8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.45; } }
.spacer { flex: 1; }
#clock { font: 15px var(--f-num); color: var(--ink-dim); }
.tb { background: var(--panel-2); border: 1px solid var(--line); min-width: 34px; height: 26px; padding: 0 8px; font: 13px var(--f-num); white-space: nowrap; }
.tb:hover { border-color: var(--amber); color: var(--amber); }

/* ───────── Objectifs & messages ───────── */
#objectives { position: absolute; top: 50px; left: 10px; width: 270px; background: rgba(27,21,16,0.86); border: 1px solid var(--line); padding: 8px 10px; z-index: 2; pointer-events: none; }
#objectives h3 { margin: 0 0 6px; font: 12px var(--f-ui); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--amber); }
#objectives ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
#objectives li { font-size: 12.5px; display: flex; gap: 8px; align-items: center; color: var(--ink); }
#objectives li b { width: 10px; height: 10px; border: 1.5px solid var(--ink-dim); flex: none; }
#objectives li.done { color: var(--ink-dim); text-decoration: line-through; }
#objectives li.done b { background: var(--good); border-color: var(--good); }
#objectives li.main { font-weight: 700; color: var(--amber); }
#messages { position: absolute; left: 10px; bottom: 12px; width: min(500px, 60%); display: flex; flex-direction: column; gap: 4px; z-index: 2; }
.msg { font-size: 13px; padding: 4px 10px; background: rgba(18,13,9,0.82); border-left: 3px solid var(--ink-dim); text-shadow: 0 1px 0 #000; }
.msg span { font: 11px var(--f-num); color: var(--ink-dim); margin-right: 8px; }
.msg.alert { border-color: var(--alert); color: #ffd0c6; }
.msg.good { border-color: var(--good); }
.msg.loc { cursor: pointer; }
.msg.loc:hover { background: rgba(40,30,20,0.95); }

/* ───────── Barre latérale ───────── */
.mm-wrap { padding: 10px 10px 8px; border-bottom: 1px solid var(--line); }
#minimap { width: 100%; height: auto; display: block; border: 1px solid var(--line); image-rendering: pixelated; cursor: pointer; background: #000; }
#selection { padding: 10px 12px; border-bottom: 1px solid var(--line); min-height: 128px; }
.sel-head { display: flex; gap: 10px; align-items: center; }
.portrait { width: 64px; height: 64px; background: radial-gradient(circle at 50% 40%, #3a2e22, #15100b); border: 1px solid var(--line); flex: none; }
.portrait.creature { background: radial-gradient(ellipse at 50% 50%, #9c8667 0 30%, #4e4031 31% 45%, #15100b 46%); }
.sel-title { font-weight: 700; font-size: 15px; letter-spacing: 0.02em; }
.sel-owner { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); }
.sel-owner.o0 { color: var(--good); } .sel-owner.o1 { color: var(--violet); } .sel-owner.o2 { color: var(--amber); }
.hpbar { position: relative; height: 14px; margin-top: 5px; background: #0008; border: 1px solid var(--line); width: 190px; }
.hpbar i { display: block; height: 100%; }
.hpbar span { position: absolute; inset: 0; font: 11px/12px var(--f-num); text-align: center; color: #fff; text-shadow: 0 1px 1px #000; }
.kvs { display: grid; gap: 2px; margin-top: 8px; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.kv span { color: var(--ink-dim); }
.kv b { font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.desc, .hint { color: var(--ink-dim); font-size: 12px; margin: 8px 0 0; line-height: 1.45; }
.sel-empty .sel-title { margin-bottom: 6px; color: var(--amber); }
.sel-multi { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 8px; }
.mini { position: relative; background: var(--panel-2); border: 1px solid var(--line); padding: 2px; aspect-ratio: 1; }
.mini img { width: 100%; height: 100%; display: block; }
.mini span { position: absolute; right: 2px; bottom: 0; font: 12px var(--f-num); text-shadow: 0 1px 2px #000; }
.mini:hover { border-color: var(--amber); }

#commands { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.cmd-title { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--amber); margin: 10px 0 6px; }
.cmd-title small { font-weight: 400; letter-spacing: 0.02em; text-transform: none; color: var(--ink-dim); margin-left: 4px; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.cmd { position: relative; background: linear-gradient(180deg, #2b2219, #1d1711); border: 1px solid var(--line); padding: 3px 2px 2px; display: flex; flex-direction: column; align-items: center; min-height: 82px; overflow: hidden; }
.cmd img { width: 46px; height: 46px; }
.cmd .lbl { font-size: 10.5px; line-height: 1.1; text-align: center; color: var(--ink); overflow-wrap: anywhere; hyphens: auto; }
.cmd .cost { display: flex; gap: 4px; font: 10.5px var(--f-num); margin-top: auto; }
.cost i, .tcost i { font-style: normal; }
.cost .m { color: var(--metal); } .cost .e { color: var(--energy); }
.tcost .c, .cost .c { color: var(--crystal); }
.cmd:hover { border-color: var(--amber); background: linear-gradient(180deg, #3a2d1f, #241c14); }
.cmd.active { border-color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber); }
.cmd.poor .cost .m { color: var(--alert); }
.cmd.locked { opacity: 0.42; filter: grayscale(0.8); }
.cmd .lock { position: absolute; top: 2px; right: 3px; font-size: 11px; }
.cmd .count { position: absolute; top: 2px; left: 4px; font: 14px var(--f-num); color: var(--amber); text-shadow: 0 1px 2px #000; }
.cmd .prog { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--energy); }
.cmd.producing { border-color: #4b6c7a; }
.grid.actions .cmd { min-height: 56px; justify-content: center; }
.cmd .big { font-size: 20px; line-height: 1.1; color: var(--amber); }
.techs { display: grid; gap: 4px; }
.tech { position: relative; display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); padding: 5px 8px; text-align: left; overflow: hidden; }
.tech .lvl { font: 11px var(--f-num); color: var(--violet); width: 22px; }
.tech .tname { flex: 1; font-size: 12.5px; }
.tech .tcost { font: 12px var(--f-num); }
.tech .prog { position: absolute; left: 0; bottom: 0; height: 2px; width: 0; background: var(--violet); }
.tech.done { opacity: 0.55; } .tech.done .tcost { color: var(--good); }
.tech.locked { opacity: 0.38; }
.tech.can { border-color: #4f6f9a; }
.tech.can:hover, .tech.available:hover { border-color: var(--crystal); }
.tech.here { border-color: var(--violet); }

#tooltip { position: fixed; display: none; z-index: 50; width: 250px; background: #0f0b08f2; border: 1px solid var(--amber); padding: 8px 10px; font-size: 12.5px; pointer-events: none; }
#tooltip b { font-size: 14px; } #tooltip small { color: var(--ink-dim); font-weight: 400; }
#tooltip p { margin: 5px 0 0; color: var(--ink); line-height: 1.4; }
.tt-cost { font: 12px var(--f-num); color: var(--amber); margin-top: 2px; }
.tt-stats { font: 11.5px var(--f-num); color: var(--ink-dim); margin-top: 5px; }
.tt-req { margin-top: 5px; color: var(--violet); font-size: 12px; }

/* ───────── Écrans ───────── */
.screen { position: fixed; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; overflow-y: auto;
  padding-block: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.screen.show { display: flex; }
.screen.dim { background: rgba(10,7,5,0.72); backdrop-filter: blur(2px); }
#screen-start, #screen-loading { background: var(--ground); }
.title-bg { position: absolute; inset: 0; overflow: hidden;
  background:
    radial-gradient(ellipse 60% 35% at 72% 18%, rgba(255,190,110,0.22), transparent 70%),
    radial-gradient(circle at 72% 18%, #ffd9a0 0 3.2%, rgba(255,200,130,0.35) 3.4% 4.4%, transparent 4.6%),
    linear-gradient(180deg, #2a1c14 0%, #6d4126 46%, #b8743c 62%, #3a2516 63%, #1a110b 100%); }
.title-bg::before, .title-bg::after { content: ""; position: absolute; left: -10%; right: -10%; bottom: 0; }
.title-bg::before { height: 44%; background: #4a2f1c; clip-path: polygon(0 40%, 12% 22%, 26% 34%, 41% 14%, 55% 30%, 68% 18%, 82% 32%, 100% 20%, 100% 100%, 0 100%); }
.title-bg::after { height: 30%; background: #24170e; clip-path: polygon(0 30%, 18% 12%, 33% 28%, 50% 8%, 70% 26%, 86% 10%, 100% 22%, 100% 100%, 0 100%); }
.panel { position: relative; background: rgba(23,17,12,0.94); border: 1px solid var(--line); box-shadow: 0 30px 80px #000a; padding: 26px 30px; }
.panel.start { width: min(1180px, 100%); max-height: 100%; overflow-y: auto; }
.brand { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 18px; }
.logo { font: clamp(34px, 6vw, 60px)/1 var(--f-display); letter-spacing: 0.06em; color: var(--amber); text-wrap: balance; }
.logo.small { font-size: 30px; }
.tag { font: 13px var(--f-num); color: var(--ink-dim); letter-spacing: 0.06em; }
.start-grid { display: grid; grid-template-columns: 250px 1.4fr 1fr; gap: 26px; }
.start-grid > * { min-width: 0; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: 6px; }
.brief h2 { margin: 0; font: 600 26px var(--f-ui); color: var(--ink); text-wrap: balance; }
.brief .sub, .sub { color: var(--ink-dim); margin-top: 2px; }
#briefing p { margin: 12px 0 0; line-height: 1.6; max-width: 62ch; color: #d8c9ae; }
#briefing p:first-child { color: var(--ink); }
.side { display: flex; flex-direction: column; gap: 10px; }
.diffs { display: flex; gap: 6px; }
.diffs button { flex: 1; background: var(--panel-2); border: 1px solid var(--line); padding: 8px 4px; }
.diffs button.on { border-color: var(--amber); color: var(--amber); }
button.primary { background: var(--amber); color: #1b1108; border: none; padding: 12px 18px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
button.primary:hover { background: #ffbb55; }
.side .primary { margin: 6px 0 12px; font-size: 16px; }
.keys { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 13px; color: #d8c9ae; }
.mobile-note { display: none; color: var(--alert); font-size: 13px; }
@media (max-width: 1020px) { .start-grid { grid-template-columns: 230px 1fr; } .start-grid .side { grid-column: 1 / -1; } }
@media (max-width: 820px), (pointer: coarse) { .mobile-note { display: block; } .start-grid { grid-template-columns: 1fr; } }
.loading { text-align: center; color: var(--ink-dim); }
.spin { width: 46px; height: 46px; margin: 22px auto; border: 3px solid var(--line); border-top-color: var(--amber); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.small-panel { width: min(420px, 100%); text-align: center; }
.col { display: grid; gap: 8px; margin-top: 18px; }
.col button:not(.primary), .row button:not(.primary) { background: var(--panel-2); border: 1px solid var(--line); padding: 10px; }
.col button:not(.primary):hover, .row button:not(.primary):hover { border-color: var(--amber); }
.row { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }
.end .kvs { text-align: left; margin-top: 16px; }
.end #end-sub { line-height: 1.5; margin-top: 10px; }
#screen-end.won .logo { color: var(--good); }
#screen-end:not(.won) .logo { color: var(--alert); }
.panel.help { width: min(1060px, 100%); }
.help-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin: 16px 0 20px; }
.help-grid > * { min-width: 0; }
.help-grid h3 { margin: 0 0 6px; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--amber); }
.help-grid h3:not(:first-child) { margin-top: 16px; }
.help-grid p { margin: 0 0 8px; font-size: 13px; line-height: 1.5; color: #d8c9ae; }
.help-grid b.m { color: var(--metal); } .help-grid b.e { color: var(--energy); } .help-grid b.c { color: var(--crystal); }
@media (max-width: 900px) { .help-grid { grid-template-columns: 1fr; } }
@media (max-width: 1100px) { :root { --sidebar: 260px; } .res-bar { display: none; } #objectives { width: 230px; } }
@media (prefers-reduced-motion: reduce) { .spin, .warn { animation: none; } }

.cmd .cd { font: 11px var(--f-num); color: var(--energy); }
.cmd.cooling { opacity: 0.55; }
.cmd.launch { border-color: var(--alert); background: linear-gradient(180deg, #4a1a12, #2a0f0a); }
.cmd.launch .big { color: var(--alert); }

.tb.off { opacity: 0.45; text-decoration: line-through; }
.vols { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; margin-top: 18px; text-align: left; font-size: 13px; color: var(--ink-dim); }
.vols input { accent-color: var(--amber); width: 100%; }

.res-split { font: 11px var(--f-num); color: var(--ink-dim); margin-left: 6px; }
.res.energy, .res.metal { cursor: help; }
.tt-sec { margin-top: 7px; font-weight: 600; font-size: 12.5px; color: var(--ink); }
.tt-row { display: flex; justify-content: space-between; gap: 10px; font: 11.5px var(--f-num); color: var(--ink-dim); }
.tt-row small { color: var(--alert); }
#tooltip { width: 320px; }
@media (max-width: 1300px) { .res-split { display: none; } }

/* ───── Campagne ───── */
#mission-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.mis { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; background: var(--panel-2); border: 1px solid var(--line); padding: 7px 10px; }
.mis .n { font: 22px/1 var(--f-display); color: var(--ink-dim); width: 18px; text-align: center; }
.mis .t { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; }
.mis .t small { display: block; font-weight: 400; font-size: 11.5px; color: var(--ink-dim); }
.mis .st { color: var(--good); font-size: 15px; }
.mis:hover:not(.locked) { border-color: var(--amber); }
.mis.on { border-color: var(--amber); background: linear-gradient(90deg, #3a2a18, var(--panel-2)); }
.mis.on .n { color: var(--amber); }
.mis.locked { opacity: 0.45; cursor: not-allowed; }
#btn-load-menu { width: 100%; background: var(--panel-2); border: 1px solid var(--line); padding: 9px; }
#btn-load-menu:hover:not(:disabled) { border-color: var(--amber); color: var(--amber); }
#btn-load-menu:disabled { opacity: 0.4; cursor: default; }

/* ───── Sauvegardes ───── */
.slots-panel { width: min(560px, 100%); }
#slots { display: grid; gap: 8px; margin-top: 16px; }
.slot { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name act" "info act"; gap: 2px 12px; align-items: center; background: var(--panel-2); border: 1px solid var(--line); padding: 9px 12px; }
.sl-name { grid-area: name; font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--amber); }
.sl-info { grid-area: info; font-size: 13px; color: #d8c9ae; }
.sl-info small, .sl-info i { color: var(--ink-dim); }
.sl-act { grid-area: act; display: flex; gap: 6px; }
.sl-act button.primary { padding: 8px 14px; font-size: 13px; }
.sl-act button.primary:disabled { opacity: 0.35; cursor: default; }
.sl-act button:not(.primary) { background: transparent; border: 1px solid var(--line); width: 34px; }
.sl-act button:not(.primary):hover { border-color: var(--alert); color: var(--alert); }
#slots-note { color: var(--alert); min-height: 1em; }

/* ───── Vidéo d'introduction ───── */
#screen-video { background: #000; }
#intro-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
#btn-video-skip { position: absolute; right: 24px; bottom: 22px; background: rgba(27,21,16,0.8); border: 1px solid var(--line); padding: 9px 18px; letter-spacing: 0.08em; z-index: 2; }
#btn-video-skip:hover { border-color: var(--amber); color: var(--amber); }

/* ───── Conseiller (tutoriel) ───── */
#tutorial { position: absolute; top: 50px; left: 50%; transform: translateX(-50%); width: min(470px, calc(100% - 320px)); z-index: 3; display: none;
  background: rgba(23,17,12,0.95); border: 1px solid var(--amber); box-shadow: 0 10px 30px #000a; padding: 10px 14px 12px; }
#tutorial.show { display: block; animation: tutIn 0.35s ease-out; }
.tut-head { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--amber); margin-bottom: 6px; }
.tut-ico { margin-right: 6px; }
.tut-body { font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.tut-body b { color: #ffd38a; }
#tutorial button.primary { margin-top: 10px; padding: 7px 16px; font-size: 13px; }
@keyframes tutIn { from { opacity: 0; transform: translate(-50%, -8px); } }
.tut-hl { position: relative; outline: 2px solid var(--amber); outline-offset: 1px; animation: tutPulse 1s ease-in-out infinite; z-index: 1; }
@keyframes tutPulse { 50% { outline-color: #fff3c4; box-shadow: 0 0 14px 2px rgba(232,163,58,0.7); } }
@media (max-width: 1100px) { #tutorial { left: auto; right: 10px; transform: none; width: min(420px, calc(100% - 260px)); } @keyframes tutIn { from { opacity: 0; } } }
@media (prefers-reduced-motion: reduce) { .tut-hl, #tutorial.show { animation: none; } }

/* objectifs localisés : cliquables, centrent la vue */
#objectives li.loc { pointer-events: auto; cursor: pointer; }
#objectives li.loc:hover { color: #ffd38a; }
#objectives li i { font-style: normal; margin-left: auto; color: var(--amber); font-size: 13px; }

/* ───── Écran titre illustré (background.png à côté d'index.html) ───── */
.title-art { position: absolute; inset: 0; background: url(background.png) center 30% / cover no-repeat; }
.title-art::after { content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse 75% 65% at 50% 55%, rgba(10,7,5,0.35), rgba(10,7,5,0.05) 70%), linear-gradient(180deg, rgba(10,7,5,0.05) 0%, rgba(10,7,5,0.1) 50%, rgba(10,7,5,0.6) 100%); }
#screen-start .panel.start { background: rgba(20,14,10,0.80); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-color: rgba(232,163,58,0.25); }

/* ═════════ Écrans tactiles et petits écrans ═════════ */
html, body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
#view { touch-action: none; }
#minimap { touch-action: none; }
button { touch-action: manipulation; }
.touch-only, .ios-note, .touch-keys { display: none; }
body.touch .touch-only { display: revert; }
body.touch .touch-keys { display: grid; }
body.touch .side .keys:not(.touch-keys) { display: none; }
body.ios-tip .ios-note { display: block; color: var(--amber); font-size: 12.5px; line-height: 1.4; margin: 6px 0 0; }
#btn-fs { display: none; }
body.touch.can-fs #btn-fs { display: inline-block; }
.mobile-note { display: none !important; }

/* objectifs repliables (toucher le titre) */
#objectives h3[data-fold] { pointer-events: auto; cursor: pointer; display: flex; align-items: center; gap: 8px; }
#objectives .fold { margin-left: auto; font: 11px var(--f-num); color: var(--ink-dim); letter-spacing: 0; }
#objectives.flip ul { display: none; }
#objectives.flip h3 { margin-bottom: 0; }
/* conseiller repliable (toucher l'en-tête) */
.tut-head { cursor: pointer; display: flex; align-items: center; }
.tut-fold { margin-left: auto; padding-left: 10px; color: var(--ink-dim); }
#tutorial.min .tut-body, #tutorial.min button { display: none; }
#tutorial.min .tut-head { margin-bottom: 0; }

/* barre tactile */
#touchbar { position: absolute; right: 8px; bottom: 8px; z-index: 3; gap: 6px; }
body.touch #touchbar { display: flex; }
#touchbar button { width: 52px; height: 46px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: rgba(27,21,16,0.88); border: 1px solid var(--line); color: var(--amber); font-size: 19px; line-height: 1; border-radius: 6px; }
#touchbar button span { font: 600 9px var(--f-ui); color: var(--ink-dim); letter-spacing: 0.04em; }
#touchbar button.on { border-color: var(--amber); background: rgba(80,55,20,0.92); box-shadow: inset 0 0 0 1px var(--amber); }
#touchbar button:active { background: rgba(60,45,30,0.95); }
body.touch #messages { bottom: 62px; }

/* téléphone en mode portrait : on demande de tourner l'appareil */
#rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 900px) {
  #rotate { display: flex; position: fixed; inset: 0; z-index: 100; align-items: center; justify-content: center; text-align: center;
    background: var(--ground) url(background.png) 60% 50% / cover no-repeat; padding: 24px; }
  #rotate > div { background: rgba(20,14,10,0.85); border: 1px solid var(--line); padding: 22px 26px; max-width: 320px; }
  #rotate span { display: block; font-size: 46px; color: var(--amber); animation: spin 2.4s ease-in-out infinite; }
  #rotate p { margin: 10px 0 0; font-size: 16px; line-height: 1.4; }
}

/* ───── interface compacte : téléphones (paysage) et petites fenêtres ───── */
@media (max-height: 540px), (max-width: 760px) {
  :root { --sidebar: 212px; }
  body { font-size: 12px; }
  #topbar { height: 30px; gap: 9px; padding: 0 6px; }
  .res { gap: 4px; }
  .res .ico { width: 11px; height: 11px; }
  .res-name, .res-bar, .res-split, #btn-music, #btn-sound { display: none !important; }
  .res-val { font-size: 13px; } .res-val small { font-size: 10px; }
  .res-rate { font-size: 10px; }
  #clock { font-size: 12px; }
  .tb { height: 24px; min-width: 28px; padding: 0 6px; font-size: 12px; }
  .warn { font-size: 9px; padding: 0 4px; margin-left: 4px; }

  #objectives { top: 36px; left: 6px; width: auto; max-width: 230px; padding: 4px 8px; }
  #objectives h3 { font-size: 10.5px; margin-bottom: 3px; }
  #objectives li { font-size: 11px; gap: 6px; }
  #objectives li b { width: 8px; height: 8px; }
  #objectives:not(.flip) ul { display: none; }
  #objectives:not(.flip) h3 { margin-bottom: 0; }
  #objectives.flip ul { display: block; }

  #tutorial { top: 36px; left: auto; right: 6px; transform: none; width: min(380px, calc(100% - 200px)); padding: 6px 10px 8px; max-height: calc(100% - 110px); overflow-y: auto; }
  @keyframes tutIn { from { opacity: 0; } }
  .tut-head { font-size: 9.5px; margin-bottom: 4px; }
  .tut-body { font-size: 12px; line-height: 1.4; }
  #tutorial button.primary { margin-top: 6px; padding: 6px 14px; font-size: 12px; }

  #messages { left: 6px; bottom: 6px; width: min(380px, 55%); gap: 2px; }
  .msg { font-size: 11px; padding: 2px 7px; }
  .msg:nth-last-child(n+4) { display: none; }

  #sidebar { border-left-width: 1px; }
  .mm-wrap { padding: 4px; }
  #selection { padding: 5px 7px; min-height: 0; }
  .sel-head { gap: 6px; }
  .portrait { width: 38px; height: 38px; }
  .sel-title { font-size: 12.5px; }
  .sel-owner { font-size: 9px; }
  .hpbar { width: 120px; height: 11px; margin-top: 3px; }
  .hpbar span { font-size: 9px; line-height: 10px; }
  .kvs { margin-top: 4px; }
  .kv { font-size: 10.5px; }
  .desc, .hint { display: none; }
  .sel-multi { grid-template-columns: repeat(6, 1fr); gap: 2px; margin-top: 4px; }
  .mini span { font-size: 10px; }
  #commands { padding: 2px 6px 10px; }
  .cmd-title { font-size: 9.5px; margin: 6px 0 4px; }
  .grid { grid-template-columns: repeat(3, 1fr); gap: 3px; }
  .cmd { min-height: 60px; padding: 2px 1px 1px; }
  .cmd img { width: 32px; height: 32px; }
  .cmd .lbl { font-size: 8.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .cmd .cost { font-size: 9px; gap: 3px; }
  .cmd .count { font-size: 11px; }
  .grid.actions .cmd { min-height: 40px; }
  .cmd .big { font-size: 16px; }
  .tech { padding: 3px 6px; gap: 5px; }
  .tech .tname { font-size: 10.5px; } .tech .tcost, .tech .lvl { font-size: 10px; }
  #tooltip { width: 220px; font-size: 11px; }
  #touchbar button { width: 46px; height: 40px; font-size: 17px; }
  body.touch #messages { bottom: 54px; }

  /* écrans de menu */
  .screen { padding: 8px; align-items: flex-start; }
  .screen > .panel { margin: auto; }
  .panel { padding: 12px 14px; }
  .brand { padding-bottom: 8px; margin-bottom: 10px; }
  .logo { font-size: 30px; } .logo.small { font-size: 22px; }
  .tag { font-size: 10.5px; }
  .start-grid { grid-template-columns: 200px 1fr; gap: 14px; }
  .start-grid .side { grid-column: 2; }
  .start-grid .campaign { grid-row: span 2; }
  .brief h2 { font-size: 19px; }
  #briefing p { font-size: 12px; margin-top: 6px; line-height: 1.45; }
  .mis { padding: 4px 8px; gap: 8px; } .mis .n { font-size: 17px; } .mis .t { font-size: 12.5px; } .mis .t small { font-size: 10px; }
  #mission-list { gap: 4px; margin-bottom: 8px; }
  .diffs button { padding: 6px 4px; }
  .side { gap: 6px; }
  .side .primary { margin: 2px 0 6px; font-size: 14px; padding: 10px; }
  .keys { font-size: 11.5px; gap: 3px; }
  .col { gap: 6px; margin-top: 10px; }
  .col button:not(.primary), .row button:not(.primary) { padding: 8px; }
  button.primary { padding: 9px 14px; }
  .vols { margin-top: 10px; }
  .row { margin-top: 10px; }
  .end .kvs { margin-top: 8px; }
  .help-grid { grid-template-columns: 1fr 1fr; gap: 14px; margin: 8px 0 10px; }
  .help-grid p, .help-grid li { font-size: 11.5px; }
  #slots { margin-top: 10px; gap: 5px; } .slot { padding: 6px 10px; }
}
@media (max-width: 560px) { .start-grid { grid-template-columns: 1fr; } .start-grid .side { grid-column: auto; } .help-grid { grid-template-columns: 1fr; } }
@media (max-width: 1500px) and (min-height: 541px) { .res-split { display: none; } }
.tut-body b.m { color: var(--metal); } .tut-body b.e { color: var(--energy); } .tut-body b.c { color: var(--crystal); }
/* infobulles des ressources */
#tooltip .tt-row .pos { color: var(--good); } #tooltip .tt-row .neg { color: #ff9a86; }
#tooltip .tt-row span:first-child { font-family: var(--f-ui); }
.tt-tip { margin-top: 8px; padding: 5px 7px; font-size: 12px; line-height: 1.35; border-left: 3px solid var(--good); background: rgba(142,224,122,0.08); }
.tt-tip.warn { border-color: var(--amber); background: rgba(232,163,58,0.1); }
.tt-tip.bad { border-color: var(--alert); background: rgba(255,106,82,0.1); }
.res.energy, .res.metal { cursor: help; }
