:root {
  --paper: #fbf6e8;
  --map: #efe2c3;
  --ink: #181611;
  --soft-ink: #5e5748;
  --brick: #a33a2a;
  --brick-deep: #6f241d;
  --leaf: #2f6a53;
  --leaf-light: #9dbb7f;
  --sky: #43788e;
  --ochre: #c08a2d;
  --chalk: #fffaf0;
  --line: rgba(24, 22, 17, 0.18);
  --line-strong: rgba(24, 22, 17, 0.42);
  --shadow: 0 22px 60px rgba(58, 43, 19, 0.18);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(24, 22, 17, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 22, 17, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 80% 8%, rgba(67, 120, 142, 0.22), transparent 28%),
    radial-gradient(circle at 14% 88%, rgba(163, 58, 42, 0.16), transparent 30%),
    var(--paper);
  background-size: 26px 26px, 26px 26px, 100% 100%, 100% 100%, auto;
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 22px;
}

.site-header {
  max-width: 1220px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-stamp {
  display: grid;
  width: 58px;
  aspect-ratio: 1;
  place-items: center;
  color: var(--chalk);
  background:
    linear-gradient(90deg, transparent 46%, rgba(255, 250, 240, 0.14) 47% 53%, transparent 54%),
    linear-gradient(0deg, transparent 46%, rgba(255, 250, 240, 0.14) 47% 53%, transparent 54%),
    var(--brick);
  border: 2px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  font-size: 1.7rem;
  font-weight: 900;
}

.eyebrow,
.screen-kicker {
  margin: 0;
  color: var(--brick-deep);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.85rem, 4vw, 3.15rem);
  line-height: 0.94;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.55rem, 3vw, 2.45rem);
  line-height: 1.12;
}

h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ghost-button,
.choice-button,
.icon-button {
  border: 2px solid var(--ink);
  background: var(--chalk);
  color: var(--ink);
  cursor: pointer;
}

.ghost-button {
  min-height: 42px;
  padding: 9px 13px;
  font-weight: 800;
  box-shadow: 3px 3px 0 var(--ink);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  box-shadow: 3px 3px 0 var(--ink);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ghost-button:hover,
.choice-button:hover,
.icon-button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--ink);
}

.game-board {
  display: grid;
  grid-template-columns: minmax(390px, 1fr) minmax(330px, 0.78fr) 292px;
  gap: 16px;
  max-width: 1220px;
  margin: 0 auto;
  align-items: stretch;
}

.map-panel,
.mission-panel,
.notebook {
  border: 2px solid var(--ink);
  background: rgba(255, 250, 240, 0.78);
  box-shadow: var(--shadow);
}

.map-panel {
  min-height: 680px;
  padding: 14px;
}

.map-meta {
  min-height: 42px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line-strong);
  padding: 0 2px 12px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 900;
}

.campus-map {
  position: relative;
  min-height: 600px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(34deg, transparent 49%, rgba(47, 106, 83, 0.22) 50% 52%, transparent 53%),
    linear-gradient(120deg, transparent 52%, rgba(192, 138, 45, 0.18) 53% 55%, transparent 56%),
    var(--map);
}

.campus-map::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px dashed rgba(24, 22, 17, 0.28);
  pointer-events: none;
}

.north-mark {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  width: 38px;
  height: 52px;
  display: grid;
  place-items: start center;
  padding-top: 6px;
  color: var(--chalk);
  background: var(--ink);
  clip-path: polygon(50% 0, 100% 100%, 50% 82%, 0 100%);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.8rem;
  font-weight: 900;
}

.path {
  position: absolute;
  background: rgba(255, 250, 240, 0.66);
  border: 1px solid rgba(24, 22, 17, 0.18);
}

.path-main {
  left: 13%;
  right: 16%;
  top: 48%;
  height: 34px;
  transform: rotate(-8deg);
}

.path-court {
  left: 47%;
  top: 18%;
  width: 30px;
  height: 62%;
  transform: rotate(18deg);
}

.zone {
  position: absolute;
  display: grid;
  place-items: center;
  border: 2px solid rgba(24, 22, 17, 0.32);
  color: rgba(24, 22, 17, 0.76);
  font-weight: 900;
}

.zone-classroom {
  left: 7%;
  top: 12%;
  width: 34%;
  height: 22%;
  background:
    repeating-linear-gradient(90deg, rgba(163, 58, 42, 0.16) 0 22px, rgba(163, 58, 42, 0.05) 22px 44px),
    rgba(255, 250, 240, 0.42);
}

.zone-yard {
  left: 52%;
  top: 28%;
  width: 36%;
  height: 27%;
  border-radius: 50%;
  background: rgba(47, 106, 83, 0.22);
}

.zone-hall {
  left: 17%;
  bottom: 13%;
  width: 34%;
  height: 22%;
  background:
    linear-gradient(135deg, rgba(67, 120, 142, 0.22), rgba(255, 250, 240, 0.34));
}

.map-pin {
  position: absolute;
  z-index: 4;
  width: 132px;
  min-height: 62px;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--ink);
  background: var(--chalk);
  color: var(--ink);
  box-shadow: 4px 4px 0 rgba(24, 22, 17, 0.35);
  padding: 8px;
  text-align: left;
  cursor: pointer;
}

.map-pin span {
  display: grid;
  width: 31px;
  aspect-ratio: 1;
  place-items: center;
  color: var(--chalk);
  background: var(--brick);
  border: 1px solid var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-weight: 900;
}

.map-pin strong {
  line-height: 1.2;
}

.map-pin[data-site="gate"] {
  left: 9%;
  top: 42%;
}

.map-pin[data-site="corridor"] {
  left: 27%;
  top: 19%;
}

.map-pin[data-site="roof"] {
  right: 9%;
  top: 16%;
}

.map-pin[data-site="timber"] {
  right: 13%;
  top: 48%;
}

.map-pin[data-site="marker"] {
  left: 14%;
  bottom: 16%;
}

.map-pin[data-site="well"] {
  right: 20%;
  bottom: 14%;
}

.map-pin.is-locked {
  filter: grayscale(1);
  opacity: 0.54;
}

.map-pin.is-active {
  background: #ffe6a6;
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 var(--ink);
}

.map-pin.is-cleared span {
  background: var(--leaf);
}

.mission-panel {
  min-height: 680px;
  padding: 24px;
}

.mission-copy {
  color: var(--soft-ink);
  font-size: 1.02rem;
  line-height: 1.8;
}

.tool-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
}

.tool-chip {
  min-height: 58px;
  border: 1px solid var(--line-strong);
  background: rgba(239, 226, 195, 0.58);
  padding: 8px;
}

.tool-chip span {
  display: block;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.7rem;
  font-weight: 900;
  color: var(--brick-deep);
}

.tool-chip strong {
  display: block;
  margin-top: 3px;
  font-size: 0.92rem;
}

.choice-list {
  display: grid;
  gap: 10px;
}

.choice-button {
  width: 100%;
  min-height: 88px;
  padding: 13px;
  text-align: left;
  box-shadow: 3px 3px 0 var(--ink);
}

.choice-button strong {
  display: block;
  margin-bottom: 5px;
  font-size: 1.03rem;
}

.choice-button span {
  display: block;
  color: var(--soft-ink);
  line-height: 1.55;
}

.notebook {
  min-height: 680px;
  padding: 18px;
}

.score-card {
  display: grid;
  gap: 8px;
}

.score-card div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 250, 240, 0.68);
  padding: 10px;
}

.score-card span {
  color: var(--soft-ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.score-card strong {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 1.25rem;
}

.stamp-book,
.field-log {
  margin-top: 18px;
  border-top: 2px solid var(--ink);
  padding-top: 14px;
}

.stamp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stamp {
  min-height: 72px;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(24, 22, 17, 0.36);
  color: rgba(24, 22, 17, 0.38);
  background: rgba(239, 226, 195, 0.42);
  font-weight: 900;
  text-align: center;
}

.stamp.is-collected {
  color: var(--brick-deep);
  border-color: var(--brick);
  background:
    linear-gradient(45deg, transparent 45%, rgba(163, 58, 42, 0.12) 46% 54%, transparent 55%),
    rgba(255, 250, 240, 0.8);
}

.field-log ol,
.field-log li,
#logList {
  margin: 0;
  padding: 0;
}

#logList {
  list-style: none;
  display: grid;
  gap: 9px;
}

#logList li {
  border-left: 4px solid var(--brick);
  background: rgba(255, 250, 240, 0.72);
  padding: 8px 9px;
  color: var(--soft-ink);
  font-size: 0.9rem;
  line-height: 1.45;
}

.ending-code {
  margin-top: 14px;
  border: 2px solid var(--ink);
  background: var(--brick);
  color: var(--chalk);
  padding: 14px;
  text-align: center;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 1.15rem;
  font-weight: 900;
}

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

  .mission-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }

  .notebook {
    min-height: auto;
  }
}

@media (max-width: 780px) {
  .app-shell {
    padding: 14px;
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .game-board {
    grid-template-columns: 1fr;
  }

  .map-panel,
  .mission-panel,
  .notebook {
    min-height: auto;
  }

  .campus-map {
    min-height: 520px;
  }

  .map-pin {
    width: 118px;
    min-height: 58px;
    grid-template-columns: 30px 1fr;
    font-size: 0.86rem;
  }

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

  .stamp-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .brand-stamp {
    width: 50px;
  }

  .campus-map {
    min-height: 620px;
  }

  .map-pin[data-site="gate"] {
    left: 5%;
    top: 39%;
  }

  .map-pin[data-site="corridor"] {
    left: 14%;
    top: 16%;
  }

  .map-pin[data-site="roof"] {
    right: 5%;
    top: 28%;
  }

  .map-pin[data-site="timber"] {
    right: 5%;
    top: 52%;
  }

  .map-pin[data-site="marker"] {
    left: 6%;
    bottom: 16%;
  }

  .map-pin[data-site="well"] {
    right: 7%;
    bottom: 5%;
  }
}
