:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-strong: #e8eff1;
  --ink: #102125;
  --muted: #5d6c70;
  --brand: #0b2f35;
  --brand-2: #0f766e;
  --accent: #d97706;
  --danger: #b42318;
  --success: #117a45;
  --border: #d8e1e4;
  --shadow: 0 14px 34px rgba(11, 47, 53, 0.12);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

img,
video {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 20;
  transform: translateY(-160%);
  background: var(--brand);
  color: #fff;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4rem;
  padding: 0.75rem max(1rem, env(safe-area-inset-left)) 0.75rem max(1rem, env(safe-area-inset-right));
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--brand);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
}

.top-nav {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  background: var(--surface-strong);
  border-radius: 8px;
}

.top-nav a {
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
}

.top-nav a[aria-current="page"] {
  background: var(--surface);
  color: var(--brand);
  box-shadow: 0 1px 6px rgba(16, 33, 37, 0.08);
}

.app-main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 1rem 1rem calc(2.5rem + var(--safe-bottom));
}

.screen-title {
  display: grid;
  gap: 0.65rem;
  margin: 0.5rem 0 1rem;
}

.screen-title h1,
.detail-heading h1,
.tour-topbar h1,
.panel h1 {
  margin: 0;
  color: var(--brand);
  font-size: 2rem;
  line-height: 1.08;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--brand-2);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.muted,
.form-note {
  color: var(--muted);
}

.search-panel,
.panel,
.purchase-panel,
.tour-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.search-panel {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 1rem;
}

.search-panel label,
.admin-form label {
  display: grid;
  gap: 0.4rem;
  color: var(--brand);
  font-weight: 750;
}

.search-row {
  display: grid;
  gap: 0.65rem;
}

input,
textarea,
select {
  width: 100%;
  min-height: 2.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0.72rem 0.8rem;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.3);
  outline-offset: 2px;
}

.quick-actions,
.purchase-actions,
.tour-actions,
.answer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.85rem;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  padding: 0.7rem 1rem;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.button:hover {
  background: #13464f;
}

.button.secondary {
  border-color: var(--brand-2);
  background: var(--brand-2);
}

.button.ghost {
  background: #fff;
  color: var(--brand);
}

.button.disabled,
.button:disabled {
  border-color: #aab8bc;
  background: #aab8bc;
  color: #f7fbfc;
  cursor: not-allowed;
}

.adventure-list {
  display: grid;
  gap: 1rem;
}

.adventure-card {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(16, 33, 37, 0.08);
}

.adventure-card[hidden] {
  display: none;
}

.card-media {
  min-height: 100%;
  background: var(--surface-strong);
}

.card-media img {
  width: 100%;
  height: 100%;
  min-height: 9rem;
  object-fit: cover;
}

.card-body {
  display: grid;
  gap: 0.4rem;
  padding: 0.85rem;
  min-width: 0;
}

.card-body h2,
.purchase-panel h2,
.step-preview h2,
.admin-form h2,
.panel h2,
.tour-step h2 {
  margin: 0;
  color: var(--brand);
  font-size: 1.25rem;
  line-height: 1.15;
}

.card-body h2 a {
  text-decoration: none;
}

.card-body p,
.purchase-panel p,
.panel p,
.detail-body p,
.tour-step p,
.admin-item p {
  margin: 0;
}

.card-meta,
.card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.65rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.card-footer strong {
  color: var(--accent);
}

.detail {
  display: grid;
  gap: 1rem;
}

.detail-media {
  overflow: hidden;
  margin: -1rem -1rem 0;
  background: var(--surface-strong);
}

.detail-media img {
  width: 100%;
  max-height: 22rem;
  object-fit: cover;
}

.detail-body {
  display: grid;
  gap: 1rem;
}

.detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.back-link {
  color: var(--brand-2);
  font-weight: 800;
  width: fit-content;
}

.lead {
  color: var(--brand);
  font-size: 1.08rem;
  font-weight: 700;
}

.price-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(217, 119, 6, 0.35);
  border-radius: 8px;
  background: #fff7ed;
  color: var(--accent);
  padding: 0.4rem 0.65rem;
  font-weight: 850;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin: 0;
}

.stats-grid div {
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.stats-grid dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.stats-grid dd {
  margin: 0.2rem 0 0;
  color: var(--brand);
  font-weight: 850;
}

.purchase-panel {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.step-preview {
  display: grid;
  gap: 0.65rem;
}

.step-preview ol {
  display: grid;
  gap: 0.65rem;
  margin: 0;
  padding-left: 1.25rem;
}

.step-preview li {
  padding-left: 0.2rem;
}

.step-preview span,
.item-status {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.step-preview strong {
  display: block;
}

.tour-shell {
  display: grid;
  gap: 1rem;
  max-width: 760px;
  margin: 0 auto;
}

.tour-topbar {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  justify-content: space-between;
}

.tour-topbar h1 {
  font-size: 1.45rem;
}

.progress-track {
  height: 0.6rem;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface-strong);
}

.progress-track span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 8px;
  background: var(--brand-2);
  transition: width 180ms ease;
}

.tour-step {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.tour-media {
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface-strong);
}

.tour-media img,
.camera-frame video {
  width: 100%;
  max-height: 26rem;
  object-fit: cover;
}

.answer-grid {
  display: grid;
}

.answer-button {
  justify-content: flex-start;
  width: 100%;
  background: #fff;
  color: var(--brand);
}

.answer-button.is-correct {
  border-color: var(--success);
  background: #ecfdf3;
  color: var(--success);
}

.answer-button.is-wrong {
  border-color: var(--danger);
  background: #fff1f0;
  color: var(--danger);
}

.feedback {
  min-height: 1.5rem;
  color: var(--muted);
  font-weight: 750;
}

.feedback.success {
  color: var(--success);
}

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

.camera-frame {
  display: grid;
  gap: 0.75rem;
}

.camera-frame video {
  border-radius: 8px;
  background: #06191d;
  aspect-ratio: 4 / 3;
}

.qr-manual {
  display: grid;
  gap: 0.65rem;
  padding: 0.85rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.panel {
  padding: 1rem;
}

.panel.narrow {
  max-width: 640px;
  margin: 2rem auto;
}

.notice {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

.notice.success {
  border-color: rgba(17, 122, 69, 0.35);
  color: var(--success);
}

.notice.error {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--danger);
}

.notice ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.admin-grid {
  display: grid;
  gap: 1rem;
}

.admin-form {
  display: grid;
  gap: 0.9rem;
}

.form-pair {
  display: grid;
  gap: 0.75rem;
}

.admin-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.admin-item {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.admin-item img {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-strong);
}

.admin-item h3 {
  margin: 0.15rem 0;
  color: var(--brand);
}

@media (min-width: 640px) {
  .app-main {
    padding: 1.5rem 1.25rem 3rem;
  }

  .screen-title {
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 24rem);
    align-items: end;
  }

  .search-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .adventure-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .adventure-card {
    grid-template-columns: 1fr;
  }

  .card-media img {
    height: 13rem;
  }

  .purchase-panel {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .form-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 920px) {
  .detail {
    grid-template-columns: minmax(20rem, 0.9fr) minmax(0, 1.1fr);
    align-items: start;
  }

  .detail-media {
    position: sticky;
    top: 5rem;
    margin: 0;
    border-radius: 8px;
  }

  .detail-media img {
    max-height: 40rem;
  }

  .admin-grid {
    grid-template-columns: minmax(22rem, 0.9fr) minmax(0, 1.1fr);
    align-items: start;
  }
}

@media (max-width: 420px) {
  .screen-title h1,
  .detail-heading h1,
  .panel h1 {
    font-size: 1.65rem;
  }

  .adventure-card {
    grid-template-columns: 6.25rem minmax(0, 1fr);
  }

  .card-media img {
    min-height: 10rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .detail-heading {
    display: grid;
  }

  .button {
    width: 100%;
  }
}
