* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  overflow: hidden;
  font-family: system-ui, sans-serif;
  background: #0a1628;
}

#hud {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 10;
  color: #a8d4f0;
  background: rgba(10, 22, 40, 0.88);
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid rgba(125, 211, 252, 0.25);
  font-size: 13px;
  line-height: 1.55;
  max-width: 320px;
}

#hud strong {
  color: #fff;
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

#hud em {
  color: #7dd3fc;
  font-style: normal;
  font-size: 12px;
}

#hud kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(125, 211, 252, 0.35);
  background: rgba(125, 211, 252, 0.12);
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: #e0f2fe;
}

#map-legend {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 10;
  color: #a8d4f0;
  background: rgba(10, 22, 40, 0.88);
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid rgba(125, 211, 252, 0.25);
  font-size: 12px;
  line-height: 1.45;
  max-width: 240px;
}

#map-legend strong {
  color: #fff;
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

#map-legend .map-diagram {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  color: #7dd3fc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.35;
}

#map-legend p {
  margin: 0 0 6px;
}

#map-legend p:last-child {
  margin-bottom: 0;
}

#map-legend code {
  color: #fbbf24;
  font-size: 11px;
}

#map-legend .map-hint {
  color: #94a3b8;
  font-size: 11px;
}

#map-legend .map-colors {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(125, 211, 252, 0.18);
  color: #94a3b8;
  font-size: 11px;
}

@media (max-width: 720px) {
  #map-legend {
    top: auto;
    bottom: 14px;
    right: 14px;
    left: 14px;
    max-width: none;
  }
}

/* PRE-FINAL · mode bar + event trace */
#mode-bar {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
}

#mode-badge {
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(10, 22, 40, 0.88);
  border: 1px solid rgba(125, 211, 252, 0.35);
  color: #7dd3fc;
  font-size: 13px;
  font-weight: 600;
}

#exit-btn {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid #fbbf24;
  background: #fbbf24;
  color: #0a1628;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

#exit-btn:hover {
  background: #fcd34d;
}

#exit-btn[hidden] {
  display: none;
}

body[data-mode="inside"] #map-legend {
  display: none;
}

#event-trace {
  position: fixed;
  bottom: 14px;
  left: 14px;
  z-index: 10;
  width: 360px;
  max-width: calc(100vw - 28px);
  color: #a8d4f0;
  background: rgba(10, 22, 40, 0.88);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(125, 211, 252, 0.25);
  font-size: 12px;
}

#event-trace strong {
  display: block;
  margin-bottom: 4px;
  color: #fff;
  font-size: 12px;
}

#event-log {
  list-style: none;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.45;
}

#event-log li + li {
  opacity: 0.6;
}

#event-log code {
  color: #fbbf24;
}

#event-log span {
  display: block;
  color: #94a3b8;
}

@media (max-width: 720px) {
  #mode-bar {
    top: auto;
    bottom: 200px;
  }

  #event-trace {
    display: none;
  }
}
