/* Ink & Signal. Keep these UI tokens aligned with config.theme / graphics.palette. */
:root {
  --mek-ink: #202725;
  --mek-deep: #18201d;
  --mek-panel: #2b3430;
  --mek-hover: #35423b;
  --mek-ivory: #f3e7cf;
  --mek-muted: #bdc0ae;
  --mek-border: #647168;
  --mek-signal: #d95338;
  --mek-energy: #8ecbb7;
  --mek-ochre: #ddb35b;
  --mek-danger: #f1876d;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--mek-ink);
}
body:has(.mek-wrap) .mm-seo {
  display: none;
}
/* Native title actions use fixed blue/green fills rather than theme tokens.
   Recolor those buttons only; the shell retains layout, focus and behavior. */
.mm-root .mm-menu-btn[data-menu="join"] {
  background: var(--mek-panel);
  color: var(--mek-ivory);
  border: 1px solid var(--mek-signal);
  box-shadow: none;
}
.mm-root .mm-menu-btn[data-menu="lobby"] {
  background: var(--mek-ivory);
  color: var(--mek-ink);
  border: 1px solid var(--mek-ivory);
  box-shadow: none;
}
.mm-root .mm-menu-btn[data-menu="join"]:hover { background: var(--mek-hover); }
.mm-root .mm-menu-btn[data-menu="lobby"]:hover { background: var(--mek-ochre); }
/* Picker dialogs mount outside .mm-root, directly under the document. */
.mm-modal-loadout .mm-lo-pro { color: var(--mek-energy) !important; }
.mm-modal-loadout .mm-lo-con { color: var(--mek-ochre) !important; }
.mek-wrap {
  position: relative;
  overflow: hidden;
  font-family: "Trebuchet MS", system-ui, sans-serif;
  color: var(--mek-ivory);
  isolation: isolate;
  --mek-bottom: 84px;
}
.mek-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}
.mek-deployment-still {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.mek-wrap.mek-deploying { background: var(--mek-ink); }
.mek-deploying > :not(.mek-deployment-still) { visibility: hidden; }
.mek-deploying > .mek-deployment-still { display: block; }
.mek-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.mek-brand {
  position: absolute;
  top: max(18px, var(--mm-safe-top, 0px));
  left: 22px;
  background: #202725f2;
  padding: 14px 22px 12px;
  border-left: 3px solid var(--mek-signal);
  clip-path: polygon(0 0, 100% 0, 100% 80%, 94% 100%, 0 100%);
}
.mek-brand > strong {
  display: block;
  width: 190px;
  height: 44px;
  max-width: 100%;
  background: url("./assets/branding/mekaron-logo.webp?v=de5b464a") left center / contain no-repeat;
}
.mek-brand > span {
  display: block;
  margin-top: 8px;
  color: var(--mek-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.mek-score {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 12px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #bdc0ae40;
  white-space: nowrap;
}
.mek-score span {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  font-weight: 900;
  color: var(--mek-energy);
}
.mek-score span:nth-of-type(2) {
  color: var(--mek-ochre);
}
.mek-score b {
  font:
    900 26px/1 "Trebuchet MS",
    sans-serif;
  letter-spacing: 2px;
}
.mek-score em {
  font-style: normal;
  font-size: 24px;
  color: var(--mek-muted);
}
.mek-score small {
  flex-basis: 100%;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--mek-muted);
}
.mek-bottom {
  position: absolute;
  bottom: var(--mek-bottom);
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 40px));
}
.mek-loadout {
  display: grid;
  grid-template-columns: 1.45fr repeat(7, 1fr);
  border: 1px solid var(--mek-border);
  border-bottom: 3px solid var(--mek-energy);
  border-radius: 15px 3px 15px 3px;
  background: #202725f5;
  overflow: hidden;
  box-shadow: 0 8px 25px #18201d33;
}
.mek-loadout.dual { grid-template-columns: 1.55fr repeat(3, 1fr); }
.mek-loadout button,
.mek-ability {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 11px 6px 9px;
  background: none;
  color: var(--mek-muted);
  border: 0;
  border-left: 1px solid var(--mek-border);
  font: inherit;
}
.mek-loadout button {
  pointer-events: auto;
  cursor: pointer;
}
.mek-loadout button:hover {
  background: var(--mek-hover);
  color: #fff;
}
.mek-loadout button:focus-visible {
  outline: 2px solid white;
  outline-offset: -4px;
}
.mek-loadout button.selected {
  color: var(--mek-energy);
  background: #35423b;
  box-shadow: inset 0 -3px var(--mek-signal);
}
.mek-loadout svg {
  width: 40px;
  height: 24px;
  fill: currentColor;
  color: var(--mek-energy);
}
.mek-loadout b {
  font-size: 11px;
  letter-spacing: 0.8px;
}
.mek-loadout kbd,
.mek-ability span {
  font:
    10px system-ui,
    sans-serif;
  color: var(--mek-muted);
}
.mek-ability i {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--mek-energy);
}
.mek-hull {
  position: relative;
  padding: 13px 16px 10px;
  color: var(--mek-energy);
}
.mek-portrait {
  position: absolute;
  right: 9px;
  top: 30px;
  width: 37px;
  height: 37px;
}
.mek-hull > span {
  display: block;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
}
.mek-hull small {
  float: right;
  color: var(--mek-muted);
  font-size: 8px;
  padding-top: 2px;
}
.mek-hull strong {
  display: block;
  font-size: 32px;
  line-height: 1.25;
  color: var(--mek-ivory);
}
.mek-health {
  height: 4px;
  background: var(--mek-hover);
  margin-top: 3px;
}
.mek-health i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--mek-energy);
}
.mek-hull.low .mek-health i {
  background: var(--mek-danger);
}
.mek-hull.low strong {
  color: var(--mek-danger);
}
.mek-reticle {
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 1px 2px var(--mek-ink));
}
.mek-reticle i {
  position: absolute;
  background: var(--mek-ivory);
  width: 3px;
  height: 8px;
  left: 14px;
  top: 0;
}
.mek-reticle i:nth-child(2) {
  top: 22px;
}
.mek-reticle i:nth-child(3) {
  top: 14px;
  left: 0;
  width: 8px;
  height: 3px;
}
.mek-reticle i:nth-child(4) {
  top: 14px;
  left: 22px;
  width: 8px;
  height: 3px;
}
.mek-reticle.hit i {
  background: var(--mek-ochre);
}
/* Designator marker. Drawn in HTML so a painted mech still reads through two
   metres of cover; the brackets close as the paint builds. */
.mek-lock {
  position: absolute;
  left: 0;
  top: 0;
  width: 74px;
  height: 74px;
  --mek-lock-progress: 0;
  color: var(--mek-danger);
  filter: drop-shadow(0 1px 2px var(--mek-ink));
  pointer-events: none;
}
.mek-lock i {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  opacity: calc(0.35 + 0.65 * var(--mek-lock-progress));
  /* Closed brackets = a live lock; open ones are still painting. */
  --mek-lock-gap: calc(18px * (1 - var(--mek-lock-progress)));
}
.mek-lock i:nth-child(1) { border-right: 0; border-bottom: 0; left: calc(0px - var(--mek-lock-gap)); top: calc(0px - var(--mek-lock-gap)); }
.mek-lock i:nth-child(2) { border-left: 0; border-bottom: 0; right: calc(0px - var(--mek-lock-gap)); top: calc(0px - var(--mek-lock-gap)); }
.mek-lock i:nth-child(3) { border-right: 0; border-top: 0; left: calc(0px - var(--mek-lock-gap)); bottom: calc(0px - var(--mek-lock-gap)); }
.mek-lock i:nth-child(4) { border-left: 0; border-top: 0; right: calc(0px - var(--mek-lock-gap)); bottom: calc(0px - var(--mek-lock-gap)); }
.mek-lock b,
.mek-lock em {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font: 600 9px/1.2 system-ui, sans-serif;
  letter-spacing: 1.5px;
  white-space: nowrap;
}
.mek-lock b { top: -16px; }
.mek-lock em { bottom: -16px; font-style: normal; color: var(--mek-ivory); }
.mek-lock.held {
  color: var(--mek-signal);
}
.mek-lock.held i { border-width: 3px; }
.mek-threat {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border: 1px solid var(--mek-signal);
  border-radius: 14px;
  background: #202725e0;
  color: var(--mek-danger);
  text-align: center;
  animation: mek-threat-pulse 1.1s steps(2, end) infinite;
  pointer-events: none;
}
.mek-threat strong { display: block; font: 700 12px/1.3 system-ui, sans-serif; letter-spacing: 2px; }
.mek-threat small { font: 10px/1.3 system-ui, sans-serif; color: var(--mek-muted); }
@keyframes mek-threat-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
  .mek-threat { animation: none; }
}
.mek-name {
  position: absolute;
  top: 0;
  left: 0;
  background: #202725eb;
  color: var(--mek-ivory);
  border-bottom: 2px solid var(--mek-energy);
  border-radius: 3px;
  font-size: 10px;
  padding: 3px 7px;
  pointer-events: none;
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mek-status {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  letter-spacing: 2px;
  font-size: 13px;
  font-weight: 900;
  text-shadow: 0 2px 8px #18201d;
}
.mek-status:empty {
  display: none;
}
.mek-error {
  position: absolute;
  inset: 20%;
  display: grid;
  place-items: center;
  font:
    18px/1.7 system-ui,
    sans-serif;
}
.mek-tune-launch,
.mek-tune button {
  pointer-events: auto;
  border: 1px solid var(--mek-border);
  border-radius: 7px;
  background: var(--mek-panel);
  color: var(--mek-ivory);
  font:
    700 12px/1.2 system-ui,
    sans-serif;
  padding: 10px 13px;
  cursor: pointer;
}
.mek-tune-launch {
  margin-top: 10px;
  border-color: var(--mek-border);
  color: var(--mek-ivory);
  letter-spacing: 2px;
}
.mek-tune button:hover,
.mek-tune-launch:hover {
  background: var(--mek-hover);
}
.mek-tune-presets button[aria-pressed="true"] {
  border-color: var(--mek-ivory);
  background: var(--mek-hover);
  color: var(--mek-ivory);
}
.mek-tune button:focus-visible,
.mek-tune-launch:focus-visible,
.mek-tune input:focus-visible,
.mek-tune select:focus-visible,
.mek-tune textarea:focus-visible {
  outline: 2px solid var(--mek-ivory);
  outline-offset: 3px;
}
.mek-tune {
  position: fixed;
  inset: var(--mek-tune-top, 76px) 14px auto auto;
  margin: 0;
  padding: 0;
  width: min(380px, calc(100vw - 28px));
  max-height: calc(100dvh - var(--mek-tune-top, 76px) - 16px);
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid var(--mek-border);
  border-radius: 14px;
  background: var(--mek-panel);
  color: var(--mek-ivory);
  box-shadow: 0 16px 60px #18201daa;
  font:
    13px/1.5 system-ui,
    sans-serif;
  pointer-events: auto;
}
.mek-tune[open] {
  display: flex;
  flex-direction: column;
}
.mek-tune::backdrop {
  background: #18201d40;
}
.mek-tune header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--mek-border);
}
.mek-tune header small {
  color: var(--mek-muted);
  font-size: 9px;
  letter-spacing: 2px;
}
.mek-tune h2 {
  margin: 2px 0 0;
  font-size: 25px;
  letter-spacing: 3px;
  line-height: 1.2;
}
.mek-tune [data-resume] {
  background: var(--mek-ivory);
  border-color: var(--mek-ivory);
  color: var(--mek-ink);
}
.mek-tune-scroll {
  padding: 0 18px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.mek-tune-tabs {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
  padding: 12px 18px 0;
}
.mek-tune-tabs button { flex: 1; }
.mek-tune-tabs [aria-selected="true"] {
  background: var(--mek-hover);
  border-color: var(--mek-ivory);
  color: var(--mek-ivory);
}
.mek-tune [role="tabpanel"][hidden] { display: none; }
.mek-tune button:disabled { opacity: 0.45; cursor: not-allowed; }
.mek-tune [data-game-feedback] { color: var(--mek-energy); font-size: 12px; }
.mek-tune-notice {
  padding: 10px 12px;
  background: #403a2a;
  border-radius: 7px;
  color: var(--mek-ochre);
  font-size: 12px;
}
.mek-tune-notice strong {
  display: block;
  color: var(--mek-ochre);
}
.mek-tune-presets,
.mek-tune-export {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.mek-tune-presets button,
.mek-tune-export button {
  flex: 1;
}
.mek-tune-help {
  color: var(--mek-muted);
  font-size: 11px;
  line-height: 1.6;
}
.mek-tune fieldset {
  margin: 20px 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.mek-tune legend {
  width: 100%;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--mek-border);
  color: var(--mek-energy);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.mek-tune-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  margin-top: 13px;
  font-size: 12px;
}
.mek-tune-control output {
  font-variant-numeric: tabular-nums;
  color: var(--mek-ivory);
}
.mek-tune-control-heading {
  display: flex;
  align-items: center;
  gap: 7px;
  position: relative;
}
.mek-tune button.mek-tune-tip-button {
  flex: 0 0 23px;
  width: 23px;
  height: 23px;
  padding: 0;
  border-radius: 50%;
  color: var(--mek-energy);
  font-size: 11px;
}
.mek-tune-tooltip {
  display: none;
  position: absolute;
  z-index: 5;
  top: 100%;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  margin: 4px 0 0;
  padding: 11px 13px;
  border: 1px solid var(--mek-border);
  border-radius: 8px;
  background: var(--mek-panel);
  color: var(--mek-ivory);
  box-shadow: 0 6px 20px #18201db3;
  font-size: 12px;
  line-height: 1.55;
  pointer-events: none;
}
.mek-tune-control-heading:hover .mek-tune-tooltip,
.mek-tune-control-heading:focus-within .mek-tune-tooltip,
.mek-tune-control-heading[data-help-open] .mek-tune-tooltip {
  display: block;
}
.mek-tune-inactive input,
.mek-tune-inactive select,
.mek-tune-inactive output {
  opacity: 0.45;
}
.mek-tune-inactive input,
.mek-tune-inactive select {
  cursor: not-allowed;
}
.mek-tune input[type="range"] {
  width: 100%;
  margin: 0;
  min-height: 28px;
  grid-column: 1 / -1;
  accent-color: var(--mek-ivory);
  cursor: pointer;
}
.mek-tune select {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 5px;
  padding: 9px;
  border: 1px solid var(--mek-border);
  border-radius: 6px;
  background: var(--mek-panel);
  color: var(--mek-ivory);
  font: inherit;
}
.mek-tune-json {
  margin-top: 24px;
}
.mek-tune-json > label {
  font-weight: 700;
}
.mek-tune textarea {
  box-sizing: border-box;
  width: 100%;
  margin: 8px 0;
  padding: 10px;
  resize: vertical;
  border: 1px solid var(--mek-border);
  border-radius: 6px;
  background: var(--mek-deep);
  color: var(--mek-ivory);
  font:
    11px/1.5 ui-monospace,
    monospace;
}
.mek-tune-feedback {
  min-height: 18px;
  margin-bottom: 0;
  color: var(--mek-energy);
  font-size: 12px;
}
.mek-diagnostics {
  max-width: min(660px, calc(100% - 28px));
  overflow-wrap: anywhere;
  position: absolute;
  left: 14px;
  bottom: calc(var(--mek-bottom) + 125px);
  padding: 12px;
  white-space: pre-line;
  background: #202725ed;
  color: var(--mek-energy);
  font: 11px/1.7 monospace;
}
.mek-diagnostics[hidden] {
  display: none;
}
.mek-cover-label {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  color: var(--mek-ink);
  background: #f3e7cfe8;
  padding: 1px 4px;
  border-radius: 3px;
  font: 700 10px monospace;
}
.mek-impact {
  position: absolute;
  left: 0;
  top: 0;
  color: var(--mek-ochre);
  font:
    900 26px/1 system-ui,
    sans-serif;
  transform: translate(-50%, -50%);
  text-shadow: 0 1px 5px #18201d;
  pointer-events: none;
}
@media (max-width: 1050px) {
  .mek-brand {
    top: 82px;
    padding: 10px 15px;
  }
  .mek-brand > strong {
    width: 152px;
    height: 35px;
  }
  .mek-brand > span {
    font-size: 10px;
  }
}
@media (max-width: 600px) {
  .mek-tune {
    inset: auto 12px 12px;
    width: calc(100vw - 24px);
    max-height: 70dvh;
  }
  .mek-brand {
    left: 12px;
    top: 72px;
    padding: 9px 11px;
  }
  .mek-brand > strong {
    width: 128px;
    height: 30px;
  }
  .mek-brand > span {
    font-size: 8px;
  }
  .mek-score {
    gap: 4px 9px;
  }
  .mek-score span {
    font-size: 8px;
    gap: 7px;
  }
  .mek-score b {
    font-size: 24px;
  }
  .mek-bottom {
    width: calc(100% - 20px);
  }
  .mek-loadout {
    grid-template-columns: 1.3fr repeat(7, 1fr);
  }
  .mek-loadout.dual { grid-template-columns: 1.4fr repeat(3, 1fr); }
  .mek-hull {
    padding: 12px 8px;
  }
  .mek-hull small {
    display: none;
  }
  .mek-loadout svg {
    width: 29px;
    height: 19px;
  }
  .mek-loadout b {
    font-size: 8px;
    letter-spacing: 0;
  }
  .mek-ability span {
    font-size: 8px;
  }
}
.mek-ui [hidden] { display: none !important; }
.mek-loadout-launch {
  pointer-events: auto; margin-top: 8px; padding: 9px 12px;
  color: var(--mek-ink); background: var(--mek-ivory); border: 0; border-radius: 6px;
  font: 700 12px system-ui; cursor: pointer;
}
.mek-loadout-launch:disabled { opacity: .6; cursor: default; }
@media (max-height: 550px) {
  .mek-bottom {
    bottom: max(var(--mm-safe-bottom, 0px), 12px);
  }
  .mek-brand {
    top: 70px;
  }
  .mek-loadout button,
  .mek-ability {
    padding-top: 7px;
    padding-bottom: 5px;
  }
  .mek-hull {
    padding-top: 7px;
    padding-bottom: 5px;
  }
}

/* The engine resolves these zones from both reserved and live chrome. */
.mek-brand { top: var(--mek-brand-top, 72px); }
@media (max-width: 600px) {
  /* On narrow screens the engine's right-hand controls span the header. */
  .mek-brand {
    top: var(--mek-header-mobile-top, 72px);
    width: min(220px, calc(100% - 24px));
  }
}
