:root {
  color-scheme: dark;
  --night: #14213a;
  --deep: #0b1020;
  --ink: #f8e7b4;
  --paper: #f2d08b;
  --paper-dark: #c68b48;
  --wood: #8a4f35;
  --wood-dark: #4e2b28;
  --leaf: #3f8f5b;
  --leaf-dark: #1e513d;
  --water: #4f9fb8;
  --berry: #c94c5e;
  --gold: #f3b24b;
  --cream: #fff1c9;
  --shadow: rgba(8, 12, 20, 0.58);
  --pixel: 4px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--deep);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Noto Sans SC", monospace;
  background:
    linear-gradient(180deg, #101a30 0 36%, #21394a 36% 54%, #244a31 54% 100%);
  image-rendering: pixelated;
}

button,
input {
  font: inherit;
}

.page {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 26px;
}

.topbar {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--cream);
  text-decoration: none;
  font-weight: 900;
}

.brand-mark {
  width: 28px;
  height: 28px;
  background: var(--gold);
  box-shadow:
    0 0 0 4px var(--wood-dark),
    8px 8px 0 0 var(--berry),
    -8px 8px 0 0 var(--leaf);
}

.chapter {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #b8cfaa;
  font-size: 14px;
}

.chapter strong {
  color: var(--gold);
}

.game {
  display: grid;
  grid-template-columns: minmax(0, 1.34fr) minmax(340px, 0.66fr);
  gap: 18px;
  align-items: start;
}

.world-panel,
.notebook {
  position: relative;
  border: var(--pixel) solid var(--wood-dark);
  background: #1b2a34;
  box-shadow:
    0 0 0 var(--pixel) #d49a52,
    0 18px 0 var(--shadow);
}

.world-panel::before,
.notebook::before,
.dialogue::before,
.lockbox::before,
.sealed-note::before {
  content: "";
  position: absolute;
  inset: 4px;
  pointer-events: none;
  border: 2px solid rgba(255, 241, 201, 0.22);
}

.scene {
  position: relative;
  overflow: hidden;
  aspect-ratio: 3 / 2;
  min-height: 0;
  background: #18253a;
}

.map-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(180deg, transparent 0 72%, rgba(9, 12, 20, 0.18));
  background-size: 16px 16px, 16px 16px, auto;
}

.point {
  position: absolute;
  display: grid;
  place-items: center;
  gap: 5px;
  padding: 0;
  color: var(--cream);
  background: transparent;
  border: 0;
  cursor: pointer;
  image-rendering: pixelated;
}

.point:focus-visible {
  outline: 4px solid var(--gold);
  outline-offset: 6px;
}

.pin {
  width: 16px;
  height: 16px;
  background: var(--berry);
  box-shadow:
    0 -8px 0 var(--gold),
    0 8px 0 var(--water),
    -8px 0 0 var(--cream),
    8px 0 0 var(--cream),
    0 0 0 4px var(--wood-dark),
    6px 6px 0 rgba(0,0,0,0.25);
}

.point-name {
  padding: 5px 8px;
  color: #241a18;
  background: var(--paper);
  border: 3px solid var(--wood-dark);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.25);
  font-size: 13px;
  font-weight: 900;
}

.point.is-found .pin {
  background: var(--leaf);
}

.point.is-found .point-name {
  background: var(--gold);
}

.cabin { left: 18%; top: 57%; }
.well { left: 44%; top: 67%; }
.greenhouse { left: 70%; top: 54%; }
.mailbox { left: 88%; top: 56%; }

.dialogue {
  position: relative;
  min-height: 156px;
  margin: 16px;
  padding: 22px 24px 24px;
  color: #2a1a1a;
  background: var(--paper);
  border: var(--pixel) solid var(--wood-dark);
  box-shadow: 8px 8px 0 rgba(0,0,0,0.28);
}

.speaker,
.eyebrow {
  margin: 0;
  color: #7d2e37;
  font-size: 13px;
  font-weight: 900;
}

h1,
h2,
p {
  letter-spacing: 0;
}

h1 {
  margin: 8px 0 10px;
  color: #2b211e;
  font-size: 38px;
  line-height: 1;
}

.dialogue p:last-child,
.sealed-note p:last-child,
.clue-card p,
.lockbox p {
  line-height: 1.65;
}

#storyText {
  margin: 0;
  font-size: 18px;
}

.notebook {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,0.04) 1px, transparent 1px),
    #263447;
  background-size: 16px 16px;
}

.notebook-head h2,
.sealed-note h2 {
  margin: 6px 0 0;
  font-size: 28px;
}

.clue-grid {
  display: grid;
  gap: 12px;
}

.clue-card,
.lockbox,
.sealed-note {
  position: relative;
  border: 4px solid var(--wood-dark);
  background: #f1d69a;
  color: #2a1a1a;
  box-shadow: 6px 6px 0 rgba(0,0,0,0.24);
}

.clue-card {
  min-height: 112px;
  padding: 16px 16px 16px 66px;
  opacity: 0.78;
}

.clue-card span {
  position: absolute;
  left: 16px;
  top: 18px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--cream);
  background: var(--wood-dark);
  box-shadow: 4px 4px 0 rgba(0,0,0,0.18);
}

.clue-card strong {
  display: block;
  margin-bottom: 7px;
  font-size: 18px;
}

.clue-card p {
  margin: 0;
}

.clue-card.is-found {
  opacity: 1;
  background: #ffe3a5;
}

.clue-card.is-found span {
  background: var(--leaf-dark);
}

.lockbox,
.sealed-note {
  padding: 18px;
}

.lockbox label {
  display: block;
  margin-bottom: 12px;
  color: #7d2e37;
  font-weight: 900;
}

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

.lock-row input {
  min-width: 0;
  height: 52px;
  padding: 0 14px;
  color: var(--cream);
  background: #1b2431;
  border: 4px solid var(--wood-dark);
  outline: 0;
  font-size: 28px;
  font-weight: 900;
}

.lock-row input:focus {
  border-color: #7d2e37;
}

.lock-row button {
  height: 52px;
  color: #241a18;
  background: var(--gold);
  border: 4px solid var(--wood-dark);
  cursor: pointer;
  font-weight: 900;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.22);
}

.lock-row button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.22);
}

.lock-row button:disabled,
.lock-row input:disabled {
  opacity: 0.75;
}

.lockbox p {
  min-height: 52px;
  margin: 12px 0 0;
}

.sealed-note {
  background: #dff0c1;
}

.sealed-note[hidden] {
  display: none;
}

.credits {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
  color: #b8cfaa;
  font-size: 12px;
}

.is-shaking {
  animation: shake 0.18s linear 2;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

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

  .notebook {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .notebook-head,
  .clue-grid {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .page {
    width: min(100% - 20px, 520px);
    padding-top: 12px;
  }

  .topbar,
  .credits {
    align-items: flex-start;
    flex-direction: column;
  }

  .game {
    gap: 14px;
  }

  .point-name {
    font-size: 12px;
    padding: 4px 6px;
  }

  .pin {
    width: 12px;
    height: 12px;
    box-shadow:
      0 -6px 0 var(--gold),
      0 6px 0 var(--water),
      -6px 0 0 var(--cream),
      6px 0 0 var(--cream),
      0 0 0 3px var(--wood-dark),
      4px 4px 0 rgba(0,0,0,0.25);
  }

  .cabin { left: 14%; top: 58%; }
  .well { left: 42%; top: 68%; }
  .greenhouse { left: 68%; top: 54%; }
  .mailbox { left: 82%; top: 55%; }

  .dialogue {
    min-height: 0;
    margin: 12px;
    padding: 16px;
  }

  h1 {
    font-size: 30px;
  }

  #storyText {
    font-size: 16px;
  }

  .notebook {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .lock-row {
    grid-template-columns: 1fr;
  }

  .lock-row button {
    width: 100%;
  }
}
