:root {
  --bg: #07140a;
  --bg-2: #0a1c0e;
  --panel: #0d1f12;
  --panel-2: #132616;
  --gold: #d4af37;
  --gold-2: #e8c547;
  --gold-dim: #8a7020;
  --text: #e8efe6;
  --muted: #8fa38c;
  --line: rgba(212, 175, 55, 0.28);
  --danger: #c0392b;
  --ok: #4caf6a;
  --front: #e8c547;
  --nav-h: 64px;
  --top-h: 52px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --font: "Oswald", "Segoe UI", system-ui, sans-serif;
  --mono: "Share Tech Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: var(--font);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }

/* Grid état-major */
.hq-bg {
  background:
    linear-gradient(rgba(7,20,10,.88), rgba(7,20,10,.92)),
    repeating-linear-gradient(0deg, transparent, transparent 19px, rgba(212,175,55,.05) 20px),
    repeating-linear-gradient(90deg, transparent, transparent 19px, rgba(212,175,55,.05) 20px),
    radial-gradient(circle at 20% 10%, #1a3a1a 0%, transparent 40%),
    var(--bg);
}

/* Banner maquette — always visible */
.mock-banner {
  flex: 0 0 auto;
  background: #3a2a08;
  color: var(--gold-2);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .06em;
  text-align: center;
  padding: 6px 10px;
  line-height: 1.35;
  z-index: 40;
}
.mock-banner strong { color: #fff3c4; }

/* Landing */
.landing {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(20px + var(--safe-top)) 20px calc(24px + var(--safe-bot));
}
.landing-hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.logo-ww {
  width: 96px; height: 96px; border-radius: 50%;
  border: 3px solid var(--gold); margin-bottom: 18px;
  box-shadow: 0 0 24px rgba(212,175,55,.35);
}
.landing h1 {
  font-size: 42px; letter-spacing: .18em; color: var(--gold);
  text-shadow: 0 0 18px rgba(212,175,55,.35);
  line-height: 1;
}
.landing .tag { margin-top: 8px; color: var(--gold-2); letter-spacing: .12em; font-size: 15px; text-transform: uppercase; }
.landing .pitch { margin: 18px 16px 0; color: var(--text); font-weight: 400; font-size: 16px; line-height: 1.45; max-width: 340px; }
.btn {
  min-height: 52px; padding: 14px 20px; border: none; border-radius: 4px;
  font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  width: 100%; max-width: 360px;
}
.btn-gold { background: var(--gold); color: #0a1408; box-shadow: 0 6px 20px rgba(212,175,55,.28); }
.btn-gold:active { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--gold); border: 1px solid var(--gold); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-row { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; margin-top: 28px; }
.hint { margin-top: 14px; font-size: 13px; color: var(--muted); line-height: 1.4; max-width: 360px; }
.install-help { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 8px; line-height: 1.5; }

/* Shell */
.shell { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  flex: 0 0 auto;
  padding: calc(8px + var(--safe-top)) 12px 8px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--line);
  background: rgba(7,20,10,.94);
  min-height: calc(var(--top-h) + var(--safe-top));
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand img { width: 32px; height: 32px; border-radius: 50%; }
.brand-name { font-size: 16px; letter-spacing: .14em; color: var(--gold); }
.res {
  margin-left: auto; display: flex; gap: 6px; font-family: var(--mono); font-size: 11px;
}
.res b { color: var(--gold); display: block; font-weight: 400; }
.res span { color: var(--muted); font-size: 9px; letter-spacing: .04em; }
.res-item {
  background: var(--panel); border: 1px solid var(--line);
  padding: 4px 7px; min-width: 48px; text-align: center; border-radius: 3px;
}
.icon-btn {
  width: 48px; height: 48px; flex: 0 0 48px;
  background: var(--panel); border: 1px solid var(--line); color: var(--gold);
  border-radius: 4px; position: relative; font-size: 18px;
}
.icon-btn .badge {
  position: absolute; top: 6px; right: 6px; background: var(--danger); color: #fff;
  font-family: var(--mono); font-size: 9px; min-width: 16px; height: 16px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.view { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding-bottom: 8px; }
.nav {
  flex: 0 0 auto;
  display: grid; grid-template-columns: repeat(5, 1fr);
  min-height: calc(var(--nav-h) + var(--safe-bot));
  padding-bottom: var(--safe-bot);
  border-top: 1px solid var(--line);
  background: #0a180c;
}
.nav button {
  background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 56px; font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
}
.nav button .ico { font-size: 18px; line-height: 1; }
.nav button.active { color: var(--gold); }
.nav button.active { box-shadow: inset 0 2px 0 var(--gold); }

/* Panels */
.pad { padding: 12px 14px 20px; }
.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px;
  margin-bottom: 12px;
  position: relative;
}
.panel:before, .panel:after {
  content: ""; position: absolute; width: 10px; height: 10px; border: 1px solid var(--gold);
}
.panel:before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel:after { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.h-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.h-row h2, .panel h2 { font-size: 15px; letter-spacing: .12em; color: var(--gold); text-transform: uppercase; }
.sub { font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* Forms */
label { display: block; font-size: 12px; letter-spacing: .08em; color: var(--gold); text-transform: uppercase; margin: 0 0 6px; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  background: #071209; border: 1px solid var(--line); border-radius: 3px; margin-bottom: 12px;
}
textarea { min-height: 72px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* XP / bars */
.bar { height: 8px; background: #0a140c; border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-dim), var(--gold)); width: 0; transition: width .6s ease; }
.soldier-head { display: flex; gap: 12px; align-items: center; }
.avatar {
  width: 64px; height: 64px; border-radius: 50%; flex: 0 0 64px;
  border: 2px solid var(--gold); display: flex; align-items: center; justify-content: center;
  font-size: 22px; letter-spacing: .04em; color: var(--gold); background: #0a160c;
}
.medals { display: flex; gap: 8px; flex-wrap: wrap; }
.medal {
  width: 48px; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 18px; background: #0a160c; border: 1px solid var(--line); border-radius: 4px;
}
.medal small { font-size: 8px; color: var(--muted); letter-spacing: .04em; text-align: center; padding: 0 2px; }

/* Lists */
.list-item, .mission, .case, .rank-row, .obj, .chat-line, .notif, .country-chip {
  min-height: 48px;
}
.mission, .case, .rank-row, .obj, .notif {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px; border: 1px solid var(--line); background: #0a160c;
  border-radius: 3px; margin-bottom: 8px;
}
.mission button, .case button, .sheet button { min-height: 48px; }
.grow { flex: 1; min-width: 0; }
.mission h3, .case h3, .obj strong, .notif strong { font-size: 14px; letter-spacing: .03em; }
.cd { font-family: var(--mono); color: var(--gold-2); font-size: 12px; }
.tag-pill {
  display: inline-block; font-family: var(--mono); font-size: 10px;
  border: 1px solid var(--line); padding: 2px 6px; color: var(--gold); letter-spacing: .06em;
}
.tag-pill.hot { border-color: var(--danger); color: #f5c4bf; }
.tag-pill.ok { border-color: var(--ok); color: #b8e0c2; }

/* Map */
.map-wrap { position: relative; height: 42vh; min-height: 260px; overflow: hidden; background: #06100a; border-bottom: 1px solid var(--line); touch-action: none; }
.map-svg { width: 100%; height: 100%; display: block; }
.pin {
  cursor: pointer;
}
.pin circle { filter: drop-shadow(0 0 4px rgba(212,175,55,.5)); }
.front-line { stroke: var(--front); stroke-width: 1.6; stroke-dasharray: 6 4; animation: dash 1.6s linear infinite; opacity: .85; }
@keyframes dash { to { stroke-dashoffset: -20; } }
.map-legend { padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: var(--muted); }
.map-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.war-score {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center;
  text-align: center; font-family: var(--mono);
}
.war-score .score { font-size: 22px; color: var(--gold); }
.map-tools { position: absolute; right: 8px; bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.map-tools button { width: 48px; height: 48px; background: rgba(13,31,18,.92); border: 1px solid var(--gold); color: var(--gold); border-radius: 4px; font-size: 20px; }

/* Chat */
.chat { display: flex; flex-direction: column; height: 100%; }
.chat-log { flex: 1; overflow: auto; padding: 12px 14px; }
.chat-line { margin-bottom: 8px; }
.chat-line .who { color: var(--gold); font-size: 12px; }
.chat-line .msg { font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.chat-line.me .who { color: var(--gold-2); }
.chat-form { display: flex; gap: 8px; padding: 8px 12px calc(8px + var(--safe-bot)); border-top: 1px solid var(--line); }
.chat-form input { margin: 0; flex: 1; }
.chat-form button { width: auto; min-width: 72px; padding: 0 12px; flex: 0 0 auto; }

/* Sheets / toasts */
.sheet-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 520px; max-height: 82vh; overflow: auto;
  background: var(--panel); border-top: 1px solid var(--gold);
  padding: 16px 16px calc(20px + var(--safe-bot));
  border-radius: 12px 12px 0 0;
}
.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  top: calc(var(--safe-top) + 86px);
  bottom: auto;
  background: #1a2e14; border: 1px solid var(--gold); color: var(--gold-2);
  padding: 10px 14px; border-radius: 4px; z-index: 70; opacity: 0;
  transition: .25s ease; font-size: 14px; max-width: 90%; text-align: center;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Tabs inside views */
.seg { display: flex; gap: 6px; margin-bottom: 12px; }
.seg button {
  flex: 1; min-height: 44px; background: #0a160c; border: 1px solid var(--line);
  color: var(--muted); letter-spacing: .08em; text-transform: uppercase; font-size: 12px;
}
.seg button.on { color: #0a1408; background: var(--gold); border-color: var(--gold); }

.story { font-size: 15px; line-height: 1.55; color: var(--text); }
.kicker { font-family: var(--mono); font-size: 11px; color: var(--gold); letter-spacing: .12em; text-transform: uppercase; margin-bottom: 6px; }

.hidden { display: none !important; }
@media (max-width: 360px) {
  .landing h1 { font-size: 34px; }
  .res { gap: 4px; font-size: 10px; }
  .res-item { padding: 4px 5px; min-width: 42px; }
}

.flag-img {
  width: 32px; height: 21px; object-fit: cover; flex: 0 0 32px;
  border: 1px solid rgba(212,175,55,.4); border-radius: 2px;
  background: #071209; display: inline-block; vertical-align: middle;
}
.nation-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.who .flag-img { width: 22px; height: 15px; flex-basis: 22px; }
.country-pick {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 48px; padding: 8px 10px; margin-bottom: 6px;
  background: #0a160c; border: 1px solid var(--line); color: var(--text);
  text-align: left; border-radius: 3px; text-transform: none;
  letter-spacing: 0; font-weight: 500; font-size: 15px;
}
.country-pick.on { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.country-pick .sub { display: block; }
.featured { margin-bottom: 12px; }
.country-results, .map-hits { max-height: 40vh; overflow: auto; margin: 0 0 12px; -webkit-overflow-scrolling: touch; }
.map-hits { max-height: 30vh; }
#f-country-search, #map-search { margin-bottom: 8px; }
