:root {
  --forest: #172f17;
  --forest-2: #244522;
  --moss: #4d6d31;
  --gold: #b98935;
  --gold-soft: #d8b36d;
  --paper: #f6e8c6;
  --paper-2: #ead3a0;
  --ink: #132313;
  --muted: #5f4e2f;
  --danger: #8a3a26;
  --ok: #2f6d35;
  --shadow: 0 18px 42px rgba(19, 35, 19, .18);
  --radius: 24px;
  --nav-h: 72px;
}

* { box-sizing: border-box; }

html {
  background: #172f17;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 221, 145, .28), transparent 28rem),
    linear-gradient(180deg, rgba(19, 41, 18, .96), rgba(22, 46, 22, .92)),
    #183418;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  background-image: radial-gradient(circle, rgba(255,220,117,.22) 0 1px, transparent 2px);
  background-size: 34px 34px;
  z-index: -1;
}

a { color: inherit; }

.site-header-wrap {
  position: sticky;
  top: 0;
  z-index: 30;
  width: min(1240px, calc(100% - 24px));
  margin: 0 auto;
  padding: 10px 0 8px;
}

.site-header {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px clamp(12px, 2.5vw, 20px);
  border-radius: 999px;
  border: 1px solid rgba(216, 179, 109, .55);
  background: linear-gradient(180deg, rgba(13,67,34,.97), rgba(8,37,20,.98));
  box-shadow: 0 14px 30px rgba(0,0,0,.30), inset 0 1px rgba(255,255,255,.08);
}

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

.brand-logo {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 999px;
  border: 2px solid rgba(255,239,173,.82);
  box-shadow: 0 7px 14px rgba(0,0,0,.36);
  background: rgba(255, 239, 173, .05);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: .98;
  min-width: 0;
}

.brand-copy strong {
  color: #ffe7a7;
  font-size: clamp(1.18rem, 2.9vw, 2.35rem);
  font-weight: 900;
  letter-spacing: -.035em;
  white-space: nowrap;
  text-shadow: 0 2px 0 rgba(0,0,0,.34);
}

.brand-copy small {
  color: #ffe7a7;
  font-size: clamp(.82rem, 1.2vw, .98rem);
  font-weight: 800;
  white-space: nowrap;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
}

.top-nav button,
.top-nav a,
.mobile-menu button,
.mobile-menu a {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: #ffe7a7;
  border-radius: 999px;
  padding: 10px 13px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.top-nav button:hover,
.top-nav a:hover,
.top-nav button.active,
.mobile-menu button.active {
  background: rgba(216,179,109,.20);
  border-color: rgba(216,179,109,.34);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.header-progress {
  background: rgba(246, 232, 198, .08);
}

.menu-toggle {
  display: none;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(217, 163, 59, .65);
  background: rgba(0,0,0,.16);
  color: #ffe7a7;
  font-size: 1.35rem;
  font-weight: 900;
}

.mobile-menu {
  margin: 8px 8px 0;
  padding: 8px;
  border-radius: 22px;
  border: 1px solid rgba(216,179,109,.45);
  background: rgba(8,37,20,.98);
  box-shadow: 0 14px 26px rgba(0,0,0,.26);
}

.mobile-menu[hidden] { display: none; }

.mobile-menu button,
.mobile-menu a {
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border-radius: 15px;
}

.site-footer {
  width: min(1240px, calc(100% - 24px));
  margin: 10px auto 34px;
  padding: clamp(18px, 3vw, 28px);
  border-radius: 28px;
  color: #f8e6bd;
  background: rgba(4,18,8,.74);
  border: 1px solid rgba(219,174,73,.30);
  text-align: center;
  box-shadow: 0 18px 42px rgba(0,0,0,.20);
}

.footer-title h2 {
  margin: 0 0 6px;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: .96;
  color: #ffe7a7;
  letter-spacing: -.035em;
}

.footer-title p,
.footer-note {
  margin: 0;
  color: #f4dfb1;
  line-height: 1.4;
}

.footer-links {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.footer-link {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 118px;
  padding: 15px 12px;
  border-radius: 18px;
  border: 1px solid rgba(229,194,106,.34);
  background: linear-gradient(135deg, rgba(255,242,197,.12), rgba(224,181,80,.08));
  color: #fff0bf;
  text-decoration: none;
  text-align: center;
}

.footer-link:hover,
.footer-link:focus-visible {
  transform: translateY(-2px);
  background: linear-gradient(135deg, rgba(255,242,197,.18), rgba(224,181,80,.12));
  outline: 3px solid rgba(239,198,92,.16);
}

.footer-link strong {
  color: #ffe8a4;
  font-size: 1.02rem;
  line-height: 1.05;
}

.footer-link span {
  color: #f4dfb1;
  font-size: .9rem;
  line-height: 1.28;
}

.footer-current {
  background: linear-gradient(135deg, rgba(255,232,164,.21), rgba(34,89,46,.20));
  border-color: rgba(255,232,164,.62);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .72; }

img {
  display: block;
  width: 100%;
  height: auto;
}

.app {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 14px 12px 28px;
}

.noscript {
  max-width: 720px;
  margin: 30px auto;
  padding: 18px;
  color: var(--paper);
  background: #451f16;
  border: 2px solid var(--gold);
  border-radius: 16px;
}

.screen {
  animation: soft-in .22s ease-out;
}

@keyframes soft-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 12px;
}

.brand-small {
  color: var(--paper);
  font-weight: 700;
  letter-spacing: .02em;
  text-shadow: 0 2px 8px rgba(0,0,0,.4);
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(216, 179, 109, .7);
  background: rgba(246, 232, 198, .1);
  color: var(--paper);
  border-radius: 999px;
  padding: 8px 11px;
  font-size: .92rem;
  white-space: nowrap;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 2px solid #9f7430;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0)),
    radial-gradient(circle at 50% 0%, rgba(255, 229, 156, .72), transparent 24rem),
    var(--paper);
  box-shadow: var(--shadow);
}

.panel::before,
.panel::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(137, 91, 29, .38);
  border-radius: calc(var(--radius) - 8px);
  pointer-events: none;
}

.panel-inner {
  position: relative;
  z-index: 1;
  padding: 18px;
}

.hero-title {
  font-size: clamp(2.15rem, 9vw, 5.4rem);
  line-height: .98;
  margin: 4px 0 10px;
  color: var(--forest);
  text-align: center;
  letter-spacing: -.03em;
}

.title {
  font-size: clamp(1.8rem, 7vw, 4.1rem);
  line-height: 1;
  margin: 0 0 8px;
  color: var(--forest);
  letter-spacing: -.02em;
}

.subtitle,
.lead {
  margin: 0 auto 14px;
  max-width: 760px;
  font-size: clamp(1.02rem, 4vw, 1.35rem);
  line-height: 1.38;
  text-align: center;
  color: #25351e;
}

.text {
  font-size: 1.06rem;
  line-height: 1.48;
  color: #263820;
}

.muted { color: var(--muted); }
.center { text-align: center; }

.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 10px auto 16px;
  color: var(--gold);
}

.ornament::before,
.ornament::after {
  content: "";
  width: min(118px, 22vw);
  height: 1px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
}

.ornament span { font-size: 1.2rem; }

.hero-image,
.location-image {
  border-radius: 18px;
  border: 2px solid rgba(143, 98, 36, .75);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35), 0 10px 24px rgba(55,32,6,.14);
  background: #d8b36d;
  overflow: hidden;
}

.hero-image img,
.location-image img {
  width: 100%;
  height: auto;
  object-fit: contain;
  background: #ead3a0;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.btn {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(180deg, #f7d98a, #b9852c);
  color: #1d2512;
  font-weight: 700;
  box-shadow: 0 5px 0 #7a541e, 0 12px 24px rgba(77, 44, 8, .22);
}

.btn:active { transform: translateY(2px); box-shadow: 0 3px 0 #7a541e, 0 7px 16px rgba(77,44,8,.18); }

.btn.secondary {
  background: linear-gradient(180deg, #fff6dc, #ddbf7d);
  box-shadow: 0 5px 0 #9f7831, 0 10px 22px rgba(77,44,8,.12);
}

.btn.ghost {
  background: rgba(255, 248, 225, .34);
  border: 1px solid rgba(111, 75, 29, .35);
  box-shadow: none;
}

.btn.danger {
  background: linear-gradient(180deg, #efc0a8, #a95035);
  color: #fffbe9;
  box-shadow: 0 5px 0 #692d1d, 0 10px 22px rgba(77,44,8,.12);
}

.card-grid {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.location-card,
.task-card,
.word-card,
.answer-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(137, 91, 29, .45);
  border-radius: 20px;
  background: rgba(255, 248, 225, .67);
  box-shadow: 0 10px 22px rgba(61, 38, 10, .11);
}

.location-card img,
.task-card img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.card-body { padding: 13px; }
.card-body h3 { margin: 0 0 6px; font-size: 1.35rem; color: var(--forest); }
.card-body p { margin: 0 0 10px; line-height: 1.35; color: #314125; }

.status {
  display: inline-flex;
  margin-bottom: 9px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: .86rem;
  font-weight: 700;
  background: rgba(47, 109, 53, .14);
  color: #245227;
  border: 1px solid rgba(47, 109, 53, .22);
}
.status.locked { background: rgba(137, 91, 29, .13); color: #6e4c1b; }
.status.done { background: rgba(47, 109, 53, .18); }

.task-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.task-button {
  width: 100%;
  display: grid;
  grid-template-columns: 76px 1fr auto;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 1px solid rgba(137, 91, 29, .45);
  border-radius: 18px;
  background: rgba(255, 248, 225, .78);
  padding: 8px;
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(61, 38, 10, .08);
}

.task-button img {
  width: 76px;
  height: 76px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid rgba(137, 91, 29, .38);
}

.task-button strong { display: block; font-size: 1.08rem; color: var(--forest); }
.task-button span { display: block; font-size: .93rem; color: var(--muted); margin-top: 2px; }
.task-button .mark { font-size: 1.35rem; color: var(--ok); }

.answers {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.answer-card {
  width: 100%;
  text-align: left;
  padding: 14px 15px;
  color: var(--ink);
  font-weight: 700;
}

.answer-card.selected,
.answer-card:hover,
.task-button:hover,
.location-card:hover {
  outline: 3px solid rgba(184, 137, 53, .25);
}

.sequence-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  min-height: 44px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(255,255,255,.34);
  border: 1px dashed rgba(137,91,29,.45);
}

.token {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 14px;
  background: #fff4d6;
  border: 1px solid rgba(137, 91, 29, .45);
  font-weight: 700;
  color: var(--forest);
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.word-slot {
  min-height: 54px;
  border-radius: 16px;
  border: 1px dashed rgba(137,91,29,.5);
  background: rgba(255,248,225,.48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  font-weight: 700;
  color: var(--forest);
}

.word-slot.empty { color: rgba(95,78,47,.56); font-weight: 400; }

.phrase-output {
  min-height: 70px;
  margin: 14px 0;
  padding: 13px;
  border-radius: 18px;
  border: 1px solid rgba(137, 91, 29, .45);
  background: rgba(255,255,255,.37);
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--forest);
}

.knock-counter {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 12px 0;
}

.knock-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(137,91,29,.55);
  background: rgba(255,255,255,.32);
}
.knock-dot.on { background: radial-gradient(circle, #fff6bc, #b98935); }

.diploma-wrap {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
}

.diploma-text {
  margin: 14px auto 0;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255,248,225,.78);
  border: 1px solid rgba(137,91,29,.45);
  text-align: center;
}

.diploma-text h2 { margin: 0 0 7px; color: var(--forest); font-size: clamp(1.6rem, 7vw, 3rem); }
.diploma-text p { margin: 7px 0; font-size: 1.06rem; line-height: 1.42; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(18px);
  z-index: 20;
  width: min(calc(100% - 24px), 560px);
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(23, 47, 23, .96);
  color: #fff5d8;
  border: 1px solid rgba(216,179,109,.65);
  box-shadow: 0 14px 32px rgba(0,0,0,.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.bottom-nav {
  position: fixed;
  z-index: 10;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-h);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  background: rgba(18, 36, 17, .96);
  border-top: 1px solid rgba(216,179,109,.45);
  box-shadow: 0 -10px 28px rgba(0,0,0,.25);
}
.bottom-nav[hidden] { display: none; }
.bottom-nav button {
  border: 1px solid rgba(216,179,109,.24);
  border-radius: 14px;
  background: rgba(246,232,198,.1);
  color: var(--paper);
  font-size: .92rem;
  font-weight: 700;
}
.bottom-nav button.active { background: rgba(216,179,109,.26); color: #fff6da; }

.two-col { display: grid; gap: 14px; }

.help-box {
  margin-top: 12px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(137,91,29,.45);
  background: rgba(255,248,225,.56);
}

@media (min-width: 760px) {
  .app { padding: 18px 20px 36px; }
  .panel-inner { padding: 28px; }
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .task-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .word-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .two-col { grid-template-columns: .9fr 1.1fr; align-items: start; }
  .hero-image img,
  .location-image img { max-height: none; object-fit: contain; background: #ead3a0; }
}

@media (min-width: 1050px) {
  .bottom-nav {
    left: 50%;
    right: auto;
    bottom: 18px;
    width: min(760px, calc(100% - 36px));
    transform: translateX(-50%);
    border-radius: 22px;
    border: 1px solid rgba(216,179,109,.45);
  }
}


@media (max-width: 980px) {
  .top-nav { display: none; }
  .menu-toggle { display: grid; }
  .site-header-wrap { width: min(100%, calc(100% - 12px)); padding-top: 6px; }
  .site-header { min-height: 66px; padding: 8px 10px; border-radius: 26px; }
  .brand-logo { width: 46px; height: 46px; flex-basis: 46px; }
  .brand-copy strong { font-size: clamp(1.05rem, 5vw, 1.45rem); }
  .brand-copy small { font-size: .78rem; }
  .header-progress { padding: 7px 9px; font-size: .85rem; }
}

@media (max-width: 460px) {
  .site-header { gap: 8px; }
  .brand-header { gap: 8px; }
  .brand-logo { width: 42px; height: 42px; flex-basis: 42px; }
  .brand-copy strong { font-size: 1.08rem; }
  .brand-copy small { font-size: .72rem; }
  .header-progress { font-size: .78rem; padding: 7px 8px; }
  .menu-toggle { width: 40px; height: 40px; font-size: 1.15rem; }
  .footer-links { grid-template-columns: 1fr; }
}

@media (min-width: 461px) and (max-width: 760px) {
  .footer-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .footer-links { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

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

.bottom-nav { display: none !important; }
