body {
  min-width: 320px;
  min-height: 100vh;
}

.page-shell {
  display: grid;
  min-height: 100vh;
  padding: 20px;
  place-items: start center;
}

.game-card {
  width: min(100%, 1080px);
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid var(--line);
  border-radius: 34px;
  background: linear-gradient(135deg, var(--surface), #f4efe2);
  box-shadow: var(--shadow);
}

.game-navigation {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.game-navigation .brand-lock {
  gap: 8px;
  text-align: left;
}

.game-navigation .brand-mark {
  width: 38px;
  height: 38px;
}

.game-navigation .brand-name {
  font-size: 1.05rem;
}

.game-navigation .brand-name small {
  font-size: 0.53rem;
}

.back-link {
  color: var(--navy);
  font: 800 0.82rem var(--sans);
  text-decoration: none;
}

.back-link:hover {
  color: var(--gold-dark);
  text-decoration: underline;
}

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

h1,
h2 {
  color: var(--navy);
  font-family: var(--serif);
}

h1 {
  margin-bottom: 7px;
  text-align: center;
  font-size: clamp(2.2rem, 5vw, 3.55rem);
  line-height: 1;
}

h2 {
  margin-bottom: 7px;
  font-size: clamp(1.4rem, 3vw, 2rem);
  line-height: 1.05;
}

.game-card > .eyebrow {
  display: flex;
  justify-content: center;
}

.intro {
  max-width: 690px;
  margin: 0 auto 22px;
  color: #3e4142;
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.55;
}

.section-label {
  margin-bottom: 7px;
  color: var(--gold-dark);
  font: 900 0.68rem var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.objective-panel,
.challenge-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.game-workspace {
  display: grid;
  grid-template-columns: minmax(245px, 0.62fr) minmax(470px, 1.38fr);
  align-items: start;
  gap: 16px;
}

.objective-panel {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 22px;
  background: linear-gradient(115deg, var(--navy) 0%, #18415b 58%, #29656c 100%);
  margin-bottom: 0;
}

.objective-panel .section-label {
  color: #e9d87f;
}

.objective-copy h2 {
  color: var(--white);
}

.objective-copy p:not(.section-label) {
  max-width: 360px;
  margin-bottom: 0;
  color: #e9eef2;
  font-size: 0.95rem;
  line-height: 1.55;
}

.target-grid,
.puzzle-grid {
  --grid-size: 4;
  display: grid;
  grid-template-columns: repeat(var(--grid-size), minmax(0, 1fr));
}

.target-grid {
  width: min(100%, 360px);
  justify-self: center;
  gap: 3px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 18px;
  background: rgba(2, 12, 21, 0.3);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 18px 32px rgba(3, 11, 18, 0.24);
}

.challenge-panel {
  padding: clamp(18px, 3vw, 28px);
  background: rgba(255, 253, 246, 0.78);
}

.challenge-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.challenge-header h2,
.challenge-header .section-label {
  margin-bottom: 0;
}

.level-picker {
  display: flex;
  overflow: hidden;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-2);
}

.level-option {
  min-width: 76px;
  padding: 7px 8px 6px;
  border: 0;
  border-radius: 10px;
  color: var(--navy);
  background: transparent;
  cursor: pointer;
  font: 900 0.73rem/1 var(--sans);
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.level-option small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font: 700 0.58rem/1 var(--sans);
}

.level-option:not(:disabled):hover,
.level-option:not(:disabled):focus-visible {
  background: rgba(6, 27, 49, 0.09);
}

.level-option.is-selected {
  color: var(--white);
  background: var(--navy);
  box-shadow: 0 3px 7px rgba(6, 27, 49, 0.18);
}

.level-option.is-selected small {
  color: var(--gold-soft);
}

.level-option:disabled {
  opacity: 0.68;
  cursor: default;
}

.game-status {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.game-status p {
  margin: 0;
  padding: 11px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  font: 800 0.7rem var(--sans);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.game-status strong {
  display: inline-block;
  color: var(--navy);
}

.time-panel {
  margin-top: 14px;
}

.time-heading {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--muted);
  font: 800 0.74rem var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.time-heading strong {
  color: var(--navy);
}

.time-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ddc8;
}

.time-bar {
  display: block;
  width: var(--time-progress, 100%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6ea9b7, #d5c35b);
  transition: width 100ms linear, background 200ms ease;
}

.time-bar.is-urgent {
  background: #b45f4a;
}

.game-message {
  min-height: 24px;
  margin: 13px 0 9px;
  color: var(--gold-dark);
  text-align: center;
  font: 800 0.9rem/1.35 var(--sans);
}

.instructions {
  margin: 0 0 13px;
  color: #4f514c;
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.55;
}

.instructions span {
  display: inline-grid;
  width: 23px;
  height: 23px;
  margin: 0 3px;
  border-radius: 50%;
  place-items: center;
  color: var(--navy);
  background: var(--gold-soft);
  font: 900 1rem/1 var(--sans);
}

.puzzle-grid {
  width: min(100%, 540px);
  gap: clamp(5px, 1vw, 9px);
  margin: 0 auto;
  padding: clamp(9px, 2vw, 14px);
  border: 1px solid #c7b981;
  border-radius: 20px;
  background: linear-gradient(135deg, #ede4bf, #d9cb91);
}

.target-slot,
.puzzle-slot {
  min-width: 0;
  aspect-ratio: 1;
}

.puzzle-slot {
  border-radius: 10px;
  background: rgba(6, 27, 49, 0.13);
}

.target-tile,
.puzzle-tile {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(6, 27, 49, 0.38);
  border-radius: 9px;
  background: #f7f4ea;
}

.target-tile {
  pointer-events: none;
}

.puzzle-tile {
  position: relative;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.puzzle-tile:not(:disabled):hover,
.puzzle-tile:not(:disabled):focus-visible {
  box-shadow: 0 10px 18px rgba(6, 27, 49, 0.2);
  transform: translateY(-3px);
}

.puzzle-tile:focus-visible {
  outline: 3px solid var(--white);
  outline-offset: 3px;
}

.puzzle-tile:active {
  cursor: grabbing;
}

.puzzle-tile:disabled {
  cursor: default;
}

.puzzle-tile.is-correct {
  box-shadow: 0 0 0 3px #fff4b7, inset 0 0 0 2px rgba(96, 132, 76, 0.58);
}

.puzzle-tile.is-dragging {
  opacity: 0.2;
}

.tile-surface {
  display: block;
  width: 100%;
  height: 100%;
  background-color: #f7f4ea;
  background-image:
    radial-gradient(circle at 18% 23%, rgba(231, 198, 78, 0.98) 0 7%, transparent 7.8%),
    radial-gradient(circle at 78% 31%, rgba(101, 164, 184, 0.95) 0 9%, transparent 9.8%),
    radial-gradient(circle at 70% 78%, rgba(189, 104, 83, 0.86) 0 8%, transparent 8.8%),
    linear-gradient(38deg, transparent 0 38%, rgba(6, 27, 49, 0.9) 38.5% 43%, transparent 43.5% 100%),
    linear-gradient(130deg, transparent 0 46%, rgba(255, 253, 246, 0.75) 46.5% 51%, transparent 51.5% 100%),
    conic-gradient(from 18deg at 56% 48%, #17425b 0 20%, #6fa8b7 20% 37%, #e5cf72 37% 57%, #c06f5e 57% 72%, #f7f4ea 72% 100%);
  background-position: var(--bg-x) var(--bg-y);
  background-size: var(--bg-size) var(--bg-size);
  transform: rotate(var(--piece-rotation, 0deg));
  transform-origin: center;
  transition: transform 230ms cubic-bezier(0.34, 1.4, 0.64, 1);
}

.target-grid .tile-surface {
  transition: none;
}

.drag-ghost {
  position: fixed;
  z-index: 10;
  margin: 0;
  pointer-events: none;
  filter: drop-shadow(0 13px 15px rgba(6, 27, 49, 0.28));
  transform: translate(-50%, -50%) rotate(2deg) scale(1.05);
}

.game-actions,
.result-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.game-actions {
  margin-top: 17px;
}

.button {
  display: inline-flex;
  min-height: 47px;
  align-items: center;
  justify-content: center;
  padding: 12px 19px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button-primary {
  color: #071523;
  background: var(--gold-2);
}

.button-primary:hover {
  background: var(--gold);
}

.button-secondary {
  border-color: var(--line);
  color: var(--navy);
  background: var(--surface);
}

.button-secondary:hover {
  background: var(--navy-soft);
}

.result-dialog {
  width: min(calc(100% - 32px), 480px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.result-dialog::backdrop {
  background: rgba(3, 12, 22, 0.8);
}

.result-dialog__content {
  padding: clamp(26px, 6vw, 38px);
  text-align: center;
}

.result-dialog__content .eyebrow {
  justify-content: center;
}

.result-dialog__content h2 {
  font-size: clamp(1.85rem, 5vw, 2.4rem);
}

.result-dialog__content > p:not(.eyebrow) {
  margin-bottom: 25px;
  color: #3e4142;
  line-height: 1.55;
}

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

  .objective-panel {
    position: sticky;
    top: 8px;
    z-index: 2;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 16px;
    box-shadow: 0 10px 22px rgba(6, 27, 49, 0.2);
    margin-bottom: 16px;
  }

  .objective-copy {
    min-width: 0;
    text-align: left;
  }

  .objective-copy h2 {
    margin-bottom: 0;
    font-size: clamp(1.25rem, 4vw, 1.6rem);
  }

  .objective-copy p:not(.section-label) {
    display: none;
  }

  .target-grid {
    width: 150px;
    flex: 0 0 150px;
    padding: 7px;
    box-shadow: none;
  }

  .challenge-header {
    align-items: center;
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 590px) {
  .page-shell {
    padding: 12px;
  }

  .game-card {
    padding: 25px 18px;
    border-radius: 22px;
  }

  .game-navigation {
    flex-direction: column-reverse;
    align-items: center;
    margin-bottom: 26px;
  }

  .level-picker {
    width: 100%;
  }

  .level-option {
    min-width: 0;
    flex: 1;
    padding-inline: 5px;
  }

  .game-status p {
    padding-inline: 5px;
    font-size: 0.62rem;
  }

  .puzzle-grid {
    gap: 5px;
  }

  .game-actions .button,
  .result-dialog__actions .button {
    width: 100%;
    min-height: 52px;
  }
}

@media (max-width: 380px) {
  .instructions {
    font-size: 0.82rem;
  }

  .level-option small {
    font-size: 0.52rem;
  }
}

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