:root {
  --bg: #062719;
  --panel: rgba(255, 249, 211, 0.94);
  --panel-solid: #fff7c2;
  --ink: #092317;
  --muted: #3d5b42;
  --line: rgba(9, 35, 23, 0.18);
  --accent: #ffd429;
  --accent-dark: #e6b800;
  --gold: #ffd429;
  --green: #078c45;
  --green-dark: #045f32;
  --ok: #078c45;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  color-scheme: dark;
}

body {
  min-height: 100svh;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 20;
  transform: translateY(-160%);
  background: var(--panel-solid);
  color: var(--ink);
  padding: 0.7rem 0.9rem;
  border: 2px solid var(--ink);
}

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

.topbar {
  position: fixed;
  inset: max(0.85rem, env(safe-area-inset-top)) clamp(0.85rem, 2vw, 1.4rem) auto auto;
  z-index: 10;
  width: min(420px, calc(100vw - 1.7rem));
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: start;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  background: var(--panel);
  color: var(--ink);
  border: 2px solid var(--green);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow,
.intro,
.score,
.sheet-kicker,
.feedback,
.landmarks p {
  margin: 0;
}

.eyebrow {
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 360px;
  margin: 0.12rem 0 0;
  font-size: clamp(1.1rem, 2vw, 1.6rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.intro {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.score {
  min-width: 112px;
  color: var(--green-dark);
  font-size: 0.92rem;
  font-weight: 800;
  text-align: left;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  border: 1px solid transparent;
  padding: 0.72rem 0.92rem;
  font-weight: 850;
  border-radius: 8px;
}

.primary-button {
  background: var(--green);
  color: #fff7c2;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--green-dark);
}

.secondary-button {
  background: rgba(250, 250, 247, 0.9);
  color: var(--ink);
}

.secondary-button:hover,
.secondary-button:focus-visible {
  background: #fff;
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.hint-button:focus-visible,
.close-button:focus-visible,
.hotspot:focus-visible,
input:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.map-shell {
  min-height: 100svh;
  padding-top: 0;
}

.map-scroll {
  width: 100vw;
  height: 100svh;
  overflow: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: grid;
  place-items: center;
}

.map-stage {
  position: relative;
  width: min(100vw, calc(100svh * 1.777));
  aspect-ratio: 1672 / 941;
  margin: 0 auto;
  isolation: isolate;
}

.map-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

.map-image-base {
  filter: grayscale(1) saturate(0.12) brightness(1.22) contrast(0.8);
}

.map-image-color {
  --reveal-mask: radial-gradient(circle at 50% 50%, transparent 0, transparent 1px);
  opacity: 1;
  -webkit-mask-image: var(--reveal-mask);
  mask-image: var(--reveal-mask);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  transition: -webkit-mask-image 220ms ease, mask-image 220ms ease;
}

.hotspot-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.hotspot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 54px;
  height: 54px;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #111;
}

.hotspot::before,
.hotspot::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 999px;
}

.hotspot::before {
  background: #fffaf3;
  border: 2px solid var(--green-dark);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
}

.hotspot::after {
  inset: 21px;
  background: var(--gold);
}

.hotspot[aria-pressed="true"]::before {
  background: var(--gold);
  border-color: var(--ok);
}

.hotspot[aria-pressed="true"]::after {
  background: var(--ok);
}

.answer-sheet {
  position: fixed;
  z-index: 14;
  left: var(--sheet-left, 50%);
  top: var(--sheet-top, 50%);
  width: min(420px, calc(100vw - 2rem));
  padding: 1rem;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(8px) scale(0.98);
  transform-origin: left center;
  transition: opacity 180ms ease, transform 220ms ease, visibility 220ms ease;
}

.answer-sheet.is-open {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.answer-sheet::before {
  content: "";
  position: absolute;
  top: calc(50% - 9px);
  left: -9px;
  width: 18px;
  height: 18px;
  background: var(--panel);
  border-left: 1px solid rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid rgba(255, 255, 255, 0.72);
  transform: rotate(45deg);
}

.answer-sheet[data-side="left"] {
  transform-origin: right center;
}

.answer-sheet[data-side="left"]::before {
  right: -9px;
  left: auto;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.72);
  border-top: 1px solid rgba(255, 255, 255, 0.72);
}

.close-button {
  position: absolute;
  right: 0.75rem;
  top: 0.65rem;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1;
}

.sheet-kicker {
  padding-right: 2.5rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.answer-sheet h2 {
  margin: 0.25rem 2.4rem 0.35rem 0;
  font-size: 1.35rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.sheet-copy {
  margin: 0 0 0.9rem;
  color: var(--muted);
}

.guess-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.help-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.hint-button {
  min-height: 38px;
  border: 1px solid var(--green);
  border-radius: 8px;
  padding: 0.48rem 0.68rem;
  background: rgba(255, 255, 255, 0.7);
  color: var(--green-dark);
  font-size: 0.88rem;
  font-weight: 850;
}

.hint-button:hover,
.hint-button:focus-visible {
  background: var(--gold);
  color: var(--ink);
}

.helper-output {
  min-height: 1.35rem;
  margin: 0.6rem 0 0;
  padding: 0.6rem 0.7rem;
  border: 1px solid rgba(7, 140, 69, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 750;
}

.helper-output:empty {
  display: none;
}

label {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
}

input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.78rem;
  background: #fff;
  color: var(--ink);
}

.feedback {
  min-height: 1.4rem;
  margin-top: 0.8rem;
  color: var(--green-dark);
  font-weight: 800;
}

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

.landmarks {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@media (max-width: 760px) {
  body {
    overflow: hidden;
  }

  .topbar {
    width: min(300px, calc(100vw - 1.5rem));
    padding: 0.72rem 0.8rem;
  }

  h1 {
    max-width: 260px;
    font-size: 1rem;
  }

  .intro {
    max-width: 360px;
  }

  .actions {
    width: 100%;
    justify-content: start;
  }

  .score {
    min-width: auto;
    text-align: left;
  }

  .map-stage {
    width: calc(100svh * 1672 / 941);
    max-width: none;
    height: 100svh;
    margin: 0;
  }

  .map-scroll {
    display: block;
    overflow-x: auto;
    overflow-y: hidden;
    padding-top: 0;
  }

  .answer-sheet {
    inset: auto 0 0;
    width: 100vw;
    max-height: min(58svh, 420px);
    overflow: auto;
    border-radius: 12px 12px 0 0;
    padding: 1rem max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    opacity: 1;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(calc(100% + 2rem));
    transform-origin: center bottom;
  }

  .answer-sheet.is-open {
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }

  .answer-sheet::before {
    display: none;
  }

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

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