@import url("https://fonts.googleapis.com/css2?family=Archivo+Black&family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  --image-aspect: 4 / 3;
  --ink: #142a3a;
  --ink-soft: #4e6572;
  --paper: #f7f2e7;
  --paper-deep: #e9e0cd;
  --cream: #fffaf0;
  --gold: #f2b422;
  --gold-deep: #d89a0e;
  --green: #468548;
  --blue: #1e90c2;
  --line: rgba(20, 42, 58, 0.16);
  --shadow: 0 22px 60px rgba(41, 48, 43, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 8%, rgba(242, 180, 34, 0.14), transparent 23rem),
    radial-gradient(circle at 92% 25%, rgba(30, 144, 194, 0.09), transparent 28rem),
    var(--paper);
  font-family: "Manrope", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.site-shell {
  width: min(1380px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar {
  min-height: 108px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: block;
  width: 190px;
  flex: 0 0 auto;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 7px;
}

.mission-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  color: #356e3c;
  background: rgba(70, 133, 72, 0.1);
  border: 1px solid rgba(70, 133, 72, 0.28);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.mission-badge span {
  color: #54a65c;
  font-size: 10px;
  animation: pulse 1.8s ease-in-out infinite;
}

.hero-copy {
  padding: 56px 0 42px;
  text-align: center;
}

.eyebrow,
.reference-card .card-heading p,
.level-picker > div > div > p {
  margin: 0;
  color: var(--gold-deep);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2.4px;
}

.hero-copy h1 {
  max-width: 880px;
  margin: 12px auto 12px;
  font-family: "Archivo Black", Impact, sans-serif;
  font-size: clamp(44px, 6vw, 78px);
  letter-spacing: -3px;
  line-height: 0.98;
}

.hero-copy > p:last-child {
  max-width: 680px;
  margin: 0 auto;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.7;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(250px, 0.72fr) minmax(0, 2fr);
  gap: 24px;
  align-items: start;
}

.reference-card,
.play-card,
.level-picker {
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.reference-card {
  position: sticky;
  top: 18px;
  padding: 22px;
  border-radius: 3px;
}

.card-heading,
.play-toolbar,
.play-footer,
.level-picker,
.level-picker > div,
.level-buttons,
footer {
  display: flex;
  align-items: center;
}

.card-heading,
.play-toolbar,
.play-footer,
.level-picker,
footer {
  justify-content: space-between;
}

.card-heading > div,
.level-picker > div {
  gap: 12px;
}

.section-number {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  flex: 0 0 auto;
  color: var(--cream);
  background: var(--ink);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
}

.evidence-tag {
  padding: 6px 8px;
  color: #846111;
  background: rgba(242, 180, 34, 0.15);
  border: 1px solid rgba(216, 154, 14, 0.25);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
}

.reference-image-wrap {
  position: relative;
  margin-top: 18px;
  overflow: hidden;
  background: var(--paper-deep);
  border: 6px solid white;
  box-shadow: 0 6px 20px rgba(20, 42, 58, 0.13);
  transform: rotate(-1deg);
}

.reference-image-wrap img {
  display: block;
  width: 100%;
  aspect-ratio: var(--image-aspect);
  object-fit: contain;
}

.reference-image-wrap span {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 5px 7px;
  color: var(--ink);
  background: var(--gold);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1px;
}

.tip {
  display: flex;
  gap: 10px;
  margin: 20px 2px 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}

.tip span {
  color: var(--gold-deep);
  font-size: 22px;
  line-height: 1;
}

.play-card {
  padding: 22px;
  border-radius: 3px;
}

.play-toolbar {
  min-height: 56px;
  gap: 18px;
  margin-bottom: 18px;
}

.stats {
  display: flex;
  align-items: stretch;
  gap: 20px;
}

.stats div span,
.stats div strong {
  display: block;
}

.stats div span {
  margin-bottom: 4px;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.4px;
}

.stats div strong {
  font-family: "Archivo Black", Impact, sans-serif;
  font-size: 24px;
  letter-spacing: 0.5px;
  line-height: 1;
}

.stats i {
  width: 1px;
  background: var(--line);
}

.timer-active {
  color: var(--gold-deep);
}

.restart-button,
.success-overlay button {
  min-height: 44px;
  padding: 0 18px;
  color: var(--ink);
  background: transparent;
  border: 1px solid rgba(20, 42, 58, 0.28);
  border-radius: 2px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  transition: 160ms ease;
}

.restart-button:hover,
.restart-button:focus-visible {
  background: var(--ink);
  color: white;
  outline: none;
}

.restart-button span {
  margin-right: 5px;
  font-size: 17px;
}

.puzzle-grid {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: var(--image-aspect);
  overflow: hidden;
  background: var(--ink);
  border: 7px solid var(--ink);
  box-shadow: 0 15px 34px rgba(20, 42, 58, 0.17);
}

.puzzle-piece {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  background-repeat: no-repeat;
  border: 1.5px solid rgba(255, 255, 255, 0.84);
  border-radius: 1px;
  cursor: grab;
  touch-action: none;
  transition: filter 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.puzzle-piece:hover {
  filter: brightness(1.07);
  z-index: 2;
}

.puzzle-piece:focus-visible,
.puzzle-piece.is-selected {
  z-index: 4;
  outline: 4px solid var(--gold);
  outline-offset: -4px;
  box-shadow: inset 0 0 0 2px var(--ink);
}

.puzzle-piece.is-dragging {
  z-index: 5;
  cursor: grabbing;
  filter: brightness(1.12) saturate(1.1);
  transform: scale(0.94);
  box-shadow: 0 8px 20px rgba(20, 42, 58, 0.35);
}

.puzzle-grid.is-complete .puzzle-piece {
  border-color: transparent;
}

.success-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: white;
  background: rgba(20, 42, 58, 0.88);
  text-align: center;
  animation: reveal 300ms ease both;
  backdrop-filter: blur(4px);
}

.success-stamp {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  margin-bottom: 16px;
  color: var(--ink);
  background: var(--gold);
  border: 4px solid white;
  border-radius: 50%;
  font-size: 34px;
  font-weight: 900;
  transform: rotate(-7deg);
}

.success-overlay p {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2.4px;
}

.success-overlay h2 {
  max-width: 540px;
  margin: 0 0 12px;
  font-family: "Archivo Black", Impact, sans-serif;
  font-size: clamp(26px, 4vw, 46px);
  letter-spacing: -1px;
}

.success-overlay > span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
}

.success-overlay > span strong {
  color: white;
}

.success-overlay button {
  margin-top: 22px;
  color: var(--ink);
  background: var(--gold);
  border-color: var(--gold);
}

.success-overlay button:hover {
  background: white;
  border-color: white;
}

.play-footer {
  gap: 20px;
  padding-top: 18px;
}

.play-footer p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.play-footer p span {
  margin-right: 6px;
  color: var(--gold-deep);
  font-size: 18px;
  font-weight: 800;
}

.progress-track {
  width: 140px;
  height: 5px;
  flex: 0 0 auto;
  overflow: hidden;
  background: var(--paper-deep);
  border-radius: 10px;
}

.progress-track span {
  display: block;
  height: 100%;
  background: var(--gold);
  border-radius: inherit;
  transition: width 300ms ease;
}

.level-picker {
  gap: 28px;
  margin-top: 24px;
  padding: 24px 28px;
}

.level-picker h2 {
  margin: 4px 0 0;
  font-family: "Archivo Black", Impact, sans-serif;
  font-size: 20px;
}

.level-buttons {
  gap: 8px;
}

.level-buttons button {
  min-width: 128px;
  padding: 11px 15px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  cursor: pointer;
  text-align: left;
  transition: 160ms ease;
}

.level-buttons button span,
.level-buttons button small {
  display: block;
}

.level-buttons button span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.level-buttons button small {
  margin-top: 2px;
  font-size: 10px;
}

.level-buttons button:hover,
.level-buttons button:focus-visible,
.level-buttons button.active {
  background: var(--gold);
  border-color: var(--gold-deep);
  outline: none;
}

footer {
  min-height: 120px;
  color: var(--ink-soft);
  font-size: 11px;
}

footer span {
  font-weight: 800;
  letter-spacing: 1.7px;
}

footer p {
  margin: 0;
  font-style: italic;
}

@keyframes pulse {
  50% { opacity: 0.35; }
}

@keyframes reveal {
  from { opacity: 0; transform: scale(0.985); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 940px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .reference-card {
    position: static;
    display: grid;
    grid-template-columns: minmax(220px, 0.65fr) 1fr;
    column-gap: 24px;
    align-items: center;
  }

  .card-heading {
    grid-column: 1 / -1;
  }

  .reference-image-wrap {
    grid-row: 2 / 4;
  }

  .tip {
    align-self: center;
  }

  .level-picker {
    align-items: flex-start;
    flex-direction: column;
  }

  .level-buttons {
    width: 100%;
  }

  .level-buttons button {
    flex: 1;
  }
}

@media (max-width: 650px) {
  .site-shell {
    width: min(100% - 24px, 1380px);
  }

  .topbar {
    min-height: 82px;
  }

  .brand { width: 150px; }

  .mission-badge {
    width: 12px;
    height: 12px;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: transparent;
  }

  .mission-badge span {
    font-size: 12px;
  }

  .hero-copy {
    padding: 42px 0 30px;
    text-align: left;
  }

  .hero-copy h1 {
    margin-left: 0;
    font-size: clamp(42px, 14vw, 60px);
    letter-spacing: -2px;
  }

  .hero-copy > p:last-child {
    font-size: 14px;
  }

  .reference-card {
    display: block;
    padding: 16px;
  }

  .reference-image-wrap {
    margin-top: 14px;
  }

  .tip {
    margin-top: 14px;
  }

  .play-card {
    padding: 9px;
  }

  .play-toolbar {
    align-items: center;
    gap: 8px;
    margin: 7px 5px 12px;
  }

  .stats {
    flex: 1;
    justify-content: space-between;
    gap: 8px;
  }

  .stats div span {
    font-size: 7px;
    letter-spacing: 0.8px;
  }

  .stats div strong {
    font-size: 18px;
  }

  .stats i {
    display: none;
  }

  .restart-button {
    width: 42px;
    min-height: 42px;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }

  .restart-button span {
    margin: 0;
    font-size: 22px;
  }

  .puzzle-grid {
    border-width: 4px;
  }

  .play-footer {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 12px 5px 6px;
  }

  .play-footer p {
    font-size: 10px;
  }

  .progress-track {
    width: 100%;
  }

  .level-picker {
    padding: 20px 16px;
  }

  .level-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }

  .level-buttons button {
    min-width: 0;
    padding: 10px 8px;
    text-align: center;
  }

  .level-buttons button span {
    font-size: 10px;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
