:root {
  --bg: #081225;
  --panel: #ffffff;
  --ink: #101827;
  --muted: #5f6878;
  --line: #d5deea;
  --accent: #e4553f;
  --accent-dark: #9f2e25;
  --green: #248a5a;
  --blue: #246b9d;
  --yellow: #e9b949;
  --cyan: #4aa3c7;
  --shadow: 0 18px 46px rgba(3, 10, 28, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  overflow-x: hidden;
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

.space-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 20%, rgba(74, 163, 199, 0.2), transparent 26%),
    radial-gradient(circle at 84% 16%, rgba(80, 94, 160, 0.22), transparent 28%),
    radial-gradient(circle at 50% 120%, rgba(233, 185, 73, 0.12), transparent 28%),
    linear-gradient(160deg, #081225 0%, #101b38 48%, #172348 100%);
}

.space-scene::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), transparent 86%);
}

.stars {
  position: absolute;
  inset: -20%;
  opacity: 0.86;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.9) 0 1px, transparent 1.2px),
    radial-gradient(circle, rgba(233, 185, 73, 0.55) 0 1px, transparent 1.3px),
    radial-gradient(circle, rgba(74, 163, 199, 0.75) 0 1px, transparent 1.2px);
  background-position: 0 0, 80px 50px, 130px 120px;
  background-size: 190px 190px, 260px 260px, 340px 340px;
}

.stars-one {
  opacity: 0.72;
}

.nebula {
  position: absolute;
  width: 42vmax;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(42px);
  opacity: 0.42;
  mix-blend-mode: screen;
}

.nebula-one {
  left: -12vmax;
  top: 20vh;
  background: radial-gradient(circle, rgba(74, 163, 199, 0.58), transparent 64%);
}

.nebula-two {
  right: -14vmax;
  top: 4vh;
  background: radial-gradient(circle, rgba(92, 98, 170, 0.54), transparent 66%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  position: relative;
  z-index: 1;
  width: min(1280px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding: 18px;
  border: 3px solid rgba(36, 120, 212, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-block;
  margin: 0 0 8px;
  padding: 7px 11px;
  border-radius: 999px;
  background: #e7f7ff;
  color: #115c8e;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 5vw, 66px);
  line-height: 0.95;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #17223b;
  text-shadow: none;
}

.status-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 10px;
  min-width: min(520px, 100%);
}

.status-panel > div {
  display: grid;
  gap: 5px;
  align-content: center;
  min-height: 84px;
  padding: 14px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.status-panel > div:nth-child(1) {
  border-color: rgba(37, 164, 106, 0.45);
}

.status-panel > div:nth-child(2) {
  border-color: rgba(255, 120, 168, 0.5);
}

.status-panel > div:nth-child(3) {
  border-color: rgba(36, 120, 212, 0.5);
}

.status-panel > div.metric-pop {
  animation: metricPop 0.75s ease;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-panel strong {
  font-size: 24px;
  color: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}

.flag-list,
.mission {
  border: 3px solid rgba(36, 120, 212, 0.23);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.flag-list {
  position: sticky;
  top: 20px;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(240, 249, 255, 0.94)),
    var(--panel);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  font-weight: 900;
  text-transform: uppercase;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 2px solid rgba(36, 120, 212, 0.25);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 23px;
  line-height: 1;
}

.flag-buttons {
  display: grid;
  gap: 10px;
}

.flag-button {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 68px;
  padding: 10px;
  border: 2px solid rgba(36, 120, 212, 0.2);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.flag-button.active {
  border-color: var(--accent);
  background: #fff7ed;
  box-shadow: inset 6px 0 0 var(--accent), 0 8px 18px rgba(16, 24, 39, 0.08);
}

.flag-button.done {
  border-color: rgba(37, 164, 106, 0.62);
  background: #eafff3;
}

.flag-number {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
}

.flag-text {
  min-width: 0;
}

.flag-name {
  display: block;
  font-weight: 900;
  line-height: 1.15;
}

.flag-skill {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.flag-state {
  font-size: 24px;
}

.final-button,
.primary-button,
.secondary-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  font-weight: 900;
}

.final-button {
  width: 100%;
  margin-top: 14px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(255, 90, 61, 0.18);
}

.final-button:disabled {
  cursor: not-allowed;
  background: #b9c1bd;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 16px rgba(255, 90, 61, 0.16);
}

.secondary-button {
  border: 2px solid rgba(36, 120, 212, 0.25);
  background: #f5fbff;
  color: var(--ink);
}

.mission {
  min-height: 640px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 251, 232, 0.94)),
    var(--panel);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  gap: 26px;
  align-items: stretch;
}

.hero-copy {
  display: grid;
  align-content: center;
  min-height: 560px;
}

.hero-copy h2,
.mission-title {
  margin-bottom: 14px;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.98;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-copy p,
.mission-lead {
  max-width: 680px;
  color: var(--muted);
  font-size: 21px;
  line-height: 1.45;
}

.machine-visual {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  border: 2px solid #26372f;
  border-radius: 8px;
  background:
    radial-gradient(circle at 30% 25%, rgba(233, 185, 73, 0.28), transparent 24%),
    radial-gradient(circle at 78% 68%, rgba(74, 163, 199, 0.24), transparent 26%),
    linear-gradient(145deg, #173d73, #101b38 64%);
}

.safe {
  position: absolute;
  left: 50%;
  top: 48%;
  width: min(340px, 78%);
  aspect-ratio: 0.92;
  padding: 18px;
  border: 12px solid #9eacbb;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 34%),
    linear-gradient(160deg, #6f7f90, #2f4054);
  transform: translate(-50%, -50%);
  box-shadow:
    0 28px 48px rgba(0, 0, 0, 0.34),
    inset 0 0 0 6px rgba(255, 255, 255, 0.08);
}

.safe::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -30px;
  width: 82%;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.28);
  filter: blur(8px);
  transform: translateX(-50%);
}

.safe-door {
  position: relative;
  width: 100%;
  height: 100%;
  border: 7px solid #c5d0dc;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.16), transparent 26%),
    linear-gradient(145deg, #52677c, #233246);
  box-shadow:
    inset 0 0 0 4px rgba(16, 24, 39, 0.35),
    inset 0 18px 30px rgba(255, 255, 255, 0.09);
}

.safe-hinges {
  position: absolute;
  right: -16px;
  top: 22%;
  display: grid;
  gap: 48px;
}

.safe-hinges span {
  display: block;
  width: 24px;
  height: 50px;
  border: 4px solid #c5d0dc;
  border-radius: 8px;
  background: #6f7f90;
}

.safe-dial {
  position: absolute;
  left: 50%;
  top: 43%;
  display: grid;
  place-items: center;
  width: 112px;
  aspect-ratio: 1;
  border: 8px solid #d5deea;
  border-radius: 50%;
  background:
    conic-gradient(from 0deg, #d5deea 0 8deg, #40546b 8deg 18deg, #d5deea 18deg 26deg, #40546b 26deg 36deg, #d5deea 36deg 44deg, #40546b 44deg 360deg);
  box-shadow:
    0 10px 18px rgba(0, 0, 0, 0.24),
    inset 0 0 0 12px #52677c;
  transform: translate(-50%, -50%);
  animation: safeDial 7s ease-in-out infinite;
}

.safe-dial span {
  width: 34px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #101827;
  box-shadow: inset 0 0 0 6px #9eacbb;
}

.safe-panel {
  position: absolute;
  left: 50%;
  bottom: 38px;
  display: grid;
  gap: 3px;
  min-width: 132px;
  padding: 10px 14px;
  border: 4px solid #c5d0dc;
  border-radius: 8px;
  background: #111a2b;
  color: #d8f7ff;
  text-align: center;
  transform: translateX(-50%);
}

.safe-panel span {
  color: #86d7f2;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.safe-panel strong {
  color: #ffffff;
  font-size: 31px;
  line-height: 1;
  letter-spacing: 0;
}

.mission-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: start;
  margin-bottom: 22px;
}

.mission-badge {
  display: inline-grid;
  place-items: center;
  min-width: 76px;
  min-height: 76px;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 38px;
  font-weight: 900;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 20px 0;
}

.task-card,
.journal,
.answer-panel,
.result-panel {
  border: 2px solid rgba(36, 120, 212, 0.22);
  border-radius: 8px;
  background: #fff;
}

.task-card {
  display: grid;
  min-height: 138px;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  box-shadow: 0 8px 18px rgba(36, 120, 212, 0.08);
}

.task-icon {
  display: block;
  margin-bottom: 14px;
  font-size: 42px;
}

.task-icon svg {
  width: 92px;
  height: 68px;
}

.task-card strong,
.journal strong {
  font-size: 20px;
}

.task-card span,
.journal p {
  color: var(--muted);
  line-height: 1.35;
}

.journal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  margin: 28px 0 34px;
}

.journal {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 300px;
  padding: 20px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.journal h3 {
  margin-bottom: 0;
  color: var(--accent-dark);
  font-size: 15px;
  text-transform: uppercase;
}

.journal h4 {
  margin: 0;
  font-size: 18px;
  text-transform: uppercase;
}

.journal-row {
  display: grid;
  gap: 6px;
  padding-top: 14px;
  border-top: 2px solid var(--line);
}

.journal-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.journal-row strong {
  font-size: 18px;
  line-height: 1.25;
}

.journal-row.lost {
  margin: 2px -6px 0;
  padding: 14px 12px;
  border: 3px solid rgba(225, 77, 42, 0.45);
  border-radius: 8px;
  background: #fff1eb;
}

.journal-row.lost strong {
  color: var(--accent-dark);
  font-size: 22px;
  text-transform: uppercase;
}

.secret-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 22px 0 16px;
  color: var(--muted);
  font-weight: 800;
}

.missing-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(90px, 1fr));
  gap: 14px;
  margin: 18px 0 28px;
}

.secret-board {
  min-height: 198px;
}

.secret-summary {
  display: grid;
  gap: 22px;
  margin-top: 18px;
}

.secret-summary-board {
  grid-template-columns: repeat(5, minmax(90px, 1fr));
}

.secret-summary-round {
  padding: 16px;
  border: 2px solid rgba(36, 120, 212, 0.22);
  border-radius: 8px;
  background: #fff;
}

.secret-summary-round h3 {
  margin-bottom: 12px;
  font-size: 20px;
  text-transform: uppercase;
}

.secret-summary-round p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 800;
}

.secret-summary-round p strong {
  color: var(--accent-dark);
}

.object-tile {
  display: grid;
  grid-template-rows: 112px auto;
  gap: 10px;
  place-items: center;
  min-height: 164px;
  padding: 12px;
  border: 2px solid rgba(36, 120, 212, 0.22);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  text-align: center;
  font-weight: 800;
  line-height: 1.15;
}

.object-tile .visual {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 112px;
  font-size: 48px;
}

.object-tile svg {
  width: 100%;
  max-width: 128px;
  height: 96px;
}

.object-tile.missing {
  border-style: dashed;
  border-color: rgba(225, 77, 42, 0.45);
  background: #fff2ee;
  color: var(--accent-dark);
  font-size: 18px;
}

.timer {
  display: grid;
  place-items: center;
  min-height: 260px;
  margin: 22px 0;
  border: 2px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at center, rgba(255, 211, 79, 0.22), transparent 42%),
    linear-gradient(135deg, #17223b, #284a95);
  color: #fff;
}

.timer strong {
  font-size: clamp(88px, 16vw, 180px);
  line-height: 1;
}

.answer-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.answer-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
}

.answer-row input {
  min-width: 0;
  min-height: 48px;
  border: 2px solid rgba(36, 120, 212, 0.25);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

.attempts,
.hint-text {
  color: var(--muted);
  font-weight: 700;
}

.hint-box,
.result-panel {
  padding: 14px;
  line-height: 1.45;
}

.result-panel strong {
  display: block;
  margin-bottom: 6px;
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1;
  text-transform: uppercase;
}

.result-panel span {
  display: block;
}

.hint-box {
  border: 2px solid rgba(37, 111, 156, 0.35);
  border-radius: 8px;
  background: #eef8ff;
}

.alphabet-hint {
  display: grid;
  grid-template-columns: repeat(11, minmax(46px, 1fr));
  gap: 6px;
}

.alphabet-hint span {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  min-height: 38px;
  overflow: hidden;
  border: 1px solid rgba(36, 107, 157, 0.25);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

.alphabet-hint strong {
  display: grid;
  place-items: center;
  height: 100%;
  background: #e7f2fb;
  color: var(--blue);
  font-size: 13px;
}

.result-panel.success {
  border-color: rgba(47, 143, 91, 0.5);
  background: #effaf3;
  color: #155634;
  animation: successFlash 1s ease;
}

.result-panel.error {
  border-color: rgba(225, 77, 42, 0.5);
  background: #fff2ee;
}

.final-code {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 360px;
  text-align: center;
}

.final-code strong {
  display: block;
  margin: 18px 0;
  font-size: clamp(78px, 14vw, 160px);
  line-height: 1;
  letter-spacing: 0;
  color: var(--accent);
}

.access-granted {
  background: #e8f8ef;
  color: #146c43;
}

.open-safe {
  position: relative;
  width: min(430px, 86vw);
  height: 300px;
  margin: 30px auto 0;
}

.open-safe-box {
  position: absolute;
  left: 28%;
  top: 20px;
  width: 60%;
  height: 238px;
  padding: 16px;
  border: 12px solid #9eacbb;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 34%),
    linear-gradient(160deg, #6f7f90, #2f4054);
  box-shadow:
    inset 0 0 0 6px rgba(255, 255, 255, 0.08),
    0 22px 36px rgba(0, 0, 0, 0.22);
}

.open-safe-inner {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 7px solid #c5d0dc;
  border-radius: 8px;
  background:
    radial-gradient(circle at center, rgba(78, 194, 125, 0.2), transparent 38%),
    linear-gradient(145deg, #263246, #111a2b);
  box-shadow: inset 0 0 0 4px rgba(16, 24, 39, 0.55);
}

.open-safe-door {
  position: absolute;
  left: 4%;
  top: 34px;
  width: 34%;
  height: 216px;
  border: 7px solid #c5d0dc;
  border-radius: 8px;
  background:
    radial-gradient(circle at 52% 42%, rgba(255, 255, 255, 0.16), transparent 27%),
    linear-gradient(145deg, #52677c, #233246);
  box-shadow:
    inset 0 0 0 4px rgba(16, 24, 39, 0.35),
    0 16px 24px rgba(0, 0, 0, 0.24);
  transform: perspective(520px) rotateY(-26deg) skewY(-2deg);
  transform-origin: right center;
}

.open-safe-dial {
  position: absolute;
  left: 50%;
  top: 40%;
  width: 58px;
  aspect-ratio: 1;
  border: 6px solid #d5deea;
  border-radius: 50%;
  background: #52677c;
  box-shadow: inset 0 0 0 11px #101827;
  transform: translate(-50%, -50%);
}

.open-safe-panel {
  position: absolute;
  left: 50%;
  bottom: 28px;
  min-width: 74px;
  padding: 7px 10px;
  border: 3px solid #c5d0dc;
  border-radius: 6px;
  background: #111a2b;
  color: #a9f0c4;
  font-size: 12px;
  font-weight: 900;
  transform: translateX(-50%);
}

.toy-stamp {
  display: grid;
  grid-template-rows: 54px 34px 54px;
  place-items: center;
  color: #0f5f3a;
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.25));
}

.stamp-handle {
  width: 58px;
  height: 58px;
  border: 7px solid #136b42;
  border-radius: 50%;
  background: #53d989;
}

.stamp-neck {
  width: 34px;
  height: 40px;
  border: 6px solid #136b42;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: #43c878;
}

.stamp-base {
  display: grid;
  place-items: center;
  width: 128px;
  height: 52px;
  border: 7px solid #136b42;
  border-radius: 12px;
  background: #5ee08f;
  color: #0f5f3a;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
}

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rotateBack {
  to {
    transform: rotate(-360deg);
  }
}

@keyframes safeDial {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(-8deg);
  }

  45% {
    transform: translate(-50%, -50%) rotate(34deg);
  }

  70% {
    transform: translate(-50%, -50%) rotate(16deg);
  }
}

@keyframes metricPop {
  0% {
    transform: scale(1);
    border-color: var(--line);
    background: #fff;
  }

  35% {
    transform: scale(1.07);
    border-color: var(--yellow);
    background: #fff7d8;
  }

  100% {
    transform: scale(1);
    border-color: var(--line);
    background: #fff;
  }
}

@keyframes successFlash {
  0% {
    transform: scale(0.98);
    box-shadow: 0 0 0 0 rgba(47, 143, 91, 0.42);
  }

  45% {
    transform: scale(1.03);
    box-shadow: 0 0 0 12px rgba(47, 143, 91, 0.12);
  }

  100% {
    transform: scale(1);
    box-shadow: none;
  }
}

@media (max-width: 980px) {
  .topbar,
  .workspace,
  .hero-grid,
  .journal-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .flag-list {
    position: static;
  }
}

@media (max-width: 680px) {
  .app {
    padding: 12px;
  }

  .status-panel,
  .task-grid,
  .missing-board,
  .answer-row,
  .alphabet-hint {
    grid-template-columns: 1fr;
  }

  .mission {
    min-height: 0;
    padding: 16px;
  }

  .mission-header {
    grid-template-columns: 1fr;
  }

  .hero-copy,
  .machine-visual {
    min-height: 420px;
  }
}
