/* 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: #7dd8ff;
  --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(980px, 100%); }
.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: 1.4fr 1fr; gap: 28px; }
.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: 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: 290px; }
@media (max-width: 1300px) { .res-split { display: none; } }
