:root {
  --ink: #0f1b2d;
  --ink-soft: #3d4f5f;
  --paper: #eef4f6;
  --mist: #d4e4e8;
  --leaf: #1a8a7a;
  --leaf-deep: #0d2b4a;
  --sun: #e8a317;
  --coral: #c45c3a;
  --line: rgba(13, 43, 74, 0.12);
  --shadow: 0 24px 60px rgba(13, 43, 74, 0.14);
  --radius: 18px;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
}

body {
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: -20% -10% auto;
  height: 70vh;
  background:
    radial-gradient(ellipse 60% 50% at 20% 30%, rgba(26, 138, 122, 0.2), transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 10%, rgba(13, 43, 74, 0.14), transparent 55%),
    radial-gradient(ellipse 40% 35% at 60% 60%, rgba(26, 138, 122, 0.08), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.topo-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(20, 32, 26, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 32, 26, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, black, transparent);
  pointer-events: none;
  z-index: 0;
}

.screen {
  display: none;
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.screen.active {
  display: flex;
}

#screen-home {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem 6rem;
  text-align: center;
  animation: rise 0.7s ease both;
}

.site-header {
  max-width: 36rem;
}

.eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--leaf);
}

.brand {
  margin: 0;
  line-height: 0;
}

.brand-logo {
  display: block;
  width: min(420px, 88vw);
  height: auto;
  margin: 0 auto;
  animation: rise 0.7s ease both;
}

.tagline {
  margin: 1.5rem auto 2rem;
  max-width: 28rem;
  font-size: 1.1rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.field-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  width: min(520px, 100%);
  margin: 0 auto;
}

.field-card {
  appearance: none;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  border-radius: 16px;
  padding: 1.35rem 1.25rem;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow);
}

.field-card:hover {
  transform: translateY(-3px);
  border-color: var(--leaf);
}

.field-icon {
  display: block;
  font-size: 1.4rem;
  color: var(--leaf);
  margin-bottom: 0.5rem;
}

.field-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin-bottom: 0.35rem;
  color: var(--leaf-deep);
}

.field-card span:last-child {
  font-size: 0.9rem;
  color: var(--ink-soft);
  line-height: 1.35;
}

.home-admin {
  margin-top: 2rem;
  font-size: 0.9rem;
}

.home-admin a {
  color: var(--leaf);
  font-weight: 600;
}

.topic-card {
  position: relative;
}

.topic-swatch {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.empty-hint {
  color: var(--ink-soft);
  line-height: 1.5;
}

.empty-hint a {
  color: var(--leaf);
  font-weight: 600;
}

.map-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--leaf-deep);
  pointer-events: none;
}

@media (max-width: 560px) {
  .field-pick {
    grid-template-columns: 1fr;
  }
}

.home-preview {
  position: relative;
  margin-top: 3rem;
  width: min(520px, 90vw);
  height: 160px;
  border-radius: 999px;
  background:
    linear-gradient(120deg, rgba(31, 107, 74, 0.15), rgba(232, 163, 23, 0.12)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cpath d='M0 40 Q20 20 40 40 T80 40' fill='none' stroke='%231f6b4a' stroke-opacity='0.15' stroke-width='2'/%3E%3C/svg%3E");
  border: 1px solid var(--line);
  overflow: hidden;
}

.preview-pin {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 6px rgba(196, 92, 58, 0.25);
  animation: pulse 2.4s ease-in-out infinite;
}

.preview-pin.p1 { top: 42%; left: 22%; animation-delay: 0s; }
.preview-pin.p2 { top: 28%; left: 55%; background: var(--leaf); box-shadow: 0 0 0 6px rgba(31, 107, 74, 0.25); animation-delay: 0.4s; }
.preview-pin.p3 { top: 58%; left: 72%; background: var(--sun); box-shadow: 0 0 0 6px rgba(232, 163, 23, 0.25); animation-delay: 0.8s; }

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  padding: 0.9rem 1.6rem;
  border-radius: 999px;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--leaf-deep);
  color: #f3faf5;
}

.btn-primary:hover {
  background: var(--leaf);
}

.btn-ghost {
  background: transparent;
  color: var(--leaf-deep);
  border: 1.5px solid var(--line);
}

.btn-ghost:hover {
  border-color: var(--leaf);
  color: var(--leaf);
}

.btn-back {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  margin-bottom: 1.25rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}

.btn-back:hover {
  color: var(--leaf);
}

#screen-topics,
#screen-done {
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

.panel {
  width: min(920px, 100%);
  padding: 2rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  animation: rise 0.5s ease both;
}

.panel-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--leaf-deep);
}

.panel-desc {
  margin: 0 0 1.75rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.topic-card {
  appearance: none;
  text-align: left;
  border: 1px solid var(--line);
  background: #f7fbf8;
  border-radius: 14px;
  padding: 1.2rem 1.25rem;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.topic-card:hover {
  border-color: var(--leaf);
  background: #fff;
  transform: translateY(-2px);
}

.topic-card .count {
  display: inline-block;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sun);
}

.topic-card h3 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
}

.topic-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
  line-height: 1.4;
}

#screen-game {
  padding: 0;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  width: 100%;
  min-height: 100vh;
}

.game-sidebar {
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.88);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  z-index: 2;
  max-height: 100vh;
  overflow-y: auto;
}

.topic-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--leaf);
}

.quest-card {
  padding: 1.1rem 1.2rem;
  border-radius: 14px;
  background: linear-gradient(145deg, #0d2b4a, #1a8a7a);
  color: #eef7f1;
  animation: questIn 0.45s ease both;
}

.quest-kicker {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 0.35rem;
}

.quest-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.quest-hint {
  margin: 0.55rem 0 0;
  font-size: 0.9rem;
  opacity: 0.85;
  line-height: 1.4;
}

.progress-block {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--mist);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--leaf), var(--sun));
  border-radius: inherit;
  transition: width 0.35s ease;
}

.type-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
  min-height: 0;
}

.type-panel[hidden],
.name-list-wrap[hidden] {
  display: none !important;
}

.type-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.type-form input {
  flex: 1;
  min-width: 140px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 0.9rem;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}

.type-form input:focus {
  outline: 2px solid var(--leaf);
  border-color: var(--leaf);
}

.type-form .btn {
  padding: 0.75rem 1.1rem;
}

.found-answers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-height: 160px;
  overflow-y: auto;
}

.found-answers li {
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: #e5f3eb;
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--leaf-deep);
}

.map-pin.label-pin {
  width: auto;
  min-width: 36px;
  height: auto;
  min-height: 36px;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
}

.map-pin .pin-label {
  font-size: 0.78rem;
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.name-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow-y: auto;
  max-height: min(48vh, 420px);
  padding-right: 0.25rem;
}

.name-chip {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1.5px solid var(--line);
  background: #f7fbf8;
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.name-chip:hover:not(:disabled) {
  border-color: var(--leaf);
  background: #fff;
}

.name-chip.selected {
  border-color: var(--leaf);
  background: #e5f3eb;
  box-shadow: inset 3px 0 0 var(--leaf);
}

.name-chip.matched {
  opacity: 0.45;
  text-decoration: line-through;
  cursor: default;
  background: var(--mist);
}

.feedback {
  min-height: 1.4em;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.feedback.far { color: var(--coral); }
.feedback.close { color: var(--sun); }
.feedback.hit { color: var(--leaf); }

.map-wrap {
  position: relative;
  min-height: 100vh;
}

#map {
  position: absolute;
  inset: 0;
  background: #c5d5cb;
}

.map-hint {
  position: absolute;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: rgba(20, 32, 26, 0.82);
  color: #f3faf5;
  font-size: 0.85rem;
  font-weight: 600;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.map-hint.hide {
  opacity: 0;
}

.done-panel {
  text-align: center;
}

.done-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.leaflet-container {
  font-family: var(--font-body);
}

.leaflet-div-icon {
  background: transparent;
  border: none;
}

.map-pin {
  width: 36px;
  height: 36px;
  border: 2.5px solid #fff;
  border-radius: 50%;
  background: var(--pin, var(--leaf-deep));
  color: #f3faf5;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 61, 44, 0.35);
  transition: transform 0.15s ease, background 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.map-pin.colored {
  background: var(--pin);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--pin) 45%, transparent);
}

.map-pin:hover {
  transform: scale(1.12);
  filter: brightness(1.08);
}

.map-pin.wrong {
  background: var(--coral) !important;
  animation: shake 0.4s ease;
}

.map-pin.revealed {
  background: var(--pin);
  cursor: default;
  animation: popIn 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.pin-check {
  font-size: 1rem;
  font-weight: 800;
}

.leaflet-popup-content-wrapper {
  border-radius: 12px;
  font-family: var(--font-body);
}

.leaflet-popup-content {
  margin: 0.75rem 0.9rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

.leaflet-popup-content strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.75; }
}

@keyframes questIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.2); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@media (max-width: 860px) {
  .game-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .game-sidebar {
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .map-wrap {
    min-height: 55vh;
    height: 55vh;
  }

  .name-list {
    max-height: 180px;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .name-chip {
    width: auto;
    flex: 1 1 auto;
    min-width: calc(50% - 0.3rem);
  }
}
