:root { color-scheme: dark; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button { font: inherit; }
button:focus-visible, a:focus-visible, canvas:focus-visible {
  outline: 2px solid #c0d0b1;
  outline-offset: 4px;
}

.expedition-controls {
  position: fixed;
  z-index: 8;
  bottom: max(.75rem, env(safe-area-inset-bottom));
  left: max(.75rem, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: .4rem;
  max-width: calc(100vw - 1.5rem);
  font-size: .7rem;
}
.expedition-controls[hidden] { display: none; }
.expedition-button, .expedition-pin {
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: .45rem .65rem;
  border: 1px solid #45455d;
  border-radius: 3px;
  background: rgba(17, 17, 30, .9);
  color: #bdbdce;
  cursor: pointer;
  touch-action: manipulation;
}
.expedition-button:hover, .expedition-pin:hover {
  border-color: #9393a6;
  color: #eeeef4;
}
.expedition-save { color: #a1a1b7; font-size: .63rem; padding: .2rem; }
.expedition-save.is-error { color: #f0bb93; background: #171722; border-radius: 2px; }

.expedition-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(36rem, calc(100vw - 2rem));
  max-height: min(44rem, calc(100dvh - 2rem));
  padding: 1.3rem 1.5rem;
  background: #141420;
  color: #d0d0dd;
  border: 1px solid #525266;
  border-radius: 4px;
  box-shadow: 0 1rem 5rem #0008;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #55556b #141420;
  font: .8rem/1.65 'Courier New', monospace;
  text-align: left;
}
.expedition-dialog::backdrop { background: rgba(6, 6, 13, .72); }
.expedition-heading { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 1rem; background: #141420; }
.expedition-heading h1 { font-size: 1.1rem; font-weight: 400; color: #efefe9; }
.expedition-heading .expedition-button { font-size: .7rem; flex-shrink: 0; }
.expedition-muted { color: #a5a5b9; font-size: .72rem; }
.expedition-tabs { display: flex; gap: .7rem; margin: 1rem 0 .7rem; }
.expedition-tabs .expedition-button { background: transparent; border-color: transparent; padding: .35rem .2rem; border-radius: 0; }
.expedition-tabs [aria-current="page"] { border-bottom-color: #b7c5a4; color: #e0e8d4; }
.expedition-vitals { color: #b1b1c8; font-size: .72rem; padding-bottom: 1rem; border-bottom: 1px solid #333344; }
.expedition-section { margin-top: 1.4rem; }
.expedition-section h2 { color: #d4ddc7; font-size: .85rem; font-weight: 400; margin-bottom: .5rem; }
.expedition-section h3 { color: #d0d0dd; font-size: .78rem; font-weight: 400; }
.expedition-section p + p { margin-top: .65rem; }
.expedition-steps { padding-left: 1.4rem; margin-top: .7rem; }
.expedition-steps li { padding: .15rem 0; }
.expedition-steps .is-complete { color: #a7b995; }
.expedition-clues, .expedition-places, .expedition-records { list-style: none; padding: 0; }
.expedition-clues li + li { margin-top: .9rem; }
.expedition-clues p { color: #b8b8cd; }
.expedition-places li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .45rem 0; border-top: 1px solid #303040; }
.expedition-places li > div { min-width: 0; overflow-wrap: anywhere; }
.expedition-places small { display: block; color: #a5a5b9; font-size: .7rem; }
.expedition-pin { min-width: 4rem; flex-shrink: 0; font-size: .7rem; }
.expedition-pin[aria-pressed="true"] { color: #d6e2c7; border-color: #7d8c70; }
.expedition-places + .expedition-muted { margin-top: .4rem; }
.expedition-records { color: #b8b8cd; }
.expedition-records li + li { margin-top: .2rem; }
.expedition-legend { display: grid; grid-template-columns: minmax(5rem, 8rem) minmax(0, 1fr); gap: .6rem 1rem; }
.expedition-legend dt { color: #b0c5db; overflow-wrap: anywhere; }
.expedition-legend dd { margin: 0; min-width: 0; }
.expedition-legend img { image-rendering: pixelated; object-fit: contain; vertical-align: middle; }
.fantasy-world .expedition-legend img { image-rendering: auto; }
.expedition-save-detail { margin-top: 1.6rem; padding-top: .8rem; border-top: 1px solid #333344; }
.expedition-save-detail.is-error { color: #f0bb93; }

body.expedition-active #log { bottom: 4.25rem; width: max-content; max-width: min(600px, calc(100vw - 1.5rem)); }
body.expedition-active #links img { height: 32px; }
body.expedition-active #links { gap: .55rem; }

@media (max-width: 540px) {
  .expedition-dialog { width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); padding: 1rem; }
  .expedition-heading h1 { font-size: 1rem; }
  .expedition-legend { grid-template-columns: minmax(4rem, 6rem) minmax(0, 1fr); gap: .7rem; }
  .expedition-controls { gap: .3rem; }
  .expedition-save { position: absolute; bottom: 3rem; left: 0; white-space: nowrap; background: #141420d9; }
  body.expedition-active #log { bottom: 5rem; font-size: .7rem; max-height: 4.8rem; }
  body.expedition-active #links img { height: 25px; }
  body.expedition-active #links { bottom: max(1.2rem, env(safe-area-inset-bottom)); gap: .4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
body.fantasy-world canvas { image-rendering: auto; }
