:root {
  --paper: #e7efe6;
  --ink: #14241c;
  --muted: #3e5348;
  --line: #c5d4c8;
  --box: #14683a;
  --box-soft: #d7eadc;
  --road: #8a4e08;
  --road-soft: #f3e2c4;
  --tap: #5c675f;
  --map-frame: #d5e0d6;
  --shadow: 0 10px 28px rgba(20, 36, 28, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  background: var(--paper);
  font-family: "Atkinson Hyperlegible", "Segoe UI", sans-serif;
  font-size: 17px;
}

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  align-items: end;
  padding: 0.85rem 1.1rem 0.7rem;
  border-bottom: 1px solid var(--line);
}

.round-name {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 0.95rem;
  color: var(--box);
}

h1 {
  margin: 0.1rem 0 0;
  font-family: Fraunces, Georgia, serif;
  font-weight: 560;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
  max-width: 22ch;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
  max-width: 36rem;
}

.filters label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  color: var(--muted);
  cursor: pointer;
}

.filters input { accent-color: var(--box); }

.frame {
  display: grid;
  grid-template-columns: 22.5rem minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
}

.sheet {
  overflow: auto;
  min-height: 0;
  padding: 0.4rem 0 1.5rem;
  border-right: 1px solid var(--line);
  background: #f4f8f3;
}

.sheet section { padding: 0.8rem 1rem 0.2rem; }

h2 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
  font-weight: 700;
}

.lede {
  margin: 0 0 0.6rem;
  color: var(--muted);
  line-height: 1.4;
}

ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row {
  width: 100%;
  text-align: left;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0.62rem 0.15rem;
  display: grid;
  grid-template-columns: 2.3rem 1fr;
  gap: 0.45rem;
  cursor: pointer;
}

.row:hover, .row:focus-visible, .row.is-on {
  background: white;
  outline: none;
}

.num {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--box);
  padding-top: 0.15rem;
}

.row.is-open .num { color: var(--muted); }

.name { font-weight: 700; display: block; }

.key, .hint {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.3;
  margin-top: 0.12rem;
}

.stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
}

#map { height: 100%; min-height: 0; background: #d5ddd4; }

.look {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.9rem;
  background: var(--ink);
  color: #f4f8f3;
}

.look p {
  margin: 0;
  line-height: 1.3;
}

.look-actions {
  display: flex;
  flex: none;
  gap: 0.45rem;
}

.look a,
.look button {
  flex: none;
  color: var(--ink);
  background: #f4f8f3;
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  padding: 0.4rem 0.8rem;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.look button {
  color: #3d3208;
  background: #e3b423;
}

.look button[aria-pressed="true"] {
  color: var(--ink);
  background: #f4f8f3;
}

.look a:focus-visible,
.look button:focus-visible,
.base-switch button:focus-visible {
  outline: 2px solid #f4f8f3;
  outline-offset: 2px;
}

.me {
  background: transparent;
  border: 0;
  pointer-events: none;
}

.me span {
  display: block;
  width: 18px;
  height: 18px;
  margin: 7px;
  border-radius: 50%;
  background: #12315f;
  border: 5px solid #e3b423;
  box-shadow: 0 0 0 3px #fffef8, 0 0 0 0 rgba(227, 180, 35, 0.75);
  animation: here 1.6s ease-out infinite;
}

@keyframes here {
  70% { box-shadow: 0 0 0 3px #fffef8, 0 0 0 22px rgba(227, 180, 35, 0); }
  100% { box-shadow: 0 0 0 3px #fffef8, 0 0 0 0 rgba(227, 180, 35, 0); }
}

.base-switch {
  display: flex;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.base-switch button {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.92rem;
  padding: 0.32rem 0.75rem;
  color: var(--muted);
  cursor: pointer;
}

.base-switch button[aria-pressed="true"] {
  background: var(--box);
  color: white;
}

.tag, .turn, .dot, .ring {
  background: transparent;
  border: 0;
}

.tag span, .turn span {
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  color: white;
  font-family: Fraunces, Georgia, serif;
  font-size: 0.95rem;
  box-shadow: var(--shadow);
}

.tag span {
  width: auto;
  min-width: 1.7rem;
  padding: 0 0.4rem;
  background: var(--box);
  border-radius: 3px 11px 11px 3px;
}

.tag.unsure span {
  background: var(--paper);
  color: var(--box);
  border: 2px solid var(--box);
}

.turn span {
  background: var(--road);
  border-radius: 4px;
  font-family: "Atkinson Hyperlegible", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  width: auto;
  min-width: 1.7rem;
  padding: 0 0.35rem;
}

.dot span {
  display: block;
  width: 11px;
  height: 11px;
  margin: 4px;
  border-radius: 50%;
  background: var(--tap);
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.ring span {
  display: block;
  width: 14px;
  height: 14px;
  margin: 3px;
  border-radius: 50%;
  border: 2px solid #1d4e86;
  background: rgba(255, 255, 255, 0.85);
}

.leaflet-popup-content {
  margin: 0.7rem 0.85rem;
  font-family: "Atkinson Hyperlegible", sans-serif;
  font-size: 0.98rem;
  line-height: 1.35;
}

.leaflet-popup-content strong { display: block; font-size: 1.05rem; }
.leaflet-popup-content p { margin: 0.35rem 0 0; }
.leaflet-popup-content a { color: var(--box); font-weight: 700; }

@media (max-width: 900px) {
  .top {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    padding: 0.55rem 0.7rem 0.4rem;
    padding-top: max(0.55rem, env(safe-area-inset-top));
  }
  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    max-width: none;
  }
  .filters label { flex: none; padding: 0.4rem 0.65rem; }
  h1 { font-size: 1.35rem; }
  .frame {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1.45fr) minmax(8.5rem, 0.55fr);
  }
  .stage { order: -1; }
  .look {
    align-items: stretch;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.55rem 0.75rem calc(0.55rem + env(safe-area-inset-bottom));
  }
  .look-actions { flex-direction: column; }
  .look a, .look button { text-align: center; padding: 0.7rem 0.8rem; }
  .sheet { border-right: 0; border-top: 1px solid var(--line); }
}
