/*
 * Maths HQ declutter: one headline per panel, no repeated information, and a slim
 * mission row so the topic cards get the room. Hides labels only; every button,
 * number and progress bar a player uses stays.
 */

/* "INVASION IN" lives under the quiz during a maths mission. Maths HQ keeps the
   radar, welcome and blueprint; only that stakes strip stays off the picker. */
body.mission-mode.hq-home #mission-invasion {
  display: none !important;
}

/* Author display rules were beating the hidden attribute, so "Maths HQ" showed on Maths HQ. */
body.mission-mode .mission-control-home[hidden] {
  display: none;
}

body.mission-mode #screen-home .mission-defend {
  width: 100%;
  margin-top: 8px;
  padding: 14px 18px;
  border: 3px solid #ffd27a;
  border-radius: 14px;
  background: radial-gradient(circle at 35% 28%, #ff9a88 0%, #ec2a1e 42%, #8e0a08 100%);
  box-shadow: 0 6px 0 #5a0604, 0 0 24px rgba(255, 60, 40, .85);
  color: #fff;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2vw, 1.8rem);
  letter-spacing: .06em;
  text-shadow: 0 2px 0 #5a0604;
  cursor: pointer;
}

/* Centre: the panel title, "Quick start" and "Topics" / "Level" labels. */
body.mission-mode #screen-home .mission-workspace-heading,
body.mission-mode #screen-home .mission-kicker,
body.mission-mode #screen-home .mission-recommended,
body.mission-mode #screen-home .mission-topic-heading h2,
body.mission-mode #screen-home .mission-level-intro {
  display: none;
}

/* "Mixed Maths Mission" goes; the START button says it. "Granny's under attack!" stays when a siege is ready. */
body.mission-mode #screen-home .mission-mixed-card:not(.is-under-attack) .mission-mixed-copy {
  display: none;
}

body.mission-mode #screen-home .mission-mixed-card.is-under-attack .mission-mixed-copy {
  width: 100%;
  text-align: center;
}

body.mission-mode #screen-home .mission-topic-heading {
  justify-content: flex-end;
}

/* Armory: turret, its name, the XP bar and the button. "Ready!" still shows when it can be unlocked. */
body.mission-mode #screen-home .armory-promo-eyebrow,
body.mission-mode #screen-home .armory-promo:not(.armory-promo-ready) h2,
body.mission-mode #screen-home .armory-promo:not(.armory-promo-ready) .armory-promo-progress-label strong,
body.mission-mode #screen-home .armory-promo-footnote {
  display: none;
}

body.mission-mode #screen-home .armory-promo-progress-label {
  justify-content: flex-end;
}

/* The map becomes a small link rather than a full-width bar. */
body.mission-mode #screen-home .mission-map-details:not([open]) {
  justify-self: end;
  padding: 2px 4px;
  border: none;
  background: transparent;
}

body.mission-mode #screen-home .mission-map-details:not([open]) summary {
  font-size: .68rem;
  opacity: .75;
}

/* Left: no panel title, no top-secret stamp, and no alert while all is calm (warnings still show). */
body.mission-mode .mission-control-eyebrow,
body.mission-mode .threat-dossier-stamp {
  display: none;
}

/* The alien side is red: green means the player's own things (maths, crystals, gear),
   so the radar and the enemy blueprint shift to a red-orange threat colour. */
body.mission-mode .mission-control-radar,
body.mission-mode .mission-control-blueprint {
  filter: hue-rotate(-125deg) saturate(1.25) brightness(1.05);
}

/* Threat meter between the radar and the dossier: amber while calm, then hotter as the aliens close in. */
body.mission-mode .mission-control-alert {
  --threat: 18%;
  --threat-colour: #ff9a3c;
  position: relative;
  padding: 16px 10px 23px;
  border: 1px solid rgba(255, 120, 60, .4);
  border-radius: 8px;
  background: rgba(24, 8, 4, .7);
  color: #ffb27a;
  text-align: center;
  letter-spacing: .08em;
}

body.mission-mode .mission-control-alert::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 9px;
  height: 5px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--threat-colour) var(--threat), rgba(255, 255, 255, .08) var(--threat));
  box-shadow: 0 0 8px var(--threat-colour);
}

body.mission-mode .mission-control-alert[data-urgency="warning"] { --threat: 55%; --threat-colour: #ff6a2a; }
body.mission-mode .mission-control-alert[data-urgency="critical"] { --threat: 82%; --threat-colour: #ff5a3c; }
body.mission-mode .mission-control-alert[data-urgency="now"] { --threat: 100%; --threat-colour: #ff2d2d; animation: threat-flash .9s ease-in-out infinite; }

@keyframes threat-flash {
  50% { box-shadow: 0 0 16px rgba(255, 45, 45, .6); }
}

/* Right: no panel title or "Systems offline". */
body.mission-mode .power-eyebrow,
body.mission-mode .power-rig[data-stage="offline"] .power-rank-name {
  display: none;
}

/* Fully armed: the count, bar and cells give way to one gold badge. */
body.mission-mode .mission-power .power-rig[data-stage="ready"] .power-charge-number,
body.mission-mode .mission-power .power-rig[data-stage="ready"] .power-charge-track,
body.mission-mode .mission-power .power-rig[data-stage="ready"] .power-charge-cells {
  display: none;
}

body.mission-mode .mission-power .power-rig[data-stage="ready"] .power-rank {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
  margin: 4px 0 10px;
}

/* The fully-armed line is a celebration, not a control, so it is a tilted victory ribbon that stamps in
   once and shimmers, rather than a pill that pulses like a button. The glow sits on the parent because
   the ribbon's notched ends are a clip-path, which would cut off its own shadow. */
body.mission-mode .mission-power .power-rig[data-stage="ready"] .power-rank {
  filter: drop-shadow(0 0 12px rgba(255, 190, 40, .55)) drop-shadow(0 3px 0 rgba(0, 0, 0, .35));
}

body.mission-mode .mission-power .power-rig[data-stage="ready"] .power-rank-name {
  display: inline-block;
  padding: 8px 46px 9px;
  border: none;
  border-radius: 0;
  background:
    linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, .55) 50%, transparent 60%) -150% 0 / 250% 100% no-repeat,
    linear-gradient(180deg, #ffe592, #e0960f 58%, #b06a08);
  clip-path: polygon(0 0, 100% 0, calc(100% - 18px) 50%, 100% 100%, 0 100%, 18px 50%);
  color: #2a1700;
  font-size: clamp(1.25rem, 1.5vw, 1.6rem);
  letter-spacing: .08em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .45);
  box-shadow: none;
  transform: rotate(-3deg);
  animation:
    armed-stamp .55s cubic-bezier(.34, 1.56, .64, 1) both,
    armed-shine 3.2s ease-in-out .8s infinite;
}

@keyframes armed-stamp {
  from { opacity: 0; transform: rotate(-3deg) scale(1.8); }
  to { opacity: 1; transform: rotate(-3deg) scale(1); }
}

@keyframes armed-shine {
  0%, 55% { background-position: -150% 0, 0 0; }
  100% { background-position: 250% 0, 0 0; }
}

/* START is the hero: full width, big, and gently pulsing so it is the first thing a kid sees. */
body.mission-mode #screen-home #mission-start-mixed {
  width: 100%;
  max-width: none;
  min-height: 58px;
  font-size: clamp(1.1rem, 1.5vw, 1.5rem);
  letter-spacing: .04em;
  animation: start-pulse 1.8s ease-in-out infinite;
}

body.mission-mode #screen-home #mission-start-mixed:hover {
  animation-play-state: paused;
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.12);
}

@keyframes start-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 170, 40, .55), 0 6px 18px rgba(255, 140, 0, .35); }
  50% { box-shadow: 0 0 0 9px rgba(255, 170, 40, 0), 0 6px 26px rgba(255, 160, 20, .7); }
}

/* Right: "Sieges played" now lives in My progress, and the forge turret gets the space. */
body.mission-mode .mission-control-metrics {
  display: none;
}

/* Desktop: a slim mission row, so the height goes to the topic cards. */
@media (min-width: 1321px) and (min-height: 600px) {
  /* With the panel title and topic heading gone, the mission row takes their height. */
  body.mission-mode #screen-home .mission-mixed-card,
  body.mission-mode #screen-home .armory-promo {
    min-height: 168px;
    padding: 12px 14px;
  }

  body.mission-mode #screen-home #mission-start-mixed {
    min-height: 70px;
    font-size: clamp(1.35rem, 1.9vw, 1.9rem);
  }

  /* Difficulty sits under the mission button it applies to, labelled LEVEL, with no box around it. */
  body.mission-mode #screen-home .mission-mixed-card .mission-level-control {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin-top: 14px;
  }

  body.mission-mode #screen-home .mission-mixed-card .mission-level-intro {
    display: block;
    text-align: center;
  }

  body.mission-mode #screen-home .mission-mixed-card .mission-level-title {
    font-size: .8rem;
    font-weight: 900;
    letter-spacing: .16em;
    color: #e9ddff;
  }

  body.mission-mode #screen-home .mission-mixed-card .mission-level-buttons {
    display: flex;
    gap: 4px;
    padding: 0;
    border: none;
    background: none;
    box-shadow: none;
  }

  body.mission-mode #screen-home .mission-mixed-card .mission-level-option {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    min-height: 44px;
  }

  body.mission-mode #screen-home .mission-mixed-card .mission-level-reward {
    white-space: nowrap;
  }

  body.mission-mode #screen-home .mission-topic-heading {
    display: none;
  }

  body.mission-mode #screen-home .mission-mixed-card {
    justify-content: center;
  }

  /* The next turret is the star: big art, with a compact name, XP bar and button beside it. */
  body.mission-mode #screen-home .armory-promo {
    grid-template-columns: minmax(130px, 46%) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }

  body.mission-mode #screen-home .armory-promo-art {
    min-height: 0;
    height: 100%;
  }

  body.mission-mode #screen-home .armory-promo-art img {
    width: auto;
    max-width: 100%;
    height: 100%;
    max-height: 150px;
    object-fit: contain;
    filter: drop-shadow(0 0 16px rgba(120, 255, 90, .45));
  }

  body.mission-mode #screen-home .armory-promo-copy {
    max-width: 240px;
  }

  body.mission-mode #screen-home .armory-promo-featured {
    font-size: 1.05rem;
  }

  body.mission-mode #screen-home .armory-promo-cta {
    min-height: 38px;
    font-size: .95rem;
  }

  body.mission-mode #screen-home .armory-promo-featured {
    margin: 0 0 3px;
  }

  body.mission-mode #screen-home .armory-promo-progress {
    margin-bottom: 5px;
  }

  body.mission-mode #screen-home .mission-mixed-card {
    align-items: stretch;
    padding: 10px 14px;
  }

  /* A bigger forge stage; the turrets are sized from it, so they grow too. */
  body.mission-mode .mission-power .power-scene {
    width: min(100%, 340px);
    height: clamp(220px, 40dvh, 380px);
  }

  body.mission-mode .mission-power .power-halo-outer {
    width: min(92%, 300px);
    height: min(92%, 300px);
  }

  body.mission-mode .mission-power .power-halo-inner {
    width: min(72%, 236px);
    height: min(72%, 236px);
  }

  /* Left: a bigger radar and a taller alien dossier fill the panel. */
  body.mission-mode .mission-control-inner {
    height: 100%;
    justify-content: space-evenly;
  }

  body.mission-mode .mission-control-radar .inbound-radar-dish {
    width: min(290px, 19vw, 32dvh);
  }

  body.mission-mode .mission-control.is-theatre .mission-control-radar .inbound-radar-dish {
    width: min(330px, 22vw, 38dvh);
  }

  /* One fixed height, whichever alien is on file, so the panel never jumps. */
  body.mission-mode .mission-control-blueprint .threat-dossier {
    display: flex;
    flex-direction: column;
    height: 236px;
    overflow: hidden;
  }

  body.mission-mode .mission-control.is-theatre .mission-control-blueprint .threat-dossier {
    height: clamp(224px, 27dvh, 288px);
  }

  body.mission-mode .mission-control-blueprint .threat-dossier-body {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  body.mission-mode .mission-control-blueprint .threat-dossier-wire {
    min-height: 0;
    height: 100%;
  }

  /* Right: My progress is always shown, in the space below the forge. */
  body.mission-mode .mission-battle-stats .mission-control-details[open] {
    background: transparent;
    box-shadow: none;
  }

  body.mission-mode .mission-battle-stats .mission-control-details[open] .mission-control-detail-grid {
    position: static;
    border: none;
    box-shadow: none;
    background: transparent;
    padding: 4px 0 0;
  }
}

body.mission-mode .mission-battle-stats .mission-control-details summary {
  pointer-events: none;
  list-style: none;
}

body.mission-mode .mission-battle-stats .mission-control-details summary::-webkit-details-marker,
body.mission-mode .mission-battle-stats .mission-control-details summary span {
  display: none;
}

/* Fewer outlines: only the three main panels, the radar dish and the alien blueprint frame keep a
   stroke. Everything inside them separates with soft backgrounds and glows instead. */
body.mission-mode #screen-home .mission-mixed-card,
body.mission-mode #screen-home .armory-promo,
body.mission-mode .mission-control-alert,
body.mission-mode .threat-dossier-kills,
body.mission-mode .threat-hex-rail,
body.mission-mode .threat-meter,
body.mission-mode .mission-battle-stats,
body.mission-mode .crystal-vault,
body.mission-mode .armory-promo-art-badge,
body .rank-badge,
body .core-pill {
  border-color: transparent;
}

body.mission-mode .mission-battle-stats {
  border-top: none;
}

body.mission-mode #screen-home .mission-mixed-card {
  background: linear-gradient(160deg, rgba(60, 40, 110, .55), rgba(30, 22, 58, .55));
}

body.mission-mode #screen-home .armory-promo {
  background: linear-gradient(160deg, rgba(70, 50, 30, .45), rgba(28, 22, 40, .6));
}

body.mission-mode #screen-home .armory-promo.armory-promo-ready {
  box-shadow: 0 0 0 2px rgba(120, 255, 120, .55), 0 0 24px rgba(120, 255, 120, .25);
}

/* Level buttons: no boxes, just the number and XP; the chosen level gets a gold ring. */
body.mission-mode #screen-home .mission-mixed-card .mission-level-option {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

body.mission-mode #screen-home .mission-mixed-card .mission-level-option:hover {
  background: rgba(255, 255, 255, .06);
}

body.mission-mode #screen-home .mission-mixed-card .mission-level-option.is-selected {
  border-color: #f3b33b;
  background: rgba(243, 179, 59, .14);
  box-shadow: 0 0 12px rgba(243, 179, 59, .35);
}

/* Right panel: the forge and the Crystal Vault share the height, the forge slightly taller.
   The forge turret keeps its size; only the space around it tightens. */
@media (min-width: 1321px) and (min-height: 600px) {
  body.mission-mode .mission-power {
    grid-template-rows: minmax(0, 1.07fr) minmax(0, .93fr);
  }

  body.mission-mode .mission-power .power-rig {
    padding-top: 8px;
    padding-bottom: 6px;
  }

  body.mission-mode .mission-power .power-rank {
    min-height: 0;
  }

  /* With the taller half, the vault stacks: the jar takes the height, with one compact block
     underneath (the count beside the tier and next goal, then the spend button). */
  body.mission-mode .crystal-vault {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    justify-items: center;
    gap: 4px;
    padding: 8px 10px 10px;
  }

  body.mission-mode .crystal-vault-jar {
    width: auto;
    height: 100%;
    max-width: none;
    max-height: 460px;
  }

  body.mission-mode .crystal-vault-copy {
    display: grid;
    grid-template-columns: auto auto;
    align-items: center;
    justify-content: center;
    column-gap: 12px;
    row-gap: 6px;
  }

  body.mission-mode .crystal-vault-total {
    display: grid;
    justify-items: center;
    line-height: 1;
  }

  body.mission-mode .crystal-vault-count {
    font-size: clamp(2.4rem, 3vw, 3.2rem);
  }

  body.mission-mode .crystal-vault-label {
    font-size: .58rem;
    letter-spacing: .14em;
  }

  body.mission-mode .crystal-vault-info {
    display: grid;
    gap: 2px;
    text-align: left;
  }

  body.mission-mode .crystal-vault-next {
    margin-top: 0;
    white-space: nowrap;
  }

  body.mission-mode .crystal-vault-spend {
    grid-column: 1 / -1;
    justify-self: center;
    margin-top: 0;
  }
}

/* The crystal sum, so the vault total and the spendable crystals never look mismatched. */
body.mission-mode .crystal-vault-sum {
  grid-column: 1 / -1;
  justify-self: center;
  font-size: .7rem;
  font-weight: 800;
  color: rgba(214, 255, 232, .78);
}

body.mission-mode .crystal-vault-sum b {
  color: #9dff7a;
}

/* Random Mission: the alien button art is the button. It bobs and glows instead of a box pulse,
   because the alien pokes out above the pill. */
body.mission-mode #screen-home #mission-start-mixed.mission-start-art {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
  cursor: pointer;
  animation: mission-art-pulse 1.8s ease-in-out infinite;
}

body.mission-mode #screen-home #mission-start-mixed.mission-start-art img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 120px;
  object-fit: contain;
  pointer-events: none;
}

body.mission-mode #screen-home #mission-start-mixed.mission-start-art:hover {
  animation-play-state: paused;
  transform: translateY(-3px) scale(1.03);
  filter: brightness(1.12) drop-shadow(0 0 16px rgba(255, 180, 40, .8));
}

body.mission-mode #screen-home #mission-start-mixed.mission-start-art:active {
  transform: scale(.97);
}

@keyframes mission-art-pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 4px 10px rgba(255, 140, 0, .35)); }
  50% { transform: scale(1.025); filter: drop-shadow(0 0 18px rgba(255, 175, 40, .75)); }
}

@media (prefers-reduced-motion: reduce) {
  body.mission-mode #screen-home #mission-start-mixed.mission-start-art,
  body.mission-mode .mission-power .power-rig[data-stage="ready"] .power-rank-name { animation: none; }
}

/* The rare green Special Mission glows green so it stands out from the gold ones. */
body.mission-mode #screen-home #mission-start-mixed.mission-start-art.is-special {
  animation-name: mission-art-special;
}

@keyframes mission-art-special {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 4px 12px rgba(120, 255, 80, .45)); }
  50% { transform: scale(1.035); filter: drop-shadow(0 0 24px rgba(140, 255, 90, .95)); }
}

body.mission-mode #screen-home #mission-start-mixed.mission-start-art.is-special {
  position: relative;
}

body.mission-mode #screen-home .mission-special-badge {
  position: absolute;
  top: -18%;
  right: 1%;
  z-index: 2;
  width: clamp(44px, 19%, 70px);
  aspect-ratio: 1;
  font-size: clamp(.62rem, 1.05vw, 1rem);
  rotate: 10deg;
  animation: mission-special-badge-pulse 1.6s ease-in-out infinite;
  pointer-events: none;
}

body.mission-mode #screen-home .mission-special-disc {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  border: 3px solid #fff;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff7a4d 0%, #e3241c 55%, #a10f18 100%);
  box-shadow: 0 4px 0 #6e0810, 0 0 18px rgba(255, 90, 50, .75);
  color: #fff;
  font-family: var(--font-display);
  line-height: .9;
  text-align: center;
}

body.mission-mode #screen-home .mission-special-badge b {
  font-size: 2em;
  font-weight: 400;
  text-shadow: 2px 2px 0 #6e0810;
}

body.mission-mode #screen-home .mission-special-badge small {
  color: #ffc21a;
  font-size: 1em;
  letter-spacing: .08em;
  text-shadow: 1px 1px 0 #6e0810;
}

/* Gold sunburst turning slowly behind the badge. */
body.mission-mode #screen-home .mission-special-rays {
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 210, 60, .85) 0deg 12deg, transparent 12deg 30deg);
  mask: radial-gradient(circle, #000 45%, transparent 72%);
  animation: mission-special-rays-spin 8s linear infinite;
}

@keyframes mission-special-badge-pulse {
  50% { scale: 1.1; }
}

@keyframes mission-special-rays-spin {
  to { rotate: 360deg; }
}

@media (prefers-reduced-motion: reduce) {
  body.mission-mode #screen-home .mission-special-badge,
  body.mission-mode #screen-home .mission-special-rays {
    animation: none;
  }
}

/* While a Special Mission is up, the level buttons show the doubled reward in the same green. */
body.mission-mode #screen-home .mission-level-buttons.is-boosted .mission-level-reward {
  color: #a8ff6a;
  text-shadow: 0 0 8px rgba(140, 255, 90, .6);
}

/* The jar is the count now (the header pill shows the number), so it gets the room. */
@media (min-width: 1321px) and (min-height: 600px) {
  body.mission-mode .crystal-vault-jar {
    max-height: 600px;
  }

  body.mission-mode .crystal-vault-copy {
    grid-template-columns: auto;
    justify-items: center;
  }

  body.mission-mode .crystal-vault-info {
    justify-items: center;
    text-align: center;
  }
}
