/*
 * Mission Control layout, 12 November 2026.
 * Keeps navigation and progress visible while the active maths activity
 * changes independently in the workspace. Respect old game screens.
 */

body.mission-mode #app {
  max-width: 1710px;
  padding: clamp(12px, 1.8vw, 28px) clamp(12px, 2vw, 30px) 36px;
}

.mission-shell {
  display: grid;
  grid-template-columns: minmax(300px, 370px) minmax(0, 1fr);
  gap: clamp(15px, 1.6vw, 26px);
  align-items: start;
  width: 100%;
}

.mission-shell[hidden],
.mission-extra-topics[hidden] {
  display: none !important;
}

.mission-control,
.mission-workspace {
  min-width: 0;
  border: 1px solid rgba(146, 129, 187, 0.32);
  border-radius: 19px;
  overflow: hidden;
}

.mission-control {
  position: sticky;
  top: 12px;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  scrollbar-width: thin;
  background:
    linear-gradient(180deg, rgba(7, 9, 17, 0.5) 0%, rgba(7, 10, 17, 0.9) 27%, #0b0d17 64%),
    url('../assets/home/hero-village.png') center top / 100% auto no-repeat,
    #0b0d17;
  box-shadow: 0 14px 48px rgba(0, 0, 0, 0.34);
}

.mission-control-inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: clamp(16px, 2vw, 24px);
}

.mission-control-heading {
  text-align: center;
}

.mission-control-eyebrow,
.mission-kicker,
.mission-recommended {
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  color: #ffc66d;
}

.mission-control-greeting {
  margin: 8px 0 6px;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 2.2vw, 2rem);
  font-weight: 400;
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0.015em;
}

.mission-control-greeting span {
  color: var(--gold);
}

.mission-control-heading p,
.mission-control-progress p {
  margin: 0;
  color: #d9d5e4;
  font-size: 0.87rem;
  line-height: 1.45;
}

.mission-control-radar .inbound-radar {
  max-width: 100%;
  gap: 9px;
}

.mission-control-radar .inbound-radar-dish {
  width: min(200px, 56vw);
}

/* Stakes moved under the quiz — left rail becomes threat theatre. */
body.mission-mode .mission-control.is-theatre .mission-control-radar .inbound-radar {
  max-width: none;
}

body.mission-mode .mission-control.is-theatre .mission-control-radar .inbound-radar-dish {
  width: min(300px, 92%, 34dvh);
}

body.mission-mode .mission-control.is-theatre .mission-control-blueprint {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

body.mission-mode .mission-control.is-theatre .mission-control-blueprint .threat-dossier {
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
  height: clamp(208px, 26dvh, 272px);
  margin-left: 0;
  opacity: 0.92;
}

body.mission-mode .mission-control.is-theatre .mission-control-blueprint .threat-dossier-frame {
  height: 100%;
}

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

body.mission-mode .mission-control.is-theatre .mission-control-blueprint .threat-dossier-wire {
  min-height: 0;
  height: auto;
  align-self: stretch;
}

.mission-control-signal {
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 120, 90, 0.35);
  background: rgba(40, 12, 18, 0.55);
  color: #ffb39a;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  line-height: 1.3;
}

.mission-control-signal[data-urgency='critical'],
.mission-control-signal[data-urgency='now'] {
  border-color: rgba(255, 70, 70, 0.55);
  color: #ff8a7a;
  box-shadow: 0 0 14px rgba(255, 60, 40, 0.25);
}

.mission-control-radar .inbound-radar-label {
  margin: 2px 0 0;
  color: #b6e0bd;
  font-size: 0.75rem;
  line-height: 1.3;
  text-align: center;
}

.mission-control-radar .gb-attack-hero-cta {
  width: 100%;
  max-width: none;
  min-height: 50px;
  margin-top: 5px;
  font-size: clamp(1rem, 1.45vw, 1.25rem);
  letter-spacing: 0.035em;
  white-space: normal;
}

.mission-control-radar #btn-hold-line[hidden] {
  display: none !important;
}

.mission-control-progress {
  padding: 13px 14px 12px;
  border-radius: 12px;
  background: rgba(3, 15, 12, 0.84);
  border: 1px solid rgba(64, 162, 114, 0.44);
}

.mission-control-progress-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 5px 10px;
  margin-bottom: 11px;
  font-size: 0.81rem;
}

.mission-control-progress-line strong {
  color: #b1fbc9;
  letter-spacing: 0.055em;
}

.mission-control-progress-line span {
  color: #f7f5eb;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.mission-control-track {
  overflow: hidden;
  height: 10px;
  border-radius: 99px;
  background: #19261f;
  border: 1px solid rgba(132, 198, 156, 0.38);
  margin-bottom: 9px;
}

.mission-control-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #398d56, #8dec9e);
  box-shadow: 0 0 16px rgba(132, 248, 153, 0.32);
  transition: width 450ms ease;
}

.mission-control-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.mission-control-metrics > div {
  border: 1px solid rgba(88, 178, 126, 0.29);
  border-radius: 11px;
  background: rgba(4, 13, 11, 0.82);
  padding: 11px 12px;
}

.mission-control-metrics span,
.mission-control-detail-grid span {
  display: block;
  color: #91b9a3;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.mission-control-metrics strong {
  display: block;
  margin-top: 4px;
  color: #a4f4aa;
  font-size: 1.3rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.mission-control-details {
  border: 1px solid rgba(146, 129, 187, 0.29);
  border-radius: 10px;
  background: rgba(12, 11, 23, 0.76);
}

.mission-control-details summary {
  cursor: pointer;
  padding: 12px;
  font-size: 0.85rem;
  font-weight: 800;
}

.mission-control-details summary span {
  float: right;
  color: #c9c0dd;
}

.mission-control-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 5px 13px 14px;
}

.mission-control-detail-grid strong {
  display: block;
  margin-top: 3px;
  color: #f7f2dd;
  font-size: 1.1rem;
}

/* Granny's cottage on every way back to Maths HQ. */
.btn-house {
  width: auto;
  height: 1.9em;
  margin: -0.4em 0.45em -0.4em 0;
  vertical-align: middle;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
}

.mission-control-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid rgba(177, 156, 215, 0.42);
  border-radius: 10px;
  background: rgba(18, 15, 32, 0.85);
  color: #f4edf7;
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
}

.mission-workspace {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: min(760px, 75dvh);
  background: linear-gradient(160deg, rgba(29, 22, 49, 0.97), rgba(12, 11, 22, 0.99) 58%);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.28);
  padding: clamp(18px, 2.25vw, 34px);
}

.mission-workspace > .screen {
  flex: 0 0 auto;
  min-height: 0;
}

.mission-invasion {
  flex: 0 0 auto;
  margin-top: 44px;
}

.mission-invasion[hidden] {
  display: none !important;
}

.invasion-briefing {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px 18px;
  width: 80%;
  max-width: 720px;
  margin-inline: auto;
  padding: 10px 16px 12px;
  border: 2px solid transparent;
  border-radius: 14px;
  background:
    linear-gradient(180deg, #2a1830, #140a18) padding-box,
    linear-gradient(180deg, #ff9a6a, #c42828 55%, #5a1010) border-box;
  box-shadow: 0 0 22px rgba(255, 60, 40, 0.28), inset 0 -3px 8px rgba(0, 0, 0, 0.4);
}

.invasion-briefing.is-detected {
  background:
    linear-gradient(180deg, #3a1420, #18060c) padding-box,
    linear-gradient(180deg, #ffe27a, #ff5a3a 50%, #8a1010) border-box;
  animation: invasion-pulse 1.1s ease-in-out infinite alternate;
}

.invasion-briefing.is-open {
  display: block;
  position: relative;
  padding: 14px 16px 16px;
  background:
    linear-gradient(180deg, #2c2443, #161122) padding-box,
    linear-gradient(180deg, #ffe39a, #d29a35 40%, #8a5a16) border-box;
  animation: none;
}

.invasion-countdown {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 9.5rem;
  padding: 2px 4px;
  line-height: 1;
}

.invasion-kicker {
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 2.2vw, 1.2rem);
  font-weight: 400;
  letter-spacing: 0.08em;
  color: #ffc8b0;
  text-shadow: 0 2px 0 rgba(40, 8, 6, 0.85);
}

.invasion-briefing.is-detected .invasion-kicker {
  color: #ffe27a;
}

.invasion-count {
  font-family: var(--font-display);
  font-size: clamp(3.8rem, 9.5vw, 5.4rem);
  font-weight: 400;
  color: #fff4e0;
  text-shadow: 0 3px 0 #4a0a08, 0 0 18px rgba(255, 80, 40, 0.55);
  transform-origin: center;
}

.invasion-briefing.is-detected .invasion-count {
  color: #ffd36b;
  text-shadow: 0 3px 0 #4a2a00, 0 0 20px rgba(255, 180, 40, 0.6);
}

/* Last five answers: big pulse + zoom so kids feel the siege coming. */
.invasion-count.is-pulse {
  color: #ff6a4a;
  text-shadow: 0 3px 0 #4a0a08, 0 0 26px rgba(255, 60, 30, 0.85);
  animation: invasion-count-pulse 0.7s ease-in-out infinite alternate;
}

.invasion-briefing.is-final {
  animation: invasion-pulse 0.7s ease-in-out infinite alternate;
}

@keyframes invasion-count-pulse {
  from { transform: scale(1); filter: brightness(1); }
  to { transform: scale(1.22); filter: brightness(1.25); }
}

@media (prefers-reduced-motion: reduce) {
  .invasion-count.is-pulse,
  .invasion-briefing.is-final,
  .invasion-briefing.is-detected {
    animation: none;
  }
}

.invasion-unit {
  margin-top: 1px;
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 1.9vw, 1.05rem);
  font-weight: 400;
  letter-spacing: 0.06em;
  color: #ffd2c0;
  text-align: center;
  text-shadow: 0 2px 0 rgba(40, 8, 6, 0.85);
}

.invasion-meter {
  position: relative;
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid rgba(255, 140, 100, 0.45);
  background: rgba(0, 0, 0, 0.45);
}

.invasion-meter-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff5a3a, #ffb02e);
  box-shadow: 0 0 12px rgba(255, 90, 40, 0.55);
  transition: width 220ms ease;
}

.invasion-meter-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

.invasion-sub {
  grid-column: 1 / -1;
  margin: 0;
  color: rgba(255, 220, 200, 0.75);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

@keyframes invasion-pulse {
  from { box-shadow: 0 0 16px rgba(255, 80, 40, 0.25); }
  to { box-shadow: 0 0 28px rgba(255, 140, 40, 0.5); }
}

@media (max-width: 640px) {
  .invasion-briefing:not(.is-open) {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .invasion-meter {
    width: 100%;
  }
}

.mission-workspace-heading {
  margin-bottom: 22px;
}

.mission-workspace-heading h1 {
  margin: 6px 0 8px;
  color: #fff7e5;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 3.5vw, 3rem);
  font-weight: 400;
  line-height: 1.07;
  letter-spacing: 0.015em;
}

.mission-workspace-heading p,
.mission-topic-heading p {
  margin: 0;
  color: #c2bbd2;
  line-height: 1.5;
  font-size: clamp(0.91rem, 1.1vw, 1rem);
}

.mission-mixed-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px 18px;
  padding: 18px 22px;
  margin-bottom: 28px;
  background: linear-gradient(110deg, rgba(68, 40, 112, 0.58), rgba(24, 20, 44, 0.97));
  border: 1px solid rgba(255, 197, 84, 0.5);
  border-radius: 15px;
}

.mission-mixed-symbol {
  width: 55px;
  height: 55px;
  flex: 0 0 55px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  font-size: 1.7rem;
  background: rgba(255, 190, 76, 0.16);
}

.mission-mixed-copy {
  flex: 1 1 220px;
  min-width: 0;
}

.mission-mixed-copy h2 {
  margin: 4px 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.25rem, 2.1vw, 1.65rem);
  color: #fff4d6;
}

.mission-mixed-copy p {
  margin: 0;
  color: #d7cde1;
  font-size: 0.88rem;
}

.mission-mixed-card .gb-forge-btn {
  flex: 0 1 205px;
  min-height: 50px;
  margin: 0;
  font-size: 1rem;
  white-space: normal;
}

.mission-topic-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 16px;
}

.mission-topic-heading h2 {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2vw, 1.9rem);
  font-weight: 400;
  color: #f8eedb;
  margin: 0 0 5px;
}

.mission-topic-heading .gb-level-btn {
  min-width: 38px;
  min-height: 39px;
  padding: 0 8px;
}

.mission-more-button {
  display: block;
  margin: 18px auto 14px;
  min-height: 45px;
  padding: 8px 23px;
  border: 1px solid rgba(191, 168, 235, 0.56);
  border-radius: 12px;
  background: rgba(36, 25, 57, 0.8);
  color: #fff0d7;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 800;
  cursor: pointer;
}

.mission-extra-topics {
  margin-top: 12px;
}

.mission-map-details {
  margin-top: 28px;
  padding: 14px 16px;
  background: rgba(11, 10, 21, 0.6);
  border: 1px solid rgba(143, 125, 179, 0.3);
  border-radius: 13px;
}

.mission-map-details summary {
  cursor: pointer;
  color: #d7c9e8;
  font-size: 0.88rem;
  font-weight: 800;
}

.mission-map-details > :not(summary) {
  margin-top: 16px;
}

.mission-workspace .times-panel,
.mission-workspace .forge-panel,
.mission-workspace .prep-panel {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.mission-workspace .panel {
  box-shadow: none;
}

.mission-shell button:focus-visible,
.mission-shell summary:focus-visible {
  outline: 3px solid #ffd36b;
  outline-offset: 3px;
}

@media (max-width: 870px) {
  .mission-shell {
    grid-template-columns: 1fr;
  }
  .mission-control {
    position: static;
    max-height: none;
  }
  .mission-control-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    align-items: center;
    gap: 12px;
  }
  .mission-control-heading {
    grid-column: 1 / -1;
  }
  .mission-control-radar {
    grid-row: span 3;
  }
  .mission-control-radar .inbound-radar-dish {
    width: min(160px, 32vw);
  }
  .mission-control-progress,
  .mission-control-metrics,
  .mission-control-details {
    grid-column: 2;
  }
  .mission-control-home {
    grid-column: 1 / -1;
  }
  .mission-workspace {
    min-height: 0;
  }
}

@media (max-width: 540px) {
  body.mission-mode #app {
    padding: 10px 9px 28px;
  }
  .mission-shell {
    gap: 11px;
  }
  .mission-control-inner {
    display: flex;
    padding: 12px;
    gap: 11px;
  }
  .mission-control-radar .inbound-radar-dish {
    width: 140px;
  }
  .mission-control-radar .gb-attack-hero-cta {
    min-height: 45px;
  }
  .mission-control-home {
    padding: 8px;
  }
  .mission-workspace {
    padding: 15px 12px;
    border-radius: 12px;
  }
  .mission-workspace-heading h1 {
    font-size: 1.9rem;
  }
  .mission-mixed-card {
    padding: 14px;
    gap: 10px;
  }
  .mission-mixed-card .gb-forge-btn {
    flex-basis: 100%;
    max-width: none;
  }
  .mission-topic-heading .gb-level-picker {
    gap: 2px;
  }
}

/* The original four-button level picker, with the XP pay-off visible on every button.
   Only the selected difficulty is accented. No competing "recommended" highlights. */
.mission-level-control {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.mission-level-intro {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mission-level-title {
  color: #d7c8e7;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.mission-level-hint {
  color: #c9bfd7;
  font-size: 0.74rem;
  font-weight: 700;
  max-width: 150px;
  line-height: 1.2;
}

.mission-level-buttons {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: stretch;
  gap: 5px;
  padding: 5px;
  border: 1px solid rgba(129, 103, 168, 0.5);
  border-radius: 14px;
  background: rgba(9, 7, 21, 0.85);
}

.mission-level-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 70px;
  min-height: 65px;
  padding: 7px 4px 6px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: rgba(33, 27, 49, 0.88);
  color: #e2d9f2;
  cursor: pointer;
  font-family: var(--font-display);
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.mission-level-option:hover:not(.is-selected) {
  border-color: rgba(255, 205, 115, 0.45);
  background: rgba(57, 42, 74, 0.98);
}

.mission-level-option.is-selected {
  border-color: #ffac35;
  background: linear-gradient(180deg, #45301c, #30201a);
  box-shadow: 0 0 0 1px rgba(255, 173, 53, 0.25), inset 0 0 14px rgba(255, 173, 53, 0.13);
  color: #ffda83;
}

.mission-level-number {
  font-size: 1.45rem;
  line-height: 1;
}

.mission-level-reward {
  color: #c9bfd7;
  font-family: Nunito, sans-serif;
  font-size: 0.70rem;
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
}

.mission-level-option.is-selected .mission-level-reward {
  color: #ffda83;
}

.mission-level-option:focus-visible {
  outline: 3px solid #ffd36b;
  outline-offset: 3px;
}

@media (max-width: 540px) {
  .mission-level-control {
    width: 100%;
    justify-content: space-between;
  }

  .mission-level-buttons {
    gap: 3px;
    padding: 4px;
  }

  .mission-level-option {
    width: clamp(53px, 14vw, 70px);
    min-height: 58px;
  }

  .mission-level-reward {
    font-size: 0.65rem;
  }
}

/* Pictures for picture questions (clocks, fraction shapes, 2D shapes). */
.question-visual {
  display: flex;
  justify-content: center;
  margin: 4px auto 10px;
}

.question-visual svg {
  width: clamp(110px, 16vw, 170px);
  height: auto;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45));
}

/* "Defences charged!" — the might builder filled during a topic set. */
.charged-banner {
  position: fixed;
  top: 84px;
  left: 50%;
  z-index: 8000;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 24px);
  padding: 10px 14px 10px 18px;
  border: 3px solid #fff;
  border-radius: 20px;
  background: linear-gradient(160deg, #ef3b2d, #b3121b);
  box-shadow: 0 6px 0 #6e0810, 0 12px 26px rgba(0, 0, 0, .55);
  color: #fff;
  translate: -50% 0;
  animation: charged-banner-in .4s cubic-bezier(.2, 1.4, .4, 1);
}

.charged-banner-text {
  display: grid;
  line-height: 1.1;
}

.charged-banner-text b {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 400;
  letter-spacing: .05em;
  text-shadow: 2px 2px 0 #6e0810;
}

.charged-banner-text span {
  font-size: .9rem;
  font-weight: 700;
}

.charged-banner-go {
  padding: 8px 14px;
  border: 3px solid #fff;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffd84a, #ff9500);
  box-shadow: 0 4px 0 #a85a00;
  color: #7a0c12;
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: .05em;
  white-space: nowrap;
  cursor: pointer;
}

.charged-banner-stay {
  border: none;
  background: none;
  color: rgba(255, 255, 255, .85);
  font-weight: 700;
  text-decoration: underline;
  white-space: nowrap;
  cursor: pointer;
}

@keyframes charged-banner-in {
  from { translate: -50% -30px; opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .charged-banner { animation: none; }
}
