/* ============================================================
   DESKTOP FOUNDATION
   ============================================================ */

:root {
  --desktop-max: 1180px;
  --content-max: 860px;
  --shadow-large: 0 30px 90px rgba(0, 0, 0, 0.42);
  --operator-panel-width: 320px;
  --operator-portrait-width: 270px;
  --operator-portrait-height: 300px;
}

html,
body { min-height: 100%; }

body {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(
      circle at 50% -10%,
      rgba(233, 183, 189, 0.14),
      transparent 34%
    ),
    radial-gradient(
      circle at 15% 65%,
      rgba(112, 94, 132, 0.08),
      transparent 32%
    ),
    radial-gradient(
      circle at 90% 72%,
      rgba(233, 183, 189, 0.045),
      transparent 26%
    ),
    #0f0f14;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(
      rgba(255, 255, 255, 0.018) 1px,
      transparent 1px
    ),
    linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.018) 1px,
      transparent 1px
    );
  background-size: 64px 64px;
  mask-image:
    linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.65),
      transparent 88%
    );
  opacity: 0.55;
}

.app {
  position: relative;
  z-index: 1;
  width:
    min(
      calc(100% - 80px),
      var(--desktop-max)
    );
  min-height: 100vh;
  margin: 0 auto;
  padding: 52px 0 72px;
}

.app:has(.mission-topbar) {
  padding-top: 28px;
}

h1 {
  font-size:
    clamp(
      3rem,
      5vw,
      4.8rem
    );
  line-height: 0.94;
}

.eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.22em;
}

.intro {
  max-width: 760px;
  margin: 0 auto;
  padding: 72px 0 12px;
  text-align: center;
}

.intro h1 { margin-top: 6px; }

.intro-text {
  max-width: 48ch;
  margin: 22px auto 0;
  font-size: 1.05rem;
  line-height: 1.65;
}

.operators {
  display: grid;
  grid-template-columns:
    repeat(
      2,
      minmax(0, 1fr)
    );
  gap: 24px;
  max-width: 920px;
  margin: 44px auto 0;
}

.operator-card {
  grid-template-columns: 170px 1fr;
  min-height: 220px;
  padding: 20px 30px 20px 16px;
  border-radius: 30px;
  background:
    radial-gradient(
      circle at 20% 10%,
      rgba(233, 183, 189, 0.08),
      transparent 42%
    ),
    linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.085),
      rgba(255, 255, 255, 0.028)
    );
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.18);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.operator-image {
  width: 165px;
  height: 185px;
}

.operator-info { padding-left: 18px; }

.operator-info strong {
  font-size:
    clamp(
      2rem,
      3vw,
      2.8rem
    );
}

.operator-card::after {
  right: 24px;
  bottom: 22px;
}

@media (hover: hover) and (pointer: fine) {
  .operator-card:hover {
    transform: translateY(-6px);
    border-color: rgba(233, 183, 189, 0.34);
    background:
      radial-gradient(
        circle at 20% 10%,
        rgba(233, 183, 189, 0.13),
        transparent 42%
      ),
      linear-gradient(
        145deg,
        rgba(255, 255, 255, 0.11),
        rgba(255, 255, 255, 0.045)
      );
    box-shadow: 0 32px 75px rgba(0, 0, 0, 0.32);
  }
}

.status { margin-top: 34px; }

.mission-screen {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding-top: 8px;
}

.mission-topbar {
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.back-button { font-size: 0.86rem; }

.sector-progress {
  font-size: 0.7rem;
  letter-spacing: 0.13em;
}

.mission-mascot-wrap {
  margin: 10px auto 24px;
}

.mission-mascot {
  width: var(--operator-portrait-width);
  height: var(--operator-portrait-height);
}

.mission-screen > .eyebrow,
.mission-screen > h1 {
  text-align: center;
}

.mission-screen > .mission-message {
  max-width: 650px;
  margin: 26px auto;
  text-align: center;
  font-size: 1.02rem;
  line-height: 1.7;
}

.mission-screen > .primary-button {
  display: block;
  width: min(100%, 420px);
  margin: 28px auto 0;
}

.puzzle-card {
  position: relative;
  margin-top: 34px;
  padding: 34px 38px 36px;
  overflow: hidden;
  background:
    radial-gradient(
      circle at 100% 0%,
      rgba(233, 183, 189, 0.07),
      transparent 28%
    ),
    linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.065),
      rgba(255, 255, 255, 0.035)
    );
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 28px;
  box-shadow: var(--shadow-large);
}

.puzzle-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 48px;
  right: 48px;
  height: 1px;
  background:
    linear-gradient(
      90deg,
      transparent,
      rgba(233, 183, 189, 0.4),
      transparent
    );
}

.puzzle-mascot {
  width: 112px;
  height: 112px;
  margin: 0 auto 22px;
  filter:
    drop-shadow(
      0 14px 22px
      rgba(0, 0, 0, 0.28)
    );
}

.primary-button {
  min-height: 56px;
  border-radius: 15px;
  transition:
    transform 130ms ease,
    filter 130ms ease,
    box-shadow 130ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .primary-button:hover:not(:disabled) {
    filter: brightness(1.06);
    box-shadow: 0 10px 30px rgba(233, 183, 189, 0.14);
    transform: translateY(-1px);
  }

  .log-button:hover,
  .signal-play:hover {
    border-color: rgba(233, 183, 189, 0.28);
    background: rgba(255, 255, 255, 0.085);
  }
}

.answer-input {
  min-height: 56px;
  padding: 14px 18px;
  border-radius: 14px;
}

.clue-panel,
.binary-panel,
.cipher-panel {
  padding: 22px 24px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.26);
  box-shadow:
    inset 0 1px 0
    rgba(255, 255, 255, 0.025);
}

.sequence-display { padding: 17px 19px; }

.shape-grid {
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.shape-button { min-height: 112px; }

.signal-grid { gap: 12px; }

.signal-button {
  min-height: 82px;
  aspect-ratio: auto;
  border-radius: 15px;
}

.archive-grid { gap: 12px; }

.archive-fragment {
  min-height: 92px;
  aspect-ratio: auto;
}

.crossref-row { padding: 15px 18px; }

.crossref-row strong { font-size: 0.96rem; }

.crossref-row span { font-size: 0.88rem; }

body.dev-mode { padding-bottom: 92px; }

.dev-toolbar { padding: 9px 14px; }

.dev-toolbar-main {
  max-width: 1180px;
  margin: 0 auto 7px;
}

.dev-sector-list {
  max-width: 1180px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .app { width: calc(100% - 40px); }

  .operators {
    grid-template-columns: 1fr;
    max-width: 620px;
  }

  .operator-card {
    grid-template-columns: 150px 1fr;
  }

  .operator-image { width: 145px; }
}

/* ============================================================
   DESKTOP PUZZLE SHELL
   ============================================================ */

.mission-screen--puzzle { max-width: 1180px; }

.puzzle-layout {
  display: grid;
  grid-template-columns: var(--operator-panel-width) minmax(0, 1fr);
  gap: 30px;
  align-items: stretch;
  margin-top: 28px;
}

.puzzle-context {
  padding: 28px 26px;
  background:
    linear-gradient(
      160deg,
      rgba(255, 255, 255, 0.045),
      rgba(255, 255, 255, 0.018)
    );
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
}

.puzzle-context--portrait {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(
      circle at 50% 48%,
      rgba(233, 183, 189, 0.12),
      transparent 58%
    ),
    linear-gradient(
      160deg,
      rgba(255, 255, 255, 0.045),
      rgba(255, 255, 255, 0.018)
    );
}

.puzzle-context--portrait .puzzle-context-mascot {
  width: min(100%, var(--operator-portrait-width));
  min-height: 0;
  margin: 0;
}

.puzzle-context.puzzle-context--portrait .puzzle-mascot {
  width: min(100%, var(--operator-portrait-width));
  height: var(--operator-portrait-height);
}

.puzzle-context-mascot {
  display: flex;
  justify-content: center;
  min-height: 160px;
  margin-bottom: 22px;
  align-items: center;
}

.puzzle-context .puzzle-mascot {
  width: 170px;
  height: 170px;
  margin: 0;
  object-fit: contain;
  animation: mascotArrive 500ms ease-out both;
}

.puzzle-context-mascot--linked {
  position: static;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 80px;
}

.puzzle-context--linked {
  min-height: 520px;
}

.puzzle-linked-operator {
  display: flex;
  align-items: center;
  justify-content: center;
}

.puzzle-linked-operator--local {
  width: var(--operator-portrait-width);
  height: var(--operator-portrait-height);
}

.puzzle-context.puzzle-context--portrait .puzzle-linked-operator--local .puzzle-mascot {
  width: 100%;
  height: 100%;
}

.puzzle-linked-operator--remote {
  position: absolute;
  z-index: 2;
  top: 24px;
  right: 20px;
  width: 145px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(233, 183, 189, 0.12), transparent 72%);
}

.puzzle-context.puzzle-context--portrait .puzzle-linked-operator--remote .puzzle-mascot {
  width: 135px;
  height: 145px;
}

.puzzle-link-line {
  position: absolute;
  top: 160px;
  right: 92px;
  width: 1px;
  height: 44px;
  background: linear-gradient(transparent, rgba(233, 183, 189, 0.8), transparent);
  transform: rotate(30deg);
}

.puzzle-link-line::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: -3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(233, 183, 189, 0.8);
}

.puzzle-link-status {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: var(--font-label);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-align: center;
}

.is-connecting .puzzle-linked-operator--remote img {
  opacity: 0.48;
  filter: grayscale(1) brightness(0.75) blur(10px);
}

.is-connecting .puzzle-link-line {
  background: repeating-linear-gradient(0deg, rgba(233, 183, 189, 0.7) 0 3px, transparent 3px 6px);
}

@keyframes mascotArrive {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .puzzle-context .puzzle-mascot { animation: none; }
}

.puzzle-workspace {
  margin-top: 0;
  min-width: 0;
  padding: 34px 36px 26px;
}

.puzzle-workspace .feedback:empty {
  min-height: 0;
  margin: 0;
}

.puzzle-screen-brief {
  margin-bottom: 26px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.puzzle-screen-brief .panel-label {
  margin-bottom: 10px;
  color: var(--accent);
}

.puzzle-screen-brief .mission-message {
  margin: 0;
  font-size: var(--font-body);
  line-height: 1.55;
}

.puzzle-screen-brief .mission-message p { margin: 0; }

.decode-data-grid {
  display: grid;
  grid-template-columns: minmax(230px, 0.75fr) minmax(0, 1.35fr);
  gap: 18px;
  align-items: stretch;
}

.decode-data-grid .clue-panel,
.decode-data-grid .cipher-panel {
  margin: 0;
}

.panel-label {
  display: block;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.decode-reference-data {
  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 1rem;
  line-height: 1.75;
  letter-spacing: 0.11em;
}

.decode-reference-data p {
  margin: 0;
  color: var(--text);
}

.decode-challenge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.decode-challenge strong {
  white-space: nowrap;
  font-size: clamp(1.8rem, 2.5vw, 2.6rem);
  letter-spacing: 0.12em;
}

.decode-challenge small {
  max-width: 34ch;
  line-height: 1.45;
}

.answer-area {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    180px;
  gap: 14px;
  align-items: end;
  margin-top: 22px;
}

.answer-field { min-width: 0; }

.answer-area .answer-label { margin-top: 0; }

.answer-area .answer-input { margin-bottom: 0; }

.answer-area .primary-button { min-height: 56px; }

.result-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

.result-actions .primary-button {
  width: auto;
  min-width: 180px;
  margin: 0;
}

.clear-selection {
  padding: 12px 18px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: 15px;
  cursor: pointer;
}

.clear-selection:disabled { opacity: 0.5; }

.shape-button.selected:disabled,
.archive-fragment.selected:disabled { opacity: 1; }

button[aria-pressed="true"]:not(.wrong):not(.correct) {
  border-color: rgba(233, 183, 189, 0.65);
  background: rgba(233, 183, 189, 0.12);
}

@media (max-width: 900px) {
  .puzzle-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  .puzzle-context-mascot {
    min-height: 0;
    margin: 0;
  }

  .decode-data-grid { grid-template-columns: 1fr; }
}
