:root {
      --ink: #2a1f14;
      --muted: #6b5340;
      --parchment: #e8d9b8;
      --parchment-deep: #d4c19a;
      --leather: #4a2f1c;
      --brass: #a67c2d;
      --brass-bright: #c4963a;
      --stamp: #8b2e2e;
      --good: #4d6b32;
      --warn: #9a5b24;
      --dust: #c4b08a;
      --panel-shadow: 0 14px 40px rgba(42, 31, 20, 0.45);
      --hud-stack: 0px;
      --safe-bottom: env(safe-area-inset-bottom, 0px);
      --safe-top: env(safe-area-inset-top, 0px);
    }

    * { box-sizing: border-box; }

    html, body {
      margin: 0;
      height: 100%;
      height: 100dvh;
      overflow: hidden;
      font-family: "Special Elite", "Courier New", monospace;
      color: var(--ink);
      background: #2a1f14;
    }

    #map { position: absolute; inset: 0; }

    .film {
      position: absolute;
      inset: 0;
      z-index: 2;
      pointer-events: none;
      background:
        radial-gradient(ellipse at center, transparent 42%, rgba(42, 31, 20, 0.55) 100%),
        repeating-linear-gradient(
          0deg,
          transparent,
          transparent 2px,
          rgba(42, 31, 20, 0.03) 2px,
          rgba(42, 31, 20, 0.03) 3px
        );
      animation: flicker 7s ease-in-out infinite;
    }

    @keyframes flicker {
      0%, 100% { opacity: 1; }
      48% { opacity: 1; }
      50% { opacity: 0.92; }
      52% { opacity: 1; }
    }

    .corner-stamp {
      position: absolute;
      z-index: 3;
      top: 18px;
      right: 18px;
      width: 92px;
      height: 92px;
      border: 3px solid var(--stamp);
      border-radius: 50%;
      color: var(--stamp);
      display: grid;
      place-items: center;
      text-align: center;
      font-family: "Cinzel", serif;
      font-size: 0.62rem;
      font-weight: 700;
      letter-spacing: 0.06em;
      line-height: 1.15;
      text-transform: uppercase;
      transform: rotate(12deg);
      opacity: 0.82;
      background: rgba(232, 217, 184, 0.35);
      box-shadow: inset 0 0 0 1px rgba(139, 46, 46, 0.35);
      pointer-events: none;
      animation: stamp-in 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) both;
    }

    body:not(.playing) .hud,
    body:not(.playing) .corner-stamp {
      visibility: hidden;
      pointer-events: none;
    }

    .start-screen {
      display: none;
      position: absolute;
      z-index: 8;
      inset: 0;
      align-items: stretch;
      justify-content: center;
      padding: clamp(12px, 3vh, 28px);
      background:
        radial-gradient(ellipse at 30% 20%, rgba(196, 150, 58, 0.12), transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(139, 46, 46, 0.18), transparent 45%),
        rgba(42, 31, 20, 0.78);
      overflow: auto;
    }

    .start-screen.on { display: flex; }

    .start-card {
      width: min(560px, 100%);
      margin: auto;
      padding: clamp(22px, 4vw, 34px) clamp(20px, 4vw, 32px) 24px;
      border: 3px solid var(--leather);
      background:
        linear-gradient(160deg, rgba(255, 255, 255, 0.22), transparent 40%),
        repeating-linear-gradient(
          0deg,
          transparent,
          transparent 28px,
          rgba(74, 47, 28, 0.04) 28px,
          rgba(74, 47, 28, 0.04) 29px
        ),
        var(--parchment);
      box-shadow: var(--panel-shadow);
      animation: dossier-in 0.55s cubic-bezier(0.2, 1.3, 0.4, 1) both;
    }

    .start-card .eyebrow {
      margin: 0 0 6px;
      font-size: 0.72rem;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: var(--stamp);
    }

    .start-card h1 {
      margin: 0 0 10px;
      font-family: "Cinzel", serif;
      font-size: clamp(1.55rem, 4.5vw, 2.15rem);
      font-weight: 700;
      letter-spacing: 0.03em;
      line-height: 1.15;
      color: var(--leather);
    }

    .start-card .tagline {
      margin: 0 0 18px;
      font-size: 0.95rem;
      line-height: 1.45;
      color: var(--muted);
    }

    .start-card h2 {
      margin: 18px 0 8px;
      font-family: "Cinzel", serif;
      font-size: 0.95rem;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--brass);
      border-bottom: 1px solid rgba(166, 124, 45, 0.45);
      padding-bottom: 4px;
    }

    .start-card p {
      margin: 0 0 10px;
      font-size: 0.86rem;
      line-height: 1.5;
      color: var(--ink);
    }

    .start-card p:last-of-type { margin-bottom: 0; }

    .start-card ul {
      margin: 0 0 4px;
      padding: 0 0 0 1.1rem;
      font-size: 0.84rem;
      line-height: 1.5;
      color: var(--ink);
    }

    .start-card li { margin-bottom: 6px; }

    .start-card .cite {
      font-size: 0.78rem;
      color: var(--muted);
    }

    .start-card .cite a {
      color: var(--leather);
    }

    .start-facts {
      display: grid;
      gap: 8px;
      margin: 4px 0 8px;
    }

    .start-fact {
      padding: 8px 10px;
      border-left: 3px solid var(--brass);
      background: rgba(255, 248, 230, 0.5);
      font-size: 0.8rem;
      line-height: 1.4;
      color: var(--ink);
    }

    .start-fact strong {
      font-family: "Cinzel", serif;
      font-size: 0.72rem;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--leather);
      display: block;
      margin-bottom: 2px;
    }

    .start-actions {
      margin-top: 20px;
      display: flex;
      flex-direction: column;
      gap: 8px;
      align-items: stretch;
    }

    .start-actions .primary {
      font-size: 1rem;
      padding: 12px 18px;
    }

    .start-ready {
      margin: 0;
      text-align: center;
      font-size: 0.75rem;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--muted);
      min-height: 1.2em;
    }

    .start-ready.ok { color: var(--good); }

    @keyframes stamp-in {
      from { transform: rotate(12deg) scale(1.4); opacity: 0; }
      to { transform: rotate(12deg) scale(1); opacity: 0.82; }
    }

    @keyframes dossier-in {
      from { transform: translateY(18px) scale(0.96); opacity: 0; }
      to { transform: none; opacity: 1; }
    }

    .hud {
      position: absolute;
      z-index: 3;
      top: 14px;
      left: 14px;
      width: min(400px, calc(100vw - 28px));
      max-height: calc(100vh - 28px);
      max-height: calc(100dvh - 28px);
      overflow: auto;
      padding: 18px 18px 16px;
      color: var(--ink);
      background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 40%),
        repeating-linear-gradient(
          0deg,
          var(--parchment) 0px,
          var(--parchment) 28px,
          var(--parchment-deep) 28px,
          var(--parchment-deep) 29px
        );
      border: 2px solid var(--leather);
      box-shadow:
        var(--panel-shadow),
        inset 0 0 0 1px rgba(166, 124, 45, 0.35),
        inset 0 0 40px rgba(74, 47, 28, 0.08);
      animation: journal-slide 0.55s ease-out both;
    }

    .hud-grab {
      display: none;
    }

    .hud-peek-actions {
      margin-bottom: 10px;
    }

    .hud-more-actions {
      margin-bottom: 10px;
    }

    @keyframes journal-slide {
      from { transform: translateX(-18px); opacity: 0; }
      to { transform: translateX(0); opacity: 1; }
    }

    .hud::before {
      content: "";
      position: absolute;
      left: 0;
      top: 0;
      bottom: 0;
      width: 10px;
      background: linear-gradient(180deg, #6b4228, var(--leather), #3a2414);
      box-shadow: 2px 0 0 rgba(166, 124, 45, 0.4);
    }

    .eyebrow {
      margin: 0 0 4px 8px;
      font-family: "Cinzel", serif;
      font-size: 0.68rem;
      letter-spacing: 0.18em;
      text-transform: uppercase;
      color: var(--stamp);
    }

    .hud h1 {
      margin: 0 0 6px 8px;
      font-family: "Cinzel", serif;
      font-size: 1.35rem;
      font-weight: 700;
      letter-spacing: 0.04em;
      line-height: 1.15;
      color: var(--leather);
      text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
    }

    .isle-link {
      appearance: none;
      border: none;
      background: none;
      padding: 0;
      margin: 0;
      font: inherit;
      color: var(--stamp);
      cursor: pointer;
      text-decoration: underline;
      text-decoration-thickness: 2px;
      text-underline-offset: 3px;
      text-shadow: inherit;
    }

    .isle-link:hover {
      color: #6e2020;
    }

    .isle-brief {
      display: none;
      position: absolute;
      z-index: 5;
      inset: 0;
      align-items: center;
      justify-content: center;
      padding: 20px;
      background: rgba(42, 31, 20, 0.62);
    }

    .isle-brief.on { display: flex; }

    .isle-card {
      width: min(560px, 100%);
      max-height: min(88vh, 720px);
      overflow: auto;
      padding: 20px 18px 16px;
      border: 3px solid var(--leather);
      background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 40%),
        var(--parchment);
      box-shadow: var(--panel-shadow);
      animation: stamp-in 0.45s cubic-bezier(0.2, 1.35, 0.4, 1) both;
    }

    .isle-card .eyebrow { margin: 0 0 4px; }

    .isle-card h2 {
      margin: 0 0 10px;
      font-family: "Cinzel", serif;
      font-size: 1.35rem;
      color: var(--leather);
    }

    .isle-card p {
      margin: 0 0 10px;
      font-size: 0.84rem;
      line-height: 1.5;
      color: var(--ink);
    }

    .isle-card p.muted { color: var(--muted); font-size: 0.78rem; }

    #aegeanMap {
      width: 100%;
      height: 220px;
      margin: 4px 0 12px;
      border: 2px solid var(--leather);
      background: #2a1f14;
    }

    .isle-card .row { margin: 0; justify-content: flex-end; }

    .chapter-brief {
      display: none;
      position: absolute;
      z-index: 5;
      inset: 0;
      align-items: center;
      justify-content: center;
      padding: 20px;
      background: rgba(42, 31, 20, 0.68);
    }

    .chapter-brief.on { display: flex; }

    .chapter-card {
      width: min(520px, 100%);
      max-height: min(88vh, 680px);
      overflow: auto;
      padding: 22px 20px 16px;
      border: 3px solid #3f5a28;
      background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent 42%),
        var(--parchment);
      box-shadow: var(--panel-shadow);
      animation: stamp-in 0.5s cubic-bezier(0.2, 1.35, 0.4, 1) both;
    }

    .chapter-card .eyebrow { margin: 0 0 4px; color: var(--good); }

    .chapter-card h2 {
      margin: 0 0 6px;
      font-family: "Cinzel", serif;
      font-size: 1.4rem;
      color: var(--leather);
    }

    .chapter-card .when {
      margin: 0 0 12px;
      font-family: "Cinzel", serif;
      font-size: 0.68rem;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--stamp);
    }

    .chapter-card p {
      margin: 0 0 10px;
      font-size: 0.86rem;
      line-height: 1.5;
      color: var(--ink);
    }

    .chapter-card .museum {
      margin: 12px 0 14px;
      padding: 10px 12px;
      border: 2px dashed var(--brass);
      background: rgba(255, 248, 230, 0.65);
      font-size: 0.88rem;
      line-height: 1.45;
    }

    .chapter-card .museum strong { color: var(--good); }

    .chapter-card .chapter-art {
      display: block;
      width: 100%;
      aspect-ratio: 4 / 3;
      object-fit: cover;
      margin: 0 0 12px;
      border: 2px solid rgba(63, 90, 40, 0.45);
      background: rgba(255, 248, 230, 0.4);
    }

    .chapter-card .chapter-art[hidden] {
      display: none;
    }

    .chapter-card .row { margin: 0; justify-content: flex-end; }

    @media (max-width: 640px) {
      #aegeanMap { height: 180px; }
    }

    .lede {
      margin: 0 0 14px 8px;
      color: var(--muted);
      font-size: 0.86rem;
      line-height: 1.45;
    }

    .stats {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 6px;
      margin: 0 0 12px 8px;
    }

    .stat {
      padding: 8px 6px;
      border: 1px dashed rgba(74, 47, 28, 0.35);
      background: rgba(255, 248, 230, 0.45);
    }

    .stat .k {
      display: block;
      font-family: "Cinzel", serif;
      font-size: 0.58rem;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--muted);
    }

    .stat .v {
      font-size: 1rem;
      font-weight: 700;
      font-variant-numeric: tabular-nums;
      color: var(--ink);
    }

    .phase {
      margin: 0 0 12px 8px;
      font-size: 0.9rem;
      line-height: 1.45;
      min-height: 2.6em;
    }

    .phase strong { color: var(--stamp); }

    .row {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin: 0 0 10px 8px;
    }

    button {
      appearance: none;
      border: 2px solid var(--leather);
      border-radius: 0;
      background: linear-gradient(180deg, #f0e2c0, #d8c49a);
      color: var(--ink);
      font-family: "Cinzel", serif;
      font-size: 0.72rem;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      padding: 9px 12px;
      cursor: pointer;
      box-shadow: 0 2px 0 rgba(74, 47, 28, 0.35);
      transition: transform 0.12s ease, background 0.12s ease;
    }

    button:hover {
      background: linear-gradient(180deg, #f7ebcf, #e0cc9f);
      transform: translateY(-1px);
    }

    button:active { transform: translateY(1px); box-shadow: none; }
    button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

    button.primary {
      background: linear-gradient(180deg, #b23a3a, var(--stamp));
      border-color: #5c1c1c;
      color: #f8ecd4;
      font-weight: 700;
    }

    button.primary:hover {
      background: linear-gradient(180deg, #c44949, #9a3434);
    }

    button.survey.on {
      background: linear-gradient(180deg, #3f5a28, var(--good));
      border-color: #2a3f1c;
      color: #f4ecd8;
    }

    .hud.paused {
      box-shadow:
        var(--panel-shadow),
        inset 0 0 0 2px rgba(77, 107, 50, 0.55),
        inset 0 0 40px rgba(74, 47, 28, 0.08);
    }

    .scout-legend {
      display: none;
      margin: 0 0 12px 8px;
      padding: 10px 10px 8px;
      border: 1px dashed rgba(74, 47, 28, 0.4);
      background: rgba(255, 248, 230, 0.5);
      font-size: 0.7rem;
      line-height: 1.5;
      color: var(--muted);
    }

    .hud.paused .scout-legend { display: block; }

    .scout-legend > summary {
      cursor: pointer;
      list-style: none;
      color: var(--ink);
      font-family: "Cinzel", serif;
      font-size: 0.72rem;
      letter-spacing: 0.04em;
      margin-bottom: 6px;
    }

    .scout-legend > summary::-webkit-details-marker { display: none; }

    .scout-swatches {
      line-height: 1.55;
    }

    .survey-legend {
      margin: 0 0 12px 8px;
      padding: 10px 10px 8px;
      border: 1px dashed rgba(74, 47, 28, 0.4);
      background: rgba(255, 248, 230, 0.5);
      font-size: 0.7rem;
      line-height: 1.55;
      color: var(--muted);
    }

    .survey-legend strong {
      display: block;
      color: var(--ink);
      font-family: "Cinzel", serif;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      font-size: 0.65rem;
      margin-bottom: 6px;
    }

    .survey-legend .lede-mini {
      display: block;
      margin-top: 6px;
      font-size: 0.65rem;
    }

    .hunt-picker {
      margin: 8px 0 0;
      padding: 10px 10px 8px;
      border: 1px dashed rgba(74, 47, 28, 0.35);
      background: rgba(255, 248, 230, 0.45);
      font-size: 0.7rem;
      line-height: 1.55;
      color: var(--muted);
    }

    .hunt-picker strong {
      display: block;
      color: var(--ink);
      font-family: "Cinzel", serif;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      font-size: 0.65rem;
      margin-bottom: 8px;
    }

    .hunt-picker .lede-mini {
      display: block;
      margin-top: 8px;
      font-size: 0.65rem;
    }

    .hunt-thesis-note {
      margin: 8px 0 0;
      padding: 8px 10px;
      border-left: 3px solid var(--brass, #a67c2d);
      font-size: 0.72rem;
      line-height: 1.45;
      color: var(--muted);
    }

    .hunt-thesis-note strong {
      color: var(--ink);
    }

    .field-brief-hint {
      margin: 0 0 12px 8px;
      padding: 0;
      border: 1px dashed rgba(74, 47, 28, 0.35);
      background: rgba(255, 248, 230, 0.35);
      color: var(--muted);
      font-size: 0.72rem;
    }

    .field-brief-hint[hidden] {
      display: none !important;
    }

    .field-brief-hint > summary {
      cursor: pointer;
      list-style: none;
      padding: 8px 10px;
      font-family: "Cinzel", serif;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      font-size: 0.68rem;
      color: var(--ink);
      user-select: none;
    }

    .field-brief-hint > summary::-webkit-details-marker {
      display: none;
    }

    .field-brief-hint > summary::before {
      content: "▸ ";
      color: var(--brass, #a67c2d);
    }

    .field-brief-hint[open] > summary::before {
      content: "▾ ";
    }

    .field-brief-hint > summary .field-brief-active {
      margin-left: 4px;
      font-family: "Special Elite", monospace;
      letter-spacing: 0;
      text-transform: none;
      font-size: 0.7rem;
      color: var(--muted);
    }

    .field-brief-hint > summary .field-brief-sum {
      color: var(--ink);
    }

    .field-brief-cost {
      color: #8a3a1a;
      font-weight: 700;
    }

    button#btnSurveyPass:not(.on):not(:disabled) {
      background: linear-gradient(180deg, #8a5a28, #5a3a18);
      border-color: #3a2410;
      color: #f8f0dc;
    }

    .field-brief-hint > .lede-mini,
    .field-brief-hint > .field-brief-actions,
    .field-brief-hint > .hunt-picker,
    .field-brief-hint > .hunt-thesis-note {
      margin-left: 10px;
      margin-right: 10px;
    }

    .field-brief-hint > .lede-mini {
      margin-top: 0;
      margin-bottom: 8px;
      font-size: 0.68rem;
      line-height: 1.45;
    }

    .field-brief-hint > .field-brief-actions {
      margin-bottom: 8px;
    }

    .field-brief-hint[open] {
      padding-bottom: 10px;
    }

    .hunt-options {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }

    .hunt-options button {
      margin: 0;
      padding: 6px 8px;
      font-size: 0.65rem;
      line-height: 1.2;
      text-transform: none;
      letter-spacing: 0.02em;
    }

    .hunt-options button.on {
      background: linear-gradient(180deg, #6a5020, #4a3818);
      border-color: #3a2a10;
      color: #f4ecd8;
    }

    button#btnSurveyPass.on {
      background: linear-gradient(180deg, #6a5020, #4a3818);
      border-color: #3a2a10;
      color: #f4ecd8;
    }

    .scout-legend strong { color: var(--ink); }
    .scout-legend .lede-mini {
      display: block;
      margin-bottom: 6px;
      color: var(--muted);
    }

    .scout-swatch {
      display: inline-block;
      width: 0.75em;
      height: 0.75em;
      margin-right: 3px;
      vertical-align: -0.08em;
      border: 1px solid rgba(74, 47, 28, 0.4);
    }

    .scout-swatch.line {
      height: 0;
      border: none;
      border-top: 3px solid #b85c38;
      width: 0.9em;
      vertical-align: 0.15em;
      background: transparent;
    }

    .maplibregl-popup.dig-popup .maplibregl-popup-content {
      padding: 0;
      border: 2px solid var(--leather);
      border-radius: 0;
      background: var(--parchment);
      box-shadow: var(--panel-shadow);
      color: var(--ink);
      font-family: "Special Elite", "Courier New", monospace;
      max-width: 320px;
    }

    .maplibregl-popup.dig-popup .maplibregl-popup-tip {
      border-top-color: var(--leather);
      border-bottom-color: var(--leather);
    }

    .maplibregl-popup.dig-popup .maplibregl-popup-close-button {
      color: var(--leather);
      font-size: 18px;
      padding: 2px 8px;
    }

    .dig-pop {
      padding: 12px 14px 11px;
    }

    .dig-pop .kind {
      margin: 0 0 4px;
      font-family: "Cinzel", serif;
      font-size: 0.58rem;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: var(--stamp);
    }

    .dig-pop h3 {
      margin: 0 0 8px;
      font-family: "Cinzel", serif;
      font-size: 0.95rem;
      color: var(--leather);
      font-weight: 700;
    }

    .dig-pop .landscape-art {
      display: block;
      width: 100%;
      aspect-ratio: 4 / 3;
      object-fit: cover;
      margin: 0 0 8px;
      border: 1px solid rgba(74, 47, 28, 0.35);
      background: rgba(255, 248, 230, 0.45);
    }

    .maplibregl-popup.dig-popup-chase .dig-pop .landscape-art {
      max-height: 140px;
      aspect-ratio: auto;
    }

    .maplibregl-popup.dig-popup-chase .dig-pop p {
      font-size: 0.74rem;
    }

    .dig-pop p {
      margin: 0 0 7px;
      font-size: 0.78rem;
      line-height: 1.45;
    }

    .dig-pop p:last-child { margin-bottom: 0; }

    .dig-pop .dig-tip {
      padding-top: 7px;
      border-top: 1px dashed rgba(74, 47, 28, 0.3);
      color: var(--muted);
    }

    .dig-pop .dig-tip strong { color: var(--stamp); }

    .mystery {
      margin: 8px 0 0 8px;
      padding-top: 10px;
      border-top: 2px solid rgba(74, 47, 28, 0.25);
    }

    .mystery h2 {
      margin: 0 0 8px;
      font-family: "Cinzel", serif;
      font-size: 0.72rem;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: var(--leather);
      font-weight: 700;
    }

    .era {
      position: relative;
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 4px 8px;
      align-items: center;
      margin-bottom: 7px;
      font-size: 0.8rem;
      padding: 4px 4px 6px;
      cursor: help;
      border: 1px solid transparent;
      transition: background 0.15s ease, border-color 0.15s ease;
    }

    .era:hover,
    .era:focus-within {
      background: rgba(255, 248, 230, 0.55);
      border-color: rgba(166, 124, 45, 0.45);
      outline: none;
    }

    .era .name { color: var(--ink); }
    .era.done .name { color: var(--good); font-weight: 700; }
    .era .bar {
      grid-column: 1 / -1;
      height: 5px;
      background: rgba(74, 47, 28, 0.15);
      overflow: hidden;
      border: 1px solid rgba(74, 47, 28, 0.2);
    }
    .era .bar > span {
      display: block;
      height: 100%;
      background: linear-gradient(90deg, var(--brass), var(--brass-bright));
      width: 0%;
      transition: width 0.4s ease;
    }
    .era.done .bar > span { background: linear-gradient(90deg, #3f5a28, var(--good)); }

    .mystery-note {
      margin: 0 0 8px;
      font-size: 0.68rem;
      color: var(--muted);
      line-height: 1.35;
    }

    .era-tip {
      position: fixed;
      z-index: 8;
      width: min(340px, calc(100vw - 24px));
      padding: 12px 14px;
      border: 2px solid var(--leather);
      background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 45%),
        var(--parchment);
      color: var(--ink);
      box-shadow: var(--panel-shadow);
      pointer-events: none;
      opacity: 0;
      transform: translateY(4px);
      transition: opacity 0.15s ease, transform 0.15s ease;
    }

    .era-tip.on {
      opacity: 1;
      transform: translateY(0);
    }

    .era-tip .era-art {
      display: block;
      width: 100%;
      aspect-ratio: 4 / 3;
      object-fit: cover;
      margin: 0 0 10px;
      border: 1px solid rgba(74, 47, 28, 0.35);
      background: rgba(255, 248, 230, 0.4);
    }

    .era-tip .when {
      margin: 0 0 6px;
      font-family: "Cinzel", serif;
      font-size: 0.62rem;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--stamp);
    }

    .era-tip h3 {
      margin: 0 0 8px;
      font-family: "Cinzel", serif;
      font-size: 0.95rem;
      color: var(--leather);
      font-weight: 700;
    }

    .era-tip p {
      margin: 0 0 8px;
      font-size: 0.78rem;
      line-height: 1.45;
      color: var(--ink);
    }

    .era-tip p:last-child { margin-bottom: 0; }

    .era-tip .where {
      padding-top: 7px;
      border-top: 1px dashed rgba(74, 47, 28, 0.3);
      color: var(--muted);
    }

    .era-tip .where strong { color: var(--stamp); }

    .log {
      margin: 10px 0 0 8px;
      max-height: 110px;
      overflow: auto;
      font-size: 0.78rem;
      line-height: 1.4;
      color: var(--muted);
      border-left: 2px solid rgba(166, 124, 45, 0.45);
      padding-left: 10px;
    }

    .log div { margin-bottom: 4px; }
    .log .hit { color: var(--good); font-weight: 700; }
    .log .miss { color: var(--warn); font-weight: 700; }

    .hint {
      margin: 12px 0 0 8px;
      font-size: 0.68rem;
      color: var(--muted);
      line-height: 1.35;
    }

    .hint a { color: var(--stamp); }

    .toast {
      position: absolute;
      z-index: 4;
      left: 50%;
      bottom: 24px;
      transform: translateX(-50%) rotate(-1deg);
      padding: 10px 18px;
      border: 2px solid var(--leather);
      background: var(--parchment);
      color: var(--ink);
      font-size: 0.92rem;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s ease;
      max-width: calc(100vw - 32px);
      box-shadow: var(--panel-shadow);
    }

    .toast.show { opacity: 1; }

    .toast.hit {
      border-color: var(--good);
      color: var(--good);
    }

    .toast.miss {
      border-color: var(--warn);
      color: var(--warn);
    }

    .dig-event {
      display: none;
      position: absolute;
      z-index: 5;
      inset: 0;
      align-items: center;
      justify-content: center;
      padding: 24px;
      background: rgba(42, 31, 20, 0.55);
      pointer-events: auto;
    }

    .dig-event.on { display: flex; }

    .dig-event-card {
      width: min(420px, 100%);
      max-height: min(88vh, 720px);
      overflow: auto;
      padding: 22px 20px 18px;
      border: 3px solid var(--leather);
      background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent 45%),
        var(--parchment);
      box-shadow: var(--panel-shadow);
      animation: stamp-in 0.45s cubic-bezier(0.2, 1.35, 0.4, 1) both;
      text-align: left;
    }

    .dig-event-card.hit-card { border-color: #3f5a28; }
    .dig-event-card.miss-card { border-color: var(--warn); }

    .dig-event-card .eyebrow {
      margin: 0 0 4px;
    }

    .dig-event-card h2 {
      margin: 0 0 10px;
      font-family: "Cinzel", serif;
      font-size: 1.45rem;
      color: var(--leather);
      letter-spacing: 0.04em;
    }

    .dig-event-card.hit-card h2 { color: var(--good); }
    .dig-event-card.miss-card h2 { color: var(--warn); }

    .dig-event-card .summary {
      margin: 0 0 12px;
      font-size: 0.86rem;
      line-height: 1.45;
      color: var(--muted);
    }

    .dig-sites {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin-bottom: 14px;
    }

    .dig-site {
      display: grid;
      grid-template-columns: auto 1fr;
      gap: 2px 10px;
      padding: 8px 10px;
      border: 1px dashed rgba(74, 47, 28, 0.35);
      background: rgba(255, 248, 230, 0.45);
      font-size: 0.78rem;
      line-height: 1.4;
    }

    .dig-site .peg {
      grid-row: 1 / span 2;
      align-self: center;
      width: 2.1rem;
      height: 2.1rem;
      display: grid;
      place-items: center;
      font-family: "Cinzel", serif;
      font-size: 0.62rem;
      font-weight: 700;
      letter-spacing: 0.04em;
      border: 2px solid currentColor;
      border-radius: 50%;
    }

    .dig-site.hit { color: var(--good); }
    .dig-site.miss { color: var(--warn); }

    .dig-site .site-title {
      font-family: "Cinzel", serif;
      font-size: 0.72rem;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--ink);
    }

    .dig-site .site-detail { color: var(--muted); grid-column: 2; }

    .dig-event-card .row { margin: 0; justify-content: flex-end; }

    .dig-event-card.good-card { border-color: #3f5a28; }
    .dig-event-card.good-card h2 { color: var(--good); }
    .dig-event-card.bad-card { border-color: var(--stamp); }
    .dig-event-card.bad-card h2 { color: var(--stamp); }
    .dig-event-card.mixed-card { border-color: var(--brass); }
    .dig-event-card.mixed-card h2 { color: var(--brass); }

    .dig-event-card .effect {
      margin: 0 0 14px;
      padding: 8px 10px;
      border: 1px dashed rgba(74, 47, 28, 0.35);
      background: rgba(255, 248, 230, 0.55);
      font-size: 0.82rem;
      line-height: 1.45;
      color: var(--ink);
    }

    .dig-event-card .field-event-choices {
      margin: 0 0 10px;
      justify-content: stretch;
      gap: 8px;
    }

    .dig-event-card .field-event-choices[hidden] {
      display: none !important;
    }

    .dig-event-card .field-event-choices button {
      flex: 1;
    }

    .dig-event-card .event-art {
      display: block;
      width: 100%;
      aspect-ratio: 4 / 3;
      object-fit: cover;
      margin: 0 0 12px;
      border: 2px solid rgba(74, 47, 28, 0.35);
      background: rgba(255, 248, 230, 0.4);
      image-rendering: auto;
    }

    .dig-event-card .event-art[hidden] {
      display: none;
    }

    .stat .v.busy { color: var(--warn); }

    .stat .rank {
      display: block;
      margin-top: 2px;
      font-family: "Cinzel", serif;
      font-size: 0.55rem;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      color: var(--brass);
      line-height: 1.2;
      cursor: help;
    }

    .glory-tip {
      position: fixed;
      z-index: 9;
      width: min(320px, calc(100vw - 24px));
      padding: 12px 14px;
      border: 2px solid var(--leather);
      background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 45%),
        var(--parchment);
      color: var(--ink);
      box-shadow: var(--panel-shadow);
      pointer-events: none;
      opacity: 0;
      transform: translateY(4px);
      transition: opacity 0.15s ease, transform 0.15s ease;
    }

    .glory-tip.on {
      opacity: 1;
      transform: translateY(0);
    }

    .glory-tip .rank-art {
      display: block;
      width: 100%;
      aspect-ratio: 4 / 3;
      object-fit: cover;
      margin: 0 0 10px;
      border: 1px solid rgba(74, 47, 28, 0.35);
      background: rgba(255, 248, 230, 0.4);
    }

    .glory-tip .eyebrow {
      margin: 0 0 4px;
      font-size: 0.62rem;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--stamp);
    }

    .glory-tip h3 {
      margin: 0 0 8px;
      font-family: "Cinzel", serif;
      font-size: 0.95rem;
      color: var(--leather);
    }

    .glory-tip p {
      margin: 0;
      font-size: 0.78rem;
      line-height: 1.45;
      color: var(--ink);
    }

    .final-card .rank-art {
      display: block;
      width: 100%;
      max-width: 360px;
      aspect-ratio: 4 / 3;
      object-fit: cover;
      margin: 0 auto 14px;
      border: 2px solid rgba(166, 124, 45, 0.55);
      background: rgba(255, 248, 230, 0.4);
    }

    .final-card .rank-art[hidden] {
      display: none;
    }

    .start-actions .hard-row {
      display: flex;
      align-items: flex-start;
      gap: 8px;
      text-align: left;
      font-size: 0.78rem;
      line-height: 1.4;
      color: var(--muted);
      margin-bottom: 4px;
    }

    .start-actions .hard-row input {
      margin-top: 3px;
    }

    .start-actions .btn-row {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }

    .start-actions .btn-row button {
      flex: 1 1 140px;
    }

    .tutorial-banner {
      display: none;
      position: absolute;
      z-index: 4;
      left: 50%;
      top: 14px;
      transform: translateX(-50%);
      max-width: min(520px, calc(100% - 28px));
      padding: 10px 14px;
      border: 2px solid var(--brass);
      background: var(--parchment);
      box-shadow: var(--panel-shadow);
      font-size: 0.82rem;
      line-height: 1.4;
      color: var(--ink);
      text-align: center;
    }

    .tutorial-banner.on { display: block; }
    .tutorial-banner strong {
      font-family: "Cinzel", serif;
      color: var(--leather);
      letter-spacing: 0.04em;
    }

    .folio-modal, .recap-modal {
      display: none;
      position: absolute;
      z-index: 7;
      inset: 0;
      align-items: center;
      justify-content: center;
      padding: 20px;
      background: rgba(42, 31, 20, 0.72);
    }

    .folio-modal.on, .recap-modal.on { display: flex; }

    .folio-card, .recap-card {
      width: min(560px, 100%);
      max-height: min(88vh, 720px);
      overflow: auto;
      padding: 20px 18px 16px;
      border: 3px solid var(--leather);
      background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent 42%),
        var(--parchment);
      box-shadow: var(--panel-shadow);
      text-align: left;
    }

    .folio-card h2, .recap-card h2 {
      margin: 0 0 8px;
      font-family: "Cinzel", serif;
      color: var(--leather);
      font-size: 1.35rem;
    }

    .folio-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
      gap: 10px;
      margin: 12px 0 16px;
    }

    .folio-stamp {
      border: 1px solid rgba(74, 47, 28, 0.35);
      background: rgba(255, 248, 230, 0.5);
      padding: 4px;
      text-align: center;
      width: 100%;
      font: inherit;
      color: inherit;
      appearance: none;
      -webkit-appearance: none;
    }

    .folio-stamp.unlocked {
      cursor: zoom-in;
    }

    .folio-stamp.unlocked:hover {
      border-color: var(--brass);
      box-shadow: 0 0 0 1px rgba(166, 124, 45, 0.35);
    }

    .folio-stamp img {
      display: block;
      width: 100%;
      aspect-ratio: 4 / 3;
      object-fit: cover;
    }

    .folio-stamp .cap {
      font-size: 0.62rem;
      margin-top: 4px;
      color: var(--muted);
      line-height: 1.25;
    }

    .folio-stamp.locked {
      opacity: 0.35;
      filter: grayscale(1);
      cursor: default;
    }

    .folio-lightbox {
      display: none;
      position: absolute;
      z-index: 8;
      inset: 0;
      align-items: center;
      justify-content: center;
      padding: 20px;
      background: rgba(42, 31, 20, 0.88);
      cursor: zoom-out;
    }

    .folio-lightbox.on {
      display: flex;
    }

    .folio-lightbox-inner {
      width: min(720px, 100%);
      max-height: min(92vh, 900px);
      overflow: auto;
      padding: 14px 14px 12px;
      border: 3px solid var(--leather);
      background: var(--parchment);
      box-shadow: var(--panel-shadow);
      cursor: default;
      text-align: center;
    }

    .folio-lightbox-inner img {
      display: block;
      width: 100%;
      height: auto;
      max-height: min(72vh, 640px);
      object-fit: contain;
      background: rgba(255, 248, 230, 0.5);
      border: 1px solid rgba(74, 47, 28, 0.3);
    }

    .folio-lightbox-inner h3 {
      margin: 10px 0 4px;
      font-family: "Cinzel", serif;
      font-size: 1.1rem;
      color: var(--leather);
    }

    .folio-lightbox-inner .hint {
      margin: 0 0 10px;
      font-size: 0.72rem;
      color: var(--muted);
    }

    .recap-stats {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      margin: 10px 0 14px;
      font-size: 0.84rem;
    }

    .recap-stats div {
      padding: 8px 10px;
      border: 1px dashed rgba(74, 47, 28, 0.35);
      background: rgba(255, 248, 230, 0.45);
    }

    .recap-stats .k {
      display: block;
      font-size: 0.62rem;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--muted);
    }

    .recap-punch {
      margin: 0 0 14px;
      padding: 10px 12px;
      border-left: 3px solid var(--brass);
      font-size: 0.9rem;
      line-height: 1.45;
      color: var(--ink);
      background: rgba(255, 248, 230, 0.55);
    }

    #recapCanvas {
      display: none;
    }

    .hud .folio-btn {
      margin-top: 0;
      width: auto;
      flex: 1 1 auto;
    }

    @keyframes dig-pulse {
      0%, 100% { opacity: 0.55; }
      50% { opacity: 0.95; }
    }

    #error {
      display: none;
      position: absolute;
      inset: 0;
      z-index: 6;
      background: var(--parchment);
      color: var(--stamp);
      padding: 28px;
      white-space: pre-wrap;
      font: 15px/1.5 "Special Elite", monospace;
    }

    .final {
      display: none;
      position: absolute;
      z-index: 5;
      inset: 0;
      background: rgba(42, 31, 20, 0.72);
      align-items: center;
      justify-content: center;
      padding: 24px;
    }

    .final.on { display: flex; }

    .final-card {
      width: min(440px, 100%);
      padding: 30px 26px;
      border: 3px solid var(--leather);
      background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent 45%),
        var(--parchment);
      text-align: center;
      box-shadow: var(--panel-shadow);
      animation: stamp-in 0.55s cubic-bezier(0.2, 1.3, 0.4, 1) both;
    }

    .final-card h2 {
      margin: 0 0 8px;
      font-family: "Cinzel", serif;
      font-size: 1.55rem;
      color: var(--leather);
    }

    .final-card p { margin: 0 0 16px; color: var(--muted); }
    .final-card .big {
      font-family: "Cinzel", serif;
      font-size: 2.4rem;
      font-weight: 700;
      color: var(--stamp);
      margin-bottom: 6px;
    }

    .final-actions {
      justify-content: center;
      flex-wrap: wrap;
      gap: 10px;
    }

    .final-actions button {
      flex: 1 1 140px;
    }

    .reveal-bar {
      display: none;
      position: absolute;
      z-index: 4;
      left: 50%;
      bottom: 18px;
      transform: translateX(-50%);
      align-items: center;
      gap: 14px;
      padding: 10px 16px;
      border: 2px solid var(--leather);
      background: var(--parchment);
      box-shadow: var(--panel-shadow);
      font-family: "Special Elite", monospace;
      font-size: 0.85rem;
      color: var(--ink);
      max-width: calc(100% - 32px);
    }

    .reveal-bar.on {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
    }

    .maplibregl-ctrl-group {
      border: 2px solid var(--leather) !important;
      border-radius: 0 !important;
      background: var(--parchment) !important;
      box-shadow: none !important;
    }

    .maplibregl-ctrl button {
      background-color: transparent !important;
    }

    @media (max-width: 640px), (max-height: 420px) and (orientation: landscape) {
      .hud {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: auto;
        max-height: none;
        padding: 8px 12px calc(10px + var(--safe-bottom));
        border-left: none;
        border-right: none;
        border-bottom: none;
        border-radius: 14px 14px 0 0;
        animation: none;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        transition: max-height 0.22s ease;
      }

      .hud::before { display: none; }

      .hud.collapsed {
        max-height: none;
        height: auto;
      }

      .hud.expanded {
        max-height: min(70dvh, calc(100dvh - 72px - var(--safe-top)));
        height: auto;
      }

      .hud-grab {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        margin: 0 0 6px;
        padding: 8px 10px;
        min-height: 44px;
        border: none;
        background: transparent;
        box-shadow: none;
        font-family: "Cinzel", serif;
        font-size: 0.68rem;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--leather);
        cursor: pointer;
      }

      .hud-grab:hover,
      .hud-grab:active {
        transform: none;
        background: transparent;
      }

      .hud-grab-bar {
        display: block;
        width: 42px;
        height: 4px;
        border-radius: 999px;
        background: rgba(74, 47, 28, 0.35);
      }

      .hud-peek {
        flex: 0 0 auto;
        position: sticky;
        top: 0;
        z-index: 1;
        background:
          linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 40%),
          var(--parchment);
        padding-bottom: 2px;
      }

      .hud-more {
        flex: 1 1 auto;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
      }

      .hud.collapsed .hud-more {
        display: none;
      }

      .hud.expanded .hud-more {
        display: block;
      }

      .stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        margin-bottom: 8px;
      }

      .stat {
        padding: 6px 8px;
      }

      .hud-peek-actions {
        display: grid;
        grid-template-columns: 1.4fr 1fr;
        gap: 8px;
        margin: 0 0 4px;
      }

      .hud-peek-actions #btnDig {
        width: 100%;
        min-height: 48px;
        font-size: 0.8rem;
      }

      .hud-peek-actions #btnClear {
        min-height: 48px;
      }

      .hud-more-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-left: 0;
      }

      .hud-more-actions button {
        min-height: 44px;
        margin: 0;
      }

      .hud-more-actions #btnFolio {
        grid-column: 1 / -1;
        width: 100%;
      }

      button {
        min-height: 44px;
        padding: 11px 12px;
        font-size: 0.74rem;
      }

      .field-brief-hint > summary {
        min-height: 44px;
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 4px;
      }

      .hunt-options button {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 0.72rem;
      }

      .scout-legend {
        max-height: 28vh;
        overflow: auto;
      }

      .scout-swatches {
        display: flex;
        flex-wrap: nowrap;
        gap: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        white-space: nowrap;
        font-size: 0.68rem;
      }

      .maplibregl-popup.dig-popup .maplibregl-popup-close-button {
        width: 36px;
        height: 36px;
        font-size: 22px;
        line-height: 36px;
        padding: 0;
        right: 2px;
        top: 2px;
      }

      .maplibregl-popup.dig-popup .maplibregl-popup-content {
        max-width: min(320px, calc(100vw - 24px));
      }

      .toast {
        bottom: calc(var(--hud-stack, 110px) + 14px);
        max-width: calc(100vw - 24px);
      }

      .reveal-bar {
        bottom: calc(var(--hud-stack, 110px) + 14px);
        left: 12px;
        right: 12px;
        width: auto;
      }

      .corner-stamp {
        width: 56px;
        height: 56px;
        font-size: 0.45rem;
        top: calc(8px + var(--safe-top));
        right: 8px;
        opacity: 0.72;
      }

      .tutorial-banner {
        top: calc(8px + var(--safe-top));
        left: 12px;
        right: 12px;
        transform: none;
        max-width: none;
        font-size: 0.74rem;
        padding: 8px 10px;
      }

      .era-tip,
      .glory-tip {
        bottom: calc(var(--hud-stack, 110px) + 12px);
        top: auto !important;
        left: 12px !important;
        right: 12px;
        width: auto !important;
        max-height: min(42dvh, 360px);
        overflow: auto;
      }

      .start-card,
      .final-card,
      .folio-card,
      .recap-card,
      .dig-event-card,
      .isle-card,
      .chapter-card {
        max-height: min(90dvh, calc(100dvh - 24px - var(--safe-top) - var(--safe-bottom)));
        overflow: auto;
        -webkit-overflow-scrolling: touch;
      }

      .start-actions .btn-row button,
      .final-actions button {
        min-height: 48px;
      }

      .lede {
        display: none;
      }

      .eyebrow {
        font-size: 0.6rem;
      }

      .hud h1 {
        font-size: 1.15rem;
        margin-bottom: 6px;
      }

      .phase {
        font-size: 0.82rem;
        min-height: 0;
      }

      .log {
        max-height: 90px;
      }
    }

    @media (max-width: 640px) and (max-height: 420px) {
      .hud.expanded {
        max-height: min(58dvh, calc(100dvh - 48px));
      }

      .corner-stamp { display: none; }

      .tutorial-banner {
        font-size: 0.68rem;
        padding: 6px 8px;
      }
    }
