:root {
  --bg: #1b1510;
  --bar: #241b14;
  --panel: rgba(28, 21, 15, 0.86);
  --panel-solid: #2a2018;
  --line: rgba(232, 200, 150, 0.14);
  --line-strong: rgba(232, 200, 150, 0.28);
  --text: #f3e9d8;
  --muted: #b9a68b;
  --accent: #e9b44c;
  --accent-ink: #2b1d08;
  --leaf: #5f8f35;
  --leaf-hi: #77aa45;
  --good: #96d46f;
  --bad: #ff8c7a;
  --warn: #ffb070;
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --title: "Bree Serif", Georgia, serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }
body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  overflow: hidden;
}

/* ---------- boutons ---------- */
button, select {
  font: inherit;
  font-weight: 700;
  color: var(--text);
}
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: 0;
  border-radius: 7px;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, transform 0.08s;
}
button:hover { background: rgba(255, 255, 255, 0.08); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: default; }
button.active { background: var(--accent); color: var(--accent-ink); }
button.primary { background: var(--leaf); color: #fff; }
button.primary:hover { background: var(--leaf-hi); }
select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 8px;
}
select option { background: var(--panel-solid); }
.ic { width: 18px; height: 18px; flex: none; }
[data-only].off { display: none !important; }
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  background: rgba(255, 255, 255, 0.06);
  font: 700 12px/1.5 var(--font);
  text-align: center;
  color: var(--text);
}

/* ---------- barre du haut ---------- */
#topbar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 12px;
  background: linear-gradient(180deg, #2c2118, var(--bar));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  position: relative;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font: 22px/1 var(--title); letter-spacing: 0.3px; color: #f6e2bd; }
.brand .logo { width: 28px; height: 28px; color: var(--accent); }
.clock {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 11px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.clock .ic { color: var(--accent); }
.clock.night .ic { color: #b7c6ff; }
.clock.rain .ic { color: #8fc3ff; }
.seg {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
}
.spacer { flex: 1; }

/* ---------- scène ---------- */
#stage { position: relative; flex: 1; min-height: 0; }
#view { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#view:active { cursor: grabbing; }
#view.tool-harvest, #view.tool-attack { cursor: crosshair; }

/* ---------- panneaux ---------- */
.panel {
  position: absolute;
  top: 12px;
  width: 300px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px 14px 10px;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.panel.left { left: 12px; }
.panel.right { right: 12px; max-height: calc(100% - 200px); }
.panel.hidden, .panel.collapsed { display: none; }

details { border-bottom: 1px solid var(--line); padding: 4px 0 8px; }
details:last-child { border-bottom: 0; }
summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 0 6px;
  font: 16px var(--title);
  color: #f6e2bd;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: '';
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s;
}
details[open] > summary::after { transform: rotate(-135deg); }

.close { position: absolute; top: 10px; right: 10px; padding: 5px; z-index: 1; }

.row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.row span:first-child { color: var(--muted); }
.row b { font-variant-numeric: tabular-nums; text-align: right; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: middle; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25); }
.sep { border-top: 1px dashed var(--line); margin: 7px 0; }

.legend { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 18px; height: 6px; border-radius: 3px; margin-right: 7px; vertical-align: middle; }

.bar { margin: 7px 0; }
.bar .lbl { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 600; }
.bar .track { height: 8px; border-radius: 5px; background: rgba(255, 255, 255, 0.07); overflow: hidden; margin-top: 3px; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4); }
.bar .fill { height: 100%; border-radius: 5px; transition: width 0.3s; background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0)); }

.antHead { display: flex; align-items: center; gap: 10px; margin: 8px 30px 2px 0; }
.antBadge { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.15); }
.antBadge svg { width: 26px; height: 26px; color: rgba(255, 255, 255, 0.55); }
.antName { font: 19px/1.2 var(--title); }
.role { display: inline-block; font-size: 12px; font-weight: 700; color: var(--muted); }
.thought {
  position: relative;
  margin: 12px 0 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(233, 180, 76, 0.12);
  border: 1px solid rgba(233, 180, 76, 0.25);
  font-style: italic;
}
.dead .thought { background: rgba(255, 120, 100, 0.1); border-color: rgba(255, 120, 100, 0.3); }

.actions { display: flex; gap: 6px; margin: 10px 0 4px; }
.actions button { flex: 1; background: rgba(255, 255, 255, 0.07); }
.actions button.active { background: var(--accent); }
.actions button.primary { background: var(--leaf); }

.log { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.log li { padding: 5px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.log li .t { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; font-size: 11.5px; }
.log li.good { color: var(--good); }
.log li.bad { color: var(--bad); }
.log li.danger { color: var(--warn); font-weight: 700; }
.log li .n { color: var(--accent); margin-left: 4px; font-weight: 700; }

/* ---------- ordres ---------- */
.olabel { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 5px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }
.seg.full { display: flex; }
.seg.full button { flex: 1; padding: 6px 4px; font-size: 12.5px; }
.orow { display: flex; gap: 6px; }
.orow button:first-child { flex: 1; }
button.soft { background: rgba(255, 255, 255, 0.07); }
button.soft.active { background: var(--accent); color: var(--accent-ink); }
button.wide { width: 100%; margin-top: 10px; }
button.recall-on { background: #3d6fb0; color: #fff; }
button.link { padding: 0 4px; font-size: 11px; color: var(--accent); text-transform: none; letter-spacing: 0; text-decoration: underline; }
.ohint { margin-top: 6px; font-size: 12px; color: var(--muted); line-height: 1.35; }
.ohint:empty { display: none; }
.ohint b { color: var(--text); }
.slider { display: grid; grid-template-columns: 92px 1fr 64px; align-items: center; gap: 8px; margin: 4px 0; font-size: 12.5px; }
.slider span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slider b { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }
.slider b em { font-style: normal; font-weight: 600; color: var(--muted); }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* ---------- mini-carte ---------- */
#minimap {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
}
#mini { display: block; width: 210px; height: 140px; border-radius: 8px; cursor: pointer; touch-action: none; }

/* ---------- aides ---------- */
.hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  background: rgba(36, 60, 22, 0.92);
  border: 1px solid #6b9a40;
  border-radius: 12px;
  font-size: 13px;
  max-width: min(760px, calc(100% - 270px));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.hint kbd { margin-right: 2px; }
.hint.hidden { display: none; }

.tip {
  position: absolute;
  pointer-events: none;
  max-width: 240px;
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(20, 15, 10, 0.94);
  border: 1px solid var(--line-strong);
  font-size: 12.5px;
  line-height: 1.35;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 4;
}
.tip.show { opacity: 1; }
.tip b { font-family: var(--title); font-weight: 400; font-size: 14px; }
.tip .m { color: var(--muted); }

#toast {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translate(-50%, -8px);
  padding: 9px 18px;
  border-radius: 22px;
  background: rgba(24, 18, 12, 0.94);
  border: 1px solid var(--accent);
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  max-width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 4;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.danger { border-color: var(--warn); color: #ffd9b3; }

/* ---------- tableau de bord de la fourmi jaune ---------- */
.hud {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
  padding: 9px 14px;
  max-width: min(860px, calc(100% - 270px));
  background: var(--panel);
  border: 1px solid rgba(226, 173, 43, 0.5);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(226, 173, 43, 0.1) inset;
  backdrop-filter: blur(10px);
  z-index: 3;
}
.hud.hidden { display: none; }
.hud-id { display: flex; align-items: center; gap: 9px; }
.hud-id b { display: block; font: 15px/1.2 var(--title); }
.hud-id span { font-size: 12px; color: var(--muted); }
.antBadge.small { width: 32px; height: 32px; }
.antBadge.small svg { width: 21px; height: 21px; }
.antBadge.yellow { background: #e2ad2b; }
.antBadge.yellow svg { color: rgba(60, 35, 0, 0.75); }
.hud-bars { display: grid; gap: 3px; min-width: 150px; }
.hud-bars div { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.hud-bars i { display: block; height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.hud-bars em { display: block; height: 100%; border-radius: 4px; transition: width 0.3s; }
.hud-group { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.hud-group b { font: 22px var(--title); color: #f3c75a; }
.hud-group span { font-size: 11px; color: var(--muted); }
.hud-actions { display: flex; gap: 4px; }
.hud-actions button { background: rgba(255, 255, 255, 0.07); padding: 5px 8px; font-size: 12.5px; }
.hud-actions kbd { margin-right: 2px; min-width: 18px; padding: 0 4px; font-size: 11px; }
.hud-hint { width: 100%; text-align: center; font-size: 12px; color: var(--muted); }
.hud-hint kbd { min-width: 18px; padding: 0 4px; font-size: 11px; }

/* ---------- jardin ---------- */
.parcel-badge {
  padding: 5px 11px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}
.parcel-badge.hidden { display: none; }
.scen-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; margin: 8px 0 4px; }
.scen-pick.hidden { display: none; }
.scen-pick button { white-space: normal; min-width: 0; text-align: left; align-items: flex-start; justify-content: flex-start; padding: 7px 9px; border-radius: 10px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; line-height: 1.3; }
.scen-pick button b { font-size: 13px; }
.scen-pick button span { color: var(--muted); }
.scen-pick button.active { border-color: var(--accent); background: rgba(233, 180, 76, 0.16); color: var(--text); }
.scen-pick button.active span { color: #e9dcc4; }
.scen-pick button .done { color: var(--good); font-weight: 700; }
.scen-pick .scen-detail { grid-column: 1 / -1; text-align: left; font-size: 12.5px; padding: 6px 4px; color: var(--text); }
.scen-box { display: flex; flex-direction: column; gap: 2px; padding: 4px 12px; border-radius: 12px; background: rgba(20, 14, 9, 0.75); border: 1px solid rgba(233, 180, 76, 0.5); font-size: 12px; min-width: 180px; max-width: 340px; }
.scen-box.hidden { display: none; }
.mission-box { position: fixed; top: 64px; right: 12px; z-index: 15; pointer-events: none; display: flex; flex-direction: column; gap: 3px; padding: 4px 12px; border-radius: 12px; background: rgba(20, 14, 9, 0.78); border: 1px solid rgba(143, 209, 106, 0.55); font-size: 12px; max-width: 380px; }
.mission-box.hidden { display: none; }
.mission-box .m-title { color: #b9f08f; font-weight: 700; font-size: 12.5px; }
.mission-box .m-title.urgent { color: #ff9a7a; }
.mission-box .m-goal { color: #e6d9c2; line-height: 1.3; }
.mission-box .m-goal.ok { color: #8fd16a; text-decoration: line-through; opacity: 0.8; }
.hud-phero { display: flex; gap: 3px; align-items: center; }
.hud-lives { display: block; font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.hud-lives b { color: #ffd760; letter-spacing: 2px; }
.hud-phero button { padding: 3px 6px; font-size: 11px; border-radius: 8px; display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.hud-phero button i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.hud-phero button.active { border-color: var(--accent); background: rgba(233, 180, 76, 0.18); color: var(--text); }
.hud-phero button.laying { animation: tutoPulse 1s infinite; border-color: #ffb06b; }
.hud-phero kbd { font-size: 10px; padding: 0 3px; }
label.check.hidden, .cta button.hidden { display: none; }
.scen-box b { color: #ffd86b; font-size: 12.5px; }
.scen-bar { display: block; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.scen-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.olabel.center { justify-content: center; margin-top: 16px; }
.card.garden-card { width: min(880px, 100%); position: relative; }
.card.garden-card h2 { margin: 0; font: 30px var(--title); color: #f8e5c2; }
.sub.small { font-size: 13px; margin-bottom: 12px; }
#gardenGrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.parcel {
  position: relative;
  aspect-ratio: 3 / 2;
  border-radius: 9px;
  padding: 5px 6px;
  text-align: left;
  font-size: 11px;
  color: #fff;
  cursor: pointer;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.parcel:hover { border-color: rgba(255, 255, 255, 0.5); }
.parcel.sel { border-color: var(--accent); }
.parcel.here { box-shadow: inset 0 0 0 3px #ffd86b; }
.parcel b { font: 15px var(--title); }
.parcel .t { opacity: 0.85; }
.parcel.house { background: repeating-conic-gradient(#d8cab0 0 25%, #c4b394 0 50%) 0 0 / 22px 22px !important; color: #2c2116; }
.parcel .hic { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }
.pbars { display: grid; gap: 2px; }
.pbar { height: 5px; border-radius: 3px; background: rgba(0, 0, 0, 0.3); overflow: hidden; }
.pbar i { display: block; height: 100%; border-radius: 3px; }
.pbar.black i { background: #1a120c; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35) inset; }
.pbar.red i { background: #e0482e; }
.pbar.amazon i { background: #e8933a; }
.garden-legend { display: flex; gap: 16px; justify-content: center; margin: 10px 0 4px; font-size: 12px; color: var(--muted); }
.lg { display: inline-block; width: 14px; height: 6px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.lg.black { background: #1a120c; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4); }
.lg.red { background: #e0482e; }
.lg.amazon { background: #e8933a; }
.lg.here { background: #ffd86b; }
#gardenInfo { margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line); text-align: left; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
#gardenInfo .gi { flex: 1; min-width: 220px; font-size: 13px; }
#gardenInfo .gi b { font: 17px var(--title); font-weight: 400; }
@media (max-width: 700px) {
  #gardenGrid { gap: 3px; }
  .parcel { font-size: 9px; padding: 3px; }
  .parcel b { font-size: 12px; }
  .parcel .t { display: none; }
}

/* ---------- écran d'accueil ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(30, 22, 14, 0.55), rgba(10, 7, 4, 0.85));
  backdrop-filter: blur(5px);
  transition: opacity 0.35s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.card {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 26px 28px 20px;
  border-radius: 20px;
  background: linear-gradient(180deg, #33261b, #241a12);
  border: 1px solid var(--line-strong);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  text-align: center;
}
.card .hero { width: 74px; height: 74px; color: var(--accent); filter: drop-shadow(0 4px 10px rgba(233, 180, 76, 0.35)); }
.card h1 { margin: 4px 0 6px; font: 40px/1.1 var(--title); color: #f8e5c2; }
.card .sub { margin: 0 auto 18px; max-width: 460px; color: #e3d3bb; }
.keys {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  text-align: left;
  padding: 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  font-size: 13px;
}
.keys div { display: flex; align-items: center; gap: 4px; }
.keys span { margin-left: 4px; color: #e3d3bb; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 12px; }
.modes.single { grid-template-columns: 1fr; }
.rebirth-card { max-width: 560px; }
.rebirth-list { display: grid; gap: 8px; margin-top: 12px; }
.rebirth-list button { display: grid; grid-template-columns: 34px 1fr auto; gap: 4px 10px; align-items: center; text-align: left; padding: 9px 12px; border-radius: 12px; white-space: normal; }
.rebirth-list button .dot { width: 26px; height: 26px; border-radius: 50%; grid-row: span 2; border: 2px solid rgba(255, 255, 255, 0.25); }
.rebirth-list button b { font-size: 14px; }
.rebirth-list button .n { color: var(--muted); font-size: 12px; }
.rebirth-list button .d { grid-column: 2 / 4; font-size: 12px; color: #d8cbb2; line-height: 1.35; }
.rebirth-list button .d em { color: #ffb070; font-style: normal; }
.rebirth-list button:disabled { opacity: 0.4; }
button.mode {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  text-align: left;
  white-space: normal;
}
button.mode .ic { width: 26px; height: 26px; }
button.mode b { font: 16px var(--title); font-weight: 400; }
button.mode span { font-size: 12.5px; font-weight: 600; opacity: 0.85; line-height: 1.35; }
button.mode.primary { background: linear-gradient(180deg, #6a9a3a, #557e2e); border-color: #7cb04a; }
button.mode.primary .ic { color: #ffd760; }
.opts { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 20px 0 6px; }
.endStats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; text-align: left; padding: 12px 16px; border-radius: 12px; background: rgba(0, 0, 0, 0.2); border: 1px solid var(--line); }
.card.win h1 { color: #ffd86b; }
.card.win .hero { color: #ffd86b; }
.card.lose h1 { color: #ff9a86; }
.card.lose .hero { color: #b05a48; filter: none; }
.seg button.rival-tab.active { background: #b0402a; color: #fff; }
button.big { padding: 11px 20px; font-size: 15px; border-radius: 11px; }
.cta button:not(.primary) { background: rgba(255, 255, 255, 0.08); }
.check { display: inline-flex; gap: 7px; align-items: center; color: var(--muted); font-size: 13px; cursor: pointer; }

/* ---------- écrans moyens et petits ---------- */
@media (max-width: 1500px) {
  #btnPhero .lbl { display: none; }
}
@media (max-width: 900px) {
  .brand span { display: none; }
  #viewGroup .lbl { display: none; }
  .spacer { display: none; }
  .panel { width: calc(100% - 24px); max-height: 46%; }
  .panel.left { display: none; }
  .panel.left.open { display: block; }
  .panel.right { top: auto; bottom: 12px; right: 12px; max-height: 50%; }
  #minimap { display: none; }
  .hint { top: 12px; bottom: auto; max-width: calc(100% - 24px); }
  .hud { max-width: calc(100% - 24px); gap: 6px 10px; }
  .hud-hint { display: none; }
  .modes { grid-template-columns: 1fr; }
  #toast { top: 150px; }
  .keys { grid-template-columns: 1fr; }
}
@media (min-width: 560px) and (max-width: 900px) {
  .keys { grid-template-columns: 1fr 1fr; }
}

/* ---------- sauvegardes ---------- */
.saves-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 14px 0 4px; }
.saves-row button { background: rgba(255, 255, 255, 0.08); padding: 9px 16px; border-radius: 10px; }
.saves-row #btnContinueSave { background: linear-gradient(180deg, #c8952f, #a8771f); color: #fff; }
.saves-row .hidden { display: none; }
.card.save-card { width: min(640px, 100%); position: relative; text-align: left; }
.card.save-card h2 { margin: 0 0 6px; font: 30px var(--title); color: #f8e5c2; text-align: center; }
.card.save-card .sub { text-align: center; }
#saveSlots { display: flex; flex-direction: column; gap: 8px; }
.slot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08); }
.slot.empty .sinfo span { opacity: 0.55; }
.slot .sinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.slot .sinfo b { font: 16px var(--title); font-weight: 400; color: #f3dfb9; }
.slot .sinfo .when { font-size: 12px; color: var(--muted); }
.slot .sbtns { display: flex; gap: 6px; flex-shrink: 0; }
.slot .sbtns button { padding: 7px 11px; border-radius: 9px; background: rgba(255, 255, 255, 0.09); font-size: 13px; }
.slot .sbtns button.primary { background: var(--leaf); }
.slot .sbtns button.del { padding: 7px 9px; }
.save-files { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.save-files button { background: rgba(255, 255, 255, 0.08); padding: 9px 14px; border-radius: 10px; }
@media (max-width: 560px) {
  .slot { flex-direction: column; align-items: stretch; }
  .slot .sbtns { justify-content: flex-end; }
}
button.wide.hidden { display: none; }

/* ---------- triangles de répartition ---------- */
.tri-box { max-width: 270px; margin: 2px auto 0; user-select: none; }
.tri-box .tri { width: 100%; display: block; touch-action: none; cursor: crosshair; }
.tri-box .hdl circle { fill: #fff8e4; stroke: #2a2014; stroke-width: 3; }
.tri-box .hdl line { stroke: rgba(255, 248, 228, 0.7); stroke-width: 1.5; }
.tri-top, .tri-bottom div { font-size: 11.5px; color: var(--muted); line-height: 1.15; }
.tri-top { text-align: center; }
.tri-top b, .tri-bottom b { display: block; font: 17px var(--title); font-weight: 400; color: #f3dfb9; }
.tri-bottom { display: flex; justify-content: space-between; margin-top: -2px; }
.tri-bottom .r { text-align: right; }
.ohint.advice { margin: 4px 0 8px; }
.ohint .warn { color: #ffb36b; }
.ohint .ok { color: #9fdc6a; }

/* ---------- guerre entre parcelles ---------- */
.war-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; width: 100%; margin-top: 8px; }
.war-btns button.war { background: #a8402e; color: #fff; padding: 9px 14px; border-radius: 10px; }
.war-btns button.war:hover { background: #c04a35; }
.war-btns .m { color: var(--muted); font-size: 13px; }
.exp-list { width: 100%; margin-top: 8px; font-size: 12.5px; color: #ffc9a8; }
.parcel .war-mark { color: #ff6a50; margin-left: 4px; }

/* objectifs du jardin */
#gardenSummary .obj { display: inline-block; width: 1.2em; color: var(--muted); font-weight: 800; }
#gardenSummary .obj.done { color: #9fdc6a; }

/* ---------- historique ---------- */
.card.history-card { width: min(1000px, 100%); position: relative; text-align: left; }
.card.encyclo-card { width: min(980px, 100%); height: min(88vh, 760px); position: relative; text-align: left; display: flex; flex-direction: column; }
.card.encyclo-card h2 { margin: 0 0 10px; font: 28px var(--title); color: #f8e5c2; text-align: center; }
.encyclo-wrap { display: grid; grid-template-columns: 210px 1fr; gap: 14px; flex: 1; min-height: 0; }
.encyclo-nav { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.encyclo-nav button { text-align: left; justify-content: flex-start; padding: 8px 10px; border-radius: 10px; font-size: 13.5px; white-space: normal; }
.encyclo-nav button .n { display: inline-block; width: 20px; color: var(--muted); }
.encyclo-nav button.active { background: rgba(233, 180, 76, 0.18); border-color: var(--accent); color: var(--text); }
.encyclo-body { overflow-y: auto; padding-right: 8px; }
.encyclo-body h3 { font: 24px var(--title); color: #ffd86b; margin: 2px 0 10px; }
.encyclo-body section { margin-bottom: 14px; overflow: hidden; }
.encyclo-body h4 { margin: 0 0 4px; font-size: 15.5px; color: #f3dcb4; }
.encyclo-body p { margin: 0; font-size: 14px; line-height: 1.55; color: #e6d9c2; }
.encyclo-body .ill { float: right; display: flex; gap: 6px; margin: 0 0 6px 12px; }
.encyclo-body .ill canvas { border-radius: 10px; border: 1px solid rgba(255, 220, 160, 0.2); }
@media (max-width: 720px) {
  .encyclo-wrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .encyclo-nav { flex-direction: row; flex-wrap: wrap; }
  .encyclo-body .ill { float: none; margin: 0 0 6px; }
}
.card.history-card h2 { margin: 0; font: 30px var(--title); color: #f8e5c2; text-align: center; }
.card.history-card .sub { text-align: center; }
.hcharts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hcharts.hidden, .htable.hidden, .hchart.hidden { display: none; }
.hchart { background: #221a13; border: 1px solid var(--line); border-radius: 12px; padding: 10px 10px 6px; min-width: 0; }
.hchart.wide { grid-column: 1 / -1; }
.hchart .ht { font: 15px var(--title); color: #f3dfb9; }
.hleg { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 3px 0 4px; font-size: 12px; color: var(--muted); min-height: 4px; }
.hleg i, .htip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hplot { position: relative; height: 170px; }
.hplot canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.htip { position: absolute; pointer-events: none; min-width: 150px; padding: 7px 9px; border-radius: 9px; background: rgba(18, 13, 9, 0.95); border: 1px solid var(--line-strong); font-size: 12px; color: var(--text); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); z-index: 2; }
.htip .h { font-weight: 800; margin-bottom: 3px; }
.htip .r { display: flex; align-items: center; gap: 4px; }
.htip .r span { flex: 1; color: var(--muted); }
.htip .r.tot { border-top: 1px solid var(--line); margin-top: 3px; padding-top: 3px; }
.htable { max-height: 60vh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.htable table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.htable th { position: sticky; top: 0; background: #2a2018; color: var(--muted); font-weight: 700; padding: 7px 8px; text-align: right; }
.htable td { padding: 5px 8px; text-align: right; border-top: 1px solid var(--line); }
.htable th:first-child, .htable td:first-child { text-align: left; }
.hfoot { display: flex; justify-content: center; margin-top: 12px; }
.hfoot button { background: rgba(255, 255, 255, 0.08); padding: 9px 16px; border-radius: 10px; }
@media (max-width: 760px) { .hcharts { grid-template-columns: 1fr; } }

/* ---------- tutoriel ---------- */
.tuto { position: absolute; top: 12px; left: 12px; width: min(360px, calc(100% - 24px)); z-index: 30; padding: 12px 14px 10px; border-radius: 14px;
  background: rgba(26, 19, 12, 0.96); border: 1px solid var(--accent); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.tuto.hidden { display: none; }
.tuto-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.tuto b#tutoTitle { display: block; margin: 4px 0 2px; font: 18px var(--title); font-weight: 400; color: #ffd86b; }
.tuto p { margin: 0 0 8px; font-size: 13.5px; line-height: 1.45; }
.tuto kbd { font-size: 11px; }
.tuto-bar { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); overflow: hidden; margin-bottom: 8px; }
.tuto-bar i { display: block; height: 100%; background: var(--accent); transition: width 0.3s; }
.tuto-btns { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.tuto-btns .hidden { display: none; }
.tuto-btns .primary { padding: 7px 16px; border-radius: 9px; }
button.tuto-start { width: 100%; margin: 4px 0 12px; padding: 10px 14px; border-radius: 12px; background: rgba(233, 180, 76, 0.14); border: 1px solid var(--accent); color: var(--text); display: flex; align-items: center; gap: 10px; justify-content: center; }
button.tuto-start b { color: #ffd86b; }
.tuto-hl { animation: tutoPulse 1.1s ease-in-out infinite; position: relative; z-index: 2; }
@keyframes tutoPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 215, 90, 0.9); } 50% { box-shadow: 0 0 0 6px rgba(255, 215, 90, 0); } }
@media (max-width: 560px) { .tuto { top: auto; bottom: 150px; } }
