:root {
  --ink: #24190f;
  --muted: #6d5137;
  --paper: #efe2ca;
  --paper-strong: #f8ecd1;
  --brown: #4b2e1a;
  --brown-deep: #26170d;
  --brown-soft: #8d6843;
  --gold: #c89b54;
  --red: #6d1f26;
  --green: #295944;
  --shadow: 0 16px 40px rgba(31, 19, 11, 0.28);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(57, 35, 19, 0.84), rgba(57, 35, 19, 0.88)),
    url("assets/map.png") center / cover fixed;
  font-family: Georgia, "Times New Roman", serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  align-items: center;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  background: rgba(38, 23, 13, 0.94);
  border-bottom: 1px solid rgba(200, 155, 84, 0.42);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}

.brand-lockup,
.icon-button,
.tool-button,
.small-map-button,
.primary-button,
.secondary-button,
.step-tab {
  border: 1px solid rgba(200, 155, 84, 0.56);
  border-radius: var(--radius);
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--paper-strong);
  background: transparent;
  text-align: left;
  padding: 0;
  border-color: transparent;
}

.brand-lockup img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.brand-lockup strong,
h1,
.location-card strong {
  font-family: "Cinzel", Georgia, "Times New Roman", serif;
  text-transform: uppercase;
  letter-spacing: 0;
}

.brand-lockup strong,
.brand-lockup small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-lockup small {
  color: #d7bd88;
  font-size: 0.77rem;
}

.icon-button,
.tool-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--paper-strong);
  background: rgba(75, 46, 26, 0.86);
  font-size: 1.7rem;
  line-height: 1;
}

.screen {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 18px 14px 28px;
  flex: 1;
}

.intro-screen,
.location-screen,
.map-screen {
  background: linear-gradient(180deg, rgba(248, 236, 209, 0.96), rgba(231, 211, 174, 0.96));
  border: 1px solid rgba(200, 155, 84, 0.7);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.intro-screen {
  min-height: calc(100dvh - 96px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 24px 18px;
  text-align: center;
}

.intro-crest img {
  width: min(54vw, 230px);
  height: auto;
  filter: drop-shadow(0 12px 20px rgba(58, 35, 19, 0.24));
}

.kicker {
  margin: 0;
  color: var(--red);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.82rem;
}

h1 {
  margin: 0;
  color: var(--brown-deep);
  font-size: clamp(1.7rem, 9vw, 3.4rem);
  line-height: 1.02;
}

p {
  line-height: 1.55;
}

.intro-screen p:not(.kicker) {
  max-width: 650px;
  margin: 0 auto;
  font-size: 1.05rem;
}

.mission-audio {
  width: min(100%, 560px);
  margin: 6px auto 0;
  accent-color: var(--brown);
}

.action-row,
.nav-row,
.answer-row {
  display: flex;
  gap: 10px;
}

.action-row {
  justify-content: center;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.small-map-button,
.step-tab {
  min-height: 44px;
  padding: 10px 14px;
  color: var(--paper-strong);
  background: var(--brown);
  font-weight: 700;
}

.secondary-button,
.step-tab {
  color: var(--brown-deep);
  background: rgba(255, 249, 232, 0.68);
}

.primary-button:active,
.secondary-button:active,
.icon-button:active,
.tool-button:active {
  transform: translateY(1px);
}

.map-screen,
.location-screen {
  padding: 14px;
}

.map-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.map-heading h1,
.location-hero h1 {
  font-size: clamp(1.4rem, 6vw, 2.35rem);
}

.progress-badge {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--paper-strong);
  background: var(--green);
  font-weight: 700;
  white-space: nowrap;
}

.map-tools {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}

.map-frame {
  position: relative;
  height: min(62dvh, 620px);
  min-height: 360px;
  overflow: hidden;
  border: 2px solid var(--brown);
  border-radius: var(--radius);
  background: #d8c398;
  touch-action: none;
}

.map-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  transform-origin: 0 0;
  will-change: transform;
}

.map-canvas img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  pointer-events: none;
}

.pin-layer {
  position: absolute;
  inset: 0;
}

.map-pin {
  position: absolute;
  z-index: 1;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  translate: -50% -50%;
  border: 1px solid #f7deb2;
  border-radius: 50%;
  transform: scale(var(--pin-scale, 1));
  transform-origin: 50% 50%;
  color: #fff;
  background: var(--red);
  box-shadow: 0 3px 8px rgba(37, 20, 11, 0.38);
}

.map-pin span {
  font-weight: 700;
  font-size: 0.76rem;
  line-height: 1;
}

.map-pin.solved {
  background: var(--green);
}

.map-pin.active {
  z-index: 5;
  outline: 3px solid rgba(200, 155, 84, 0.5);
  transform: scale(calc(var(--pin-scale, 1) * 1.16));
}

.location-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(172px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.location-card {
  min-height: 88px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  padding: 11px;
  color: var(--ink);
  background: rgba(255, 249, 232, 0.76);
  border: 1px solid rgba(75, 46, 26, 0.24);
  border-radius: var(--radius);
  text-align: left;
}

.location-card small {
  color: var(--muted);
}

.location-card.solved {
  border-color: rgba(41, 89, 68, 0.58);
  background: rgba(234, 246, 229, 0.84);
}

.location-hero {
  position: relative;
  padding: 16px;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(239, 226, 202, 0.94), rgba(239, 226, 202, 0.74)),
    url("assets/map.png") center / cover;
  border: 1px solid rgba(75, 46, 26, 0.18);
}

.location-hero p:last-child {
  max-width: 720px;
  margin-bottom: 0;
}

.small-map-button {
  float: right;
  margin-left: 10px;
  color: var(--brown-deep);
  background: rgba(255, 249, 232, 0.76);
}

.step-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.step-tab.active {
  color: var(--paper-strong);
  background: var(--brown);
}

.mission-card,
.answer-panel {
  padding: 14px;
  background: rgba(255, 249, 232, 0.76);
  border: 1px solid rgba(75, 46, 26, 0.22);
  border-radius: var(--radius);
}

.mission-card h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  color: var(--brown-deep);
}

.mission-card p {
  margin: 0 0 10px;
}

.mission-card ul {
  margin: 0;
  padding-left: 20px;
}

.answer-panel {
  margin-top: 12px;
}

.answer-panel label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.answer-row input {
  min-width: 0;
  flex: 1;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid rgba(75, 46, 26, 0.42);
  border-radius: var(--radius);
  background: #fffaf0;
  color: var(--ink);
}

.feedback {
  min-height: 1.4em;
  margin: 8px 0 0;
  font-weight: 700;
}

.feedback.ok {
  color: var(--green);
}

.feedback.error {
  color: var(--red);
}

.nav-row {
  justify-content: space-between;
  margin-top: 12px;
}

@media (max-width: 640px) {
  .screen {
    padding-inline: 10px;
  }

  .topbar {
    grid-template-columns: 42px 1fr 42px;
    padding-inline: 10px;
  }

  .brand-lockup img {
    width: 34px;
    height: 34px;
  }

  .map-frame {
    height: 52dvh;
    min-height: 310px;
  }

  .location-strip {
    grid-template-columns: 1fr;
  }

  .answer-row,
  .nav-row {
    flex-direction: column;
  }

  .answer-row .primary-button,
  .nav-row button {
    width: 100%;
  }
}
